Beispiel #1
0
        /// <summary>
        /// 登陆用户的角色
        /// </summary>
        /// <param name="userID">用户ID</param>
        /// <param name="companyCD">公司代码</param>
        /// <param name="roleList">角色集</param>
        /// <returns>插入成功与否</returns>
        public static bool InsertUserRoleWithList(string userID, string companyCD, string[] roleList)
        {
            //获取登陆用户ID
            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];

            //登陆日志
            try
            {
                bool         succ     = false;
                LogInfoModel logModel = InitLogInfo(roleList);
                logModel.Element = ConstUtil.LOG_PROCESS_INSERT;

                string    loginUserID = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).UserID; // 待修改userrole
                ArrayList arr         = new ArrayList();
                for (int i = 0; i < roleList.Length; i++)
                {
                    if (roleList[i] != "0")
                    {
                        arr.Add(roleList[i]);
                    }
                }
                string[] roleidlist = (string[])arr.ToArray(typeof(string));//讲array转换为string[]
                succ = UserRoleDBHelper.InsertUserRoleWithList(userID, companyCD, roleidlist, loginUserID);
                if (!succ)
                {
                    logModel.Remark = ConstUtil.LOG_PROCESS_FAILED;
                }
                else
                {
                    logModel.Remark = ConstUtil.LOG_PROCESS_SUCCESS;
                }
                for (int i = 0; i < roleList.Length; i++)
                {
                    if (roleList[i] != "0")
                    {
                        logModel.ObjectID = roleList[i];
                        LogDBHelper.InsertLog(logModel);
                    }
                }

                return(succ);
            }
            catch (Exception ex)
            {
                WriteSystemLog(userInfo, ex);
                return(false);
            }
        }