Exemplo n.º 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();
                }
            }
        }
Exemplo n.º 2
0
        public void AddRecord(System.Collections.Generic.List <int> InsList, YueMES.Base.Dal.DAO dao, string DBNo, string sysLinkName, string CacheKey = null)
        {
            if (InsList == null || InsList.Count == 0 || string.IsNullOrEmpty(CacheKey))
            {
                return;
            }
            string        sql = "";
            StringBuilder sbd = new StringBuilder();

            foreach (var id in InsList)
            {
                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_Role_Menus busis = (Sys_Role_Menus)busisData;
                    if (busis.Columns.Count != bv.Value.Columns.Count)
                    {
                        return;
                    }
                    lock (_lock)
                    {
                        foreach (DataRow row in bv.Value.Rows)
                        {
                            busis.LoadDataRow(row, true);
                        }

                        busis.AcceptChanges();
                    }
                }
            }
        }