Exemplo n.º 1
0
        /// <summary>
        /// 对单条记录进行添加(或者修改)
        /// </summary>
        /// <param name="keyGuid"></param>
        /// <returns></returns>
        public ActionResult Item(string keyGuid)
        {
            Guid         targetGuid   = Converter.TryToGuid(keyGuid);
            BusinessRole targetObject = BusinessRoleBLL.Get(targetGuid);

            return(View(targetObject));
        }
        /// <summary>
        /// 角色选择器
        /// </summary>
        /// <param name="userKey"></param>
        /// <returns></returns>
        public ActionResult RoleSelector(string userKey)
        {
            Guid userGuid = Converter.TryToGuid(userKey);
            List <BusinessRole> allRoleList  = BusinessRoleBLL.GetList(Logics.True, string.Empty);
            List <BusinessRole> userRoleList = BusinessUserBLL.GetUserRoles(userGuid);

            this.ViewBag.UserKey      = userKey;
            this.ViewBag.UserRoleList = userRoleList;

            return(View(allRoleList));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 角色对应的权限
        /// </summary>
        /// <param name="targetKey"></param>
        /// <param name="targetName"></param>
        /// <returns></returns>
        public ActionResult Permission(string targetKey, string targetName = "")
        {
            Guid targetGuid = Converter.TryToGuid(targetKey);

            if (string.IsNullOrWhiteSpace(targetName))
            {
                targetName = BusinessRoleBLL.Get(targetGuid).RoleName;
            }

            string returnUrl = RequestHelper.CurrentRequest.AppRelativeCurrentExecutionFilePath;

            return(RedirectToAction("Index", "Permission", new { ownerGuid = targetKey, ownerName = targetName, ownerType = ExecutorTypes.Role, permissionMode = PermissionModes.Allow, returenUrl = returnUrl }));
        }
Exemplo n.º 4
0
        public ActionResult Item(string keyGuid, BusinessRole entity, bool isOnlyPlaceHolder = true)
        {
            Guid   targetGuid     = Converter.TryToGuid(keyGuid);
            bool   isSuccessful   = false;
            string displayMessage = string.Empty;

            BusinessRole targetRole = null;

            if (targetGuid == Guid.Empty)
            {
                targetRole          = new BusinessRole();
                targetRole.RoleGuid = GuidHelper.NewGuid();

                SetTargetEntityValue(entity, ref targetRole);

                CreateUserRoleStatuses status;
                BusinessRoleBLL.CreateRole(targetRole, out status);

                if (status == CreateUserRoleStatuses.Successful)
                {
                    isSuccessful = true;
                }
                else
                {
                    isSuccessful = false;
                }
            }
            else
            {
                targetRole = BusinessRoleBLL.Get(targetGuid);

                SetTargetEntityValue(entity, ref targetRole);

                isSuccessful = BusinessRoleBLL.UpdateRole(targetRole);
            }


            if (isSuccessful == true)
            {
                displayMessage = "数据保存成功";
            }
            else
            {
                displayMessage = "数据保存失败";
            }

            return(Json(new LogicStatusInfo(isSuccessful, displayMessage)));
        }
        /// <summary>
        /// 内部员工生日提醒是发送到配置文件中设置的生日提醒接收人角色
        /// </summary>
        /// <param name="birthdayUserList"></param>
        protected override void DispatchRemindMessage(List <BusinessUser> birthdayUserList)
        {
            string[] roles = StringHelper.SplitToArray(SystemTaskInConfig.GetAddonItemValue("receiveRoleNames"));

            RemindEntity remindEntity = CreateRemindEntity();

            foreach (BusinessUser currentUser in birthdayUserList)
            {
                remindEntity.RemindTitle    = string.Format("同事【{0}】将在{1}过生日", currentUser.UserNameDisplay, currentUser.UserBirthDay.ToShortDateString());
                remindEntity.RemindCategory = RemindCategories.BirthdayRemindOfEmployee;
                remindEntity.RemindUrl      = string.Empty;

                //向指定的角色发送提醒数据
                foreach (string currentRole in roles)
                {
                    BusinessRole role = BusinessRoleBLL.Get(currentRole);
                    RemindBLL.Instance.Create(role.ExecutorGuid, ExecutorTypes.Role, remindEntity);
                }
            }
        }
        // **************************************
        // URL: /Account/LogOn
        // **************************************
        public ActionResult Login(CasUserEntity userEntity, string UserAccount, string password, string currentLanguage, string returnUrl, string paras, string viewName = "LoginV3")
        {
            string strError = "";
            string ssologin = ComixSDK.EDI.Utils.ConfigHelper.GetConfigString("SSOLogin");

            string SSOUserId  = "";
            string AUTHUserId = "";
            string SSOToken   = "";
            object bindModel  = null;

            if (!string.IsNullOrEmpty(paras))
            {
                //SortedDictionary<string, string> parasDic = new SortedDictionary<string, string>();
                //parasDic.Add("SSOUserId", "");
                //parasDic.Add("AUTHUserId", Guid.NewGuid().ToString().Replace("-", "").ToLower());
                //parasDic.Add("SSOToken", "");
                //string newparas = JSONHelper.ToJson(parasDic);
                //newparas = ComixSDK.EDI.Utils.EncryptionService.EncryptDES(newparas, eContract.Common.ConfigHelper.GetSetString("EncryptionKey"));
                //paras = newparas;

                paras = ComixSDK.EDI.Utils.EncryptionService.DecryptDES(paras, eContract.Common.ConfigHelper.GetSetString("EncryptionKey"));
                SortedDictionary <string, object> sd = ComixSDK.EDI.Utils.JSONHelper.FromJson <SortedDictionary <string, object> >(paras);
                SSOUserId = sd["SSOUserId"] == null ? "" : sd["SSOUserId"].ToString();
                bindModel = sd["BindModel"];
                SSOToken  = sd["SSOToken"] == null ? "" : sd["SSOToken"].ToString();
            }

            ViewBag.Paras     = paras;
            ViewBag.ReturnUrl = returnUrl;
            if (IsPost)
            {
                //参数解密
                //SSOUserId = ComixSDK.EDI.Utils.EncryptionService.DecryptDES(SSOUserId, eContract.Common.ConfigHelper.GetSetString("EncryptionKey"));
                //AUTHUserId = ComixSDK.EDI.Utils.EncryptionService.DecryptDES(AUTHUserId, eContract.Common.ConfigHelper.GetSetString("EncryptionKey"));
                if (IsPost || !string.IsNullOrEmpty(SSOUserId))
                {
                    WebCaching.UserCaching = null;
                    UserDomain userDomain = null;
                    if (!string.IsNullOrEmpty(SSOUserId)) //获取第三方登录用户
                    {
                        userEntity = SystemService.UserService.GetUserEntity(SSOUserId);
                        if (userEntity == null)
                        {
                            return(View(viewName, userEntity));
                        }
                        userDomain = SystemService.UserService.GetUserDomainByUserAccount("MDM", userEntity.UserAccount);
                    }
                    else
                    {
                        userDomain = SystemService.UserService.GetUserDomainByUserAccount("MDM", userEntity.UserAccount);
                    }

                    if (userDomain == null || Encryption.Decrypt(userDomain.CasUserEntity.Password) != password)
                    {
                        ViewBag.strError = "您输入的账号或密码错误,请重新输入";
                        //strError = "您输入的账号或密码错误,请重新输入";
                        //return Json(AjaxResult.Error(strError));
                        return(View(viewName, userEntity));
                    }
                    //if (userDomain.CasUserEntity.IsDelete == 1)
                    //{
                    //    strError = "该用户已被删除";
                    //    return Json(AjaxResult.Error(strError));
                    //}

                    string CacheKey = "User_" + UserId;
                    CacheHelper.Instance.Remove(CacheKey);
                    WebCaching.UserId        = userDomain.CasUserEntity.UserId;
                    WebCaching.UserAccount   = userDomain.CasUserEntity.UserAccount;
                    WebCaching.IsAdmin       = userDomain.CasUserEntity.IsAdmin.ToString();
                    WebCaching.SystemName    = "MDM";
                    userDomain.MenuDataItems = SystemService.FunctionRoleService.GetMenuDataItemByUserId("MDM", WebCaching.UserId);
                    this.CurrentUser         = userDomain;
                    ComixSDK.EDI.Utils.CookieHelper.AddCookie(LANG_COOKIE_ID, currentLanguage, DateTime.Now.AddYears(1));
                    WebCaching.CurrentLanguage = currentLanguage;
                    FormsAuthentication.SetAuthCookie(userDomain.CasUserEntity.UserAccount, false);
                    userEntity = userDomain.CasUserEntity;
                    BusinessRoleBLL          userroleBll   = new BusinessRoleBLL();
                    List <SecUserRoleEntity> listUserRoles = userroleBll.GetBusinessRoleUserDomainByUserid(userDomain.CasUserEntity.UserId);
                    //普通员工添加默认权限
                    if (listUserRoles == null || listUserRoles.Count <= 0)
                    {
                        listUserRoles = userroleBll.GetBusinessRoleUserDomainByRoleId("cd3c9135-4446-45c5-b768-550abac4368d");
                        //strError = "您输入的账号没有权限,请重新输入";
                        //if (!IsAjax)
                        //{
                        //    return View(viewName, userEntity);
                        //}
                    }
                    if (!IsAjax)
                    {
                        return(Redirect("~/home"));
                    }

                    //strError = GetResource(strError);
                    ViewBag.strError    = strError;
                    userEntity.Password = password;

                    if (IsAjax)
                    {
                        if (string.IsNullOrEmpty(strError))
                        {
                            return(Json(AjaxResult.Success()));
                        }
                        return(Json(AjaxResult.Error(strError)));
                    }
                }
            }
            return(View(viewName, userEntity));
        }
Exemplo n.º 7
0
        /// <summary>
        /// 列表
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            List <BusinessRole> list = BusinessRoleBLL.GetList(Logics.False, string.Empty);

            return(View(list));
        }