/// <summary> /// Approve or reject record /// </summary> /// <param name="document"></param> /// <returns></returns> public async Task <JsonResult> ApproveOrRejectRecord(DocumentModel document) { // Get user call api UserContext context = UserConnect.GetContext(HttpContext); UserMobile user = UserConnect.GetUserConnected(context.Token, context.Ip, context.UserAgent); try { var approvalsMgmt = GetApprove(user); var recordId = "Purchase Header: 1," + document.IdDoc; if (document.IsApprove) { approvalsMgmt.ApproveRecordApprovalRequest(recordId); } else { approvalsMgmt.RejectRecordApprovalRequest(recordId); } return(new JsonResult { Data = true, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } catch (Exception ex) { return(new JsonResult { Data = false, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); throw ex; } }
public void CreateTherapistUserApplication() { Pages.UsersManagement_Page.GoTo(); CreateUser.ClickWait(); softAssert.VerifyElementPresentInsideWindow(UserCancelBtn, UserCancelBtn); UserName.EnterClearText(Constant.userName + RandomNumber.smallNumber()); UserContinueBtn.ClickOn(); softAssert.VerifyElementPresentInsideWindow(UserEmailVerification, UserCancelBtn); UserLastname.EnterClearText(Constant.userLastName); UserEmail.EnterClearText("doctor" + RandomNumber.smallNumber() + "@doctorwin.co.il"); UserMobile.EnterClearText(Constant.userPhone); UserContinueBtn.ClickOn(); softAssert.VerifyElementPresentInsideWindow(UserGoBack, UserCancelBtn); TherapistActiveBtn.ClickOn(); TherapistDropdownPractice.ClickOn(); List <IWebElement> practiceList = Browser.Driver.FindElements(By.XPath("//*[@id='PractiseID_listbox']/li")).ToList(); var lastValue = practiceList[practiceList.Count - 1]; lastValue.ClickOn(); UserContinueBtn.ClickOn(); SelectBusinessOnUserCreate.Click(); var branchID = BranchIdOnUserCreate.GetAttribute("value"); Browser.Driver.FindElement(By.CssSelector("#branchID" + branchID + " > label")).ClickOn(); UserContinueBtn.Click(); softAssert.VerifyElementPresentInsideWindow(Pages.Home_Page.ErrorPopup, UserCancelBtn); SelectDepartmentOnUserCreate.Click(); UserContinueBtn.Click(); therapistSchedulerSetup(); UserContinueBtn.ClickOn(); softAssert.VerifySuccessMsg(); }
//create a create user public void CreateUserApplication() { Pages.UsersManagement_Page.GoTo(); CreateUser.ClickWait(); softAssert.VerifyElementPresentInsideWindow(UserCancelBtn, UserCancelBtn); UserName.EnterClearText(Constant.userName); UserContinueBtn.ClickOn(); softAssert.VerifyElementPresentInsideWindow(UserEmailVerification, UserCancelBtn); UserLastname.EnterClearText(Constant.userLastName); UserEmail.EnterClearText(Constant.userEmail); UserMobile.EnterClearText(Constant.userPhone); UserContinueBtn.ClickOn(); softAssert.VerifyElementPresentInsideWindow(UserGoBack, UserCancelBtn); UserContinueBtn.ClickOn(); SelectBusinessOnUserCreate.ClickOn(); var branchID = BranchIdOnUserCreate.GetAttribute("value"); Browser.Driver.FindElement(By.CssSelector("#branchID" + branchID + " > label")).ClickOn(); UserContinueBtn.ClickOn(); softAssert.VerifyElementPresentInsideWindow(Pages.Home_Page.ErrorPopup, UserCancelBtn); SelectDepartmentOnUserCreate.ClickOn(); UserContinueBtn.ClickOn(); softAssert.VerifySuccessMsg(); }
private async void BtnLogin_Clicked(object sender, System.EventArgs e) { IsLoading = true; try { UserService userService = new UserService(); //Cada tipo de serviço que vamos consumir na webApi terá seu próprio service, nesse caso o serviço de usuário var userTask = await Task.Factory.StartNew(() => userService.Login(EntryEmail.Text, EntryPassword.Text)); //Cria uma nova task, para que o Loading fique rodando na página enquanto essa nova task busca as informações na webapi //var userTask = await Task.Factory.StartNew(() => userService.Login("*****@*****.**", "123456")); UserMobile userMobile = userTask.Result; IsLoading = false; if (userMobile.Success) { Navigation.PushAsync(new MenuPage(userMobile)); } else { DisplayAlert("Erro", userMobile.Details, "Ok"); } } catch (Exception ex) { IsLoading = false; DisplayAlert("Erro", ex.Message, "OK"); } }
public string unsetUserType(UserMobile model) { try { using (var client = new WebClient()) { var values = new NameValueCollection(); values["api_method"] = "removeUser_Type"; values["api_data"] = JsonConvert.SerializeObject(new { mobile = model.Mobile }); var response = client.UploadValues(model.ip, values); var responseString = Encoding.Default.GetString(response); dynamic result = JsonConvert.DeserializeObject(responseString); if (!(bool)result.IsError) { this.isError = false; this.errorMessage = result.Message; } else { this.isError = true; this.errorMessage = result.Message; } } } catch (Exception e) { this.isError = true; this.errorMessage = e.Message; } return(JsonConvert.SerializeObject(new { isError = this.isError, errorMessage = this.errorMessage })); }
/// <summary> /// Get value to check /// </summary> /// <param name="document"></param> /// <returns></returns> public async Task <JsonResult> GetValueToCheck(DocumentModel document) { // Get user call api UserContext context = UserConnect.GetContext(HttpContext); UserMobile user = UserConnect.GetUserConnected(context.Token, context.Ip, context.UserAgent); LinesPurchasOrders_PortClient linesPurchasOrders_PortClient = GetLines(user); List <DocumentValuesModel> documentValues = new List <DocumentValuesModel>(); try { var lines = linesPurchasOrders_PortClient.ReadMultiple(null, null, 0).Where(art => art.Document_No == document.IdDoc.ToString()); documentValues.Add(new DocumentValuesModel { Name = "Total_Amount_Excl_VAT", Value = lines.FirstOrDefault().Total_Amount_Excl_VAT.ToString() }); documentValues.Add(new DocumentValuesModel { Name = "Total_Amount_Incl_VAT", Value = lines.FirstOrDefault().Total_Amount_Incl_VAT.ToString() }); } catch (Exception ex) { throw ex; } return(new JsonResult { Data = documentValues, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public async Task <UserMobile> Login(string Email, string Password) { if (string.IsNullOrEmpty(Email) || string.IsNullOrEmpty(Password)) { return(await Task.FromResult(new UserMobile(false, "Usuário e/ou senha inválidos"))); } else { using (var client = new HttpClient()) { UserMobile user = new UserMobile(Email, Password); var param = JsonConvert.SerializeObject(user); HttpContent contentPost = new StringContent(param, Encoding.UTF8, "application/json"); var response = client.PostAsync(string.Format(Constants.WebServiceEndPoint + Constants.UserEndPoint + "login"), contentPost).Result; var json = await response.Content.ReadAsStringAsync(); if (response.StatusCode.Equals(HttpStatusCode.OK)) { UserMobile userResponse = JsonConvert.DeserializeObject <UserMobile>(json); userResponse.Success = true; return(await Task.FromResult(userResponse)); } else { MobileException exception = JsonConvert.DeserializeObject <MobileException>(json); return(await Task.FromResult(new UserMobile(false, exception.Message))); } } } }
/// <summary> /// Connect service lines /// </summary> /// <param name="user"></param> /// <returns></returns> private LinesPurchasOrders_PortClient GetLines(UserMobile user) { LinesPurchasOrders_PortClient linesPurchasOrders_PortClient = new LinesPurchasOrders_PortClient(); linesPurchasOrders_PortClient.ClientCredentials.Windows.ClientCredential.UserName = user.User_Name; linesPurchasOrders_PortClient.ClientCredentials.Windows.ClientCredential.Password = CryptDecrypt.Decrypt(user.Password); return(linesPurchasOrders_PortClient); }
/// <summary> /// Get SalesOrder service ref /// </summary> /// <param name="user"></param> /// <returns></returns> private PurchaseOrders_PortClient GetSalesOrder(UserMobile user) { PurchaseOrders_PortClient purchaseOrders_PortClient = new PurchaseOrders_PortClient(); purchaseOrders_PortClient.ClientCredentials.Windows.ClientCredential.UserName = user.User_Name; purchaseOrders_PortClient.ClientCredentials.Windows.ClientCredential.Password = CryptDecrypt.Decrypt(user.Password); return(purchaseOrders_PortClient); }
/// <summary> /// Get RecordLink service ref /// </summary> /// <param name="user"></param> /// <returns></returns> private RecordLinkPage_PortClient GetRecordLink(UserMobile user) { RecordLinkPage_PortClient linkPage_PortClient = new RecordLinkPage_PortClient(); linkPage_PortClient.ClientCredentials.Windows.ClientCredential.UserName = user.User_Name; linkPage_PortClient.ClientCredentials.Windows.ClientCredential.Password = CryptDecrypt.Decrypt(user.Password); return(linkPage_PortClient); }
/// <summary> /// Get Approve service ref /// </summary> /// <param name="user"></param> /// <returns></returns> private ApprovalsMgmt_PortClient GetApprove(UserMobile user) { ApprovalsMgmt_PortClient approvalsMgmt = new ApprovalsMgmt_PortClient(); approvalsMgmt.ClientCredentials.Windows.ClientCredential.UserName = user.User_Name; approvalsMgmt.ClientCredentials.Windows.ClientCredential.Password = CryptDecrypt.Decrypt(user.Password); return(approvalsMgmt); }
public async Task <ActionResult> GetDocuments() { // Get user call api UserContext context = UserConnect.GetContext(HttpContext); UserMobile user = UserConnect.GetUserConnected(context.Token, context.Ip, context.UserAgent); List <DocumentModel> listsDocuments = new List <DocumentModel>(); try { var purchaseOrders_PortClient = GetSalesOrder(user); // filter on statut PurchaseOrders_Filter fi = new PurchaseOrders_Filter(); fi.Field = PurchaseOrders_Fields.Status; fi.Criteria = "Pending Approval"; PurchaseOrders_Filter[] fiArray = new PurchaseOrders_Filter[] { fi }; var results = await purchaseOrders_PortClient.ReadMultipleAsync(fiArray, null, 0); var approvalsMgmt = GetApprove(user); var recordlink = GetRecordLink(user); RecordLinkPage_Filter rlp = new RecordLinkPage_Filter(); RecordLinkPage_Filter[] rlparray = new RecordLinkPage_Filter[] { rlp }; foreach (var sale in results.ReadMultiple_Result1) { var recordId = "Purchase Header: 1," + sale.No; // check if user connected can approve a doc if (approvalsMgmt.HasOpenApprovalEntriesForCurrentUser(recordId)) { var docs = recordlink.ReadMultiple(rlparray, null, 0).Where(d => d.Record_ID == recordId); listsDocuments.AddRange(docs.Select(d => new DocumentModel() { IdDoc = sale.No, VendorName = sale.Buy_from_Vendor_Name, VendorInvoiceNo = sale.Vendor_Invoice_No, VendorShipNo = sale.Vendor_Shipment_No, DocumentDate = sale.Document_Date.ToString(), DocName = d.Description, Url = d.URL1, DocDate = d.Created, DocSatut = ((EnumStatut.Values)d.Statut).GetBool() }).ToList()); } } } catch (Exception ex) { throw ex; } return(new JsonResult { Data = listsDocuments, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
protected void SaveEmailMobiles() { CaseUserProfile u = new CaseUserProfile(ContactCaseID); UserEmail ueop = new UserEmail(); foreach (UserEmail ue in u.Emails) { if (Request.Form["tbEmail_" + ue.ID.ToString()] != null) { string Email = Request.Form["tbEmail_" + ue.ID.ToString()].ToString(); if (ue.Email != Email) { ueop.Update(ue.ID, Email); } } else { ueop.Delete(ue.ID); } } UserMobile umop = new UserMobile(); foreach (UserMobile um in u.Mobiles) { if (Request.Form["tbMobileNo_" + um.ID.ToString()] != null) { string MobileNo = Request.Form["tbMobileNo_" + um.ID.ToString()].ToString(); if (um.Mobile != MobileNo) { umop.Update(um.ID, MobileNo); } } else { umop.Delete(um.ID); } } //新增 string tbMobileNo = Request.Form["tbMobileNo"] ?? ""; string tbEmail = Request.Form["tbEmail"] ?? ""; tbMobileNo = tbMobileNo.TrimEnd(','); tbEmail = tbEmail.TrimEnd(','); //Response.Write(ContactCaseID.ToString() + tbMobileNo); //Response.End(); if (tbEmail != "") { ueop.Add(ContactCaseID, tbEmail); } if (tbMobileNo != "") { umop.Add(ContactCaseID, tbMobileNo); } u.UpdateMainMobileCol(ContactCaseID); }
public async Task <ServiceResponse <LoginResponse> > MobileUpdate(UserMobile Mobile_Res) { ServiceResponse <LoginResponse> response = new ServiceResponse <LoginResponse>(); try { if (await MobileExists(Mobile_Res.MobileNo)) { response.Success = false; response.Message = "Mobile No Already Exists"; return(response); } else { UserMaster user = await _context.UserMaster.FirstOrDefaultAsync(x => x.UserId == Mobile_Res.UserId); //&& !x.MobileNo.Equals(MobileExists(Mobile_Res.MobileNo)) user.UserId = Mobile_Res.UserId; user.MobileNo = Mobile_Res.MobileNo; //Genterate Random Number Random rnd = new Random(); int rvalue = rnd.Next(100000, 999999); user.Otp = rvalue.ToString(); TokenMaster tm = CreateToken(user); LoginResponse Login_Res = new LoginResponse(); Login_Res.UserId = user.UserId; Login_Res.EmailId = user.EmailId; Login_Res.Status = user.Status; Login_Res.Token = tm.Token; Login_Res.TokenExpiresIn = tm.tokenExpiresIn;// DateFormat.AddingTSeprator(tm.tokenExpiresIn); Login_Res.FirstName = user.FirstName; Login_Res.LastName = user.LastName; Login_Res.MobileNo = user.MobileNo; Login_Res.UserTypeId = user.UserTypeId; Login_Res.PlanId = user.PlanId; Login_Res.AddedOn = user.AddedOn; Login_Res.UpdatedOn = user.UpdatedOn; // response.Data = user.UserId.ToString(); //return jwt token response.Data = Login_Res; // response.Data = _mapper.Map<LoginResponse>(user); //_context.UserMaster.Update(user); await _context.SaveChangesAsync(); //Send Mail on success } } catch (Exception ex) { response.Success = false; response.Message = ex.Message; //response.Data = ex.Message; } return(response); }
public async Task <IActionResult> UpdateMobile(UserMobile Mobile_Res) { ServiceResponse <LoginResponse> response = await _authRepo.MobileUpdate( Mobile_Res ); if (!response.Success) { return(BadRequest(response)); } return(Ok(response)); }
public MenuPage(UserMobile user) { InitializeComponent(); NavigationPage.SetHasNavigationBar(this, false); Title = "Menu"; if (user != null) { LabelUserEmail.Text = user.Email; LabelUserLogin.Text = user.CPF; LabelUserName.Text = user.Name; } }
/// <summary> /// 手机认证,重发验证码或更换号码 /// </summary> public void RepeatRequestMobile(string userId, string mobile, string createUserId) { using (var manager = new UserMobileManager()) { if (string.IsNullOrEmpty(userId)) { throw new Exception("未查询到用户编号"); } else if (string.IsNullOrEmpty(mobile)) { throw new Exception("手机号码不能为空"); } //var entity = manager.GetUserMobile(userId); var other = manager.GetMobileInfoByMobile(mobile); if (other != null && other.IsSettedMobile && other.UserId != userId) { throw new ArgumentException(string.Format("此手机号【{0}】已被其他用户认证。", mobile)); } var entity = manager.GetUserMobile(userId); if (entity != null) { entity.IsSettedMobile = false; entity.UpdateBy = createUserId; entity.RequestTimes++; entity.Mobile = mobile; manager.UpdateUserMobile(entity); } else { entity = new UserMobile { UserId = userId, User = manager.LoadUser(userId), AuthFrom = "LOCAL", Mobile = mobile, IsSettedMobile = false, CreateBy = createUserId, UpdateBy = createUserId, }; manager.AddUserMobile(entity); } } }
public void UpdateUserMobile(UserMobile mobileEntity) { mobileEntity.UpdateTime = DateTime.Now; Update <UserMobile>(mobileEntity); }
public void DeleteUserMobile(UserMobile entity) { this.Delete <UserMobile>(entity); }
public void AddUserMobile(UserMobile mobileEntity) { mobileEntity.CreateTime = DateTime.Now; mobileEntity.UpdateTime = DateTime.Now; Add <UserMobile>(mobileEntity); }
public void AddAuthenticationMobile(string authFrom, string userId, string mobile, string createBy) { #region //using (var biz = new GameBiz.Business.GameBizBusinessManagement()) //{ // biz.BeginTran(); //using (var manager = new UserMobileManager()) //{ // var other = manager.GetOtherUserMobile(mobile, userId); // if (other != null && other.IsSettedMobile)//判断手机号码的唯一性 // { // throw new ArgumentException(string.Format("此手机号【{0}】已被其他用户认证。", mobile)); // } // var entity = manager.GetUserMobile(userId); // if (entity != null && !string.IsNullOrEmpty(entity.Mobile) && !entity.IsSettedMobile) // { // entity.Mobile = mobile; // entity.IsSettedMobile = true; // manager.UpdateUserMobile(entity); // //throw new ArgumentException(string.Format("此用户已于【{0:yyyy-MM-dd HH:mm:ss}】进行过手机认证", entity.CreateTime)); // } // else // { // if (entity == null) // { // entity = new UserMobile // { // UserId = userId, // User = manager.LoadUser(userId), // AuthFrom = authFrom, // Mobile = mobile, // IsSettedMobile = true, // CreateBy = createBy, // UpdateBy = createBy, // }; // manager.AddUserMobile(entity); // } // else // throw new ArgumentException(string.Format("此用户已于【{0:yyyy-MM-dd HH:mm:ss}】进行过手机认证", entity.CreateTime)); // } //} // biz.CommitTran(); //} #endregion using (var manager = new UserMobileManager()) { var mobileInfo = manager.GetMobileInfoByMobile(mobile); if (mobileInfo != null && !string.IsNullOrEmpty(mobileInfo.Mobile) && mobileInfo.UserId != userId) { throw new ArgumentException(string.Format("此手机号【{0}】已被其他用户认证。", mobile)); } if (mobileInfo != null && !string.IsNullOrEmpty(mobileInfo.Mobile) && !mobileInfo.IsSettedMobile) { //mobileInfo.UserId = userId; mobileInfo.UpdateBy = userId; mobileInfo.UpdateTime = DateTime.Now; mobileInfo.Mobile = mobile; mobileInfo.IsSettedMobile = true; manager.UpdateUserMobile(mobileInfo); } else { if (mobileInfo == null) { mobileInfo = new UserMobile { UserId = userId, User = manager.LoadUser(userId), AuthFrom = authFrom, Mobile = mobile, IsSettedMobile = true, CreateBy = createBy, UpdateBy = createBy, }; manager.AddUserMobile(mobileInfo); } else { throw new ArgumentException(string.Format("此用户已于【{0:yyyy-MM-dd HH:mm:ss}】进行过手机认证", mobileInfo.CreateTime)); } } } }
//首页活动 手机绑定 public void AddAuthenticationMobile_Index(string authFrom, string userId, string mobile, string createBy) { using (var manager = new UserMobileManager()) { //var other = manager.GetOtherUserMobile(mobile, userId); //if (other != null && other.IsSettedMobile)//判断手机号码的唯一性 //{ // throw new ArgumentException(string.Format("此手机号【{0}】已被其他用户认证。", mobile)); //} var mobileInfo = manager.GetMobileInfoByMobile(mobile); if (mobileInfo != null && !string.IsNullOrEmpty(mobileInfo.Mobile) && mobileInfo.UserId != userId) { throw new ArgumentException(string.Format("此手机号【{0}】已被其他用户认证。", mobile)); } //var entity = manager.GetUserMobile(userId); //if (entity != null && !string.IsNullOrEmpty(entity.Mobile) && !entity.IsSettedMobile) //{ // entity.Mobile = mobile; // entity.IsSettedMobile = true; // manager.UpdateUserMobile(entity); // //throw new ArgumentException(string.Format("此用户已于【{0:yyyy-MM-dd HH:mm:ss}】进行过手机认证", entity.CreateTime)); //} if (mobileInfo != null && !string.IsNullOrEmpty(mobileInfo.Mobile) && !mobileInfo.IsSettedMobile) { //mobileInfo.UserId = userId; mobileInfo.UpdateBy = userId; mobileInfo.UpdateTime = DateTime.Now; mobileInfo.Mobile = mobile; mobileInfo.IsSettedMobile = true; manager.UpdateUserMobile(mobileInfo); } else { if (mobileInfo == null) { mobileInfo = new UserMobile { UserId = userId, User = manager.LoadUser(userId), AuthFrom = authFrom, Mobile = mobile, IsSettedMobile = true, CreateBy = createBy, UpdateBy = createBy, }; manager.AddUserMobile(mobileInfo); var gv = new TaskListManager(); var old = gv.QueryTaskListByCategory(userId, TaskCategory.MobilBinding); if (old == null) { //增加成长值 var orderId = Guid.NewGuid().ToString("N"); BusinessHelper.Payin_UserGrowth("绑定手机号", orderId, userId, 100, "完成手机号绑定可获得100点成长值"); gv.AddUserTaskRecord(new UserTaskRecord { CreateTime = DateTime.Now, CurrentTime = DateTime.Now.ToString("yyyyMMdd"), OrderId = orderId, TaskCategory = TaskCategory.MobilBinding, TaskName = "绑定手机号", UserId = userId, }); gv.AddTaskList(new TaskList { UserId = userId, OrderId = orderId, Content = "完成手机号绑定可获得100点成长值", ValueGrowth = 100, IsGive = true, VipLevel = 0, CurrentTime = DateTime.Now.ToString("yyyyMMdd"), TaskCategory = TaskCategory.MobilBinding, TaskName = "绑定手机号", CreateTime = DateTime.Now, }); } } else { throw new ArgumentException(string.Format("此用户已于【{0:yyyy-MM-dd HH:mm:ss}】进行过手机认证", mobileInfo.CreateTime)); } } } }
public void RequestAuthenticationMobile(string userId, string mobile, int delaySeconds, string delayDescription, int maxRequestTime, string createBy) { #region //using (var biz = new GameBiz.Business.GameBizBusinessManagement()) //{ // biz.BeginTran(); // using (var manager = new UserMobileManager()) // { // var other = manager.GetOtherUserMobile(mobile, userId); // if (other != null && other.IsSettedMobile) // { // throw new ArgumentException(string.Format("此手机号【{0}】已被其他用户认证。", mobile)); // } // var entity = manager.GetUserMobile(userId); // if (entity != null) // { // if (entity.IsSettedMobile && entity.IsSettedMobile) // { // throw new ArgumentException(string.Format("已于【{0:yyyy-MM-dd HH:mm:ss}】进行过手机认证。", entity.UpdateTime)); // } // if (entity.RequestTimes >= maxRequestTime) // { // throw new ArgumentException(string.Format("已请求最大限制次数【{0}】次还未成功认证,请联系客服。", maxRequestTime)); // } // if (mobile != entity.Mobile) // { // var span = entity.UpdateTime.AddSeconds(delaySeconds) - DateTime.Now; // if (span.TotalSeconds > 0) // { // throw new ArgumentException(string.Format("换手机号码再次认证必须在【{0}】后进行。", delayDescription)); // } // } // entity.IsSettedMobile = true; // entity.UpdateBy = createBy; // entity.RequestTimes++; // entity.Mobile = mobile; // manager.UpdateUserMobile(entity); // } // else // { // entity = new UserMobile // { // UserId = userId, // User = manager.LoadUser(userId), // AuthFrom = "LOCAL", // Mobile = mobile, // IsSettedMobile = false, // CreateBy = createBy, // UpdateBy = createBy, // }; // manager.AddUserMobile(entity); // } // } // biz.CommitTran(); //} #endregion using (var manager = new UserMobileManager()) { var other = manager.GetMobileInfoByMobile(mobile); if (other != null && other.IsSettedMobile && other.UserId != userId) { throw new ArgumentException(string.Format("此手机号【{0}】已被其他用户认证。", mobile)); } //var entity = manager.GetUserMobile(userId); var entity = manager.GetUserMobile(userId); if (entity != null) { if (!string.IsNullOrEmpty(entity.Mobile) && entity.IsSettedMobile) { throw new ArgumentException(string.Format("已于【{0:yyyy-MM-dd HH:mm:ss}】进行过手机认证。", entity.UpdateTime)); } if (entity.RequestTimes >= maxRequestTime) { throw new ArgumentException(string.Format("已请求最大限制次数【{0}】次还未成功认证,请联系客服。", maxRequestTime)); } if (mobile != entity.Mobile) { var span = entity.UpdateTime.AddSeconds(delaySeconds) - DateTime.Now; if (span.TotalSeconds > 0) { throw new ArgumentException(string.Format("换手机号码再次认证必须在【{0}】后进行。", delayDescription)); } } entity.IsSettedMobile = true; entity.UpdateBy = createBy; entity.RequestTimes++; entity.Mobile = mobile; manager.UpdateUserMobile(entity); } else { entity = new UserMobile { UserId = userId, User = manager.LoadUser(userId), AuthFrom = "LOCAL", Mobile = mobile, IsSettedMobile = false, CreateBy = createBy, UpdateBy = createBy, }; manager.AddUserMobile(entity); } } }
public string RegisterResponseMobile(string userId, string mobile, int delaySeconds, string delayDescription) { using (var biz = new GameBiz.Business.GameBizBusinessManagement()) { biz.BeginTran(); var gv = new TaskListManager(); var old = gv.QueryTaskListByCategory(userId, TaskCategory.MobilBinding); if (old == null) { //增加成长值 var orderId = Guid.NewGuid().ToString("N"); BusinessHelper.Payin_UserGrowth("绑定手机号", orderId, userId, 100, "完成手机号绑定可获得100点成长值"); gv.AddUserTaskRecord(new UserTaskRecord { CreateTime = DateTime.Now, CurrentTime = DateTime.Now.ToString("yyyyMMdd"), OrderId = orderId, TaskCategory = TaskCategory.MobilBinding, TaskName = "绑定手机号", UserId = userId, }); gv.AddTaskList(new TaskList { UserId = userId, OrderId = orderId, Content = "完成手机号绑定可获得100点成长值", ValueGrowth = 100, IsGive = true, VipLevel = 0, CurrentTime = DateTime.Now.ToString("yyyyMMdd"), TaskCategory = TaskCategory.MobilBinding, TaskName = "绑定手机号", CreateTime = DateTime.Now, }); } using (var manager = new UserMobileManager()) { var entity = manager.GetUserMobile(userId); if (entity != null) { if (entity.IsSettedMobile) { throw new ArgumentException(string.Format("已于【{0:yyyy-MM-dd HH:mm:ss}】进行过手机认证。", entity.UpdateTime)); } var span = DateTime.Now - entity.UpdateTime.AddSeconds(delaySeconds); if (span.TotalSeconds > 0) { throw new ArgumentException(string.Format("提交认证手机必须在请求认证后【{0}】内完成。", delayDescription)); } entity.IsSettedMobile = true; manager.UpdateUserMobile(entity); } else { entity = new UserMobile { UserId = userId, User = manager.LoadUser(userId), AuthFrom = "LOCAL", Mobile = mobile, IsSettedMobile = true, CreateBy = userId, UpdateBy = userId, }; manager.AddUserMobile(entity); } mobile = entity.Mobile; } biz.CommitTran(); } return(mobile); }