Esempio n. 1
0
 public void ResetRoleUsers()
 {
     lock (_lock)
     {
         this.m_Users = null;
     }
 }
Esempio n. 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();
                    }
                }
            }
        }
Esempio n. 3
0
        private static object GetPropertyValue(string menuNo, DataRow[] drs)
        {
            if (drs.Length == 0)
            {
                return(null);
            }
            Sys_Property      prop     = (Sys_Property)drs[0];
            Sys_Property_Sets propsets = Sys_Property_Sets.EP;

            if (prop.IsSystem)
            {
                string sql       = string.Format("select Value from sys_Property_Set where PropertyID={0} and iUserID=-1", prop.ID);
                object valuetext = YueMES.Base.Dal.DAO.Default.ExecuteScalar(sql).Value;
                if (valuetext == null)
                {
                    return(prop.GetValue().Value);
                }
                if (valuetext == DBNull.Value)
                {
                    return(prop.GetValue().Value);
                }
                DataRow drold = propsets.FindRow("PropertyID", prop.ID);
                if (drold != null)
                {
                    lock (_lock)
                    {
                        drold["Value"] = valuetext;
                        drold.AcceptChanges();
                    }
                }


                return(prop.GetValue((string)valuetext).Value);
            }
            else
            {
                propsets = Sys_Users.GetItem(HttpContextExt.UserNo).GetProperties(menuNo);
                drs      = propsets.Select(string.Format("PropertyID={0}", prop.ID));
                if (drs.Length == 0)
                {
                    return(prop.GetValue().Value);
                }
                string valueText = (string)drs[0]["Value"];
                object value     = prop.GetValue(valueText).Value;
                if (value == null)
                {
                    value = prop.GetValue().Value;
                }
                return(value);
            }
        }
Esempio n. 4
0
        public void UpdateRecord(List <int> UpdList, DAO dao, string DBNo, string sysLinkName, string CacheKey = null)
        {
            if (UpdList == null || UpdList.Count == 0)
            {
                return;
            }
            string        sql = "";
            StringBuilder sbd = new StringBuilder();

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

            sql = string.Format("select su.*,dp.name as DepName from Sys_User su left join dept dp on su.dep=dp.dep where su.ID in({0})", 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(string.IsNullOrEmpty(CacheKey) ? Default_sql : CacheKey, DBNo, out busisData);
                    if (busisData == null)
                    {
                        return;
                    }
                    Sys_Users busis = (Sys_Users)busisData;
                    lock (_lock)
                    {
                        if (busis.Columns.Count != bv.Value.Columns.Count)
                        {
                            return;
                        }
                        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();
                    }
                }
            }

            sql = "SELECT r.ID FROM sys_User a INNER JOIN sys_Role_User b ON a.ID=b.UserID INNER JOIN sys_Role r ON b.MID=r.ID where a.ID IN({0})";
            sql = string.Format(sql, sbd.ToString(0, sbd.Length - 1));
            bv  = dao.GetDataTable(sql);

            if (bv.Success && bv.Value.Rows.Count > 0)
            {
                base.addThreadInfo(DBNo);
                foreach (DataRow row in bv.Value.Rows)
                {
                    Sys_Role busi = Sys_Roles.GetItem(Convert.ToInt32(row["ID"]));
                    if (busi == null)
                    {
                        continue;
                    }
                    busi.ResetRoleUsers();
                }
            }
        }
Esempio n. 5
0
        public void RemoveRecord(List <int> DelList, DAO dao, string DBNo, string sysLinkName, string CacheKey = null)
        {
            if (DelList == null || DelList.Count == 0)
            {
                return;
            }
            if (CacheKey != null)
            {
                object busisData = null;
                YueMES.Base.Dal.DTO.TryGetCache(string.IsNullOrEmpty(CacheKey) ? Default_sql : CacheKey, DBNo, out busisData);
                if (busisData == null)
                {
                    return;
                }
                Sys_Users busis = (Sys_Users)busisData;
                base.addThreadInfo(DBNo);
                List <DataRow> lst = null;
                if (DAO.Default.dataBaseType == DataBaseType.Oracle)
                {
                    lst = (from a in busis.AsEnumerable()
                           join b in Sys_Role_Users.Default.AsEnumerable()
                           on a.Field <Int64>("ID") equals b.Field <Int64>("UserID")
                           join c in Sys_Roles.Default.AsEnumerable()
                           on b.Field <Int64>("MID") equals c.Field <Int64>("ID")
                           where DelList.Contains(Convert.ToInt32(a.Field <Int64>("ID")))
                           select c).ToList();
                }
                else
                {
                    lst = (from a in busis.AsEnumerable()
                           join b in Sys_Role_Users.Default.AsEnumerable()
                           on a.Field <int>("ID") equals b.Field <int>("UserID")
                           join c in Sys_Roles.Default.AsEnumerable()
                           on b.Field <int>("MID") equals c.Field <int>("ID")
                           where DelList.Contains(a.Field <int>("ID"))
                           select c).ToList();
                }
                if (lst != null && lst.Count > 0)
                {
                    foreach (DataRow row in lst)
                    {
                        Sys_Role role = Sys_Roles.GetItem(Convert.ToInt32(row["ID"]));
                        if (role != null)
                        {
                            role.ResetRoleUsers();
                        }
                    }
                }


                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();
                }
            }
        }