Beispiel #1
0
        /// <summary>
        /// 构造跨站点调用的临时登录
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public LibHandle GetCrossCallHandle(string userId)
        {
            if (string.IsNullOrEmpty(userId))
            {
                return(null);
            }
            LibHandle     handle     = new LibHandle(LibHandeleType.CrossSiteCall, userId, "");
            SqlBuilder    builder    = new SqlBuilder("axp.User");
            string        sql        = builder.GetQuerySql(0, "A.PERSONID,A.PERSONNAME,A.ROLEID,A.WALLPAPER,A.WALLPAPERSTRETCH", string.Format("A.USERID={0} And A.ISUSE=1", LibStringBuilder.GetQuotString(userId)));
            LibDataAccess dataAccess = new LibDataAccess();
            bool          exist      = false;

            using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
            {
                if (reader.Read())
                {
                    handle.PersonId   = LibSysUtils.ToString(reader[0]);
                    handle.PersonName = LibSysUtils.ToString(reader[1]);
                    handle.RoleId     = LibSysUtils.ToString(reader[2]);
                    exist             = true;
                }
            }
            if (exist)
            {
                this.Set(handle.Handle, handle);
                return(handle);
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        public List <LibBusinessTask> InitTempTask()
        {
            List <LibBusinessTask> list       = new List <LibBusinessTask>();
            LibDataAccess          dataAccess = new LibDataAccess();

            using (IDataReader reader = dataAccess.ExecuteDataReader("select TASKID,PROGID,BUSINESSTASKID,EXECDATE,EXECTIME,EXECCONDITION,INTERNALID from AXPBUSINESSTEMPTASK", false))
            {
                while (reader.Read())
                {
                    LibBusinessTask task = new LibBusinessTask()
                    {
                        TaskType       = LibTaskType.TempTask,
                        TaskId         = LibSysUtils.ToString(reader["TASKID"]),
                        ProgId         = LibSysUtils.ToString(reader["PROGID"]),
                        BusinessTaskId = LibSysUtils.ToString(reader["BUSINESSTASKID"]),
                        ExecDate       = LibSysUtils.ToInt32(reader["EXECDATE"]),
                        ExecCondition  = LibSysUtils.ToString(reader["EXECCONDITION"]),
                        InternalId     = LibSysUtils.ToString(reader["INTERNALID"])
                    };
                    task.ExecTime.Add(LibSysUtils.ToInt32(reader["EXECTIME"]));
                    list.Add(task);
                }
            }
            return(list);
        }
Beispiel #3
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public static Result Login(UserInfo info)
        {
            Result res = new Result();

            try
            {
                LibDataAccess access = new LibDataAccess();
                SystemService server = new SystemService();
                if (APPCache.CacheDic.ContainsKey(info.CodeId))
                {
                    if (string.Equals(APPCache.CacheDic[info.CodeId], info.Code, StringComparison.CurrentCultureIgnoreCase))
                    {
                        LoginInfo loginInfo = server.Login(info.UserId, info.Password, false);
                        LibHandle handle    = LibHandleCache.Default.IsExistsHandle(LibHandeleType.PC, info.UserId);
                        if (loginInfo.PersonId == null)
                        {
                            res.ReturnValue = false;
                            res.Message     = "登录失败!";
                        }
                        else if (handle == null)
                        {
                            res.ReturnValue = false;
                            res.Message     = "请重新登录!";
                        }
                        else
                        {
                            string sql = string.Format("SELECT B.PHONENO,B.MAIL FROM AXPUSER A LEFT JOIN COMPERSON B ON B.PERSONID=A.PERSONID WHERE A.USERID={0}", LibStringBuilder.GetQuotString(info.UserId));
                            using (IDataReader reader = access.ExecuteDataReader(sql))
                            {
                                if (reader.Read())
                                {
                                    //loginInfo.UserPhone = LibSysUtils.ToString(reader["PHONENO"]);
                                    loginInfo.UserEMail = LibSysUtils.ToString(reader["MAIL"]);
                                }
                            }
                            loginInfo.Handle = handle.Handle;
                            res.Info         = loginInfo;
                            res.ReturnValue  = true;
                            APPCache.RemoveAPPCache(info.CodeId);
                        }
                    }
                    else
                    {
                        res.Message     = "验证码错误!";
                        res.ReturnValue = false;
                    }
                }
                else
                {
                    res.Message     = "验证码失效!";
                    res.ReturnValue = false;
                }
            }
            catch (Exception ex)
            {
                res.Message     = ex.Message;
                res.ReturnValue = false;
            }
            return(res);
        }
Beispiel #4
0
            public CalendarData(string calendarId)
            {
                if (string.IsNullOrEmpty(calendarId))
                {
                    return;
                }
                LibDataAccess dataAccess = new LibDataAccess();
                SqlBuilder    sqlBuilder = new SqlBuilder("com.Calendar");
                string        sql        = sqlBuilder.GetQuerySql(1, "B.YEAR,B.MONTH,B.WORKMARK", string.Format("B.CALENDARID={0}", LibStringBuilder.GetQuotString(calendarId)));

                using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
                {
                    while (reader.Read())
                    {
                        int year = LibSysUtils.ToInt32(reader[1]);
                        if (!WorkDayList.ContainsKey(year))
                        {
                            WorkDayList.Add(year, new int[12]);
                        }
                        int[] items = WorkDayList[year];
                        int   month = LibSysUtils.ToInt32(reader["MONTH"]);
                        items[month - 1] = LibSysUtils.ToInt32(reader["WORKMARK"]);
                    }
                }
            }
Beispiel #5
0
        /// <summary>
        /// 获取用户可访问的站点
        /// </summary>
        /// <param name="userHandle"></param>
        /// <returns></returns>
        public List <LinkSiteInfo> GetLinkSites(string userHandle)
        {
            // 判断userHandle存不存在
            LibHandle handle = LibHandleCache.Default.GetCurrentHandle(userHandle);

            if (handle == null)
            {
                throw new Exception("用户句柄无效");
            }
            List <LinkSiteInfo> linkSiteInfoList = new List <LinkSiteInfo>();
            string        sql        = string.Format("select B.SITEID, B.SITENAME, B.SHORTNAME, B.SITEURL, B.SVCURL, B.ISSLAVE,B.ISSENDTO from AXPUSERSITE A join AXPLINKSITE B on A.SITEID = B.SITEID where A.USERID = {0}", LibStringBuilder.GetQuotString(handle.UserId));
            LibDataAccess dataAccess = new LibDataAccess();

            using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
            {
                while (reader.Read())
                {
                    var siteInfo = new LinkSiteInfo()
                    {
                        SiteId    = LibSysUtils.ToString(reader["SITEID"]),
                        SiteName  = LibSysUtils.ToString(reader["SITENAME"]),
                        ShortName = LibSysUtils.ToString(reader["SHORTNAME"]),
                        SiteUrl   = LibSysUtils.ToString(reader["SITEURL"]),
                        SvcUrl    = LibSysUtils.ToString(reader["SVCURL"]),
                        IsSlave   = LibSysUtils.ToBoolean(reader["ISSLAVE"]),
                        IsSendTo  = LibSysUtils.ToBoolean(reader["ISSENDTO"]),
                    };
                    linkSiteInfoList.Add(siteInfo);
                }
            }
            return(linkSiteInfoList);
        }
Beispiel #6
0
        private LibBusinessTask GetBusinessTask(string taskId)
        {
            SqlBuilder sqlBuilder = new SqlBuilder("axp.ScheduleTask");
            string     sql        = sqlBuilder.GetQuerySql(0, "A.TASKID,A.PROGID,A.BUSINESSTASKID,A.CALENDARID,A.ISJUSTWORKDAY,A.INTERVALTIME,A.EXECDATE,A.REPEATDATEMARK,A.EXECCONDITION,A.TITLE,A.MAINCONTENT,B.EXECTIME",
                                                           string.Format("A.TASKID={0}", LibStringBuilder.GetQuotString(taskId)), "B.EXECTIME");
            LibDataAccess   dataAccess = new LibDataAccess();
            LibBusinessTask task       = null;

            using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
            {
                while (reader.Read())
                {
                    if (task == null)
                    {
                        task = new LibBusinessTask();
                        task.BusinessTaskId = LibSysUtils.ToString(reader["BUSINESSTASKID"]);
                        task.CalendarId     = LibSysUtils.ToString(reader["CALENDARID"]);
                        task.ExecCondition  = LibSysUtils.ToString(reader["ExecCondition"]);
                        task.ExecDate       = LibSysUtils.ToInt32(reader["EXECDATE"]);
                        task.IntervalTime   = LibSysUtils.ToInt32(reader["INTERVALTIME"]);
                        task.IsJustWorkDay  = LibSysUtils.ToBoolean(reader["ISJUSTWORKDAY"]);
                        task.ProgId         = LibSysUtils.ToString(reader["PROGID"]);
                        task.Title          = LibSysUtils.ToString(reader["TITLE"]);
                        task.MainContent    = LibSysUtils.ToString(reader["MAINCONTENT"]);
                        task.RepeatDateMark = LibSysUtils.ToInt32(reader["REPEATDATEMARK"]);
                        task.TaskId         = taskId;
                    }
                    task.ExecTime.Add(LibSysUtils.ToInt32(reader["EXECTIME"]));
                }
            }
            sql = string.Format("select distinct A.TASKID,A.PERSONID,D.DEPTID,C.USERID from AXPSCHEDULETASKPERSON A " +
                                "inner join AXPSCHEDULETASK B on B.TASKID=A.TASKID left join COMPERSON D on D.PERSONID=A.PERSONID inner join AXPUSER C on C.PERSONID=A.PERSONID " +
                                "where B.TASKID={0}", LibStringBuilder.GetQuotString(taskId));
            using (IDataReader reader = dataAccess.ExecuteDataReader(sql, false))
            {
                while (reader.Read())
                {
                    task.Liaison.Add(new LibBusinessTaskLiaison()
                    {
                        PersonId = LibSysUtils.ToString(reader["PERSONID"]),
                        DeptId   = LibSysUtils.ToString(reader["DEPTID"]),
                        UserId   = LibSysUtils.ToString(reader["USERID"])
                    });
                }
            }
            return(task);
        }
Beispiel #7
0
        /// <summary>
        /// 获取用户可访问的下级站点代码列表
        /// </summary>
        /// <param name="userId"></param>
        /// <returns>站点代码与站点信息的字典</returns>
        public static Dictionary <string, LinkSiteInfo> GetCanLoginSlaveSites(string userId)
        {
            if (string.IsNullOrEmpty(userId))
            {
                return(null);
            }
            Dictionary <string, LinkSiteInfo> siteIds = new Dictionary <string, LinkSiteInfo>();

            try
            {
                if (ExistLinkSiteTable == false || ExistUserLinkSiteTable == false)
                {
                    return(null);
                }

                string sql = string.Format("select distinct B.* from AXPUSERSITE A " +
                                           " left join AXPLINKSITE B on A.SITEID = B.SITEID" +
                                           " where A.USERID = {0} and ISSLAVE = 1", LibStringBuilder.GetQuotString(userId));
                LibDataAccess dataAccess = new LibDataAccess();
                string        name       = string.Empty;
                string        id         = string.Empty;
                using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
                {
                    while (reader.Read())
                    {
                        id   = LibSysUtils.ToString(reader["SITEID"]);
                        name = LibSysUtils.ToString(reader["SHORTNAME"]);
                        if (string.IsNullOrEmpty(id) == false)
                        {
                            siteIds[id] = new LinkSiteInfo()
                            {
                                SiteId    = id,
                                SiteName  = LibSysUtils.ToString(reader["SITENAME"]),
                                ShortName = LibSysUtils.ToString(reader["SHORTNAME"]),
                                SiteUrl   = LibSysUtils.ToString(reader["SITEURL"]),
                                SvcUrl    = LibSysUtils.ToString(reader["SVCURL"]),
                                IsSlave   = LibSysUtils.ToBoolean(reader["ISSLAVE"]),
                                IsSendTo  = LibSysUtils.ToBoolean(reader["ISSENDTO"]),
                            };
                        }
                    }
                }
            }
            catch
            {
                //to do log
            }
            return(siteIds);
        }
Beispiel #8
0
        public LoginInfo Login1(string userId, string password, bool quitOther = false)
        {
            LoginInfo     loginInfo  = new LoginInfo();
            SqlBuilder    builder    = new SqlBuilder("axp.User");
            string        sql        = builder.GetQuerySql(0, "A.Id,A.Name,A.UserImage", string.Format("A.Id={0} And A.Password={1} And A.ISUSE=1", LibStringBuilder.GetQuotString(userId), LibStringBuilder.GetQuotString(password)));
            LibDataAccess dataAccess = new LibDataAccess();
            string        roleId     = string.Empty;
            bool          exists     = false;

            using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
            {
                if (reader.Read())
                {
                    loginInfo.Id        = LibSysUtils.ToString(reader[0]);
                    loginInfo.Name      = LibSysUtils.ToString(reader[1]);
                    loginInfo.UserImage = LibSysUtils.ToString(reader[2]);
                    exists = true;
                }
            }
            if (exists)
            {
                LibHandle handle = LibHandleCache.Default.IsExistsHandle(LibHandeleType.PC, userId);
                if (handle != null)
                {
                    //LibHandleCache.Default.RemoveHandle(handle.Handle);
                }
                if (!loginInfo.IsUsed)
                {
                    string loginIp = string.Empty;
                    //Zhangkj20161219 增加LoginIp
                    System.ServiceModel.OperationContext context = System.ServiceModel.OperationContext.Current;
                    //对于非WCF的访问context为null
                    if (context != null)
                    {
                        System.ServiceModel.Channels.MessageProperties             properties = context.IncomingMessageProperties;
                        System.ServiceModel.Channels.RemoteEndpointMessageProperty endpoint   = properties[System.ServiceModel.Channels.RemoteEndpointMessageProperty.Name] as System.ServiceModel.Channels.RemoteEndpointMessageProperty;
                        loginIp = endpoint.Address + ":" + endpoint.Port.ToString();
                    }
                    //创建新的Handle
                    handle = LibHandleCache.Default.GetHandle(string.Empty, LibHandeleType.PC, userId, loginInfo.PersonId, loginInfo.PersonName, roleId, loginIp);
                    if (handle != null)
                    {
                        loginInfo.Handle = handle.Handle;
                    }
                }
            }
            return(loginInfo);
        }
Beispiel #9
0
        /// <summary>
        /// 获取站点代码对应的站点Url
        /// </summary>
        /// <param name="linkSiteIds"></param>
        /// <returns>返回站点代码与站点Url的对应关系字典</returns>
        public static Dictionary <string, string> GetSiteUrls(List <string> linkSiteIds)
        {
            if (linkSiteIds == null || linkSiteIds.Count == 0)
            {
                return(null);
            }
            Dictionary <string, string> dicSites = new Dictionary <string, string>();

            try
            {
                if (ExistLinkSiteTable == false)
                {
                    return(null);
                }
                string siteIdsStr = string.Empty;
                linkSiteIds.ForEach(item =>
                {
                    siteIdsStr += LibStringBuilder.GetQuotString(item) + ",";
                });
                siteIdsStr = siteIdsStr.Remove(siteIdsStr.Length - 1);
                string        sql        = string.Format("select distinct SITEID,SITEURL,SVCURL from AXPLINKSITE where  SITEID in ({0})", siteIdsStr);
                LibDataAccess dataAccess = new LibDataAccess();
                string        url        = string.Empty;
                string        id         = string.Empty;
                using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
                {
                    while (reader.Read())
                    {
                        id  = LibSysUtils.ToString(reader["SITEID"]);
                        url = LibSysUtils.ToString(reader["SVCURL"]);
                        if (string.IsNullOrEmpty(url))
                        {
                            url = LibSysUtils.ToString(reader["SITEURL"]);
                        }
                        if (string.IsNullOrEmpty(url) == false)
                        {
                            dicSites[id] = url;
                        }
                    }
                }
            }
            catch
            {
                //to do log
            }
            return(dicSites);
        }
Beispiel #10
0
        public string RecoverPassword(string userId)
        {
            string error = string.Empty;

            if (string.Compare(userId, "admin", true) == 0)
            {
                error = "账户admin不允许重置密码";
                return(error);
            }
            LibDataAccess dataAccess = new LibDataAccess();
            string        id = string.Empty, personId = string.Empty, email = string.Empty;

            using (IDataReader reader = dataAccess.ExecuteDataReader(string.Format("select A.USERID,A.PERSONID,B.MAIL from AXPUSER A inner join COMPERSON B on B.PERSONID=A.PERSONID where A.USERID={0}",
                                                                                   LibStringBuilder.GetQuotString(userId))))
            {
                if (reader.Read())
                {
                    id       = LibSysUtils.ToString(reader[0]);
                    personId = LibSysUtils.ToString(reader[1]);
                    email    = LibSysUtils.ToString(reader[2]);
                }
            }
            if (string.IsNullOrEmpty(id))
            {
                error = "该账号未注册";
            }
            else if (string.IsNullOrEmpty(email))
            {
                error = "该账号未关联邮箱,请联系管理员";
            }
            else
            {
                Random random = new Random();
                string pw     = string.Format("{0}{1}", userId, random.Next(1000, 9999));
                dataAccess.ExecuteNonQuery(string.Format("update AXPUSER set USERPASSWORD={0} where USERID={1}", LibStringBuilder.GetQuotString(pw), LibStringBuilder.GetQuotString(userId)));
                List <AxCRL.Core.Mail.LibMailParam> list  = new List <AxCRL.Core.Mail.LibMailParam>();
                AxCRL.Core.Mail.LibMailParam        param = new AxCRL.Core.Mail.LibMailParam();
                param.Content  = string.Format("您的账号 {0} 密码已重置。新密码为{1}", userId, pw);
                param.MailKind = AxCRL.Core.Mail.LibMailKind.Info;
                param.Subject  = "智慧工厂账号密码重置";
                param.To.Add(LibSysUtils.ToString(personId));
                list.Add(param);
                ThreadPool.QueueUserWorkItem(LibMailHelper.SendMail, list);
            }
            return(error);
        }
Beispiel #11
0
        public List <DeptInfo> GetDept()
        {
            List <DeptInfo> list       = new List <DeptInfo>();
            LibDataAccess   dataAccess = new LibDataAccess();

            using (IDataReader reader = dataAccess.ExecuteDataReader("select DEPTID,DEPTNAME from COMDEPT"))
            {
                while (reader.Read())
                {
                    list.Add(new DeptInfo()
                    {
                        DeptId   = LibSysUtils.ToString(reader["DEPTID"]),
                        DeptName = LibSysUtils.ToString(reader["DEPTNAME"])
                    });
                }
            }
            return(list);
        }
Beispiel #12
0
        public supplyLoginModel login(string userId, string password)
        {
            supplyLoginModel supplyLoginModel = new supplyLoginModel();
            SqlBuilder       builder          = new SqlBuilder("axp.User");
            string           sql        = builder.GetQuerySql(0, "A.PERSONID,A.PERSONNAME", string.Format("A.USERID={0} And A.USERPASSWORD={1} And A.ISUSE=1", LibStringBuilder.GetQuotString(userId), LibStringBuilder.GetQuotString(password)));
            LibDataAccess    dataAccess = new LibDataAccess();
            string           roleId     = string.Empty;

            using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
            {
                if (reader.Read())
                {
                    supplyLoginModel.PersonId     = LibSysUtils.ToString(reader[0]);
                    supplyLoginModel.LoginSuccess = true;
                }
            }
            return(supplyLoginModel);
        }
        public object RemoveCacheItem(string groupId)
        {
            string        sql        = string.Format("select distinct ROLEID from AXPROLEDETAIL where PERMISSIONGROUPID={0}", LibStringBuilder.GetQuotString(groupId));
            LibDataAccess dataAccess = new LibDataAccess();
            List <string> list       = new List <string>();

            using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
            {
                while (reader.Read())
                {
                    list.Add(LibSysUtils.ToString(reader["ROLEID"]));
                }
            }
            foreach (string roleId in list)
            {
                LibRolePermissionCache.Default.RemoveCacheItem(roleId);
            }
            return(this.Remove(groupId));
        }
Beispiel #14
0
        /// <summary>
        /// 单点登录。
        /// 1.检查当前本站点系统账户中是否存在userId,如果否则不予登录
        /// 2.使用userId、loginToken等访问sso管理站点的CheckSSOLoginState方法检验是否已经SSO登录过。
        ///   如果未登录过则不予登录。
        /// 3.判断当前站点中userId是否已经登录过,如果是则使用对应的LibHandle信息返回,否则则新构造LibHande并返回。
        /// </summary>
        ///<param name="ssoInfo">单点登录信息</param>
        /// <returns></returns>
        public LoginInfo SSOLogin(SSOInfo ssoInfo)
        {
            LoginInfo loginInfo = new LoginInfo()
            {
                IsUsed = true, IsOverUser = false
            };

            SqlBuilder    builder    = new SqlBuilder("axp.User");
            string        sql        = builder.GetQuerySql(0, "A.PERSONID,A.PERSONNAME,A.ROLEID,A.WALLPAPER,A.WALLPAPERSTRETCH", string.Format("A.USERID={0} And A.ISUSE=1", LibStringBuilder.GetQuotString(ssoInfo.UserId)));
            LibDataAccess dataAccess = new LibDataAccess();
            string        roleId     = string.Empty;

            using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
            {
                if (reader.Read())
                {
                    loginInfo.PersonId   = LibSysUtils.ToString(reader[0]);
                    loginInfo.PersonName = LibSysUtils.ToString(reader[1]);
                    roleId = LibSysUtils.ToString(reader[2]);
                    loginInfo.Wallpaper = LibSysUtils.ToString(reader[3]);
                    loginInfo.Stretch   = LibSysUtils.ToBoolean(reader[4]);
                    loginInfo.IsUsed    = false;
                }
                else
                {
                    return(loginInfo);
                }
            }
            if (CheckToken(ssoInfo))
            {
                // 授权成功
                LibHandle handle = LibHandleCache.Default.IsExistsHandle(LibHandeleType.PC, ssoInfo.UserId);
                if (handle == null)
                {
                    handle = LibHandleCache.Default.GetHandle(string.Empty, LibHandeleType.PC, ssoInfo.UserId, loginInfo.PersonId, loginInfo.PersonName, roleId);
                }
                loginInfo.Handle = handle.Handle;
                return(loginInfo);
            }
            return(loginInfo);
        }
Beispiel #15
0
        public static Dictionary <string, string[]> GetMailAddress(string send, IList <string> to, IList <string> cc)
        {
            Dictionary <string, string[]> dic = new Dictionary <string, string[]>();
            StringBuilder builder             = new StringBuilder();

            if (!string.IsNullOrEmpty(send))
            {
                builder.AppendFormat("PERSONID={0} OR ", LibStringBuilder.GetQuotString(send));
            }
            foreach (string item in to)
            {
                builder.AppendFormat("PERSONID={0} OR ", LibStringBuilder.GetQuotString(item));
            }
            foreach (string item in cc)
            {
                builder.AppendFormat("PERSONID={0} OR ", LibStringBuilder.GetQuotString(item));
            }
            if (builder.Length > 0)
            {
                builder.Remove(builder.Length - 3, 3);
                string        sql        = string.Format("select PERSONID,PERSONNAME,MAIL from COMPERSON where {0}", builder.ToString());
                LibDataAccess dataAccess = new LibDataAccess();
                using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
                {
                    while (reader.Read())
                    {
                        string personId   = LibSysUtils.ToString(reader[0]);
                        string personName = LibSysUtils.ToString(reader[1]);
                        string mail       = LibSysUtils.ToString(reader[2]);
                        if (!dic.ContainsKey(personId))
                        {
                            dic[personId] = new string[] { personName, mail }
                        }
                        ;
                    }
                }
            }
            return(dic);
        }
Beispiel #16
0
        /// <summary>
        /// 一般站点登录SSO管理站点(SSO管理站点才有用,前端不需要访问)
        /// </summary>
        /// <param name="userId">用户名</param>
        /// <param name="pwd">密码</param>
        /// <returns></returns>
        public string GetTokenByUserId(string userId, string pwd)
        {
            if (!EnvProvider.Default.IsSSOManageSite)
            {
                return(string.Empty);
            }
            LoginInfo     loginInfo  = new LoginInfo();
            SqlBuilder    builder    = new SqlBuilder("axp.User");
            string        sql        = builder.GetQuerySql(0, "A.PERSONID,A.PERSONNAME,A.ROLEID,A.WALLPAPER,A.WALLPAPERSTRETCH", string.Format("A.USERID={0} And A.USERPASSWORD={1} And A.ISUSE=1", LibStringBuilder.GetQuotString(userId), LibStringBuilder.GetQuotString(pwd)));
            LibDataAccess dataAccess = new LibDataAccess();
            string        roleId     = string.Empty;
            bool          exists     = false;

            using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
            {
                if (reader.Read())
                {
                    loginInfo.PersonId   = LibSysUtils.ToString(reader[0]);
                    loginInfo.PersonName = LibSysUtils.ToString(reader[1]);
                    roleId = LibSysUtils.ToString(reader[2]);
                    loginInfo.Wallpaper = LibSysUtils.ToString(reader[3]);
                    loginInfo.Stretch   = LibSysUtils.ToBoolean(reader[4]);
                    exists = true;
                }
            }
            if (exists)
            {
                LibHandle handle = LibHandleCache.Default.IsExistsHandle(LibHandeleType.PC, userId);
                if (handle != null)
                {
                    return(handle.GetToCheckToken());
                }
                handle = LibHandleCache.Default.GetHandle(string.Empty, LibHandeleType.PC, userId, loginInfo.PersonId, loginInfo.PersonName, roleId);
                return(handle.Token);
            }
            return(string.Empty);
        }
        /// <summary>
        /// 查找指定人员在所有部门中的最高任职岗位。如果没有任何任职则返回Null
        /// </summary>
        /// <param name="personId"></param>
        /// <returns></returns>
        public DutyPeronInfo GetHighestDuty(string personId)
        {
            DutyPeronInfo dutyInfo = null;

            if (HasAduitOfDuty == false || string.IsNullOrEmpty(personId))
            {
                return(null);
            }
            LibDataAccess dataAccess = new LibDataAccess();
            //审核配置表中包含了岗位相关字段,则多查找相关字段的信息 Zhangkj 20170323
            string sql = string.Format(" Select A.* From COMDUTY A " +
                                       "  Where A.DUTYID in (  " +
                                       "    Select distinct C.DUTYID From COMPERSON B " +
                                       "    inner join COMDEPTDUTYPERSON C on B.PERSONID = C.PERSONID " +
                                       "    where B.PERSONID = {0} " +
                                       "  ) " +
                                       " order by A.DUTYLEVEL desc",
                                       LibStringBuilder.GetQuotString(personId));

            using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
            {
                while (reader.Read())
                {
                    string dutyId    = LibSysUtils.ToString(reader["DUTYID"]);
                    string dutyName  = LibSysUtils.ToString(reader["DUTYNAME"]);
                    int    dutyLevel = LibSysUtils.ToInt32(reader["DUTYLEVEL"]);

                    dutyInfo = new DutyPeronInfo()
                    {
                        DutyId = dutyId, DutyName = dutyName, DutyLevel = dutyLevel
                    };
                    break;//只取按职级排序的第一个
                }
            }
            return(dutyInfo);
        }
Beispiel #18
0
        private static List <string> GetUserInfo(LibDataAccess dataAccess, List <string> personList)
        {
            List <string> userList = new List <string>();
            StringBuilder builder  = new StringBuilder();

            foreach (string personId in personList)
            {
                builder.AppendFormat("A.PERSONID={0} OR ", LibStringBuilder.GetQuotString(personId));
            }
            if (builder.Length > 0)
            {
                builder.Remove(builder.Length - 3, 3);
                SqlBuilder sqlBuilder = new SqlBuilder("axp.User");
                string     sql        = sqlBuilder.GetQuerySql(0, "A.USERID", builder.ToString(), string.Empty, string.Empty, true);
                using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
                {
                    while (reader.Read())
                    {
                        userList.Add(LibSysUtils.ToString(reader["USERID"]));
                    }
                }
            }
            return(userList);
        }
Beispiel #19
0
        public BarcodeRule GetBarcodeRule(string ruleId)
        {
            BarcodeRule codingRule = this.Get <BarcodeRule>(ruleId);

            if (codingRule == null)
            {
                lock (_LockRuleObj)
                {
                    codingRule = this.Get <BarcodeRule>(ruleId);
                    if (codingRule == null)
                    {
                        string     sql;
                        SqlBuilder sqlBuilder = new SqlBuilder("com.BarcodeRule");
                        sql        = sqlBuilder.GetQuerySql(1, "B.ROW_ID,B.SECTIONTYPE,B.SECTIONLENGTH,B.TABLEINDEX,B.FIELDNAME,B.SECTIONVALUE", string.Format("A.BARCODERULEID={0} And A.VALIDITYSTARTDATE <= {1} And (A.VALIDITYENDDATE >= {1} or A.VALIDITYENDDATE = 0)", LibStringBuilder.GetQuotString(ruleId), LibDateUtils.GetCurrentDate()), "B.ROWNO ASC");
                        codingRule = new BarcodeRule();
                        Dictionary <int, int> listIndex  = new Dictionary <int, int>();
                        LibDataAccess         dataAccess = new LibDataAccess();
                        using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
                        {
                            int startIndex = 0;
                            while (reader.Read())
                            {
                                BarcodeRuleItem rule = new BarcodeRuleItem();
                                rule.SectionType = (BarcodeRuleSectionType)LibSysUtils.ToInt32(reader["SECTIONTYPE"]);
                                rule.Start       = startIndex;
                                rule.Length      = LibSysUtils.ToInt32(reader["SECTIONLENGTH"]);
                                switch (rule.SectionType)
                                {
                                case BarcodeRuleSectionType.None:
                                    rule.Value = LibSysUtils.ToString(reader["SECTIONVALUE"]);
                                    break;

                                case BarcodeRuleSectionType.Dynamic:
                                    rule.TableIndex = LibSysUtils.ToInt32(reader["TABLEINDEX"]);
                                    rule.FieldName  = LibSysUtils.ToString(reader["FIELDNAME"]);
                                    rule.Values.Add(rule.FieldName, LibSysUtils.ToString(reader["SECTIONVALUE"]));
                                    int rowId = LibSysUtils.ToInt32(reader["ROW_ID"]);
                                    if (!listIndex.ContainsKey(rowId))
                                    {
                                        listIndex.Add(rowId, codingRule.Items.Count);
                                    }
                                    break;
                                }
                                startIndex += rule.Length;
                                codingRule.Items.Add(rule);
                            }
                        }
                        sql = sqlBuilder.GetQuerySql(2, "C.PARENTROWID,C.FIELDVALUE,C.SECTIONVALUE", string.Format("A.BARCODERULEID={0} And A.VALIDITYSTARTDATE <= {1} And (A.VALIDITYENDDATE >= {1} or A.VALIDITYENDDATE = 0)", LibStringBuilder.GetQuotString(ruleId), LibDateUtils.GetCurrentDate()));
                        using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
                        {
                            while (reader.Read())
                            {
                                int rowId = LibSysUtils.ToInt32(reader["PARENTROWID"]);
                                if (listIndex.ContainsKey(rowId))
                                {
                                    BarcodeRuleItem rule       = codingRule.Items[listIndex[rowId]];
                                    string          fieldValue = LibSysUtils.ToString(reader["FIELDVALUE"]);
                                    if (!rule.Values.ContainsKey(fieldValue))
                                    {
                                        rule.Values.Add(fieldValue, LibSysUtils.ToString(reader["SECTIONVALUE"]));
                                    }
                                }
                            }
                        }
                        this.Set(ruleId, codingRule, new TimeSpan(0, 180, 0));
                    }
                }
            }
            return(codingRule);
        }
Beispiel #20
0
        private static void InitBusinessTask()
        {
            Dictionary <string, LibBusinessTask> taskList = new Dictionary <string, LibBusinessTask>();
            int        currentDate = LibDateUtils.GetCurrentDate();
            SqlBuilder sqlBuilder  = new SqlBuilder("axp.ScheduleTask");
            string     sql         = sqlBuilder.GetQuerySql(0, "A.TASKID,A.PROGID,A.BUSINESSTASKID,A.CALENDARID,A.ISJUSTWORKDAY,A.INTERVALTIME,A.EXECDATE,A.REPEATDATEMARK,A.EXECCONDITION,A.TITLE,A.MAINCONTENT,B.EXECTIME",
                                                            string.Format("A.CURRENTSTATE=2 and (A.VALIDITYSTARTDATE <= {0} and (A.VALIDITYENDDATE>{0} or A.VALIDITYENDDATE = 0))", currentDate), "A.TASKID,B.EXECTIME");
            LibDataAccess dataAccess = new LibDataAccess();

            using (IDataReader reader = dataAccess.ExecuteDataReader(sql, false))
            {
                while (reader.Read())
                {
                    string taskId   = LibSysUtils.ToString(reader["TASKID"]);
                    int    execTime = LibSysUtils.ToInt32(reader["EXECTIME"]);
                    if (taskList.ContainsKey(taskId))
                    {
                        if (execTime > 0)
                        {
                            taskList[taskId].ExecTime.Add(execTime);
                        }
                    }
                    else
                    {
                        LibBusinessTask task = new LibBusinessTask();
                        task.BusinessTaskId = LibSysUtils.ToString(reader["BUSINESSTASKID"]);
                        task.CalendarId     = LibSysUtils.ToString(reader["CALENDARID"]);
                        task.ExecCondition  = LibSysUtils.ToString(reader["ExecCondition"]);
                        task.ExecDate       = LibSysUtils.ToInt32(reader["EXECDATE"]);
                        task.IntervalTime   = LibSysUtils.ToInt32(reader["INTERVALTIME"]);
                        task.IsJustWorkDay  = LibSysUtils.ToBoolean(reader["ISJUSTWORKDAY"]);
                        task.ProgId         = LibSysUtils.ToString(reader["PROGID"]);
                        task.Title          = LibSysUtils.ToString(reader["TITLE"]);
                        task.MainContent    = LibSysUtils.ToString(reader["MAINCONTENT"]);
                        task.RepeatDateMark = LibSysUtils.ToInt32(reader["REPEATDATEMARK"]);
                        task.TaskId         = taskId;
                        if (execTime > 0)
                        {
                            task.ExecTime.Add(execTime);
                        }
                        taskList.Add(taskId, task);
                    }
                }
            }
            sql = string.Format("select distinct A.TASKID,A.PERSONID,D.DEPTID,C.USERID from AXPSCHEDULETASKPERSON A " +
                                "inner join AXPSCHEDULETASK B on B.TASKID=A.TASKID left join COMPERSON D on D.PERSONID=A.PERSONID inner join AXPUSER C on C.PERSONID=A.PERSONID " +
                                "where B.CURRENTSTATE=2 and (B.VALIDITYSTARTDATE <= {0} and (B.VALIDITYENDDATE>{0} or B.VALIDITYENDDATE = 0))", currentDate);
            using (IDataReader reader = dataAccess.ExecuteDataReader(sql, false))
            {
                while (reader.Read())
                {
                    string taskId = LibSysUtils.ToString(reader["TASKID"]);
                    if (taskList.ContainsKey(taskId))
                    {
                        taskList[taskId].Liaison.Add(new LibBusinessTaskLiaison()
                        {
                            PersonId = LibSysUtils.ToString(reader["PERSONID"]),
                            DeptId   = LibSysUtils.ToString(reader["DEPTID"]),
                            UserId   = LibSysUtils.ToString(reader["USERID"])
                        });
                    }
                }
            }
            foreach (var item in taskList)
            {
                _Default.Set(item.Key, item.Value);
            }
        }
Beispiel #21
0
        public CodingRule GetCodingRule(BillType billType, string progId)
        {
            CodingRule codingRule = this.Get <CodingRule>(progId);

            if (codingRule == null)
            {
                lock (_LockRuleObj)
                {
                    codingRule = this.Get <CodingRule>(progId);
                    if (codingRule == null)
                    {
                        codingRule = new CodingRule();
                        Dictionary <int, int> listIndex  = new Dictionary <int, int>();
                        SqlBuilder            sqlBuilder = new SqlBuilder("com.CodingRule");
                        //string sql = sqlBuilder.GetQuerySql(1, "B.ROW_ID,B.SECTIONTYPE,B.SECTIONLENGTH,B.FIELDNAME,B.SECTIONVALUE", string.Format("A.PROGID = {0} And A.VALIDITYSTARTDATE <= {1} And (A.VALIDITYENDDATE >= {1} or A.VALIDITYENDDATE = 0)", LibStringBuilder.GetQuotString(progId), LibDateUtils.GetCurrentDate()), "B.ROWNO ASC");
                        string        sql        = sqlBuilder.GetQuerySql(1, "B.ROW_ID,B.SECTIONTYPE,B.SECTIONLENGTH,B.FIELDNAME,B.SECTIONVALUE", string.Format("A.PROGID = {0}", LibStringBuilder.GetQuotString(progId), LibDateUtils.GetCurrentDate()), "B.ROWNO ASC");
                        LibDataAccess dataAccess = new LibDataAccess();
                        using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
                        {
                            while (reader.Read())
                            {
                                CodingRuleItem rule = new CodingRuleItem();
                                rule.SectionType = (SectionType)LibSysUtils.ToInt32(reader["SECTIONTYPE"]);
                                rule.Length      = LibSysUtils.ToInt32(reader["SECTIONLENGTH"]);
                                switch (rule.SectionType)
                                {
                                case SectionType.None:
                                    rule.Value = LibSysUtils.ToString(reader["SECTIONVALUE"]);
                                    break;

                                case SectionType.Dynamic:
                                    rule.FieldName = LibSysUtils.ToString(reader["FIELDNAME"]);
                                    rule.Values.Add(rule.FieldName, LibSysUtils.ToString(reader["SECTIONVALUE"]));
                                    int rowId = LibSysUtils.ToInt32(reader["ROW_ID"]);
                                    if (!listIndex.ContainsKey(rowId))
                                    {
                                        listIndex.Add(rowId, codingRule.Items.Count);
                                    }
                                    if (!codingRule.CreateOnSave)
                                    {
                                        codingRule.CreateOnSave = true;
                                    }
                                    break;
                                }
                                codingRule.Items.Add(rule);
                            }
                        }
                        sql = sqlBuilder.GetQuerySql(2, "C.PARENTROWID,C.FIELDVALUE,C.SECTIONVALUE", string.Format("A.PROGID = {0}", LibStringBuilder.GetQuotString(progId)));
                        using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
                        {
                            while (reader.Read())
                            {
                                int rowId = LibSysUtils.ToInt32(reader["PARENTROWID"]);
                                if (listIndex.ContainsKey(rowId))
                                {
                                    CodingRuleItem rule       = codingRule.Items[listIndex[rowId]];
                                    string         fieldValue = LibSysUtils.ToString(reader["FIELDVALUE"]);
                                    if (!rule.Values.ContainsKey(fieldValue))
                                    {
                                        rule.Values.Add(fieldValue, LibSysUtils.ToString(reader["SECTIONVALUE"]));
                                    }
                                }
                            }
                        }
                        //如果为单据,默认产生编码规则 日期+6位流水码
                        if (codingRule.Items.Count == 0)
                        {
                            if (billType == BillType.Bill)
                            {
                                codingRule.Items.Add(new CodingRuleItem()
                                {
                                    SectionType = SectionType.DateL
                                });
                                codingRule.Items.Add(new CodingRuleItem()
                                {
                                    SectionType = SectionType.SerialNum, Length = 6
                                });
                            }
                        }
                        else
                        {
                            codingRule.IsSetRule = true;
                        }
                        if (codingRule.Items.Count > 0)
                        {
                            this.Set(progId, codingRule, new TimeSpan(0, 180, 0));
                        }
                    }
                }
            }
            return(codingRule);
        }
Beispiel #22
0
        public void RemoveFromSaleBillNo(string fromSaleBillNo)
        {
            //通过销售订单号查找派工单号
            string        sql        = string.Format(@"SELECT DISTINCT F.BILLNO
                                          FROM WORKORDER A
                                         INNER JOIN WORKORDERDETAIL B
                                            ON A.BILLNO = B.BILLNO
                                         INNER JOIN PLSSALESORDER C
                                            ON B.FROMBILLNO = C.BILLNO
                                         INNER JOIN PLSPRODUCEMONTHPLANDETAIL D
                                            ON D.WORKORDERBILLNO = B.BILLNO
                                         INNER JOIN PLSPRODUCEDAYPLANDETAIL E
                                            ON E.FROMBILLNO = D.BILLNO
                                           AND E.FROMROWID = D.ROW_ID
                                         INNER JOIN PPWORKORDER F
                                            ON E.PWORKORDERNO = F.BILLNO
                                         WHERE A.PARENTBILLNO IS NULL AND C.BILLNO = {0} ", LibStringBuilder.GetQuotString(fromSaleBillNo));
            LibDataAccess dataAccess = new LibDataAccess();
            StringBuilder builder    = new StringBuilder();
            Int32         index      = 1;

            using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
            {
                while (reader.Read())
                {
                    string        workOrderNo   = LibSysUtils.ToString(reader["BILLNO"]);
                    HYProduceData hyProduceData = LibHYProduceCache.Default.GetProduceData(workOrderNo);
                    DataTable     dt            = hyProduceData.TenWorkRecord.Tables[0];
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        string saleBillNo = LibSysUtils.ToString(dt.Rows[i]["FROMSALEBILLNO"]);
                        if (saleBillNo == fromSaleBillNo)
                        {
                            dt.Rows[i].Delete();
                        }
                    }
                    dt.AcceptChanges();
                    if (index == 1)
                    {
                        builder.AppendFormat(" AND (WORKORDERNO = {0}", LibStringBuilder.GetQuotObject(reader["BILLNO"]));
                    }
                    else
                    {
                        builder.AppendFormat(" OR WORKORDERNO = {0}", LibStringBuilder.GetQuotObject(reader["BILLNO"]));
                    }
                    index++;
                }
            }
            if (builder.Length > 0)
            {
                builder.Append(")");
                sql = string.Format(@"DELETE FROM PPTENWORKRECORD WHERE 1=1 {0} AND FROMSALEBILLNO = '{1}'", builder.ToString(), fromSaleBillNo);
                LibDBTransaction trans = dataAccess.BeginTransaction();
                try
                {
                    int result = dataAccess.ExecuteNonQuery(sql);
                    trans.Commit();
                }
                catch (Exception)
                {
                    trans.Rollback();
                }
            }
        }
Beispiel #23
0
        public LoginInfo AppLogin(string userId, string password, string clientId, int clientType, bool quitOther = false)
        {
            LoginInfo loginInfo = new LoginInfo();
            //检查是否具有 AXPUSERAPP数据表,用于判定是否支持移动端App登录
            LibSqlModel sqlModel      = LibSqlModelCache.Default.GetSqlModel("axp.User");
            bool        hasAXPUSERAPP = false;

            if (sqlModel != null && sqlModel.Tables.Count > 1 && sqlModel.Tables[1].TableName.Equals("AXPUSERAPP"))
            {
                hasAXPUSERAPP = true;
            }
            if (hasAXPUSERAPP == false)
            {
                return(loginInfo);//如果没有需要的相关字段则直接返回
            }

            SqlBuilder builder = new SqlBuilder("axp.User");
            string     sql     = string.Format(@"SELECT 
                                        A.PERSONID,
                                        A.ROLEID,
                                        A.WALLPAPER,A.WALLPAPERSTRETCH,B.PERSONNAME,B.PHONENO,B.CORNET,B.HEADPORTRAIT,B.MAIL   
                                        FROM AXPUSER A LEFT JOIN COMPERSON B ON B.PERSONID=A.PERSONID   
                                        WHERE A.USERID={0} and A.USERPASSWORD={1} AND A.ISUSE=1", LibStringBuilder.GetQuotString(userId), LibStringBuilder.GetQuotString(password));
            //builder.GetQuerySql(0, "A.PERSONID,A.PERSONNAME,A.PHONENO,A.CORNET,A.HEADPORTRAIT,A.MAIL,A.ROLEID,A.WALLPAPER,A.WALLPAPERSTRETCH", string.Format("A.USERID={0} And A.USERPASSWORD={1} And A.ISUSE=1", LibStringBuilder.GetQuotString(userId), LibStringBuilder.GetQuotString(password)));
            LibDataAccess dataAccess = new LibDataAccess();
            string        roleId     = string.Empty;
            bool          exists     = false;

            using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
            {
                if (reader.Read())
                {
                    loginInfo.PersonId   = LibSysUtils.ToString(reader["PERSONID"]);
                    loginInfo.PersonName = LibSysUtils.ToString(reader["PERSONNAME"]);
                    roleId = LibSysUtils.ToString(reader["ROLEID"]);
                    loginInfo.Wallpaper = LibSysUtils.ToString(reader["WALLPAPER"]);
                    loginInfo.Stretch   = LibSysUtils.ToBoolean(reader["WALLPAPERSTRETCH"]);
                    //20170214 施卢威 增加头像 Email 短号信息
                    loginInfo.Headportrait = LibSysUtils.ToString(reader["HEADPORTRAIT"]);
                    loginInfo.UserEMail    = LibSysUtils.ToString(reader["MAIL"]);
                    loginInfo.Cornet       = LibSysUtils.ToString(reader["CORNET"]);
                    loginInfo.UserPhone    = LibSysUtils.ToString(reader["PHONENO"]);
                    exists = true;
                }
            }
            if (exists)
            {
                #region 帐号与登录设备关联
                string appSql = string.Empty;
                //查询帐号是否已有设备标识
                int isAPPClient = LibSysUtils.ToInt32(dataAccess.ExecuteScalar(string.Format("SELECT COUNT(*) from AXPUSERAPP WHERE USERID = '{0}' and CLIENTTYPE={1}", userId, clientType)));
                if (isAPPClient > 0)
                {
                    //更新设备标识信息
                    appSql = string.Format("UPDATE AXPUSERAPP SET  CLIENTID={1}    WHERE USERID={0} AND CLIENTTYPE={2}", LibStringBuilder.GetQuotString(userId), LibStringBuilder.GetQuotString(clientId), clientType);
                }
                else
                {
                    int curMaxRowId = LibSysUtils.ToInt32(dataAccess.ExecuteScalar(string.Format("SELECT Max(ROW_ID) from AXPUSERAPP WHERE USERID='{0}'", userId)));
                    //插入账户对应的App设备标识信息。
                    appSql = string.Format("insert into AXPUSERAPP(USERID,ROW_ID,ROWNO,CLIENTTYPE,CLIENTID) values('{0}',{1},{2},{3},'{4}')",
                                           userId, curMaxRowId + 1, curMaxRowId + 1, clientType, clientId, 1);
                }
                dataAccess.ExecuteNonQuery(appSql);

                #endregion

                LibHandle handle = LibHandleCache.Default.IsExistsHandle(LibHandeleType.PC, userId);
                if (handle != null)
                {
                    if (quitOther)
                    {
                        LibHandleCache.Default.RemoveHandle(handle.Handle);
                    }
                    else
                    {
                        loginInfo.IsUsed = true;
                    }
                }
                if (!loginInfo.IsUsed)
                {
                    long currentCount = LibHandleCache.Default.GetCount();
                    long maxUserCount = (long)LibHandleCache.Default.MaxUserCount;
                    if (maxUserCount != -1 && maxUserCount < currentCount)
                    {
                        loginInfo.IsOverUser = true;
                    }
                    else
                    {
                        string loginIp = string.Empty;
                        //Zhangkj20161219 增加LoginIp
                        System.ServiceModel.OperationContext context = System.ServiceModel.OperationContext.Current;
                        //对于非WCF的访问context为null
                        if (context != null)
                        {
                            System.ServiceModel.Channels.MessageProperties             properties = context.IncomingMessageProperties;
                            System.ServiceModel.Channels.RemoteEndpointMessageProperty endpoint   = properties[System.ServiceModel.Channels.RemoteEndpointMessageProperty.Name] as System.ServiceModel.Channels.RemoteEndpointMessageProperty;
                            loginIp = endpoint.Address + ":" + endpoint.Port.ToString();
                            handle  = LibHandleCache.Default.GetHandle(string.Empty, LibHandeleType.PC, userId, loginInfo.PersonId, loginInfo.PersonName, roleId, loginIp);
                        }
                        else
                        {
                            handle = LibHandleCache.Default.GetHandle(string.Empty, LibHandeleType.PC, userId, loginInfo.PersonId, loginInfo.PersonName, roleId);
                        }
                        //创建新的Handle

                        if (handle != null)
                        {
                            loginInfo.Handle = handle.Handle;
                        }
                    }
                }
            }
            return(loginInfo);
        }
Beispiel #24
0
        public LoginInfo Login(string userId, string password, bool quitOther = false)
        {
            LoginInfo     loginInfo  = new LoginInfo();
            SqlBuilder    builder    = new SqlBuilder("axp.User");
            string        sql        = builder.GetQuerySql(0, "A.PERSONID,A.PERSONNAME,A.ROLEID,A.WALLPAPER,A.WALLPAPERSTRETCH", string.Format("A.USERID={0} And A.USERPASSWORD={1} And A.ISUSE=1", LibStringBuilder.GetQuotString(userId), LibStringBuilder.GetQuotString(password)));
            LibDataAccess dataAccess = new LibDataAccess();
            string        roleId     = string.Empty;
            bool          exists     = false;

            using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
            {
                if (reader.Read())
                {
                    loginInfo.PersonId   = LibSysUtils.ToString(reader[0]);
                    loginInfo.PersonName = LibSysUtils.ToString(reader[1]);
                    roleId = LibSysUtils.ToString(reader[2]);
                    loginInfo.Wallpaper = LibSysUtils.ToString(reader[3]);
                    loginInfo.Stretch   = LibSysUtils.ToBoolean(reader[4]);
                    exists = true;
                }
            }
            if (exists)
            {
                LibHandle handle = LibHandleCache.Default.IsExistsHandle(LibHandeleType.PC, userId);
                if (handle != null)
                {
                    if (quitOther)
                    {
                        LibHandleCache.Default.RemoveHandle(handle.Handle);
                    }
                    else
                    {
                        loginInfo.IsUsed = true;
                    }
                }
                if (!loginInfo.IsUsed)
                {
                    long currentCount = LibHandleCache.Default.GetCount();
                    long maxUserCount = (long)LibHandleCache.Default.MaxUserCount;
                    if (maxUserCount != -1 && maxUserCount < currentCount)
                    {
                        loginInfo.IsOverUser = true;
                    }
                    else
                    {
                        string loginIp = string.Empty;
                        //Zhangkj20161219 增加LoginIp
                        System.ServiceModel.OperationContext context = System.ServiceModel.OperationContext.Current;
                        //对于非WCF的访问context为null
                        if (context != null)
                        {
                            System.ServiceModel.Channels.MessageProperties             properties = context.IncomingMessageProperties;
                            System.ServiceModel.Channels.RemoteEndpointMessageProperty endpoint   = properties[System.ServiceModel.Channels.RemoteEndpointMessageProperty.Name] as System.ServiceModel.Channels.RemoteEndpointMessageProperty;
                            loginIp = endpoint.Address + ":" + endpoint.Port.ToString();
                        }
                        //创建新的Handle
                        handle = LibHandleCache.Default.GetHandle(string.Empty, LibHandeleType.PC, userId, loginInfo.PersonId, loginInfo.PersonName, roleId, loginIp);
                        if (handle != null)
                        {
                            loginInfo.Handle = handle.Handle;
                        }
                    }
                }
            }
            return(loginInfo);
        }
Beispiel #25
0
        /// <summary>
        /// 根据单据操作类型和发送人列表获取推送目标
        /// </summary>
        /// <param name="billAction">表单操作类型</param>
        /// <param name="send">主要发送到的PERSONID</param>
        /// <param name="to">发送到的PERSONID列表</param>
        /// <param name="cc">抄送的人员PERSONID列表</param>
        /// <returns></returns>
        public static List <PushTarget> GetPushTarget(BillAction billAction, string send, IList <string> to, IList <string> cc)
        {
            //检查是否具有 AXPUSERAPP数据表
            LibSqlModel sqlModel      = LibSqlModelCache.Default.GetSqlModel("axp.User");
            bool        hasAXPUSERAPP = false;

            if (sqlModel != null && sqlModel.Tables.Count > 1 && sqlModel.Tables[1].TableName.Equals("AXPUSERAPP"))
            {
                hasAXPUSERAPP = true;
            }
            if (hasAXPUSERAPP == false)
            {
                return(null);//如果没有需要的相关字段则直接返回
            }
            // 查找支持指定BillAction的AppType类型
            List <AppType> listType    = AppTypeBillActionConfig.Instance.QueryCan(billAction);
            string         listTypeStr = string.Empty;

            if (listType == null || listType.Count == 0)
            {
                return(null);
            }
            List <int> listTypeInt = new List <int>();

            listType.ForEach(type => {
                listTypeInt.Add((int)type);
            });
            listTypeStr = string.Join(",", listTypeInt);

            List <PushTarget> targetList = new List <PushTarget>();
            StringBuilder     builder    = new StringBuilder();

            if (!string.IsNullOrEmpty(send))
            {
                builder.AppendFormat("C.PERSONID={0} OR ", LibStringBuilder.GetQuotString(send));
            }
            if (to != null)
            {
                foreach (string item in to)
                {
                    builder.AppendFormat("C.PERSONID={0} OR ", LibStringBuilder.GetQuotString(item));
                }
            }
            if (cc != null)
            {
                foreach (string item in cc)
                {
                    builder.AppendFormat("C.PERSONID={0} OR ", LibStringBuilder.GetQuotString(item));
                }
            }

            if (builder.Length > 0)
            {
                builder.Remove(builder.Length - 3, 3);
                string sql = string.Format("select distinct A.CLIENTTYPE,A.CLIENTID from AXPUSERAPP A " +
                                           " left join AXPUSER B on A.USERID = B.USERID " +
                                           " left join COMPERSON C on B.PERSONID = C.PERSONID " +
                                           " where ( {0} ) and A.CLIENTTYPE in ({1})", builder.ToString(), listTypeStr);
                LibDataAccess dataAccess = new LibDataAccess();
                using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
                {
                    while (reader.Read())
                    {
                        int    appType  = LibSysUtils.ToInt32(reader[0]);
                        string clientId = LibSysUtils.ToString(reader[1]);
                        if (string.IsNullOrEmpty(clientId) == false)
                        {
                            targetList.Add(new PushTarget()
                            {
                                AppType  = appType,
                                ClientId = clientId
                            });
                        }
                    }
                }
            }
            return(targetList);
        }
        /// <summary>
        /// 从缓存中查找对象,如果没有则从数据库查找并存到缓存中
        /// </summary>
        /// <param name="deptId_p"></param>
        /// <returns></returns>
        public DeptDutyPersonInfo GetCacheItem(string deptId_p)
        {
            string key = deptId_p;

            DeptDutyPersonInfo value = this.Get <DeptDutyPersonInfo>(key);

            if (value == null)
            {
                //检查部门Bcf中是否有岗位任职从表,有则说明存在部门岗位信息
                if (HasAduitOfDuty == false)
                {
                    return(null);
                }

                LibDataAccess dataAccess = new LibDataAccess();
                string        sql        = string.Format("Select B.DEPTID,B.DEPTNAME,B.SUPERDEPTID, " +
                                                         " E.DUTYID,E.DUTYNAME,E.DUTYLEVEL," +
                                                         " A.PERSONORDER,C.PERSONID,C.PERSONNAME" +
                                                         " From COMDEPT B " + //以部门为主查询表,无论其他是否有,部门都要查到
                                                         " left join COMDEPTDUTYPERSON  A on B.DEPTID=A.DEPTID " +
                                                         " left join COMPERSON C on C.PERSONID=A.PERSONID " +
                                                         " left join COMDUTY E on A.DUTYID=E.DUTYID " +//职务表
                                                         " Where B.DEPTID={0} ",
                                                         LibStringBuilder.GetQuotString(deptId_p));
                using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
                {
                    while (reader.Read())
                    {
                        string deptId       = LibSysUtils.ToString(reader["DEPTID"]);
                        string deptName     = LibSysUtils.ToString(reader["DEPTNAME"]);
                        string parentDeptId = LibSysUtils.ToString(reader["SUPERDEPTID"]);

                        string dutyId    = LibSysUtils.ToString(reader["DUTYID"]);
                        string dutyName  = LibSysUtils.ToString(reader["DUTYNAME"]);
                        int    dutyLevel = LibSysUtils.ToInt32(reader["DUTYLEVEL"]);

                        string personId   = LibSysUtils.ToString(reader["PERSONID"]);
                        string personName = LibSysUtils.ToString(reader["PERSONNAME"]);
                        //对于一个部门中同一岗位下有多个人时,可按照序号从小到大表示职位在部门内的从高到低顺序,例如第一副经理、第二副经理
                        int personOrder = LibSysUtils.ToInt32(reader["PERSONORDER"]);

                        if (value == null)
                        {
                            value = new DeptDutyPersonInfo()
                            {
                                DeptId = deptId, DeptName = deptName, ParentDeptId = parentDeptId
                            }
                        }
                        ;
                        if (string.IsNullOrEmpty(dutyId))
                        {
                            continue;
                        }
                        DutyPeronInfo dutyPerson = value.DutyPersons.Find(item =>
                        {
                            if (item.DutyId.Equals(dutyId))
                            {
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        });
                        if (dutyPerson == null)
                        {
                            dutyPerson = new DutyPeronInfo()
                            {
                                DutyId = dutyId, DutyName = dutyName, DutyLevel = dutyLevel, PersonOrder = personOrder
                            };
                            value.DutyPersons.Add(dutyPerson);
                        }
                        if (personOrder < dutyPerson.PersonOrder)
                        {
                            dutyPerson.PersonOrder = personOrder;
                        }
                        //先按照职级从小到大排序,对于职级相同的不同职位再按位序从大到小排序。方便查找时先找职级低,位序低的人
                        value.DutyPersons = (from item in value.DutyPersons
                                             orderby item.DutyLevel ascending, item.PersonOrder descending
                                             select item).ToList();
                        if (string.IsNullOrEmpty(personId))
                        {
                            continue;
                        }
                        PersonInfo personInfo = dutyPerson.PersonList.Find(person => {
                            if (person.PersonId.Equals(personId))
                            {
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        });
                        if (personInfo == null)
                        {
                            personInfo = new PersonInfo()
                            {
                                PersonId           = personId,
                                PersonName         = personName,
                                PersonOrder        = personOrder,
                                AsBelongDeptId     = deptId,
                                AsBelongDeptName   = deptName,
                                AsBeOfficeDutyId   = dutyId,
                                AsBeOfficeDutyName = dutyName
                            };
                            dutyPerson.PersonList.Add(personInfo);
                            dutyPerson.PersonList = dutyPerson.PersonList.OrderByDescending(p => p.PersonOrder).ToList();//序号从大到小排列,表示先找位序低的人
                        }
                    }
                }

                if (value != null)
                {
                    //180分钟内不访问自动剔除
                    this.Set(key, value, new TimeSpan(0, 180, 0));
                }
            }
            return(value);
        }
Beispiel #27
0
        public object GetValueByName(string progId, object[] pks, string name)
        {
            object value = null;
            string key   = BuildCacheKey(progId, pks);
            Dictionary <string, object> destObj = this.Get <Dictionary <string, object> >(key);

            if (destObj == null)
            {
                destObj = new Dictionary <string, object>();
                LibSqlModel          sqlModel = LibSqlModelCache.Default.GetSqlModel(progId);
                DataColumnCollection columns  = sqlModel.Tables[0].Columns;
                //说明缓存不存在则需创建
                StringBuilder whereBuilder = new StringBuilder();
                for (int i = 0; i < sqlModel.Tables[0].PrimaryKey.Length; i++)
                {
                    if (i != 0)
                    {
                        whereBuilder.AppendFormat(" AND ");
                    }
                    if (pks[i].GetType() == typeof(string))
                    {
                        whereBuilder.AppendFormat("A.{0}={1}", sqlModel.Tables[0].PrimaryKey[i].ColumnName, LibStringBuilder.GetQuotObject(pks[i]));
                    }
                    else
                    {
                        whereBuilder.AppendFormat("A.{0}={1}", sqlModel.Tables[0].PrimaryKey[i].ColumnName, pks[i]);
                    }
                }
                SqlBuilder sqlBuilder = new SqlBuilder(progId);
                string     sql        = sqlBuilder.GetQuerySql(0, "A.*", whereBuilder.ToString());
                //TODO固定字段应排除
                LibDataAccess dataAccess = new LibDataAccess();
                using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
                {
                    if (reader.Read())
                    {
                        int count = reader.FieldCount;
                        for (int i = 0; i < count; i++)
                        {
                            string columnName  = reader.GetName(i);
                            object columnValue = reader.GetValue(i);
                            if (dataAccess.DatabaseType == LibDatabaseType.Oracle && columnValue.GetType() == typeof(decimal))
                            {   //如果是oracle 数值类型都是number
                                LibDataType dataType = (LibDataType)((int)columns[columnName].ExtendedProperties[FieldProperty.DataType]);
                                switch (dataType)
                                {
                                case LibDataType.Int32:
                                    columnValue = decimal.ToInt32((decimal)columnValue);
                                    break;

                                case LibDataType.Int64:
                                    columnValue = decimal.ToInt64((decimal)columnValue);
                                    break;

                                case LibDataType.Float:
                                    columnValue = decimal.ToSingle((decimal)columnValue);
                                    break;

                                case LibDataType.Double:
                                    columnValue = decimal.ToDouble((decimal)columnValue);
                                    break;

                                case LibDataType.Byte:
                                    columnValue = decimal.ToByte((decimal)columnValue);
                                    break;

                                case LibDataType.Boolean:
                                    columnValue = (decimal)columnValue == decimal.Zero ? false : true;
                                    break;
                                }
                            }
                            destObj.Add(columnName, columnValue);
                        }
                    }
                }
                if (destObj.Count > 0)
                {
                    //CacheItemPolicy policy = new CacheItemPolicy();
                    //policy.SlidingExpiration = new TimeSpan(0, 180, 0); //30分钟内不访问自动剔除
                    _Default.Set(key, destObj, new TimeSpan(0, 180, 0));
                }
            }
            destObj.TryGetValue(name, out value);
            return(value);
        }
        private LibPermissionGroup GetPermissionGroupData(string groupId)
        {
            LibPermissionGroup groupData     = null;
            string             sql           = string.Format("select PARENTGROUPID from AXPPERMISSIONGROUP where PERMISSIONGROUPID={0} and ISVALIDITY=1", LibStringBuilder.GetQuotString(groupId));
            LibDataAccess      dataAccess    = new LibDataAccess();
            string             parentGroupId = LibSysUtils.ToString(dataAccess.ExecuteScalar(sql, false));

            if (!string.IsNullOrEmpty(parentGroupId))
            {
                groupData = GetPermissionGroupData(parentGroupId);
            }
            if (groupData == null)
            {
                groupData = new LibPermissionGroup();
            }
            sql = string.Format("select PROGID,SHOWCONDITION,OPERATEMARK from AXPPERMISSIONGROUPDETAIL where PERMISSIONGROUPID={0}", LibStringBuilder.GetQuotString(groupId));
            using (IDataReader reader = dataAccess.ExecuteDataReader(sql, false))
            {
                while (reader.Read())
                {
                    string        progId        = LibSysUtils.ToString(reader["PROGID"]);
                    LibPermission permission    = new LibPermission();
                    string        showCondition = LibSysUtils.ToString(reader["SHOWCONDITION"]);
                    if (!string.IsNullOrEmpty(showCondition))
                    {
                        LibQueryCondition condition = JsonConvert.DeserializeObject(showCondition, typeof(LibQueryCondition)) as LibQueryCondition;
                        permission.ShowCondition = LibQueryConditionParser.GetQueryData(progId, condition);
                        if (!string.IsNullOrEmpty(permission.ShowCondition.Trim()))
                        {
                            foreach (var queryField in condition.QueryFields)
                            {
                                if (!permission.QueryFieldDic.ContainsKey(queryField.Name))
                                {
                                    permission.QueryFieldDic.Add(queryField.Name, new List <LibQueryField>()
                                    {
                                        queryField
                                    });
                                }
                            }
                            permission.ShowCondition = string.Format("({0})", permission.ShowCondition);
                        }
                    }
                    permission.OperateMark = LibSysUtils.ToInt32(reader["OPERATEMARK"]);
                    if (groupData.PermissionDic.ContainsKey(progId)) //对于继承关系的,直接用子覆盖父的权限
                    {
                        groupData.PermissionDic[progId] = permission;
                    }
                    else
                    {
                        groupData.PermissionDic.Add(progId, permission);
                    }
                }
            }
            sql = string.Format("select B.PROGID,A.TABLEINDEX,A.FIELDNAME,A.FIELDPOWER,A.USECONDITION from AXPFIELDPOWER A inner join AXPPERMISSIONGROUPDETAIL B on B.ROW_ID=A.PARENTROWID where A.PERMISSIONGROUPID={0}", LibStringBuilder.GetQuotString(groupId));
            using (IDataReader reader = dataAccess.ExecuteDataReader(sql, false))
            {
                while (reader.Read())
                {
                    string progId = LibSysUtils.ToString(reader["PROGID"]);
                    if (groupData.PermissionDic.ContainsKey(progId))
                    {
                        int    tableIndex = LibSysUtils.ToInt32(reader["TABLEINDEX"]);
                        string fieldName  = LibSysUtils.ToString(reader["FIELDNAME"]);
                        if (!groupData.PermissionDic[progId].FieldPowerDic.ContainsKey(tableIndex))
                        {
                            groupData.PermissionDic[progId].FieldPowerDic.Add(tableIndex, new Dictionary <string, FieldPower>());
                        }
                        Dictionary <string, FieldPower> dic = groupData.PermissionDic[progId].FieldPowerDic[tableIndex];
                        if (!dic.ContainsKey(fieldName))
                        {
                            string useCondition = LibSysUtils.ToString(reader["USECONDITION"]);
                            if (!string.IsNullOrEmpty(useCondition))
                            {
                                useCondition = string.Format("({0})", useCondition);
                            }
                            dic.Add(fieldName, new FieldPower()
                            {
                                Condition = useCondition, PowerOption = (FieldPowerOption)LibSysUtils.ToInt32(reader["FIELDPOWER"])
                            });
                        }
                    }
                }
            }
            sql = string.Format("select B.PROGID,A.BUTTONID from AXPBUTTONPOWER A inner join AXPPERMISSIONGROUPDETAIL B on B.ROW_ID=A.PARENTROWID where A.PERMISSIONGROUPID={0} and A.CANUSE=0", LibStringBuilder.GetQuotString(groupId));
            using (IDataReader reader = dataAccess.ExecuteDataReader(sql, false))
            {
                while (reader.Read())
                {
                    string progId = LibSysUtils.ToString(reader["PROGID"]);
                    if (groupData.PermissionDic.ContainsKey(progId))
                    {
                        string buttonId = LibSysUtils.ToString(reader["BUTTONID"]);
                        if (!groupData.PermissionDic[progId].NoUseButton.Contains(buttonId))
                        {
                            groupData.PermissionDic[progId].NoUseButton.Add(buttonId);
                        }
                    }
                }
            }
            return(groupData);
        }
Beispiel #29
0
        public IList <string> GetBarcode(string progId, string fieldName, string prefix, int serialLen, int number = 1)
        {
            IList <string> list     = new List <string>();
            string         key      = string.Format("{0}/t{1}", progId, prefix);
            object         lockItem = lockObjDic.GetOrAdd(key, new object());

            lock (lockItem)
            {
                BarcodeValue barcodeValue = this.Get <BarcodeValue>(key);

                if (barcodeValue == null)
                {
                    string        curSerial  = string.Empty;
                    int           len        = prefix.Length + serialLen;
                    SqlBuilder    sqlBuilder = new SqlBuilder(progId);
                    string        sql        = sqlBuilder.GetQuerySql(0, string.Format("A.{0}", fieldName), string.Format("A.{0} Like '{1}%'", fieldName, prefix), string.Format("A.{0} DESC", fieldName));
                    LibDataAccess dataAccess = new LibDataAccess();
                    int           serial     = 0;
                    using (IDataReader reader = dataAccess.ExecuteDataReader(sql))
                    {
                        while (reader.Read())
                        {
                            string temp = reader.GetString(0);
                            if (temp.Length != len)
                            {
                                continue;
                            }
                            if (!int.TryParse(temp.Substring(prefix.Length, serialLen), out serial))
                            {
                                continue;
                            }
                            curSerial = temp;
                            break;
                        }
                    }
                    int value = 0;
                    if (!string.IsNullOrEmpty(curSerial))
                    {
                        int.TryParse(curSerial.Substring(prefix.Length, serialLen), out value);
                    }
                    barcodeValue = new BarcodeValue()
                    {
                        MaxValue = value
                    };
                }
                if (barcodeValue.Unused.Count >= number)
                {
                    for (int i = 0; i < number; i++)
                    {
                        list.Add(barcodeValue.Unused.Dequeue());
                    }
                }
                else
                {
                    for (int i = 0; i < number; i++)
                    {
                        string maxValue = (++barcodeValue.MaxValue).ToString();
                        list.Add(string.Format("{0}{1}", prefix, maxValue.PadLeft(serialLen, '0')));
                    }

                    this.Set(key, barcodeValue, new TimeSpan(0, 180, 0));
                }
            }
            return(list);
        }
        public LibRolePermission GetCacheItem(string roleId)
        {
            LibRolePermission rolePermission = null;
            object            lockItem       = lockObjDic.GetOrAdd(roleId, new object());

            lock (lockItem)
            {
                rolePermission = this.Get <LibRolePermission>(roleId);
                if (rolePermission == null)
                {
                    rolePermission        = new LibRolePermission();
                    rolePermission.RoleId = roleId;
                    string        sql        = string.Format("select distinct A.ISUNLIMITED,B.PERMISSIONGROUPID from AXPROLE A left join AXPROLEDETAIL B on B.ROLEID=A.ROLEID where A.ROLEID={0} and ISVALIDITY=1", LibStringBuilder.GetQuotString(roleId));
                    LibDataAccess dataAccess = new LibDataAccess();
                    List <string> groupList  = new List <string>();
                    using (IDataReader reader = dataAccess.ExecuteDataReader(sql, false))
                    {
                        int count = 0;
                        while (reader.Read())
                        {
                            if (count == 0)
                            {
                                rolePermission.IsUnlimited = LibSysUtils.ToBoolean(reader["ISUNLIMITED"]);
                            }
                            string groupId = LibSysUtils.ToString(reader["PERMISSIONGROUPID"]);
                            if (!string.IsNullOrEmpty(groupId))
                            {
                                groupList.Add(groupId);
                            }
                            count++;
                        }
                    }
                    if (!rolePermission.IsUnlimited)
                    {
                        foreach (string groupId in groupList)
                        {
                            LibPermissionGroup group = LibPermissionGroupCache.Default.GetCacheItem(groupId);
                            if (group != null)
                            {
                                foreach (var item in group.PermissionDic)
                                {
                                    if (rolePermission.PermissionDic.ContainsKey(item.Key))
                                    {
                                        //进行宽松的权限控制
                                        LibPermission curPermission = rolePermission.PermissionDic[item.Key];
                                        //处理清单浏览条件
                                        if (!string.IsNullOrEmpty(curPermission.ShowCondition) && string.IsNullOrEmpty(item.Value.ShowCondition))
                                        {
                                            curPermission.ShowCondition = string.Empty;
                                        }
                                        else if (!string.IsNullOrEmpty(curPermission.ShowCondition) && !string.IsNullOrEmpty(item.Value.ShowCondition))
                                        {
                                            if (curPermission.ShowCondition.CompareTo(item.Value.ShowCondition) != 0)
                                            {
                                                curPermission.ShowCondition = string.Format("{0} or {1}", curPermission.ShowCondition, item.Value.ShowCondition);
                                                MergeQueryField(item.Key, curPermission, item.Value);
                                            }
                                        }
                                        //处理按钮权限
                                        if (curPermission.NoUseButton.Count > 0 && item.Value.NoUseButton.Count == 0)
                                        {
                                            curPermission.NoUseButton.Clear();
                                        }
                                        else if (curPermission.NoUseButton.Count > 0 && item.Value.NoUseButton.Count > 0)
                                        {
                                            List <string> removeList = new List <string>();
                                            foreach (string buttonId in curPermission.NoUseButton)
                                            {
                                                if (!item.Value.NoUseButton.Contains(buttonId))
                                                {
                                                    removeList.Add(buttonId);
                                                }
                                            }
                                            foreach (var buttonId in removeList)
                                            {
                                                curPermission.NoUseButton.Remove(buttonId);
                                            }
                                        }
                                        //处理操作权限
                                        if (curPermission.OperateMark != item.Value.OperateMark)
                                        {
                                            curPermission.OperateMark |= item.Value.OperateMark;
                                        }
                                        //处理字段权限
                                        if (curPermission.FieldPowerDic.Count > 0 && item.Value.FieldPowerDic.Count == 0)
                                        {
                                            curPermission.FieldPowerDic.Clear();
                                        }
                                        else if (curPermission.FieldPowerDic.Count > 0 && item.Value.FieldPowerDic.Count > 0)
                                        {
                                            List <int> remove = new List <int>();
                                            foreach (var subItem in curPermission.FieldPowerDic)
                                            {
                                                if (item.Value.FieldPowerDic.ContainsKey(subItem.Key))
                                                {
                                                    Dictionary <string, FieldPower> otherFieldPower = item.Value.FieldPowerDic[subItem.Key];
                                                    List <string> subRemove = new List <string>();
                                                    foreach (var fieldPowerItem in subItem.Value)
                                                    {
                                                        if (otherFieldPower.ContainsKey(fieldPowerItem.Key))
                                                        {
                                                            FieldPower other = otherFieldPower[fieldPowerItem.Key];
                                                            if (fieldPowerItem.Value.PowerOption == FieldPowerOption.CannotBrowse)
                                                            {
                                                                if (other.PowerOption == FieldPowerOption.CannotModify)
                                                                {
                                                                    fieldPowerItem.Value.PowerOption = other.PowerOption;
                                                                    fieldPowerItem.Value.Condition   = other.Condition;
                                                                }
                                                                else
                                                                {
                                                                    fieldPowerItem.Value.Condition = string.Format("{0} && {1}", fieldPowerItem.Value.Condition, other.Condition);
                                                                }
                                                            }
                                                            else if (other.PowerOption == FieldPowerOption.CannotModify)
                                                            {
                                                                fieldPowerItem.Value.Condition = string.Format("{0} && {1}", fieldPowerItem.Value.Condition, other.Condition);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            subRemove.Add(fieldPowerItem.Key);
                                                        }
                                                    }
                                                    foreach (string fieldName in subRemove)
                                                    {
                                                        subItem.Value.Remove(fieldName);
                                                    }
                                                }
                                                else
                                                {
                                                    remove.Add(subItem.Key);
                                                }
                                            }
                                            foreach (var tableIndex in remove)
                                            {
                                                curPermission.FieldPowerDic.Remove(tableIndex);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        rolePermission.PermissionDic[item.Key] = (LibPermission)item.Value.Clone();
                                    }
                                }
                            }
                        }
                    }
                    //CacheItemPolicy policy = new CacheItemPolicy();
                    //policy.SlidingExpiration = new TimeSpan(0, 180, 0); //180分钟内不访问自动剔除
                    this.Set(roleId, rolePermission, new TimeSpan(0, 180, 0));
                }
            }
            return(rolePermission);
        }