Beispiel #1
0
        public static IList <Sys_sysSort> TransDataTableToEntityList(DataTable dt)
        {
            IList <Sys_sysSort> list            = new List <Sys_sysSort>();
            Sys_sysSort         sys_sysProperty = null;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                sys_sysProperty = new Sys_sysSort();
                foreach (DataColumn column in dt.Columns)
                {
                    sys_sysProperty.EntityCustom.SetValue(column.ColumnName, dt.Rows[i][column]);
                }
                list.Add(sys_sysProperty);
            }
            return(list);
        }
Beispiel #2
0
        public IList <Sys_sysSort> GetSysSortListBySysId(int sysId, out IList <Sys_sysSort> parentSortList)
        {
            parentSortList = new List <Sys_sysSort>();
            IList <Sys_sysSort> entityListByWhere = base.Session.GetEntityListByWhere <Sys_sysSort>("sysid={0} and del=0 order by parentId asc", new object[1]
            {
                sysId
            }, new string[5]
            {
                "id",
                "name",
                "path",
                "sysId",
                "parentId"
            }, true);
            string sql = "select distinct parentId from sys_syssort  with(nolock) where sysid=" + sysId + " and del=0";
            Dictionary <int, int> dictionary = new Dictionary <int, int>();
            DataTable             dataTable  = base.Session.GetDataTable(sql, null);
            int num = 0;

            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                num = DataConvert.ToInt(dataTable.Rows[i]["parentId"]);
                if (num > 0)
                {
                    dictionary[num] = num;
                }
            }
            int         num2        = 0;
            Sys_sysSort sys_sysSort = null;

            for (int i = 0; i < entityListByWhere.Count; i++)
            {
                sys_sysSort = entityListByWhere[i];
                num2        = sys_sysSort.Id;
                if (dictionary.ContainsKey(num2))
                {
                    entityListByWhere.RemoveAt(i);
                    i--;
                    parentSortList.Add(sys_sysSort);
                }
            }
            return(entityListByWhere);
        }
Beispiel #3
0
        public IList <Sys_sysSort> ConvertSortToOtherSys(int curSortId, int otherSysId)
        {
            Session     session     = base.Session;
            Sys_sysSort entityByKey = session.GetEntityByKey <Sys_sysSort>((object)curSortId, true);

            if (entityByKey == null)
            {
                return(new List <Sys_sysSort>());
            }
            if (entityByKey.Sysid == otherSysId)
            {
                IList <Sys_sysSort> list = new List <Sys_sysSort>();
                list.Add(entityByKey);
                return(list);
            }
            GetSortIdToParentId(otherSysId);
            Dictionary <int, int> dictionary  = new Dictionary <int, int>();
            Dictionary <int, int> dictionary2 = new Dictionary <int, int>();
            string sql = "select distinct s.id from sys_sysSort s with(nolock) \r\n                                        inner join sys_prdSortRel r1  with(nolock)  on s.id=r1.prdSysSortId and r1.del=0\r\n                                        inner join sys_prdSortRel r2  with(nolock)  on r1.prdSortId=r2.prdSortId and r2.del=0\r\n                                        where r2.prdSysSortId={0} and r1.sysid={1}";

            object[] parms = new object[2]
            {
                curSortId,
                otherSysId
            };
            DataTable dataTable = session.GetDataTable(sql, parms);
            int       num       = 0;

            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                num = DataConvert.ToInt(dataTable.Rows[i]["id"]);
                if (_cacheChildSortList.ContainsKey(num))
                {
                    dictionary2[num] = num;
                }
                else
                {
                    dictionary[num] = num;
                }
            }
            sql       = "select distinct s.id,r.uploadNum from sys_sysSort s  with(nolock) \r\n                            inner join sys_userSortRel r  with(nolock)  on s.id=r.sortid2 \r\n                            where r.sortid1=" + curSortId + " and s.sysid=" + otherSysId + " and s.del=0";
            dataTable = session.GetDataTable(sql, parms);
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                num = DataConvert.ToInt(dataTable.Rows[i]["id"]);
                if (_cacheChildSortList.ContainsKey(num))
                {
                    dictionary2[num] = num;
                }
                else
                {
                    dictionary[num] = num;
                }
            }
            sql       = "select s.id from sys_sysSort s  with(nolock) where s.sysid=" + otherSysId + " and s.del=0 and s.Name='" + DbUtil.OerateSpecialChar(entityByKey.Name) + "'";
            dataTable = session.GetDataTable(sql, parms);
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                num = DataConvert.ToInt(dataTable.Rows[i]["id"]);
                if (_cacheChildSortList.ContainsKey(num))
                {
                    dictionary2[num] = num;
                }
                else
                {
                    dictionary[num] = num;
                }
            }
            string text = string.Empty;

            Dictionary <int, int> .Enumerator enumerator = dictionary.GetEnumerator();
            KeyValuePair <int, int>           current;
            int num2;

            try
            {
                while (enumerator.MoveNext())
                {
                    current = enumerator.Current;
                    if (string.IsNullOrEmpty(text))
                    {
                        num2 = current.Key;
                        text = num2.ToString();
                    }
                    else
                    {
                        string str = text;
                        num2 = current.Key;
                        text = str + "," + num2.ToString();
                    }
                }
            }
            finally
            {
                ((IDisposable)enumerator).Dispose();
            }
            enumerator = dictionary2.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    current = enumerator.Current;
                    IList <int> leavesSortByParentId = GetLeavesSortByParentId(otherSysId, current.Key);
                    if (leavesSortByParentId != null && leavesSortByParentId.Count > 0)
                    {
                        for (int i = 0; i < leavesSortByParentId.Count; i++)
                        {
                            if (string.IsNullOrEmpty(text))
                            {
                                num2 = leavesSortByParentId[i];
                                text = num2.ToString();
                            }
                            else
                            {
                                string str2 = text;
                                num2 = leavesSortByParentId[i];
                                text = str2 + "," + num2.ToString();
                            }
                        }
                    }
                }
            }
            finally
            {
                ((IDisposable)enumerator).Dispose();
            }
            if (string.IsNullOrEmpty(text))
            {
                return(new List <Sys_sysSort>());
            }
            sql = "id in (" + text + ")";
            return(session.GetEntityListByWhere <Sys_sysSort>(sql, null, true));
        }