Beispiel #1
0
        private void Login()
        {
            var param = GetValidAccount();

            if (param == null)
            {
                return;
            }

            SaveAccount(param);
            param.PWD     = StringExt.MD5(param.PWD);
            param.Account = param.UserName;
            #region 登录验证
            ShowWaitProgress();
            Task.Factory
            .StartNew <ExeResult>(_ => CheckCompanyBegin((SYS_UserAccountParam)_), param)
            .Done(exeResult =>
            {
                if (CheckCompanyEnd(exeResult))
                {
                    ThreadPool.QueueUserWorkItem(_ =>
                    {
                        var result = CheckLoginBegin((SYS_UserAccountParam)_);
                        BeginInvoke(new Action <ExeResult>(CheckLoginEnd), result);
                    }, param);
                }
            });
            #endregion
        }
Beispiel #2
0
        /// <summary>
        /// 添加和新增修改
        /// </summary>
        /// <param name="param">新增或修改的实体</param>
        /// <returns></returns>
        public WCFAddUpdateResult AddOrUpdate(HR_EmployeeResult param)
        {
            this.CheckSession();
            WCFAddUpdateResult ret = new WCFAddUpdateResult();

            try
            {
                int affect = 0;
                #region 判断
                if (param.EmpCode.Trim() == "")
                {
                    throw new  WarnException("请输入人员编号!");
                }
                if (param.EmpName.Trim() == "")
                {
                    throw new WarnException("请输入人员名称!");
                }
                if (param.OrgID == 0)
                {
                    throw new  WarnException("请选择所属机构!");
                }
                if (param.DeptID == 0)
                {
                    throw new WarnException("请选择所属部门!");
                }


                #endregion

                #region 判断重复
                WhereClip whereChk = HR_Employee._.EmpCode == param.EmpCode;
                if (param.EmpID > 0)
                {
                    whereChk = whereChk && HR_Employee._.EmpID != param.EmpID;
                }
                int chkNum = this.Count <HR_EmployeeResult>(whereChk);
                if (chkNum > 0)
                {
                    throw new WarnException("存在重复的人员编号!");
                }
                #endregion

                #region 系统默认值
                if (param.EmpID != 0)
                {
                    WhereClip where = HR_Employee._.EmpGuid == param.EmpGuid;
                    affect          = this.Update <HR_EmployeeResult>(param, where);
                }
                else
                {
                    param.EmpGuid    = Guid.NewGuid();
                    param.GCompanyID = this.SessionInfo.CompanyID;
                    param.IsDeleted  = false;
                    affect           = this.Insert <HR_EmployeeResult>(param);
                    param            = this.Select <HR_EmployeeResult>(new List <Field>()
                    {
                        HR_Employee._.EmpID
                    }, HR_Employee._.EmpGuid == param.EmpGuid);
                }
                #region 保存帐户登录信息
                SYS_UserAccount userAcct = new SYS_UserAccount();
                userAcct = this.Select <SYS_UserAccount>(SYS_UserAccount._.EmpID == param.EmpID && SYS_UserAccount._.IsDeleted == false);
                if (userAcct == null)
                {
                    userAcct = new SYS_UserAccount();
                }
                userAcct.Account      = param.EmpCode;
                userAcct.EmpID        = param.EmpID;
                userAcct.NeedValidate = param.NeedValidate;
                userAcct.IsActive     = param.IsActive;
                if (param.Password.ToStringHasNull().Trim() != "")
                {
                    userAcct.PWD = StringExt.MD5(param.Password);
                }
                if (userAcct.UserID.ToInt32() <= 0)
                {
                    userAcct.GCompanyID    = this.SessionInfo.CompanyID;
                    userAcct.UserGUID      = Guid.NewGuid();
                    userAcct.CreatedTime   = DateTime.Now;
                    userAcct.CreatedByID   = this.SessionInfo.UserID;
                    userAcct.CreatedByName = this.SessionInfo.UserName;
                    userAcct.IsDeleted     = false;
                    this.Insert <SYS_UserAccount>(userAcct);
                }
                else
                {
                    this.Update <SYS_UserAccount>(userAcct, SYS_UserAccount._.EmpID == param.EmpID && SYS_UserAccount._.IsDeleted == false);
                }
                #endregion
                #region 设置返回值
                ret.Key     = param.EmpID;
                ret.KeyGuid = param.EmpGuid;
                #endregion

                #endregion
            }
            catch (WarnException exp)
            {
                throw exp;
            }
            catch (System.Exception exp)
            {
                LogInfoBLL.WriteLog(this.SessionInfo, exp);
                throw exp;
            }
            return(ret);
        }