using System; using System.Data; using System.Collections.Generic; using System.Text; using DSWeb.MvcShipping.Models.MsTemplet; using Microsoft.Practices.EnterpriseLibrary.Data; using DSWeb.EntityDA; using DSWeb.Areas.CommMng.Models; using HcUtility.Comm; namespace DSWeb.Areas.MvcShipping.DAL { public partial class MsTempletDAL { #region Inquery DataList public static DataTable GetMemcachedValue(string id, string codeName, string companyid, string userid, string templetid) { return HomeService.HomeService.DeliveryMemcachedForCount(id, codeName, companyid, userid, templetid); } public static DataTable GetMemcachedValueImmediately(string id, string codeName, string companyid, string userid, string templetid) { return HomeService.HomeService.DeliveryMemcachedImmediatelyForCount(id, codeName, companyid, userid, templetid); } public static DataTable GetMemcachedList(string id, string codeName, string companyid, string userid, string templetid) { return HomeService.HomeService.DeliveryMemcachedForList(id, codeName, companyid, userid, templetid); } public static DataTable GetMemcachedListImmediately(string id, string codeName, string companyid, string userid, string templetid) { return HomeService.HomeService.DeliveryMemcachedImmediatelyForList(id, codeName, companyid, userid, templetid); } public static string GetModuleName(string url) { return HomeService.NavigationService.DeliveryMemcached(url); } public static List ReadPageStructure(string url, string id, string userid, int param) { StringBuilder sql = new StringBuilder(); sql.AppendLine("select "); switch (param) { case 0: sql.AppendLine("* "); break; case 1: sql.AppendLine("IMGURL,"); sql.AppendLine("(select GID from user_templet where ITEMID=A.ITEMID and USERID='"+userid+"' and COMPANYID=(select COMPANYID from user_company where userid='" + userid + "')) as GID, "); sql.AppendLine("(select ITEMNAME from user_templet where ITEMID=A.ITEMID and USERID='"+userid+"' and COMPANYID=(select COMPANYID from user_company where userid='" + userid + "')) as TITLE "); break; case 2: sql.AppendLine("B.* "); break; case 3: sql.AppendLine("(" + id + ") as SQL"); break; case 4: sql.AppendLine("distinct B.ITEMID,B.ITEMNAME "); break; case 5: sql.AppendLine("distinct B.* "); break; } sql.AppendLine("from templet as A "); if (param == 2 || param == 4 || param == 5) { sql.AppendLine("left join user_templet as B on A.ITEMID=B.PARENTID and B.COMPANYID=(select COMPANYID from user_company where userid='" + userid + "') "); } sql.AppendLine("where A.TEMPLETURL='" + url + "'and A.USERID='" + userid + "' "); switch (param) { case 0: sql.AppendLine("and A.PARENTITEMID='" + id + "' "); sql.AppendLine("order by A.SORT"); break; case 1: sql.AppendLine("and A.PARENTITEMID = (select distinct ITEMID from templet where PARENTITEMID='.' and TEMPLETURL='" + url + "') "); sql.AppendLine("order by A.SORT"); break; case 2: sql.AppendLine("and B.USERID='"+userid+"' and B.PARENTID in (select ITEMID from user_templet where ITEMNAME='" + id + "' and COMPANYID=(select COMPANYID from user_company where userid='" + userid + "')) "); sql.AppendLine("order by A.SORT,B.SORT "); break; case 4: sql.AppendLine("and B.ITEMID in (select distinct ITEMID from templet where PARENTITEMID=(select distinct ITEMID from templet where PARENTITEMID='" + id + "' and TEMPLETURL='" + url + "')) "); break; case 5: sql.AppendLine("and B.USERID='"+userid+"' and B.PARENTID=(select ITEMID from user_templet where ITEMNAME='" + id + "' and USERID='"+userid+"' and COMPANYID=(select COMPANYID from user_company where userid='" + userid + "') )"); break; } return SetPageStructure(sql, param); } public static List SetPageStructure(StringBuilder sql, int param) { var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql.ToString())) { while (reader.Read()) { switch (param) { case 0: MsTempletStructure data1 = new MsTempletStructure();//MsUserTempletStructure #region Set DB data to Object data1.GID = Convert.ToString(reader["GID"]); data1.TEMPLETID = Convert.ToString(reader["TEMPLETID"]); data1.TEMPLETURL = Convert.ToString(reader["TEMPLETURL"]); data1.HASIMG = Convert.ToBoolean(reader["HASIMG"]); if (reader["MAINIMGURL"] != DBNull.Value) { data1.MAINIMGURL = Convert.ToString(reader["MAINIMGURL"]); } data1.HASLIST = Convert.ToBoolean(reader["HASLIST"]); if (reader["LISTSTYLE"] != DBNull.Value) { data1.LISTSTYLE = Convert.ToInt16(reader["LISTSTYLE"]); } data1.HASCHILD = Convert.ToBoolean(reader["HASCHILD"]); data1.PARENTITEMID = Convert.ToString(reader["PARENTITEMID"]); data1.ITEMID = Convert.ToString(reader["ITEMID"]); data1.ITEMTYPE = Convert.ToInt16(reader["ITEMTYPE"]); if (reader["IMGURL"] != DBNull.Value) { data1.IMGURL = Convert.ToString(reader["IMGURL"]); } data1.SORT = Convert.ToInt16(reader["SORT"]); #endregion headList.Add(data1); break; case 1: MsTempletStructure data2 = new MsTempletStructure();//MsUserTempletStructure #region Set DB data to Object data2.GID = Convert.ToString(reader["GID"]); data2.IMGURL = Convert.ToString(reader["IMGURL"]); data2.ITEMNAME = Convert.ToString(reader["TITLE"]); #endregion headList.Add(data2); break; case 2: MsTempletStructure data3 = new MsTempletStructure();//MsUserTempletStructure #region Set DB data to Object data3.GID = Convert.ToString(reader["GID"]); data3.TEMPLETID = Convert.ToString(reader["TEMPLETID"]); data3.ITEMID = Convert.ToString(reader["ITEMID"]); data3.ITEMNAME = Convert.ToString(reader["ITEMNAME"]); data3.LINKURL = Convert.ToString(reader["LINKURL"]); data3.SQL = Convert.ToString(reader["SQL"]); data3.ICONNAME = Convert.ToString(reader["ICONNAME"]); #endregion headList.Add(data3); break; case 4: MsTempletStructure data4 = new MsTempletStructure(); #region Set DB data to Object data4.ITEMID = Convert.ToString(reader["ITEMID"]); data4.ITEMNAME = Convert.ToString(reader["ITEMNAME"]); #endregion headList.Add(data4); break; case 5: MsTempletStructure data5 = new MsTempletStructure(); #region Set DB data to Object data5.GID = Convert.ToString(reader["GID"]); data5.TEMPLETID = Convert.ToString(reader["TEMPLETID"]); data5.ITEMID = Convert.ToString(reader["ITEMID"]); data5.ITEMNAME = Convert.ToString(reader["ITEMNAME"]); data5.LINKURL = Convert.ToString(reader["LINKURL"]); data5.SQL = Convert.ToString(reader["SQL"]); data5.ISICOWAY = Convert.ToBoolean(reader["ISICOWAY"]); data5.ICONNAME = Convert.ToString(reader["ICONNAME"]); #endregion headList.Add(data5); break; } } reader.Close(); } return headList; } public static List GetLinkInfo(string id, string templetid) { StringBuilder sql = new StringBuilder(); ////////////////////// /*sql.AppendLine("select A.LINKURL,B.TEMPLETURL from user_templet as A "); sql.AppendLine("left join templet as B on A.TEMPLETID=B.TEMPLETID "); sql.AppendLine("where A.GID='" + id + "' and A.TEMPLETID='" + templetid + "'");*/ sql.AppendLine("select A.LINKURL,(select distinct TEMPLETURL from templet where TEMPLETID=A.TEMPLETID) as TEMPLETURL "); sql.AppendLine("from user_templet as A"); sql.AppendLine("where A.GID='"+id+"'"); var headList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql.ToString())) { while (reader.Read()) { MsTempletStructure data = new MsTempletStructure();//MsUserTempletStructure #region Set DB data to Object data.LINKURL = Convert.ToString(reader["LINKURL"]); data.TEMPLETURL = Convert.ToString(reader["TEMPLETURL"]); #endregion headList.Add(data); break; } reader.Close(); } return headList; } #endregion #region 查询模板地址 public static List GetTempletURL(string gid, string companyid) { List list = new List(); StringBuilder sql = new StringBuilder(); sql.AppendLine("select distinct B.GID,A.TEMPLETURL "); sql.AppendLine("from templet as A "); sql.AppendLine("left join user_templet as B on A.TEMPLETID=B.TEMPLETID "); sql.AppendLine("where A.TEMPLETID='" + gid + "' and B.LINKURL='.' and B.COMPANYID='" + companyid + "' "); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql.ToString())) { while (reader.Read()) { MsTempletStructure data = new MsTempletStructure(); data.GID = Convert.ToString(reader["GID"]); data.LINKURL = Convert.ToString(reader["TEMPLETURL"]); list.Add(data); } reader.Close(); } return list; } #endregion /* #region 权限范围 public static string GetRangDAStr(string tb, string userid, string username, string companyid) { string str = ""; var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append(" VISIBLERANGE,OPERATERANGE "); strSql.Append(" from VW_User_Authority "); strSql.Append(" where [NAME]='modOrderManagement' and USERID='" + userid + "' and ISDELETE=0"); string visiblerange = "4"; string operaterange = "4"; Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { visiblerange = Convert.ToString(reader["VISIBLERANGE"]); operaterange = Convert.ToString(reader["OPERATERANGE"]); break; } reader.Close(); } if (visiblerange == "4") { str = "1=2"; } else if (visiblerange == "3") { str = " (B.OP='" + username + "' OR B.SALE='" + username + "' OR B.CUSTSERVICE='" + username + "' OR B.DOC='" + username + "')"; } else if (visiblerange == "2") { if (tb == "index") { var rangeDa = new RangeDA(); var deptname = rangeDa.GetDEPTNAME(userid); var userstr = new StringBuilder(); userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')"); Database userdb = DatabaseFactory.CreateDatabase(); using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString())) { str = ""; while (reader.Read()) { if (str == "") { str = " (B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.DOC='" + Convert.ToString(reader["SHOWNAME"]) + "'"; } else { str = str + " or B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.DOC='" + Convert.ToString(reader["SHOWNAME"]) + "'"; }; } str = str + ")"; reader.Close(); } } else { str = " UPPER(B.Corpid)='" + companyid + "'"; } } else if (visiblerange == "1") { str = " UPPER(B.Corpid)='" + companyid + "'"; } return str; } #endregion */ #region 参照部分 #endregion } }