Пример #1
0
        public void RemoveRecord(System.Collections.Generic.List <int> DelList, YueMES.Base.Dal.DAO dao, string DBNo, string sysLinkName, string CacheKey = null)
        {
            if (DelList == null || DelList.Count == 0 || string.IsNullOrEmpty(CacheKey))
            {
                return;
            }
            if (CacheKey != null)
            {
                object busisData = null;
                YueMES.Base.Dal.DTO.TryGetCache(CacheKey, DBNo, out busisData);
                if (busisData == null)
                {
                    return;
                }
                Sys_Role_Menus busis = (Sys_Role_Menus)busisData;
                lock (_lock)
                {
                    foreach (var id in DelList)
                    {
                        DataRow[] drs = busis.Select(string.Format("ID={0}", id));
                        if (drs.Length == 0)
                        {
                            continue;
                        }
                        busis.Rows.Remove(drs[0]);
                    }

                    busis.AcceptChanges();
                }
            }
        }
Пример #2
0
        public void UpdateRecord(System.Collections.Generic.List <int> UpdList, YueMES.Base.Dal.DAO dao, string DBNo, string sysLinkName, string CacheKey = null)
        {
            if (UpdList == null || UpdList.Count == 0 || string.IsNullOrEmpty(CacheKey))
            {
                return;
            }
            string        sql = "";
            StringBuilder sbd = new StringBuilder();

            foreach (var id in UpdList)
            {
                sbd.Append(id);
                sbd.Append(",");
            }

            sql = string.Format("{0} and ma.ID in({1})", CacheKey, sbd.ToString(0, sbd.Length - 1));


            BooleanValue <DataTable> bv = dao.GetDataTable(sql);

            if (bv.Success && bv.Value.Rows.Count > 0)
            {
                if (CacheKey != null)
                {
                    object busisData = null;
                    YueMES.Base.Dal.DTO.TryGetCache(CacheKey, DBNo, out busisData);
                    if (busisData == null)
                    {
                        return;
                    }
                    Sys_Users busis = (Sys_Users)busisData;
                    if (busis.Columns.Count != bv.Value.Columns.Count)
                    {
                        return;
                    }
                    lock (_lock)
                    {
                        foreach (var id in UpdList)
                        {
                            DataRow[] drs = busis.Select(string.Format("ID={0}", id));
                            if (drs.Length == 0)
                            {
                                continue;
                            }
                            busis.Rows.Remove(drs[0]);
                        }
                        foreach (DataRow row in bv.Value.Rows)
                        {
                            busis.LoadDataRow(row, true);
                        }

                        busis.AcceptChanges();
                    }
                }
            }
        }