/// <summary> /// 分处理 /// </summary> /// <param name="requestInfo"></param> /// <returns></returns> private EyouSoft.OpenRelation.Model.MResponseInfo Hand(EyouSoft.OpenRelation.Model.MRequestInfo requestInfo) { EyouSoft.OpenRelation.Model.MResponseInfo responseInfo = null; switch (requestInfo.InstructionType) { case EyouSoft.OpenRelation.Model.InstructionType.CreateCompany: responseInfo = CreateCompanyInfo(requestInfo); break; case EyouSoft.OpenRelation.Model.InstructionType.UpdateCompany: responseInfo = UpdateCompanyInfo(requestInfo); break; case EyouSoft.OpenRelation.Model.InstructionType.DeleteCompany: responseInfo = DeleteCompanyInfo(requestInfo); break; case EyouSoft.OpenRelation.Model.InstructionType.CreateUser: responseInfo = CreateUserInfo(requestInfo); break; case EyouSoft.OpenRelation.Model.InstructionType.UpdateUser: responseInfo = UpdateUserInfo(requestInfo); break; case EyouSoft.OpenRelation.Model.InstructionType.DeleteUser: responseInfo = DeleteUserInfo(requestInfo); break; } return(responseInfo); }
/// <summary> /// 删除用户信息 /// </summary> /// <param name="requestInfo"></param> /// <returns></returns> private EyouSoft.OpenRelation.Model.MResponseInfo DeleteUserInfo(EyouSoft.OpenRelation.Model.MRequestInfo requestInfo) { EyouSoft.OpenRelation.Model.MResponseInfo responseInfo = new EyouSoft.OpenRelation.Model.MResponseInfo() { IsSuccess = true }; var ibll = EyouSoft.BLL.OpenStructure.BUser.CreateInstance(); EyouSoft.OpenRelation.Model.MUserInfo middleInfo = EyouSoft.OpenRelation.Utils.InvertJSON <EyouSoft.OpenRelation.Model.MUserInfo>(requestInfo.InstructionCode); IList <EyouSoft.Model.OpenStructure.MUserInfo> items = new List <EyouSoft.Model.OpenStructure.MUserInfo>(); switch (requestInfo.RequestSystemType) { case EyouSoft.OpenRelation.Model.SystemType.Platform: items = ibll.GetMUserList(0, (int)requestInfo.RequestSystemType, middleInfo.PlatformUserId); break; case EyouSoft.OpenRelation.Model.SystemType.TYT: items = ibll.GetMUserList(middleInfo.SystemUserId, (int)requestInfo.RequestSystemType, null); break; case EyouSoft.OpenRelation.Model.SystemType.YYT: items = ibll.GetMUserList(middleInfo.SystemUserId, (int)requestInfo.RequestSystemType, null); break; } ibll = null; if (items == null || items.Count < 1) { responseInfo.IsSuccess = true; responseInfo.Desc = "中间处理程序未找到用户对应关系,未处理任何数据!"; return(responseInfo); } foreach (var item in items) { middleInfo.PlatformCompanyId = item.PlatformCompanyId; middleInfo.PlatformUserId = item.PlatformUserId; middleInfo.SystemType = (EyouSoft.OpenRelation.Model.SystemType)item.SystemType; middleInfo.SystemUserId = item.SystemUserId; if (requestInfo.RequestSystemType == EyouSoft.OpenRelation.Model.SystemType.Platform) { requestInfo.RequestUriString = EyouSoft.OpenRelation.Utils.GetURI(middleInfo.SystemType); } else { requestInfo.RequestUriString = EyouSoft.OpenRelation.Utils.GetURI(EyouSoft.OpenRelation.Model.SystemType.Platform); } requestInfo.InstructionCode = EyouSoft.OpenRelation.Utils.ConvertJSON <EyouSoft.OpenRelation.Model.MUserInfo>(middleInfo); HandOut(requestInfo); } return(responseInfo); }
/// <summary> /// 删除用户信息 /// </summary> /// <param name="requestInfo"></param> /// <returns></returns> private EyouSoft.OpenRelation.Model.MResponseInfo DeleteUserInfo(EyouSoft.OpenRelation.Model.MRequestInfo requestInfo) { EyouSoft.OpenRelation.Model.MResponseInfo responseInfo = new EyouSoft.OpenRelation.Model.MResponseInfo() { IsSuccess = true }; return(responseInfo); /* * var ibll = EyouSoft.BLL.OpenStructure.BUser.CreateInstance(); * EyouSoft.OpenRelation.Model.MUserInfo middleInfo = EyouSoft.OpenRelation.Utils.InvertJSON<EyouSoft.OpenRelation.Model.MUserInfo>(requestInfo.InstructionCode); * IList<EyouSoft.Model.OpenStructure.MUserInfo> items = new List<EyouSoft.Model.OpenStructure.MUserInfo>(); * * switch (requestInfo.RequestSystemType) * { * case EyouSoft.OpenRelation.Model.SystemType.Platform: * items = ibll.GetMUserList(0, (int)requestInfo.RequestSystemType, middleInfo.PlatformUserId); * break; * case EyouSoft.OpenRelation.Model.SystemType.TYT: * items = ibll.GetMUserList(middleInfo.SystemUserId, (int)requestInfo.RequestSystemType, null); * break; * case EyouSoft.OpenRelation.Model.SystemType.YYT: * items = ibll.GetMUserList(middleInfo.SystemUserId, (int)requestInfo.RequestSystemType, null); * break; * } * * ibll = null; * * if (items == null || items.Count < 1) * { * responseInfo.IsSuccess = true; * responseInfo.Desc = "中间处理程序未找到用户对应关系,未处理任何数据!"; * return responseInfo; * } * * foreach (var item in items) * { * middleInfo.PlatformCompanyId = item.PlatformCompanyId; * middleInfo.PlatformUserId = item.PlatformUserId; * middleInfo.SystemType = (EyouSoft.OpenRelation.Model.SystemType)item.SystemType; * middleInfo.SystemUserId = item.SystemUserId; * * if (requestInfo.RequestSystemType == EyouSoft.OpenRelation.Model.SystemType.Platform) * { * requestInfo.RequestUriString = EyouSoft.OpenRelation.Utils.GetURI(middleInfo.SystemType); * } * else * { * requestInfo.RequestUriString = EyouSoft.OpenRelation.Utils.GetURI(EyouSoft.OpenRelation.Model.SystemType.Platform); * } * * requestInfo.InstructionCode = EyouSoft.OpenRelation.Utils.ConvertJSON<EyouSoft.OpenRelation.Model.MUserInfo>(middleInfo); * * HandOut(requestInfo); * } * * return responseInfo;*/ }
/// <summary> /// 分发处理 /// </summary> /// <param name="requestInfo"></param> /// <returns></returns> private EyouSoft.OpenRelation.Model.MResponseInfo Hand(EyouSoft.OpenRelation.Model.MRequestInfo requestInfo) { EyouSoft.OpenRelation.Model.MResponseInfo responseInfo = null; switch (requestInfo.InstructionType) { case EyouSoft.OpenRelation.Model.InstructionType.None: responseInfo = NoneInstruction(); break; case EyouSoft.OpenRelation.Model.InstructionType.CreateCompany: responseInfo = CreateCompanyInfo(requestInfo); break; case EyouSoft.OpenRelation.Model.InstructionType.CreateUser: responseInfo = CreateUserInfo(requestInfo); break; case EyouSoft.OpenRelation.Model.InstructionType.UpdateCompany: responseInfo = UpdateCompanyInfo(requestInfo); break; case EyouSoft.OpenRelation.Model.InstructionType.UpdateUser: responseInfo = UpdateUserInfo(requestInfo); break; case EyouSoft.OpenRelation.Model.InstructionType.DeleteCompany: //responseInfo = DeleteCompanyInfo(requestInfo); responseInfo = new EyouSoft.OpenRelation.Model.MResponseInfo() { IsSuccess = true }; break; case EyouSoft.OpenRelation.Model.InstructionType.DeleteUser: //responseInfo = DeleteUserInfo(requestInfo); responseInfo = new EyouSoft.OpenRelation.Model.MResponseInfo() { IsSuccess = true }; break; case EyouSoft.OpenRelation.Model.InstructionType.ExistsUser: responseInfo = ExistsUser(requestInfo); break; case EyouSoft.OpenRelation.Model.InstructionType.UserPermission: responseInfo = GetUserPermission(requestInfo); break; } responseInfo.InstructionType = requestInfo.InstructionType; return(responseInfo); }
/// <summary> /// 新增公司信息 /// </summary> /// <param name="requestInfo"></param> /// <returns></returns> private EyouSoft.OpenRelation.Model.MResponseInfo CreateCompanyInfo(EyouSoft.OpenRelation.Model.MRequestInfo requestInfo) { EyouSoft.OpenRelation.Model.MResponseInfo responseInfo = new EyouSoft.OpenRelation.Model.MResponseInfo() { IsSuccess = true }; if (requestInfo.RequestSystemType == EyouSoft.OpenRelation.Model.SystemType.Platform) { return(responseInfo); } EyouSoft.OpenRelation.Model.MCUInfo middleInfo = EyouSoft.OpenRelation.Utils.InvertJSON <EyouSoft.OpenRelation.Model.MCUInfo>(requestInfo.InstructionCode); var items = EyouSoft.BLL.OpenStructure.BCompany.CreateInstance().GetCompanyList(middleInfo.CompanyInfo.SystemCompanyId, (int)middleInfo.CompanyInfo.SystemType, null, (int)middleInfo.CompanyInfo.SystemCompanyType); if (items != null && items.Count > 0)//已存在公司对应关系,进行新增用户操作 { requestInfo.InstructionType = EyouSoft.OpenRelation.Model.InstructionType.CreateUser; requestInfo.InstructionCode = EyouSoft.OpenRelation.Utils.ConvertJSON <EyouSoft.OpenRelation.Model.MUserInfo>(middleInfo.UserInfo); return(CreateUserInfo(requestInfo)); } requestInfo.RequestUriString = EyouSoft.OpenRelation.Utils.GetURI(EyouSoft.OpenRelation.Model.SystemType.Platform); responseInfo = HandOut(requestInfo); if (responseInfo.IsSuccess)//创建成功,写对应关系 { EyouSoft.OpenRelation.Model.MRCreateUserInfo rInfo = EyouSoft.OpenRelation.Utils.InvertJSON <EyouSoft.OpenRelation.Model.MRCreateUserInfo>(responseInfo.InstructionCode); EyouSoft.BLL.OpenStructure.BCompany.CreateInstance().AddMCompany(new EyouSoft.Model.OpenStructure.MCompanyInfo() { PlatformCompanyId = rInfo.PlatformCompanyId, SystemCompanyId = middleInfo.CompanyInfo.SystemCompanyId, SystemCompanyType = (int)middleInfo.CompanyInfo.SystemCompanyType, SystemType = (int)middleInfo.CompanyInfo.SystemType }); EyouSoft.BLL.OpenStructure.BUser.CreateInstance().AddMUser(new EyouSoft.Model.OpenStructure.MUserInfo() { PlatformCompanyId = rInfo.PlatformCompanyId, PlatformUserId = rInfo.PlatformUserId, SystemType = (int)middleInfo.UserInfo.SystemType, SystemUserId = middleInfo.UserInfo.SystemUserId }); } return(responseInfo); }
/// <summary> /// 获取用户权限 /// </summary> /// <param name="requestInfo"></param> /// <returns></returns> private EyouSoft.OpenRelation.Model.MResponseInfo GetUserPermission(EyouSoft.OpenRelation.Model.MRequestInfo requestInfo) { EyouSoft.OpenRelation.Model.MResponseInfo responseInfo = new EyouSoft.OpenRelation.Model.MResponseInfo() { IsSuccess = true }; EyouSoft.OpenRelation.Model.MUserBaseInfo middleInfo = EyouSoft.OpenRelation.Utils.InvertJSON <EyouSoft.OpenRelation.Model.MUserBaseInfo>(requestInfo.InstructionCode); if (middleInfo != null) { requestInfo.RequestUriString = EyouSoft.OpenRelation.Utils.GetURI(middleInfo.SystemType); responseInfo = HandOut(requestInfo); } return(responseInfo); }
/// <summary> /// 验证请求信息 /// </summary> /// <param name="requestString">请求指令字符串 MRequestInfo json data</param> /// <param name="requestInfo">out EyouSoft.OpenRelation.Model.MRequestInfo</param> /// <returns></returns> public static EyouSoft.OpenRelation.Model.MResponseInfo ValidateRequest(string requestString, out EyouSoft.OpenRelation.Model.MRequestInfo requestInfo) { requestInfo = null; EyouSoft.OpenRelation.Model.MResponseInfo responseInfo = new EyouSoft.OpenRelation.Model.MResponseInfo() { IsSuccess = true }; if (string.IsNullOrEmpty(requestString)) { responseInfo.IsSuccess = false; responseInfo.Desc = "请求指令(MRequestInfo)为空!"; return(responseInfo); } requestInfo = EyouSoft.OpenRelation.Utils.InvertJSON <EyouSoft.OpenRelation.Model.MRequestInfo>(requestString); if (requestInfo == null) { responseInfo.IsSuccess = false; responseInfo.Desc = "请求指令(MRequestInfo)为null!"; return(responseInfo); } if (requestInfo.AppKey != EyouSoft.OpenRelation.Utils.GetAppKey()) { responseInfo.IsSuccess = false; responseInfo.Desc = "AppKey错误!"; return(responseInfo); } if (!Enum.IsDefined(typeof(EyouSoft.OpenRelation.Model.SystemType), requestInfo.RequestSystemType)) { responseInfo.IsSuccess = false; responseInfo.Desc = "错误的请求系统类型!"; return(responseInfo); } if (!Enum.IsDefined(typeof(EyouSoft.OpenRelation.Model.InstructionType), requestInfo.InstructionType)) { responseInfo.IsSuccess = false; responseInfo.Desc = "错误的指令类型!"; return(responseInfo); } return(responseInfo); }
/// <summary> /// process request /// </summary> /// <param name="context"></param> public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string request = context.Request.Form["request"]; EyouSoft.OpenRelation.Model.MRequestInfo requestInfo = null; EyouSoft.OpenRelation.Model.MResponseInfo responseInfo = EyouSoft.OpenRelation.Utils.ValidateRequest(request, out requestInfo); if (!responseInfo.IsSuccess) { ResponseWrite(context, responseInfo); return; } responseInfo = Hand(requestInfo); ResponseWrite(context, responseInfo); }
/// <summary> /// 新增用户信息 /// </summary> /// <param name="requestInfo"></param> /// <returns></returns> private EyouSoft.OpenRelation.Model.MResponseInfo CreateUserInfo(EyouSoft.OpenRelation.Model.MRequestInfo requestInfo) { EyouSoft.OpenRelation.Model.MResponseInfo responseInfo = new EyouSoft.OpenRelation.Model.MResponseInfo() { IsSuccess = true }; if (requestInfo.RequestSystemType == EyouSoft.OpenRelation.Model.SystemType.Platform) { return(responseInfo); } EyouSoft.OpenRelation.Model.MUserInfo middleInfo = EyouSoft.OpenRelation.Utils.InvertJSON <EyouSoft.OpenRelation.Model.MUserInfo>(requestInfo.InstructionCode); var items = EyouSoft.BLL.OpenStructure.BCompany.CreateInstance().GetCompanyList(middleInfo.SystemCompanyId, (int)middleInfo.SystemType, null, (int)middleInfo.SystemCompanyType); if (items == null || items.Count < 1) { responseInfo.IsSuccess = true; responseInfo.Desc = "中间处理程序未找到用户与公司对应关系,未处理任何数据!"; return(responseInfo); } middleInfo.SystemCompanyId = items[0].SystemCompanyId; middleInfo.SystemCompanyType = (EyouSoft.OpenRelation.Model.SystemCompanyType)items[0].SystemCompanyType; middleInfo.SystemType = (EyouSoft.OpenRelation.Model.SystemType)items[0].SystemType; middleInfo.PlatformCompanyId = items[0].PlatformCompanyId; requestInfo.RequestUriString = EyouSoft.OpenRelation.Utils.GetURI(EyouSoft.OpenRelation.Model.SystemType.Platform); requestInfo.InstructionCode = EyouSoft.OpenRelation.Utils.ConvertJSON <EyouSoft.OpenRelation.Model.MUserInfo>(middleInfo); responseInfo = HandOut(requestInfo); if (responseInfo.IsSuccess)//创建成功,写对应关系 { EyouSoft.OpenRelation.Model.MRCreateUserInfo rInfo = EyouSoft.OpenRelation.Utils.InvertJSON <EyouSoft.OpenRelation.Model.MRCreateUserInfo>(responseInfo.InstructionCode); EyouSoft.BLL.OpenStructure.BUser.CreateInstance().AddMUser(new EyouSoft.Model.OpenStructure.MUserInfo() { PlatformCompanyId = rInfo.PlatformCompanyId, PlatformUserId = rInfo.PlatformUserId, SystemType = (int)middleInfo.SystemType, SystemUserId = middleInfo.SystemUserId }); } return(responseInfo); }
/// <summary> /// 删除用户信息 /// </summary> /// <param name="requestInfo"></param> /// <returns></returns> private EyouSoft.OpenRelation.Model.MResponseInfo DeleteUserInfo(EyouSoft.OpenRelation.Model.MRequestInfo requestInfo) { EyouSoft.OpenRelation.Model.MResponseInfo responseInfo = new EyouSoft.OpenRelation.Model.MResponseInfo() { IsSuccess = true }; return(responseInfo); /* * if (requestInfo == null) * { * responseInfo.IsSuccess = false; * responseInfo.Desc = "http request post info对象为空!"; * * return responseInfo; * } * EyouSoft.OpenRelation.Model.MUserInfo MiddUser = EyouSoft.OpenRelation.Utils.InvertJSON<EyouSoft.OpenRelation.Model.MUserInfo>(requestInfo.InstructionCode); * if (MiddUser == null) * { * responseInfo.IsSuccess = false; * responseInfo.Desc = "Josn对象转为中间平台对象时发生错误!"; * * return responseInfo; * } * EyouSoft.IBLL.CompanyStructure.ICompanyUser UserBll = EyouSoft.BLL.CompanyStructure.CompanyUser.CreateInstance(); * * try * { * responseInfo.IsSuccess = UserBll.Remove(MiddUser.PlatformUserId); * responseInfo.Desc = "删除用户操作已完成!"; * } * catch (Exception e) * { * responseInfo.IsSuccess = false; * responseInfo.Desc = "删除用户操作执行异常!"; * responseInfo.ErrorCode = e.Message + e.StackTrace; * } * * return responseInfo;*/ }
/// <summary> /// 发送分发处理请求 /// </summary> /// <param name="requestInfo"></param> private EyouSoft.OpenRelation.Model.MResponseInfo HandOut(EyouSoft.OpenRelation.Model.MRequestInfo requestInfo) { EyouSoft.OpenRelation.Model.MResponseInfo responseInfo = EyouSoft.OpenRelation.Utils.CreateRequest(requestInfo); if (!responseInfo.IsSuccess)//写异常日志 { var ibll = EyouSoft.BLL.OpenStructure.BException.CreateInstance(); EyouSoft.Model.OpenStructure.MExceptionInfo exceptionInfo = new EyouSoft.Model.OpenStructure.MExceptionInfo() { ExceptionCode = responseInfo.ErrorCode, ExceptionDesc = responseInfo.Desc, ExecptionId = Guid.NewGuid().ToString(), ExceptionTime = DateTime.Now, InstructionCode = EyouSoft.OpenRelation.Utils.ConvertJSON <EyouSoft.OpenRelation.Model.MRequestInfo>(requestInfo), SystemType = (int)requestInfo.RequestSystemType }; ibll.AddMException(exceptionInfo); ibll = null; } return(responseInfo); }
/// <summary> /// 获取用户权限所属系统权限 /// </summary> /// <param name="SystemType">所属系统类型</param> /// <param name="SystemUserId">系统用户编号</param> /// <returns></returns> public static string SyncGetUserPermission(EyouSoft.OpenRelation.Model.SystemType SystemType, int SystemUserId) { if (SystemUserId < 1) { return(string.Empty); } EyouSoft.OpenRelation.Model.MResponseInfo response = EyouSoft.OpenRelation.Utils.CreateRequest( new EyouSoft.OpenRelation.Model.MRequestInfo() { AppKey = EyouSoft.OpenRelation.Utils.GetAppKey(), RequestUriString = EyouSoft.OpenRelation.Utils.GetMiddlewareURI(), RequestSystemType = EyouSoft.OpenRelation.Model.SystemType.Platform, InstructionType = EyouSoft.OpenRelation.Model.InstructionType.UserPermission, InstructionCode = EyouSoft.OpenRelation.Utils.ConvertJSON <EyouSoft.OpenRelation.Model.MUserBaseInfo>(new EyouSoft.OpenRelation.Model.MUserBaseInfo() { SystemUserId = SystemUserId, SystemType = SystemType }) }); return(response.InstructionCode); }
/// <summary> /// HttpContext Response Write /// </summary> /// <param name="context">System.Web.HttpContext</param> /// <param name="responseInfo">EyouSoft.OpenRelation.Model.MResponseInfo</param> private void ResponseWrite(HttpContext context, EyouSoft.OpenRelation.Model.MResponseInfo responseInfo) { context.Response.Clear(); context.Response.Write(EyouSoft.OpenRelation.Utils.ConvertJSON <EyouSoft.OpenRelation.Model.MResponseInfo>(responseInfo)); context.Response.End(); }
/// <summary> /// 用户是否存在验证 /// </summary> /// <param name="requestInfo"></param> /// <returns></returns> /// <remarks> /// 按配置文件指定的方式进行验证,用户名仅在新增用户时进行验证 /// </remarks> private EyouSoft.OpenRelation.Model.MResponseInfo ExistsUser(EyouSoft.OpenRelation.Model.MRequestInfo requestInfo) { bool isExists = false; string desc = string.Empty; var iubll = EyouSoft.BLL.CompanyStructure.CompanyUser.CreateInstance(); string platformUserId = string.Empty; var ibll = EyouSoft.BLL.OpenStructure.BUser.CreateInstance(); EyouSoft.OpenRelation.Model.MResponseInfo responseInfo = new EyouSoft.OpenRelation.Model.MResponseInfo() { IsSuccess = true }; EyouSoft.OpenRelation.Model.MExistsUserInfo middleInfo = EyouSoft.OpenRelation.Utils.InvertJSON <EyouSoft.OpenRelation.Model.MExistsUserInfo>(requestInfo.InstructionCode); var items = ibll.GetMUserList(middleInfo.SystemUserId, (int)middleInfo.SystemType, null); if (items != null && items.Count > 0) { platformUserId = items[0].PlatformUserId; } items = null; ibll = null; middleInfo.ExistsUserType = EyouSoft.OpenRelation.Utils.GetExistsUserType(); #region 修改时的验证 if (middleInfo.SystemUserId > 0 && !string.IsNullOrEmpty(platformUserId))////若有用户对应关系视为修改操作,修改操作时若配置含邮箱验证,仅对邮箱进行验证,不对用户名进行验证 { if (middleInfo.ExistsUserType == EyouSoft.OpenRelation.Model.ExistsUserType.Email || middleInfo.ExistsUserType == EyouSoft.OpenRelation.Model.ExistsUserType.Both) { isExists = iubll.IsExistsEmail(middleInfo.Email, platformUserId); if (isExists) { desc = "邮箱已存在"; } responseInfo.Desc = desc; responseInfo.InstructionCode = EyouSoft.OpenRelation.Utils.ConvertJSON <bool>(isExists); } return(responseInfo); } #endregion #region 新增时的验证 //新增时的验证 switch (middleInfo.ExistsUserType) { case EyouSoft.OpenRelation.Model.ExistsUserType.Both: if (string.IsNullOrEmpty(middleInfo.Email)) { isExists = true; desc = "邮箱为空"; } if (string.IsNullOrEmpty(middleInfo.UserName)) { isExists = true; desc = "用户名为空"; } isExists = iubll.IsExistsEmail(middleInfo.Email) || iubll.IsExists(middleInfo.UserName); if (isExists) { desc = "邮箱或用户名已存在"; } break; case EyouSoft.OpenRelation.Model.ExistsUserType.Email: if (string.IsNullOrEmpty(middleInfo.Email)) { isExists = true; desc = "邮箱为空"; } isExists = iubll.IsExistsEmail(middleInfo.Email); if (isExists) { desc = "邮箱已存在"; } break; case EyouSoft.OpenRelation.Model.ExistsUserType.UserName: if (string.IsNullOrEmpty(middleInfo.UserName)) { isExists = true; desc = "用户名为空"; } isExists = iubll.IsExists(middleInfo.UserName); if (isExists) { desc = "用户名已存在"; } break; } responseInfo.Desc = desc; responseInfo.InstructionCode = EyouSoft.OpenRelation.Utils.ConvertJSON <bool>(isExists); #endregion return(responseInfo); }
/// <summary> /// 更新用户信息 /// </summary> /// <param name="requestInfo"></param> /// <returns></returns> private EyouSoft.OpenRelation.Model.MResponseInfo UpdateUserInfo(EyouSoft.OpenRelation.Model.MRequestInfo requestInfo) { EyouSoft.OpenRelation.Model.MResponseInfo responseInfo = new EyouSoft.OpenRelation.Model.MResponseInfo() { IsSuccess = true }; if (requestInfo == null) { responseInfo.IsSuccess = false; responseInfo.Desc = "http request post info对象为空!"; return(responseInfo); } EyouSoft.OpenRelation.Model.MUserInfo MiddUser = EyouSoft.OpenRelation.Utils.InvertJSON <EyouSoft.OpenRelation.Model.MUserInfo>(requestInfo.InstructionCode); if (MiddUser == null) { responseInfo.IsSuccess = false; responseInfo.Desc = "Josn对象转为中间平台对象时发生错误!"; return(responseInfo); } EyouSoft.IBLL.CompanyStructure.ICompanyUser UserBll = EyouSoft.BLL.CompanyStructure.CompanyUser.CreateInstance(); EyouSoft.Model.CompanyStructure.CompanyUser UserModel = UserBll.GetModel(MiddUser.PlatformUserId); if (UserModel == null || UserModel.ContactInfo == null) { responseInfo.IsSuccess = false; responseInfo.Desc = "在平台中未找到对应的用户或者用户对应的联系人信息!"; return(responseInfo); } //大平台邮箱不能为空 赋值空格 if (string.IsNullOrEmpty(MiddUser.Email)) { MiddUser.Email = " "; } UserModel.UserName = MiddUser.UserName.Trim(); if (!string.IsNullOrEmpty(MiddUser.Password.Trim())) { UserModel.PassWordInfo.NoEncryptPassword = MiddUser.Password.Trim(); } UserModel.ContactInfo.ContactName = MiddUser.RealName.Trim(); UserModel.ContactInfo.ContactSex = GetGender(MiddUser.Gender); UserModel.ContactInfo.Mobile = MiddUser.Mobile.Trim(); UserModel.ContactInfo.Tel = MiddUser.Telephone.Trim(); UserModel.ContactInfo.Fax = MiddUser.Fax.Trim(); UserModel.ContactInfo.Email = MiddUser.Email.Trim(); UserModel.ContactInfo.MSN = MiddUser.MSN.Trim(); UserModel.ContactInfo.QQ = MiddUser.QQ.Trim(); try { responseInfo.IsSuccess = UserBll.UpdateChild(UserModel); responseInfo.Desc = "修改用户信息操作已完成!"; } catch (Exception e) { responseInfo.IsSuccess = false; responseInfo.Desc = "修改用户操作执行异常!"; responseInfo.ErrorCode = e.Message + e.StackTrace; } return(responseInfo); }
/// <summary> /// 新增用户信息 /// </summary> /// <param name="requestInfo"></param> /// <returns></returns> private EyouSoft.OpenRelation.Model.MResponseInfo CreateUserInfo(EyouSoft.OpenRelation.Model.MRequestInfo requestInfo) { EyouSoft.OpenRelation.Model.MResponseInfo responseInfo = new EyouSoft.OpenRelation.Model.MResponseInfo() { IsSuccess = true }; if (requestInfo == null) { responseInfo.IsSuccess = false; responseInfo.Desc = "http request post info对象为空!"; return(responseInfo); } EyouSoft.OpenRelation.Model.MUserInfo MiddUser = EyouSoft.OpenRelation.Utils.InvertJSON <EyouSoft.OpenRelation.Model.MUserInfo>(requestInfo.InstructionCode); if (MiddUser == null) { responseInfo.IsSuccess = false; responseInfo.Desc = "Josn对象转为中间平台对象时发生错误!"; return(responseInfo); } //大平台邮箱不能为空 赋值空格 if (string.IsNullOrEmpty(MiddUser.Email)) { MiddUser.Email = " "; } int provinceId, cityId; this.GetProvinceAndCityId(MiddUser.ProvinceName, MiddUser.CityName, out provinceId, out cityId); EyouSoft.Model.CompanyStructure.CompanyUser UserModel = new EyouSoft.Model.CompanyStructure.CompanyUser(); EyouSoft.IBLL.CompanyStructure.ICompanyUser UserBll = EyouSoft.BLL.CompanyStructure.CompanyUser.CreateInstance(); UserModel.PassWordInfo = new EyouSoft.Model.CompanyStructure.PassWord(); UserModel.ContactInfo = new EyouSoft.Model.CompanyStructure.ContactPersonInfo(); UserModel.UserName = MiddUser.UserName.Trim(); UserModel.PassWordInfo.NoEncryptPassword = MiddUser.Password.Trim(); UserModel.ContactInfo.ContactName = MiddUser.RealName.Trim(); UserModel.ContactInfo.ContactSex = GetGender(MiddUser.Gender); UserModel.ContactInfo.Mobile = MiddUser.Mobile.Trim(); UserModel.ContactInfo.Tel = MiddUser.Telephone.Trim(); UserModel.ContactInfo.Fax = MiddUser.Fax.Trim(); UserModel.ContactInfo.Email = MiddUser.Email.Trim(); UserModel.ContactInfo.MSN = MiddUser.MSN.Trim(); UserModel.ContactInfo.QQ = MiddUser.QQ.Trim(); UserModel.OpUserId = MiddUser.SystemUserId; UserModel.IsAdmin = false; UserModel.IsEnable = true; UserModel.CompanyID = MiddUser.PlatformCompanyId; UserModel.DepartId = string.Empty; UserModel.DepartName = string.Empty; UserModel.RoleID = string.Empty; UserModel.ProvinceId = provinceId; UserModel.CityId = cityId; try { responseInfo.IsSuccess = UserBll.Add(UserModel) == EyouSoft.Model.ResultStructure.ResultInfo.Succeed ? true : false; responseInfo.Desc = "新增用户操作执行完成!"; if (responseInfo.IsSuccess) { EyouSoft.OpenRelation.Model.MRCreateUserInfo rInfo = new EyouSoft.OpenRelation.Model.MRCreateUserInfo() { PlatformCompanyId = UserModel.CompanyID, PlatformUserId = UserModel.ID }; responseInfo.InstructionCode = EyouSoft.OpenRelation.Utils.ConvertJSON <EyouSoft.OpenRelation.Model.MRCreateUserInfo>(rInfo); responseInfo.Desc = "新增用户操作执行完成!"; } else { responseInfo.Desc = "创建用户失败,业务逻辑层返回失败信息!"; } } catch (Exception e) { responseInfo.IsSuccess = false; responseInfo.Desc = "新增用户操作执行异常!"; responseInfo.ErrorCode = e.Message + e.StackTrace; } return(responseInfo); }
/// <summary> /// 更新公司信息 /// </summary> /// <param name="requestInfo"></param> /// <returns></returns> private EyouSoft.OpenRelation.Model.MResponseInfo UpdateCompanyInfo(EyouSoft.OpenRelation.Model.MRequestInfo requestInfo) { EyouSoft.OpenRelation.Model.MResponseInfo responseInfo = new EyouSoft.OpenRelation.Model.MResponseInfo() { IsSuccess = true }; if (requestInfo == null) { responseInfo.IsSuccess = false; responseInfo.Desc = "http request post info对象为空!"; return(responseInfo); } EyouSoft.OpenRelation.Model.MCompanyInfo MiddComp = EyouSoft.OpenRelation.Utils.InvertJSON <EyouSoft.OpenRelation.Model.MCompanyInfo>(requestInfo.InstructionCode); if (MiddComp == null) { responseInfo.IsSuccess = false; responseInfo.Desc = "Josn对象转为中间平台对象时发生错误!"; return(responseInfo); } EyouSoft.IBLL.CompanyStructure.ICompanyInfo ComBll = EyouSoft.BLL.CompanyStructure.CompanyInfo.CreateInstance(); EyouSoft.Model.CompanyStructure.CompanyArchiveInfo CompanyInfo = ComBll.GetModel(MiddComp.PlatformCompanyId); if (CompanyInfo == null || CompanyInfo.ContactInfo == null) { responseInfo.IsSuccess = false; responseInfo.Desc = "在平台中未找到对应的公司或者公司对应的联系人信息!"; return(responseInfo); } //大平台邮箱不能为空 赋值空格 if (string.IsNullOrEmpty(MiddComp.ContactEmail)) { MiddComp.ContactEmail = " "; } //公司 if (!string.IsNullOrEmpty(MiddComp.CompanyName)) { CompanyInfo.CompanyName = MiddComp.CompanyName; } if (!string.IsNullOrEmpty(MiddComp.Address)) { CompanyInfo.CompanyAddress = MiddComp.Address; } if (!string.IsNullOrEmpty(MiddComp.Domain)) { CompanyInfo.WebSite = MiddComp.Domain; } //联系人 if (!string.IsNullOrEmpty(MiddComp.ContactName)) { CompanyInfo.ContactInfo.ContactName = MiddComp.ContactName; } if (!string.IsNullOrEmpty(MiddComp.ContactTelephone)) { CompanyInfo.ContactInfo.Tel = MiddComp.ContactTelephone; } if (!string.IsNullOrEmpty(MiddComp.ContactMobile)) { CompanyInfo.ContactInfo.Mobile = MiddComp.ContactMobile; } if (!string.IsNullOrEmpty(MiddComp.ContactFax)) { CompanyInfo.ContactInfo.Fax = MiddComp.ContactFax; } CompanyInfo.ContactInfo.Email = MiddComp.ContactEmail; CompanyInfo.ContactInfo.MSN = MiddComp.ContactMSN; CompanyInfo.ContactInfo.QQ = MiddComp.ContactQQ; CompanyInfo.ContactInfo.ContactSex = GetGender(MiddComp.ContactGender); try { responseInfo.IsSuccess = ComBll.UpdateSelf(CompanyInfo); responseInfo.Desc = "修改公司信息完成!"; } catch (Exception e) { responseInfo.IsSuccess = false; responseInfo.Desc = "修改公司信息操作执行异常!"; responseInfo.ErrorCode = e.Message + e.StackTrace; } return(responseInfo); }
/// <summary> /// 新增公司信息 /// </summary> /// <param name="requestInfo"></param> /// <returns></returns> private EyouSoft.OpenRelation.Model.MResponseInfo CreateCompanyInfo(EyouSoft.OpenRelation.Model.MRequestInfo requestInfo) { EyouSoft.OpenRelation.Model.MResponseInfo responseInfo = new EyouSoft.OpenRelation.Model.MResponseInfo() { IsSuccess = true }; EyouSoft.OpenRelation.Model.MCUInfo middleInfo = EyouSoft.OpenRelation.Utils.InvertJSON <EyouSoft.OpenRelation.Model.MCUInfo>(requestInfo.InstructionCode); EyouSoft.Model.CompanyStructure.CompanyArchiveInfo companyInfo = new EyouSoft.Model.CompanyStructure.CompanyArchiveInfo(); EyouSoft.Model.CompanyStructure.UserAccount userInfo = new EyouSoft.Model.CompanyStructure.UserAccount(); EyouSoft.Model.CompanyStructure.ContactPersonInfo contactInfo = new EyouSoft.Model.CompanyStructure.ContactPersonInfo(); EyouSoft.Model.CompanyStructure.CompanyRole roleInfo = new EyouSoft.Model.CompanyStructure.CompanyRole(); //大平台邮箱不能为空 赋值空格 if (string.IsNullOrEmpty(middleInfo.UserInfo.Email)) { middleInfo.UserInfo.Email = " "; } if (string.IsNullOrEmpty(middleInfo.CompanyInfo.ContactEmail)) { middleInfo.CompanyInfo.ContactEmail = " "; } int provinceId, cityId; this.GetProvinceAndCityId(middleInfo.CompanyInfo.ProvinceName, middleInfo.CompanyInfo.CityName, out provinceId, out cityId); companyInfo.CompanyName = middleInfo.CompanyInfo.CompanyName; companyInfo.CompanyAddress = middleInfo.CompanyInfo.Address; companyInfo.ProvinceId = provinceId; companyInfo.CityId = cityId; userInfo.UserName = middleInfo.UserInfo.UserName; userInfo.PassWordInfo = new EyouSoft.Model.CompanyStructure.PassWord(middleInfo.UserInfo.Password); contactInfo.ContactName = middleInfo.CompanyInfo.ContactName; contactInfo.Email = middleInfo.CompanyInfo.ContactEmail; contactInfo.Fax = middleInfo.CompanyInfo.ContactFax; contactInfo.Mobile = middleInfo.CompanyInfo.ContactMobile; contactInfo.MSN = middleInfo.CompanyInfo.ContactMSN; contactInfo.QQ = middleInfo.CompanyInfo.ContactQQ; contactInfo.Tel = middleInfo.CompanyInfo.ContactTelephone; contactInfo.ContactSex = GetGender(middleInfo.CompanyInfo.ContactGender); if (middleInfo.CompanyInfo.PlatformCompanyType == EyouSoft.OpenRelation.Model.PlatformCompanyType.ZT) { roleInfo.SetRole(EyouSoft.Model.CompanyStructure.CompanyType.组团); } else if (middleInfo.CompanyInfo.PlatformCompanyType == EyouSoft.OpenRelation.Model.PlatformCompanyType.ZX) { roleInfo.SetRole(EyouSoft.Model.CompanyStructure.CompanyType.专线); } companyInfo.AdminAccount = userInfo; companyInfo.CompanyRole = roleInfo; companyInfo.ContactInfo = contactInfo; try { EyouSoft.Model.ResultStructure.UserResultInfo resultInfo = EyouSoft.BLL.CompanyStructure.CompanyInfo.CreateInstance().Add(companyInfo, string.Empty); if (resultInfo == EyouSoft.Model.ResultStructure.UserResultInfo.Succeed) { responseInfo.IsSuccess = true; responseInfo.Desc = "创建公司成功!"; EyouSoft.OpenRelation.Model.MRCreateUserInfo rInfo = new EyouSoft.OpenRelation.Model.MRCreateUserInfo() { PlatformCompanyId = companyInfo.ID, PlatformUserId = companyInfo.AdminAccount.ID }; responseInfo.InstructionCode = EyouSoft.OpenRelation.Utils.ConvertJSON <EyouSoft.OpenRelation.Model.MRCreateUserInfo>(rInfo); EyouSoft.BLL.CompanyStructure.CompanyInfo.CreateInstance().PassRegister(companyInfo.ID); } else { responseInfo.IsSuccess = false; responseInfo.Desc = "创建公司失败,业务逻辑层返回失败信息!"; } } catch (Exception e) { responseInfo.IsSuccess = false; responseInfo.Desc = "创建公司失败,捕获到异常!"; responseInfo.ErrorCode = e.Message + e.StackTrace; } return(responseInfo); }