Beispiel #1
0
        public ExcuteResultEnum AddNewBcUserInfo(BcUserInfoEntity entity, string roleIds = null)
        {
            if (
                EntityExecution.Count <BcUserInfoEntity>(
                    n => n.UserAccount == entity.UserAccount && n.DeleteFlag == false) > 0)
            {
                return(ExcuteResultEnum.IsExist);
            }

            using (TransactionScope ts = new TransactionScope())
            {
                entity.UserId     = null;
                entity.DeleteFlag = false;
                entity.Password   = Encryption.Encrypt(entity.Password);
                var id = EntityExecution.InsertWithIdentity(entity);
                if (!string.IsNullOrEmpty(roleIds))
                {
                    foreach (string roleId in roleIds.Split(','))
                    {
                        var userRoleEntity = new BcUserRoleEntity {
                            UserId = (int?)id, RoleId = int.Parse(roleId)
                        };
                        EntityExecution.Insert(userRoleEntity);
                    }
                }
                ts.Complete();
            }
            return(ExcuteResultEnum.Success);
        }
        private BcUserInfoEntity PrepareFormData()
        {
            //校验参数的合法性
            txtUserAccount.Text.InitValidation("用户名").NotEmpty().ShorterThan(25);
            txtPassword.Text.InitValidation("密码").NotEmpty().LongerThan(3).ShorterThan(15);
            txtUserName.Text.InitValidation("姓名").NotEmpty().ShorterThan(25);
            txtOfficePhone.Text.InitValidation("座机").ShorterThan(25);
            txtMobilePhone.Text.InitValidation("手机").ShorterThan(25);
            txtEmail.Text.InitValidation("邮件").ShorterThan(50);
            ddlGroup.SelectedValue.InitValidation("组别").NotEmpty();

            var entity = new BcUserInfoEntity();

            entity.UserId       = int.Parse(hdUserId.Value);
            entity.UserAccount  = txtUserAccount.Text;
            entity.Password     = txtPassword.Text;
            entity.UserName     = txtUserName.Text;
            entity.Sex          = rMale.Checked;
            entity.OfficePhone  = txtOfficePhone.Text;
            entity.MobilePhone  = txtMobilePhone.Text;
            entity.Email        = txtEmail.Text;
            entity.ActivityFlag = rEnable.Checked;
            entity.GroupId      = int.Parse(ddlGroup.SelectedValue);
            return(entity);
        }
Beispiel #3
0
 public ExcuteResultEnum UpdateBcUserInfo(BcUserInfoEntity entity, string roleIds = null)
 {
     entity.Password = Encryption.Encrypt(entity.Password);
     using (TransactionScope ts = new TransactionScope())
     {
         entity.Update();
         EntityExecution.Delete <BcUserRoleEntity>(n => n.UserId == entity.UserId);
         if (!string.IsNullOrEmpty(roleIds))
         {
             foreach (string roleId in roleIds.Split(','))
             {
                 var userRoleEntity = new BcUserRoleEntity
                 {
                     UserId = entity.UserId,
                     RoleId = int.Parse(roleId)
                 };
                 EntityExecution.Insert(userRoleEntity);
             }
         }
         ts.Complete();
     }
     return(ExcuteResultEnum.Success);
 }
Beispiel #4
0
        protected void Application_Error(object sender, EventArgs e)
        {
            var       errorLogPath = Server.MapPath("/TempFile/ErrorLogPath");
            var       errorPage    = "/CustomPage/error.html";
            Exception ex           = null;

            try
            {
                ex = Server.GetLastError().GetBaseException();

                var sysSettingEntity = new SysGlobalSettingBiz().GetSysSettingEntity();
                errorLogPath = Server.MapPath(sysSettingEntity.ErrorLogPath);
                errorPage    = sysSettingEntity.ErrorPage;

                BcUserInfoEntity userInfo = null;
                var identity = HttpContext.Current.User.Identity as FormsIdentity;
                if (identity != null)
                {
                    userInfo = new BcUserInfoBiz().GetBcUserInfoWithPermission(identity.Ticket.UserData);
                }

                var entity = new BcLogErrorEntity();
                if (userInfo != null)
                {
                    entity.UserId   = userInfo.UserId;
                    entity.UserName = userInfo.UserName;
                }
                else
                {
                    entity.UserId   = 0;
                    entity.UserName = "";
                }
                entity.OpUrl         = Request.Url.ToString();
                entity.OpTime        = DateTime.Now;
                entity.OpHostAddress = Request.UserHostAddress;
                entity.OpHostName    = Request.UserHostName;
                entity.OpUserAgent   = Request.UserAgent;
                entity.OpQueryString = Request.QueryString.ToString();
                entity.OpHttpMethod  = Request.HttpMethod;
                entity.Message       = ex.ToString();

                try
                {
                    new BcLogErrorBiz().AddNewBcLogError(entity);
                }
                catch (Exception ex2)
                {
                    WriteLocalLog(errorLogPath, ex.ToString());
                    WriteLocalLog(errorLogPath, ex2.ToString());
                }
            }
            catch (Exception ex3)
            {
                if (ex != null)
                {
                    WriteLocalLog(errorLogPath, ex.ToString());
                }
                WriteLocalLog(errorLogPath, ex3.ToString());
            }
            finally
            {
                if (!ConfigHelper.GetConfigBool("IsDevelopMode"))
                {
                    Server.ClearError();
                    Response.Redirect(errorPage);
                }
            }
        }