public Response Execute(User currentUser, string request) { var req = JsonConvert.DeserializeObject <AccountImport>(request); var sql = @" SELECT TOP 100 * FROM dbo.UserAccount ORDER BY CreateDate DESC "; var cmd = CommandHelper.CreateText <User>(FetchType.Fetch, sql); var result = DbContext.GetInstance().Execute(cmd); Response rsp = new Response(); var logger = LoggerHelper.GetOperateLog(); foreach (var item in result.Entities) { var user = item as User; rsp = IMHelper.Instance.ImportAccount(user); if (rsp.IsSuccess == false) { logger.Error("导入失败 ,账号: " + user.Code + " " + rsp.Message); return(rsp); } logger.Debug("导入成功, 账号: " + user.Code); Thread.Sleep(10); } return(rsp); }
private ServiceBuilder() { Type type = typeof(EmptyBLL); EMPTY_BLL_AQNAME = type.AssemblyQualifiedName; EMPTY_BLL_NAME = type.Name; logger = LoggerHelper.GetOperateLog(); isDebug = ConfigurationManager.AppSettings["IsDebug"]; }
public Response Execute(string request) { string CanExecuteTempAPI = ConfigurationManager.AppSettings["CanExecuteTempAPI"]; if (CanExecuteTempAPI != "1") { return(ResultHelper.Fail("你没有执行权限")); } var sql = @" SELECT * FROM dbo.UserAccount ORDER BY CreateDate "; var cmd = CommandHelper.CreateText <User>(FetchType.Fetch, sql); var result = DbContext.GetInstance().Execute(cmd); Response rsp = new Response(); var logger = LoggerHelper.GetOperateLog(); foreach (var item in result.Entities) { var user = item as User; if (user.Password.Length != 32) { rsp = ConvertPwdToMD5(user); if (rsp.IsSuccess == false) { logger.Error("密码转换失败 ,账号: " + user.Code + " " + rsp.Message); return(rsp); } } if (user.PayPassword != null && user.PayPassword.Length != 32) { rsp = ConvertPayPwdToMD5(user); if (rsp.IsSuccess == false) { logger.Error("密码转换失败 ,账号: " + user.Code + " " + rsp.Message); return(rsp); } } logger.Debug("密码转换成功, 账号: " + user.Code); Thread.Sleep(10); } return(rsp); }
public Response RegisterUser(User user) { Logger logger = LoggerHelper.GetOperateLog(); //验证注册必要信息 if (user.CityId.IsNullOrEmpty()) { user.CityId = "75"; //return ResultHelper.Fail("城市不能为空"); } if (user.PetName.IsNullOrEmpty()) { return(ResultHelper.Fail("请输入昵称。")); } user.Id = Ext.NewId(); if (user.CardName.IsNullOrEmpty()) { user.CardName = user.PetName; } user.PetName = user.PetName.Trim(); user.CardName = user.CardName.Trim(); user.ModifyHeadIcon(); var cmd = CommandHelper.CreateProcedure(FetchType.Execute, "sp_SaveQuickUser"); cmd.Params.Add("@userId", user.Id); cmd.Params.Add("@sex", user.Sex.GetId()); cmd.Params.Add("@petName", user.PetName); cmd.Params.Add("@cardName", user.CardName); cmd.Params.Add("@mobile", user.Mobile); cmd.Params.Add("@cityId", user.CityId); cmd.Params.Add("@password", user.Password); cmd.Params.Add("@headUrl", user.HeadUrl); cmd.Params.Add("@lat", user.Lat, DataType.Double); cmd.Params.Add("@lng", user.Lng, DataType.Double); cmd.Params.Add("@userCode", null, DataType.String, ParamDirection.Output, 50); cmd.Params.Add("@address", user.Address); cmd.Params.Add("@WeiXinUnionId", user.WeiXinUnionId); cmd.Params.Add("@QQOpenId", user.QQOpenId); cmd.CreateParamMsg(); var result = DbContext.GetInstance().Execute(cmd); var userCodeParam = result.OutParams.FirstOrDefault(p => p.Name == "@userCode"); if (userCodeParam != null) { user.Code = userCodeParam.value.ToString(); } //尝试加入可能数据库不存在的城市 if (user.CityId.IsNotNullOrEmpty() && user.CityName.IsNotNullOrEmpty()) { Globals.SaveCity(user.CityId, user.CityName); } //建立IM账户 if (result.IsSuccess == true) { result = IMHelper.Instance.ImportAccount(user); BindDefaultRole(user.Id); //绑定默认角色 BindDefaultOrg(user.Id); //绑定默认机构 } if (result.IsSuccess == false) { DeleteRegisterUser(user.Id); logger.Error("注册失败:" + result.Message); return(ResultHelper.Fail("注册失败")); } result.Tag = user.Code; return(result); }