Exemple #1
0
 public string createEmployee(SyncUserInfo userInfo)
 {
     try
     {
         string    str   = ReturnCode(0);
         DataTable table = deptBll.GetDataTable(string.Format("select *from [base_user] where account='{0}'", userInfo.uid));
         if (table.Rows.Count > 0)
         {
             if (!string.IsNullOrEmpty(userInfo.displayName))
             {
                 str = this.updateEmployee(userInfo.uid, userInfo.displayName);
             }
             if (str != this.ReturnCode(0))
             {
                 return(str);
             }
             if (!string.IsNullOrEmpty(userInfo.email))
             {
                 str = this.updateEmployeEmail(userInfo.uid, userInfo.email);
             }
             if (str != this.ReturnCode(0))
             {
                 return(str);
             }
             //if (!string.IsNullOrEmpty(userInfo.password))
             //{
             //    str = this.updateEmployeePassword(userInfo.uid, userInfo.password);
             //}
             str = this.enableOrNotEmployee(userInfo, 1);
         }
         else
         {
             try
             {
                 ERCHTMS.Entity.BaseManage.UserEntity user = new Entity.BaseManage.UserEntity();
                 user.UserId   = Guid.NewGuid().ToString();
                 user.RealName = userInfo.displayName;
                 user.Account  = userInfo.uid;
                 user.Email    = userInfo.email;
                 user.Password = "******";
                 new ERCHTMS.Busines.BaseManage.UserBLL().SaveForm("", user);
                 return(this.ReturnCode(0));
             }
             catch (Exception ex)
             {
                 return(this.ReturnCode(11));
             }
         }
         return(str);
     }
     catch (Exception)
     {
         return(this.ReturnCode(11));
     }
 }
Exemple #2
0
        //[WebMethod(Description="新增人员信息")]
        public string createEmployee(SyncUserInfo userInfo)
        {
            try
            {
                string    str   = ReturnCode(0);
                DataTable table = deptBll.GetDataTable(string.Format("select userid from base_user where upper(account)='{0}'", userInfo.uid.ToUpper()));
                if (table.Rows.Count > 0)
                {
                    if (!string.IsNullOrEmpty(userInfo.displayName))
                    {
                        str = this.updateEmployee(userInfo.uid, userInfo.displayName);
                    }
                    if (str != this.ReturnCode(0))
                    {
                        return(str);
                    }
                    if (!string.IsNullOrEmpty(userInfo.email))
                    {
                        str = this.updateEmployeEmail(userInfo.uid, userInfo.email);
                    }
                    if (str != this.ReturnCode(0))
                    {
                        return(str);
                    }
                    if (!string.IsNullOrEmpty(userInfo.password))
                    {
                        str = this.updateEmployeePassword(userInfo.uid, userInfo.password);
                    }
                    str = this.enableOrNotEmployee(userInfo, 1);

                    str = this.UpdateAccountType(userInfo.uid.ToUpper());
                }
                else
                {
                    try
                    {
                        string enCode   = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL().GetItemValue("hrdl", "FactoryEncode"); //查询电厂编码
                        string orgId    = "";                                                                                         //电厂ID
                        string orgCode  = "";                                                                                         //电厂编码
                        string deptId   = "";                                                                                         //部门Id
                        string deptCode = "";                                                                                         //部门编码
                        if (!string.IsNullOrEmpty(enCode))
                        {
                            DepartmentEntity dept = deptBll.GetEntityByCode(enCode);//获取电厂信息
                            if (dept != null)
                            {
                                orgId   = dept.DepartmentId;
                                orgCode = enCode;
                                //判断是否存在临时人员的部门节点,不存在则新建
                                DataTable dtDept = deptBll.GetDataTable(string.Format("select DepartmentId,encode from BASE_DEPARTMENT where parentid='{0}' and fullname='临时人员' and Nature='部门'", orgId));
                                if (dtDept.Rows.Count > 0)
                                {
                                    deptId   = dtDept.Rows[0][0].ToString();
                                    deptCode = dtDept.Rows[0][1].ToString();
                                }
                                else
                                {
                                    //新建临时人员的部门节点
                                    dept = new DepartmentEntity
                                    {
                                        FullName    = "临时人员",
                                        ParentId    = orgId,
                                        Nature      = "部门",
                                        Description = "临时人员",
                                        IsOrg       = 0,
                                        Industry    = "电力"
                                    };
                                    deptBll.SaveForm("", dept);
                                    deptId   = dept.DepartmentId;
                                    deptCode = dept.EnCode;
                                }
                                dtDept.Dispose();
                            }
                        }
                        //新增的人员直接挂在临时人员的部门节点,后期由电厂管理员手动调整人完善员信息
                        ERCHTMS.Entity.BaseManage.UserEntity user = new Entity.BaseManage.UserEntity();
                        user.UserId         = Guid.NewGuid().ToString();
                        user.RealName       = userInfo.displayName;
                        user.Account        = userInfo.uid;
                        user.Email          = userInfo.email;
                        user.Password       = userInfo.password;
                        user.DepartmentId   = deptId;
                        user.DepartmentCode = deptCode;
                        user.OrganizeCode   = orgCode;
                        user.OrganizeId     = orgId;
                        user.RoleId         = "2a878044-06e9-4fe4-89f0-ba7bd5a1bde6";
                        user.RoleName       = "普通用户";
                        user.IsPresence     = "1";
                        user.AccountType    = "1";
                        user.Mobile         = userInfo.mobile;
                        user.EnCode         = userInfo.empno;
                        //user.WeChat = userInfo.deptId;
                        //user.OICQ = userInfo.password;
                        new ERCHTMS.Busines.BaseManage.UserBLL().SaveForm("", user, 1);
                        return(this.ReturnCode(0));
                    }
                    catch (Exception ex)
                    {
                        LdapDataLog(Newtonsoft.Json.JsonConvert.SerializeObject(ex), 4);
                        return(this.ReturnCode(11));
                    }
                }
                return(str);
            }
            catch (Exception ex)
            {
                LdapDataLog(Newtonsoft.Json.JsonConvert.SerializeObject(ex), 4);
                return(this.ReturnCode(10));
            }
        }