private void SavePersonalRecordData(PersonalRecord personalRecord) { //order = order.Remove(order.Length - 1); if (App.IsNumber(BenchpressE.Text)) { personalRecord.Benchpress = App.setNumber(BenchpressE.Text); } else { ErrorL.Text = "Zadej pouze číslo"; } if (App.IsNumber(DeathliftE.Text)) { personalRecord.Deathlift = App.setNumber(DeathliftE.Text); } else { ErrorL.Text = "Zadej pouze číslo"; } if (App.IsNumber(SquatE.Text)) { personalRecord.Squat = App.setNumber(SquatE.Text); } else { ErrorL.Text = "Zadej pouze číslo"; } personalRecord.Date = DateR.Date.ToString(); personalRecord.Date = personalRecord.Date.Remove(personalRecord.Date.Length - 8); App.DatabasePersonalRecord.SaveItemAsync(personalRecord); }
public async Task <IActionResult> AddTime(string id, string time, string location) { var user = await userManager.FindByIdAsync(id); decimal Time = Convert.ToDecimal(time); PersonalRecord r = user.PersonalRecord; //AthleteData d = new AthleteData() { Location = location, Time = Time }; //r.AthleteData.Add(d); // user.PersonalRecord.AthleteData.Add(d); decimal prevPr = user.PersonalRecord.PR; if (Time > prevPr) { //add new time to personalrecord and athletedata user.PersonalRecord.PR = Time; } var result = await userManager.UpdateAsync(user); if (!result.Succeeded) { return(View(user)); } return(RedirectToAction("Index")); }
public UpdateResponse(string xmlResponseStr) : base(xmlResponseStr) { try { if (base.Status) { PersonalRecord = new PersonalRecord { UserId = GetValueForNodeInt("arg", "name", "userid"), IcId = GetValueForNodeInt("arg", "name", "icid"), EventDate = GetValueForNodeDate("arg", "name", "eventdate"), ExpireDate = GetValueForNodeDate("arg", "name", "expiredate"), RequirementId = GetValueForNodeInt("arg", "name", "requirementid"), TypeId = GetValueForNodeInt("arg", "name", "typeid"), Note = GetValueForNode("arg", "name", "note"), StatusId = GetValueForNodeInt("arg", "name", "statusid"), IsArchive = GetValueForNodeBool("arg", "name", "archive") }; } } catch (Exception ex) { base.ErrorMessage = ex.Message; } }
private void CheckFirstRun() { var bodyStats = App.DatabaseBodyStats.SelectLastBodyStats().Result; if (bodyStats.Count == 0) { BodyStats bodyStat = new BodyStats(); bodyStat.Height = 0; bodyStat.Weight = 0; bodyStat.WaistCircumference = 0; bodyStat.ThighCircumference = 0; bodyStat.BicepsCircumference = 0; App.DatabaseBodyStats.SaveItemAsync(bodyStat); } var Records = App.DatabasePersonalRecord.SelectHighestRecord().Result; if (Records.Count == 0) { PersonalRecord personalRecord = new PersonalRecord(); personalRecord.Benchpress = 0; personalRecord.Deathlift = 0; personalRecord.Squat = 0; App.DatabasePersonalRecord.SaveItemAsync(personalRecord); } }
public Task Handle(RegisterBirthCommand command) { var personalRecord = PersonalRecord.ActOfBorn(command.PersonId, command.MotherId, command.FatherId, command.Date, command.BornLatitude, command.BornLongitude); return(_repository.SaveAggregate(personalRecord)); }
public CreateResponse(string xmlResponseStr) : base(xmlResponseStr) { try { if (base.Status) { var entityId = int.Parse(Response.Descendants().Where(x => x.Name.ToString().ToLower() == "entityid").First().Value); PersonalRecord = new PersonalRecord { UserId = GetValueForNodeInt("arg", "name", "userid"), IcId = entityId, EventDate = GetValueForNodeDate("arg", "name", "eventdate"), ExpireDate = GetValueForNodeDate("arg", "name", "expiredate"), RequirementId = GetValueForNodeInt("arg", "name", "requirementid"), TypeId = GetValueForNodeInt("arg", "name", "typeid"), Note = GetValueForNode("arg", "name", "note"), StatusId = GetValueForNodeInt("arg", "name", "statusid"), IsArchive = GetValueForNodeBool("arg", "name", "archive") }; } } catch (Exception ex) { base.ErrorMessage = ex.Message; } }
public OperationResult Update(PersonalRecordVM model, bool isSave) { try { PersonalRecord personalRecord = _PersonalRecordRepository.Entities.FirstOrDefault(c => c.SerialNumber == model.SerialNumber && c.CertificateID == model.CertificateID.Trim()); if (personalRecord == null) { throw new Exception(); } //若姓名为英文字母,不需去除字符串中的空格,若为中文,需去除空格 String nameFormat = ""; if (IsEnCh(model.Name.Trim())) { nameFormat = model.Name.Trim().Replace("\n", "").Replace("\t", "").Replace("\r", ""); } else { nameFormat = GetReplaceString(model.Name); } String idType = GetReplaceString(model.CertificateType); String birthVar = ""; String genderVar = ""; if (!"居民身份证".Equals(idType)) { birthVar = GetReplaceString(model.Birth); genderVar = GetReplaceString(model.Gender); } personalRecord.SerialNumber = model.SerialNumber; personalRecord.Name = nameFormat; personalRecord.CertificateID = GetReplaceString(model.CertificateID); personalRecord.CertificateType = GetReplaceString(model.CertificateType); personalRecord.Company = GetReplaceString(model.Company); personalRecord.Tele = GetReplaceString(model.Tele); personalRecord.PersonType = GetReplaceString(model.PersonType); personalRecord.Nationality = GetReplaceString(model.Nationality); personalRecord.Title = GetReplaceString(model.Title); personalRecord.Amount = model.Amount; personalRecord.TaxOrNot = GetReplaceString(model.TaxOrNot); personalRecord.Bank = GetReplaceString(model.Bank); personalRecord.BankDetailName = GetReplaceString(model.BankDetailName); personalRecord.AccountName = GetReplaceString(model.AccountName); personalRecord.AccountNumber = GetReplaceString(model.AccountNumber); personalRecord.PaymentType = GetReplaceString(model.PaymentType); personalRecord.ProvinceCity = GetReplaceString(model.ProvinceCity); personalRecord.CityField = GetReplaceString(model.CityField); personalRecord.Gender = genderVar; personalRecord.Birth = birthVar; personalRecord.UpdateDate = DateTime.Now; _PersonalRecordRepository.Update(personalRecord, isSave); return(new OperationResult(OperationResultType.Success, "更新数据成功!")); } catch (Exception ex) { _log.Error(ex); return(new OperationResult(OperationResultType.Error, "更新数据失败!")); } }
public void AddPersonalRecordDoc_ReturnsRequestWithCorrectCount() { //Arrange var req = CreateRequestInstance(); PersonalRecord doc = new PersonalRecord(); //Act req.AddPersonalRecordDoc(doc); //Assert Assert.Equal(1, req.PersonalRecords.Count); }
public NavigationItemViewModel(PersonalRecord record, NavigationItemViewModel parentViewModel) : base() { this.sourceRecord = record; this.parent = parentViewModel; this.initializeProperties(); this.IsExpanded = new ReactivePropertySlim <bool>(true) .AddTo(this.disposables); this.IsSelected = new ReactivePropertySlim <bool>(false) .AddTo(this.disposables); }
public OperationResult Delete(PersonalRecord model, bool isSave) { try { model.UpdateDate = DateTime.Now; _PersonalRecordRepository.Delete(model, isSave); return(new OperationResult(OperationResultType.Success, "更新数据成功!")); } catch (Exception ex) { _log.Error(ex); return(new OperationResult(OperationResultType.Error, "更新数据失败!")); } }
private static void WhenDoIUseVar() { var aNumber = 5; //not necessary. Strongly typed by compiler PersonalRecord pr = new PersonalRecord() { Name = "Thumper", Age = 23, City = "Miami", Phone = "4535551011" }; PersonalRecord pr1 = new PersonalRecord() { Name = "Bugs", Age = 21, City = "Franklin", Phone = "4535551011" }; PersonalRecord pr2 = new PersonalRecord() { Name = "Energizer", Age = 45, City = "Franklin", Phone = "4235551011" }; PersonalRecord pr3 = new PersonalRecord() { Name = "Roger", Age = 55, City = "Franklin", Phone = "4435551011" }; PersonalRecord pr4 = new PersonalRecord() { Name = "Peter", Age = 11, City = "Las Vegas", Phone = "4535551011" }; List<PersonalRecord> personalRecords = new List<PersonalRecord>(); personalRecords.Add(pr); personalRecords.Add(pr1); personalRecords.Add(pr2); personalRecords.Add(pr3); personalRecords.Add(pr4); var personalRecordQuery = personalRecords.Where(x => x.City == "Franklin").Select(x => new {x.Name, x.Phone }); foreach (var item in personalRecordQuery) //var is necessary because of anonymous type { Console.WriteLine("Name={0}, Phone={1}", item.Name, item.Phone); } }
public CreateResponse Create(PersonalRecord record) { base.RemoveChildrenFromCallNode(); base.AddChildToCallNode("arg", record.UserId, "name", "userid"); base.AddChildToCallNode("arg", record.TypeId, "name", "typeid"); base.AddChildToCallNode("arg", record.RequirementId, "name", "requirementid"); base.AddChildToCallNode("arg", record.StatusId, "name", "statusid"); base.AddChildToCallNode("arg", record.EventDate, "name", "eventdate"); base.AddChildToCallNode("arg", record.ExpireDate, "name", "expiredate"); base.AddChildToCallNode("arg", record.Note, "name", "note"); var xmlRequest = base.XRequestBase.ToString(); var response = new CreateResponse(_service.create(xmlRequest)); response.RequestXml = xmlRequest; //save for logging purposes return(response); }
public ActionResult CreatePersonal() { PersonalRecordVM[] recordVMs = ClassConvert <PersonalRecordVM> .Process(Request.Form); var result = _personalRecordService.Insert(recordVMs[0], true); var entity = new PersonalRecord { //Id = (int)System.DateTime.Now.Ticks, SerialNumber = recordVMs[0].SerialNumber, Name = recordVMs[0].Name, CertificateID = recordVMs[0].CertificateID, CertificateType = recordVMs[0].CertificateType, Company = recordVMs[0].Company, Tele = recordVMs[0].Tele, PersonType = recordVMs[0].PersonType, Nationality = recordVMs[0].Nationality, Title = recordVMs[0].Title, Amount = recordVMs[0].Amount, TaxOrNot = recordVMs[0].TaxOrNot, Bank = recordVMs[0].Bank, BankDetailName = recordVMs[0].BankDetailName, ProvinceCity = recordVMs[0].ProvinceCity, CityField = recordVMs[0].CityField, AccountName = recordVMs[0].Name, AccountNumber = recordVMs[0].AccountNumber, PaymentType = recordVMs[0].PaymentType, Gender = recordVMs[0].Gender, Birth = recordVMs[0].Birth, UpdateDate = DateTime.Now }; if (result.ResultType != OperationResultType.Success) { return(Json(new { error = result.Message, total = 1, data = new[] { entity } })); } else { return(Json(new { total = 1, data = new[] { result.Data } })); } }
private void SavePersonalRecord() { if (string.IsNullOrEmpty(BenchpressE.Text) && string.IsNullOrEmpty(DeathliftE.Text) && string.IsNullOrEmpty(SquatE.Text)) { ErrorL.TextColor = Color.FromHex("#FF4081"); ErrorL.Text = "Nevložil si data"; } else { ErrorL.Text = "MAXIMÁLKY"; var highestData = App.DatabasePersonalRecord.SelectHighestRecord().Result; PersonalRecord personalRecord = new PersonalRecord(); personalRecord.Benchpress = highestData[0].Benchpress; personalRecord.Deathlift = highestData[0].Deathlift; personalRecord.Squat = highestData[0].Squat; SavePersonalRecordData(personalRecord); ErrorL.Text = "Úspěšně uloženo"; Application.Current.MainPage = new MenuPage(); } }
public OperationResult Import(String fileName, Service.Excel.ImportData importData) { try { string userid = ((System.Web.Security.FormsIdentity)(System.Web.HttpContext.Current.User.Identity)).Ticket.UserData; var columns = importData == null ? null : importData.Columns; var maps = ImportUtil.GetColumns(columns, new PersonalRecord()); var items = ExcelService.GetObjects(fileName, columns); if (importData != null) { String serialNumber = importData.Parameters[0].Value; String paymentType = importData.Parameters[1].Value; int num = 1; foreach (var item in items) { if (CheckAllNull(item[0]) && CheckAllNull(item[1]) && CheckAllNull(item[2]) && CheckAllNull(item[3]) && CheckAllNull(item[4]) && CheckAllNull(item[5]) && CheckAllNull(item[6]) && CheckAllNull(item[7]) && CheckAllNull(item[8])) { continue; } PersonalRecord record = new PersonalRecord(); record.SerialNumber = serialNumber; record.PaymentType = paymentType; if (paymentType.Equals("银行转账")) { if (item.Count < 16) { return(new OperationResult(OperationResultType.Error, "导入数据失败", "<li>请增加银行账户等相关信息或修改为现金支付类型</li>")); } record.AccountName = item[0]; record.Bank = item[10]; record.AccountNumber = item[11]; record.BankDetailName = item[12]; record.ProvinceCity = item[13]; record.CityField = item[14]; } List <ImportFeedBack> errors = ValidatePersonalRecord(item, num++, maps, ref record); if (errors.Count > 0) { return(new OperationResult(OperationResultType.Error, "导入数据失败", ImportUtil.ParseToHtml(errors))); } //若姓名为英文字母,不需去除字符串中的空格,若为中文,需去除空格 String nameFormat = ""; if (IsEnCh(record.Name.Trim())) { nameFormat = record.Name.Trim().Replace("\n", "").Replace("\t", "").Replace("\r", ""); } else { nameFormat = GetReplaceString(record.Name); } //插入或更新数据 _PersonalRecordRepository.InsertOrUpdate(record); //保存时同步向常用领款人表TopContacts中保存 TopContacts contact = new TopContacts(); contact.UserID = userid; contact.Name = nameFormat; contact.CertificateType = GetReplaceString(record.CertificateType); contact.CertificateID = GetReplaceString(record.CertificateID); contact.Nationality = GetReplaceString(record.Nationality); contact.PersonType = GetReplaceString(record.PersonType); contact.Tele = GetReplaceString(record.Tele); contact.Title = GetReplaceString(record.Title); contact.Company = GetReplaceString(record.Company); if (!String.IsNullOrEmpty(record.Bank)) { contact.Bank = GetReplaceString(record.Bank); } if (!String.IsNullOrEmpty(record.BankDetailName)) { contact.BankDetailName = GetReplaceString(record.BankDetailName); } if (!String.IsNullOrEmpty(record.ProvinceCity)) { contact.ProvinceCity = GetReplaceString(record.ProvinceCity); } if (!String.IsNullOrEmpty(record.CityField)) { contact.CityField = GetReplaceString(record.CityField); } if (!String.IsNullOrEmpty(record.AccountNumber)) { contact.AccountNumber = GetReplaceString(record.AccountNumber); } if (!String.IsNullOrEmpty(record.Gender)) { contact.Gender = GetReplaceString(record.Gender); } if (!String.IsNullOrEmpty(record.Birth)) { contact.Birth = GetReplaceString(record.Birth); } _TopContactsService.Insert(contact); } } return(new OperationResult(OperationResultType.Success, "导入数据成功!")); } catch (Exception ex) { _log.Error(ex); ImportFeedBack feedBack = new ImportFeedBack(); feedBack.ExceptionType = "未知错误"; feedBack.ExceptionContent.Add(ex.Message); List <ImportFeedBack> erros = new List <ImportFeedBack>(); return(new OperationResult(OperationResultType.Error, "导入数据失败!", ImportUtil.ParseToHtml(new List <ImportFeedBack>() { feedBack }))); } }
public async Task <IActionResult> Register(RegisterViewModel model) { ViewData["ReCaptchaKey"] = configuration.GetSection("GoogleReCaptcha:key").Value; if (ModelState.IsValid) { if (!ReCaptchaPassed(Request.Form["g-recaptcha-response"], //gets recaptcha response and checks it configuration.GetSection("GoogleReCaptcha:secret").Value, logger)) { ModelState.AddModelError(string.Empty, "Sorry sir, no bots allowed"); return(View(model)); } PersonalRecord r = new PersonalRecord() { PR = 30 }; AthleteData d = new AthleteData() { Location = "Random Natatorium", Time = 29 }; r.AthleteData = new List <AthleteData>(); r.AthleteData.Add(d); var user = new User { UserName = model.Email, Email = model.Email, Name = model.Name, TwoFactorEnabled = model.TwoFactorEnabled, PersonalRecord = r, TotpEnabled = model.TotpEnabled }; Team team = dbContext.Teams.SingleOrDefault(t => t.TeamCode.ToLower() == model.TeamCode.ToLower()); if (team == null) { ModelState.AddModelError(string.Empty, "Team Code Invalid"); return(RedirectToAction("Register", "Account")); } Team coach = null; if (model.CoachCode != null) { coach = dbContext.Teams.SingleOrDefault(t => t.CoachCode.ToLower() == model.CoachCode.ToLower()); } if (coach == null) { ModelState.AddModelError(string.Empty, "Team Code Invalid"); return(RedirectToAction("Register", "Account")); } var result = await userManager.CreateAsync(user, model.Password); if (team != null && model.CoachEnabled == false) { user.Team = team; var roleResult = await userManager.AddToRoleAsync(user, Roles.AthleteRole); if (!roleResult.Succeeded) { ModelState.AddModelError(string.Empty, "Team Code Invalid"); return(RedirectToAction("Register", "Account")); } } else if (team != null && model.CoachEnabled == true && coach != null) { user.Team = team; user.Coach = true; var roleResult = await userManager.AddToRoleAsync(user, Roles.CoachRole); var AthleteRoleResult = await userManager.AddToRoleAsync(user, Roles.AthleteRole); if (!roleResult.Succeeded || !AthleteRoleResult.Succeeded) { ModelState.AddModelError(string.Empty, "Coach/Team Code Invalid"); return(RedirectToAction("Register", "Account")); } } else { ModelState.AddModelError(string.Empty, "Registration Failed"); return(RedirectToAction("Register", "Account")); } var UpdateResult = await userManager.UpdateAsync(user); if (!UpdateResult.Succeeded) { ModelState.AddModelError(string.Empty, "Could Not Create User"); return(RedirectToAction("Register", "Account")); } var token = await userManager.GenerateEmailConfirmationTokenAsync(user); var confirmationLink = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, token = token }, Request.Scheme); emailService.SendAuthEmail(user.Email, confirmationLink); HttpContext.Session.SetString("Id", user.Id); if (result.Succeeded) { if (user.TwoFactorEnabled == true && user.TotpEnabled == true) { HttpContext.Session.SetString("Id", user.Id); return(RedirectToAction("SetUpTotp")); } if (signInManager.IsSignedIn(User)) { return(RedirectToAction("index", "Athlete")); } return(View("/Views/Account/ConfirmEmail.cshtml", model)); } foreach (var error in result.Errors) { ModelState.AddModelError("", error.Description); } } return(View(model)); }
public void ProcessColumn( int evalueUserId, string columnName, object columnValue, object noteValue, ExpirationSettingType expirationSetting, IList <PersonalRecord> userRecords, int requirementTypeId, int?requirementTypeIdFallback, int requirementDurationTypeId ) { var log = new ColumnLog { InputColumnName = columnName, InputColumnValue = columnValue }; log.Start(); if (columnValue != null) { try { var columnValueStr = columnValue.ToString(); var noteValueStr = noteValue != null?noteValue.ToString() : string.Empty; var changes = new List <string>(); var updateRecord = new PersonalRecord { UserId = evalueUserId, StatusId = RequirementStatusOption.Constants.Not_Met, RequirementId = requirementDurationTypeId, TypeId = requirementTypeId, }; DateTime dt; if (DateTime.TryParse(columnValue.ToString(), out dt)) { updateRecord.EventDate = dt; switch (expirationSetting) { case ExpirationSettingType.Months_11: updateRecord.ExpireDate = updateRecord.EventDate.Value.AddMonths(11); break; case ExpirationSettingType.Years_1: updateRecord.ExpireDate = updateRecord.EventDate.Value.AddYears(1); break; case ExpirationSettingType.Years_5: updateRecord.ExpireDate = updateRecord.EventDate.Value.AddYears(5); break; case ExpirationSettingType.Years_10: updateRecord.ExpireDate = updateRecord.EventDate.Value.AddYears(10); break; } } else { if (string.IsNullOrEmpty(noteValueStr)) { noteValueStr = columnValueStr; } } if (!string.IsNullOrEmpty(noteValueStr)) { updateRecord.Note = noteValueStr; } var existing = userRecords.Where(x => x == updateRecord).FirstOrDefault(); //a prerequisite check is required. If a record with primary requirement type is already present, use the fallback type if (existing != null && requirementTypeIdFallback.HasValue && existing.EventDate.HasValue && updateRecord.EventDate.HasValue && existing.EventDate.Value != updateRecord.EventDate.Value) { log.Append(string.Format("A prior requirement type [{0}] was found, using fallback type of [{1}]", requirementTypeId, requirementTypeIdFallback.Value)); updateRecord.TypeId = requirementTypeIdFallback.Value; existing = userRecords.Where(x => x == updateRecord).FirstOrDefault(); } if (existing == null) { log.Append("No E*Value record found"); changes.Add("All"); } else { log.Append("E*Value record found"); updateRecord.IcId = existing.IcId; if (updateRecord.EventDate.HasValue && (!existing.EventDate.HasValue || existing.EventDate.Value != updateRecord.EventDate.Value)) { var existingDateStr = existing.EventDate.HasValue ? existing.EventDate.Value.ToShortDateString() : "null"; changes.Add("EventDate"); log.Append(string.Format("EventDate changed from {0} to {1}]", existingDateStr, updateRecord.EventDate.Value)); } if (existing.RequirementId.HasValue && existing.RequirementId.Value != updateRecord.RequirementId.Value) { changes.Add("RequirementId"); log.Append(string.Format("RequirementId changed from {0} to {1}", existing.RequirementId.Value, updateRecord.RequirementId.Value)); } if (existing.StatusId.HasValue && existing.StatusId.Value != updateRecord.StatusId.Value) { changes.Add("StatusId"); log.Append(string.Format("StatusId changed from {0} to {1}", existing.StatusId.Value, updateRecord.StatusId.Value)); } if (string.IsNullOrEmpty(existing.Note)) { existing.Note = string.Empty; } if (!string.IsNullOrEmpty(updateRecord.Note) && existing.Note != updateRecord.Note) { changes.Add("Note"); log.Append(string.Format("Note changed from {0} to {1}", existing.Note, updateRecord.Note)); } } if (changes.Count == 0) { log.ProcessingResult = ColumnProcessingResult.SKIPPED_NO_CHANGES_DETECTED; log.Append("No changes were detected."); } else { log.Append(string.Format("Updating E*Value due to changes in fields [{0}]", string.Join(",", changes.Select(x => x)))); PersonalRecord record; if (updateRecord.IcId.HasValue) { var updateResponse = _api.Update(updateRecord); log.Append("E*Value API Request", updateResponse.RequestXml); if (updateResponse.Status) { log.Append("E*Value update record succeeded"); log.ProcessingResult = ColumnProcessingResult.EVALUE_UPDATE_SUCCESS; } else { log.Append("E*Value update record failed"); log.Append(updateResponse.ErrorMessage); log.ProcessingResult = ColumnProcessingResult.EVALUE_UPDATE_FAILED; } record = updateResponse.PersonalRecord; } else { var createResponse = _api.Create(updateRecord); log.Append("E*Value API Request", createResponse.RequestXml); if (createResponse.Status) { log.Append("E*Value created succeeded"); log.ProcessingResult = ColumnProcessingResult.EVALUE_UPDATE_SUCCESS; } else { log.Append("E*Value update record failed"); log.Append(createResponse.ErrorMessage); log.ProcessingResult = ColumnProcessingResult.EVALUE_UPDATE_FAILED; } record = createResponse.PersonalRecord; } } } catch (Exception ex) { log.Append(ex.Message); log.ProcessingResult = ColumnProcessingResult.FAILED_EXCEPTION_OCCURRED; } } else { log.ProcessingResult = ColumnProcessingResult.SKIPPED_NO_VALUE_IN_INPUT_COLUMN; } _log.CurrentRow.Columns.Add(log); }
public OperationResult Insert(PersonalRecordVM model, bool isSave) { try { string userid = ((System.Web.Security.FormsIdentity)(System.Web.HttpContext.Current.User.Identity)).Ticket.UserData; //1.检查是否有重复字段 PersonalRecord[] personalRecords = _PersonalRecordRepository.Entities.Where(w => w.SerialNumber == model.SerialNumber && w.CertificateID == model.CertificateID.Trim()).ToArray(); if (personalRecords != null && personalRecords.Length > 0) { return(new OperationResult(OperationResultType.Warning, "该申请单中已经存在相同的人员信息,请修改后重新提交!")); } if (String.IsNullOrEmpty(model.CertificateID)) { return(new OperationResult(OperationResultType.Warning, "证件号码不能为空,请修改后重新提交!")); } if (String.IsNullOrEmpty(model.Nationality)) { return(new OperationResult(OperationResultType.Warning, "国籍不能为空,请修改后重新提交!")); } //若姓名为英文字母,不需去除字符串中的空格,若为中文,需去除空格 String nameFormat = ""; if (IsEnCh(model.Name.Trim())) { nameFormat = model.Name.Trim().Replace("\n", "").Replace("\t", "").Replace("\r", ""); } else { nameFormat = GetReplaceString(model.Name); } String idType = GetReplaceString(model.CertificateType); String birthVar = ""; String genderVar = ""; if (!"居民身份证".Equals(idType)) { birthVar = GetReplaceString(model.Birth); genderVar = GetReplaceString(model.Gender); } var entity = new PersonalRecord { SerialNumber = model.SerialNumber, Name = nameFormat, CertificateID = GetReplaceString(model.CertificateID), CertificateType = GetReplaceString(model.CertificateType), Company = GetReplaceString(model.Company), Tele = GetReplaceString(model.Tele), PersonType = GetReplaceString(model.PersonType), Nationality = GetReplaceString(model.Nationality), Title = GetReplaceString(model.Title), Amount = model.Amount, TaxOrNot = GetReplaceString(model.TaxOrNot), Bank = GetReplaceString(model.Bank), BankDetailName = GetReplaceString(model.BankDetailName), AccountName = GetReplaceString(model.AccountName), AccountNumber = GetReplaceString(model.AccountNumber), ProvinceCity = GetReplaceString(model.ProvinceCity), CityField = GetReplaceString(model.CityField), Gender = genderVar, Birth = birthVar, PaymentType = GetReplaceString(model.PaymentType), UpdateDate = DateTime.Now }; _PersonalRecordRepository.Insert(entity, isSave); //保存时同步向常用领款人表TopContacts中保存 TopContacts contact = new TopContacts(); contact.UserID = userid; contact.Name = nameFormat; contact.CertificateType = GetReplaceString(model.CertificateType); contact.CertificateID = GetReplaceString(model.CertificateID); contact.Nationality = GetReplaceString(model.Nationality); contact.PersonType = GetReplaceString(model.PersonType); contact.Tele = GetReplaceString(model.Tele); contact.Title = GetReplaceString(model.Title); contact.Company = GetReplaceString(model.Company); if (!String.IsNullOrEmpty(model.Bank)) { contact.Bank = GetReplaceString(model.Bank); } if (!String.IsNullOrEmpty(model.BankDetailName)) { contact.BankDetailName = GetReplaceString(model.BankDetailName); } if (!String.IsNullOrEmpty(model.AccountNumber)) { contact.AccountNumber = GetReplaceString(model.AccountNumber); } if (!String.IsNullOrEmpty(model.ProvinceCity)) { contact.ProvinceCity = GetReplaceString(model.ProvinceCity); } if (!String.IsNullOrEmpty(model.ProvinceCity)) { contact.ProvinceCity = GetReplaceString(model.ProvinceCity); } if (!String.IsNullOrEmpty(model.CityField)) { contact.CityField = GetReplaceString(model.CityField); } if (!String.IsNullOrEmpty(genderVar)) { contact.Gender = genderVar; } if (!String.IsNullOrEmpty(birthVar)) { contact.Birth = birthVar; } _TopContactsService.Insert(contact); return(new OperationResult(OperationResultType.Success, "新增数据成功!", entity)); } catch (Exception ex) { _log.Error(ex); return(new OperationResult(OperationResultType.Error, "新增数据失败:" + ex.Message)); } }
private List <ImportFeedBack> ValidatePersonalRecord(LinqToExcel.Row record, int num, Dictionary <String, String> map, ref PersonalRecord personal) { List <ImportFeedBack> list = new List <ImportFeedBack>(); ImportFeedBack feedBack = null; //非空验证 feedBack = new ImportFeedBack(); feedBack.ExceptionType = "空值"; if (personal.PaymentType.Equals("银行转账")) { var properties = personal.GetType().GetProperties(); foreach (var property in properties) { switch (property.Name) { case "Name": case "CertificateType": case "CertificateID": case "Company": case "Tele": case "PersonType": case "Nationality": case "Title": case "TaxOrNot": case "AccountNumber": if (String.IsNullOrEmpty(ImportUtil.GetValue(record, map, property.Name))) { feedBack.ExceptionContent.Add(String.Format("第{0}行记录 {1}为空!", num, map[property.Name])); } else { property.SetValue(personal, ImportUtil.GetValue(record, map, property.Name)); } break; case "BankDetailName": if (!ImportUtil.GetValue(record, map, "Bank").Equals("工商银行")) { if (String.IsNullOrEmpty(ImportUtil.GetValue(record, map, property.Name))) { feedBack.ExceptionContent.Add(String.Format("第{0}行记录 {1}为空!", num, map[property.Name])); } else { property.SetValue(personal, ImportUtil.GetValue(record, map, property.Name)); } } break; case "Gender": if (!ImportUtil.GetValue(record, map, "CertificateType").Equals("居民身份证")) { if (String.IsNullOrEmpty(ImportUtil.GetValue(record, map, property.Name))) { feedBack.ExceptionContent.Add(String.Format("第{0}行记录 {1}为空!", num, map[property.Name])); } else { property.SetValue(personal, ImportUtil.GetValue(record, map, property.Name)); } } break; case "Birth": if (!ImportUtil.GetValue(record, map, "CertificateType").Equals("居民身份证")) { if (String.IsNullOrEmpty(ImportUtil.GetValue(record, map, property.Name))) { feedBack.ExceptionContent.Add(String.Format("第{0}行记录 {1}为空!", num, map[property.Name])); } else { property.SetValue(personal, ImportUtil.GetValue(record, map, property.Name)); } } break; case "Amount": try { var value = Convert.ToDouble(ImportUtil.GetValue(record, map, property.Name)); property.SetValue(personal, value); } catch { feedBack.ExceptionContent.Add(String.Format("第{0}行记录 {1}格式不正确!", num, map[property.Name])); } break; case "ProvinceCity": if (!ImportUtil.GetValue(record, map, "Bank").Equals("工商银行")) { if (String.IsNullOrEmpty(ImportUtil.GetValue(record, map, property.Name))) { feedBack.ExceptionContent.Add(String.Format("第{0}行记录 {1}为空!", num, map[property.Name])); } else { property.SetValue(personal, ImportUtil.GetValue(record, map, property.Name)); } } break; case "CityField": if (!ImportUtil.GetValue(record, map, "Bank").Equals("工商银行")) { if (String.IsNullOrEmpty(ImportUtil.GetValue(record, map, property.Name))) { feedBack.ExceptionContent.Add(String.Format("第{0}行记录 {1}为空!", num, map[property.Name])); } else { property.SetValue(personal, ImportUtil.GetValue(record, map, property.Name)); } } break; default: break; } } } else if (personal.PaymentType.Equals("现金支付")) { var properties = personal.GetType().GetProperties(); foreach (var property in properties) { switch (property.Name) { case "Name": case "CertificateType": case "CertificateID": case "Company": case "Tele": case "PersonType": case "Nationality": case "Title": case "TaxOrNot": if (String.IsNullOrEmpty(ImportUtil.GetValue(record, map, property.Name))) { feedBack.ExceptionContent.Add(String.Format("第{0}行记录 {1}为空!", num, map[property.Name])); } else { property.SetValue(personal, ImportUtil.GetValue(record, map, property.Name)); } break; case "Gender": if (!ImportUtil.GetValue(record, map, "CertificateType").Equals("居民身份证")) { if (String.IsNullOrEmpty(ImportUtil.GetValue(record, map, property.Name))) { feedBack.ExceptionContent.Add(String.Format("第{0}行记录 {1}为空!", num, map[property.Name])); } else { property.SetValue(personal, ImportUtil.GetValue(record, map, property.Name)); } } break; case "Birth": if (!ImportUtil.GetValue(record, map, "CertificateType").Equals("居民身份证")) { if (String.IsNullOrEmpty(ImportUtil.GetValue(record, map, property.Name))) { feedBack.ExceptionContent.Add(String.Format("第{0}行记录 {1}为空!", num, map[property.Name])); } else { property.SetValue(personal, ImportUtil.GetValue(record, map, property.Name)); } } break; case "Amount": if (String.IsNullOrEmpty(ImportUtil.GetValue(record, map, property.Name))) { feedBack.ExceptionContent.Add(String.Format("第{0}行记录 {1}为空!", num, map[property.Name])); } else { try { var value = Convert.ToDouble(ImportUtil.GetValue(record, map, property.Name)); property.SetValue(personal, value); } catch { feedBack.ExceptionContent.Add(String.Format("第{0}行记录 {1}格式不正确!", num, map[property.Name])); } } break; default: break; } } } if (feedBack.ExceptionContent.Count > 0) { list.Add(feedBack); } //格式错误验证 feedBack = new ImportFeedBack(); feedBack.ExceptionType = "格式错误"; //证件类型 String[] regCerficateType = { "居民身份证", "中国护照", "外国护照", "港澳居民来往内地通行证", "港澳居民居住证", "台湾居民来往大陆通行证", "台湾居民居住证", "外国人永久居留身份证", "外国人工作许可证(A类)", "外国人工作许可证(B类)", "外国人工作许可证(C类)" }; if (!regCerficateType.Contains(personal.CertificateType)) { feedBack.ExceptionContent.Add("第" + num + "行记录 证件类型格式有误,必须是【居民身份证,中国护照,外国护照,港澳居民来往内地通行证,港澳居民居住证,台湾居民来往大陆通行证,台湾居民居住证,外国人永久居留身份证,外国人工作许可证(A类),外国人工作许可证(B类),外国人工作许可证(C类)】之一!"); } //人员类型 String[] regPersonType = { "所内", "所外" }; if (!regPersonType.Contains(personal.PersonType)) { feedBack.ExceptionContent.Add("第" + num + "行记录 人员类型格式有误,必须是【所内、所外】之一!"); } //是否含税 String[] regTaxOrNot = { "含税", "不含税" }; if (!regTaxOrNot.Contains(personal.TaxOrNot)) { feedBack.ExceptionContent.Add("第" + num + "行记录 是否含税格式有误,必须是【含税、不含税】之一!"); } //证件号码 // Regex regCerficateID = new Regex("^\\d{15}|\\d{18}$"); //Regex regCerficateID = new Regex("^[1-9]\\d{5}[1-9]9\\d{4}3[0-1]\\d{4}$|^[1-9]\\d{5}[1-9]9\\d{4}[0-2][0-9]\\d{4}$|^[1-9]\\d{5}[1-9]9\\d{4}3[0-1]\\d{3}X$|^[1-9]\\d{5}[1-9]9\\d{4}[0-2][0-9]\\d{3}X$|^[1-9]\\d{5}\\d{4}3[0-1]\\d{4}$|^[1-9]\\d{5}\\d{4}[0-2][0-9]\\d{4}$|^[1-9]\\d{5}\\d{4}3[0-1]\\d{3}X$|^[1-9]\\d{5}\\d{4}[0-2][0-9]\\d{3}X$"); //^[1-9]\d{5}[1-9]9\d{4}3[0-1]\d{4}$|^[1-9]\d{5}[1-9]9\d{4}[0-2][0-9]\d{4}$|^[1-9]\d{5}[1-9]9\d{4}3[0-1]\d{3}X$|^[1-9]\d{5}[1-9]9\d{4}[0-2][0-9]\d{3}X$|^[1-9]\d{5}\d{4}3[0-1]\d{4}$|^[1-9]\d{5}\d{4}[0-2][0-9]\d{4}$|^[1-9]\d{5}\d{4}3[0-1]\d{3}X$|^[1-9]\d{5}\d{4}[0-2][0-9]\d{3}X$ if (!String.IsNullOrEmpty(personal.CertificateType) && personal.CertificateType.Equals("居民身份证")) { if (personal.CertificateID.Length == 18) { if (CheckIDCard18(personal.CertificateID) == false && CheckIDCardFormat(personal.CertificateID) == false) { feedBack.ExceptionContent.Add("第" + num + "行记录 证件号码格式有误!"); } } else if (personal.CertificateID.Length == 15) { if (CheckIDCard15(personal.CertificateID) == false && CheckIDCardFormat(personal.CertificateID) == false) { feedBack.ExceptionContent.Add("第" + num + "行记录 证件号码格式有误!"); } } else if (personal.CertificateID.Length != 15 && personal.CertificateID.Length != 18) { feedBack.ExceptionContent.Add("第" + num + "行记录 证件号码格式有误!"); } else if (personal.CertificateID.Length == 18) { string tmp = personal.CertificateID.Substring(6, 2); if (!tmp.Equals("19") && !tmp.Equals("20")) { feedBack.ExceptionContent.Add("第" + num + "行记录 证件号码格式有误!"); } } //验证身份证号码后四位是否为0000 if (personal.CertificateID.Substring(personal.CertificateID.Length - 4).Equals("0000")) { feedBack.ExceptionContent.Add("第" + num + "行记录 请检查证件号码后四位!"); } } //出生日期格式验证 Regex regBirth = new Regex("^(\\d{4})(-)(\\d{2})(-)(\\d{2})$"); if (!String.IsNullOrEmpty(personal.Birth)) { if (!regBirth.IsMatch(personal.Birth)) { feedBack.ExceptionContent.Add("第" + num + "行记录 出生日期格式不正确,格式为1970-01-01,居民身份证可不填"); } } //联系电话 //Regex regPhone = new Regex("^0\\d{2,3}-?\\d{7,8}$"); //Regex regMobile = new Regex("^1[34578]\\d{9}$"); // if (!regPhone.IsMatch(personal.Tele) && !regMobile.IsMatch(personal.Tele)) //if (String.IsNullOrEmpty(personal.Tele) || System.Text.RegularExpressions.Regex.IsMatch(personal.Tele, @"^(\d{3,4}-)?\d{6,8}$")) //{ // feedBack.ExceptionContent.Add("第" + num + "行记录 联系电话格式有误!若为座机请填写区号,如01082306380"); //} //Regex regPhone = new Regex("^0\\d{2,3}-?\\d{7,8}$"); //Regex regMobile = new Regex("^1[34578]\\d{9}$"); Regex regMobile = new Regex("^1(3|4|5|6|7|8|9)\\d{9}$"); // if (!regPhone.IsMatch(personal.Tele) && !regMobile.IsMatch(personal.Tele)) if (String.IsNullOrEmpty(personal.Tele) || !regMobile.IsMatch(personal.Tele)) { feedBack.ExceptionContent.Add("第" + num + "行记录 联系电话格式有误!请填写11位手机号码"); } //银行名称是否包含在开户行详细名称中 if (!String.IsNullOrEmpty(personal.Bank) && !String.IsNullOrEmpty(personal.BankDetailName)) { if (personal.Bank.Equals("工商银行")) { if (!personal.BankDetailName.Contains(personal.Bank)) { feedBack.ExceptionContent.Add("第" + num + "行记录 所选银行与开户行详细名称不符,工商银行可不填写开户行详细名称"); } } if (!personal.Bank.Equals("工商银行")) { if (!personal.BankDetailName.Contains(personal.Bank)) { feedBack.ExceptionContent.Add("第" + num + "行记录 所选银行与开户行详细名称不符,开户行详细名称应包含所选银行名称"); } } } //银行卡号 Regex regAccountNumber1 = new Regex("^(\\d{4}[\\s\\-]?){4,5}\\d{3}$"); Regex regAccountNumber2 = new Regex("^(\\d{16}|\\d{17}|\\d{18}|\\d{19}|\\d{20}|\\d{21})$"); if (!String.IsNullOrEmpty(personal.PaymentType) && personal.PaymentType.Equals("银行转账")) { if (String.IsNullOrEmpty(personal.AccountNumber) || !regAccountNumber1.IsMatch(personal.AccountNumber)) { if (String.IsNullOrEmpty(personal.AccountNumber) || !regAccountNumber2.IsMatch(personal.AccountNumber)) { feedBack.ExceptionContent.Add("第" + num + "行记录 银行卡号格式有误!"); } } //验证号码后三位是否为000 if (personal.AccountNumber.Substring(personal.AccountNumber.Length - 3).Equals("000")) { feedBack.ExceptionContent.Add("第" + num + "行记录 请检查银行卡号后三位!"); } } if (feedBack.ExceptionContent.Count > 0) { list.Add(feedBack); } //若为所内:姓名、身份证验证 feedBack = new ImportFeedBack(); feedBack.ExceptionType = "所内所外姓名验证"; String nameAndStatus = _TaxBaseByMonthRepository.GetNameByCerID(personal.CertificateID); string[] names = nameAndStatus.Split(','); if (names[1].Equals("upper")) { feedBack.ExceptionContent.Add("第" + num + "行记录 该人员证件号码中的字母需从小写修改为大写!"); } else if (names[1].Equals("lower")) { feedBack.ExceptionContent.Add("第" + num + "行记录 该人员证件号码中的字母需从大写修改为小写!"); } if (String.IsNullOrEmpty(names[0]) && !String.IsNullOrEmpty(personal.PersonType)) { if (personal.PersonType.Equals("所内") && names[0].Equals("")) { feedBack.ExceptionContent.Add("第" + num + "行记录 该人员不是所内人员,人员类型需要填写为【所外】!"); } } else { if (!String.IsNullOrEmpty(personal.PersonType)) { if (personal.PersonType.Equals("所内") && !names[0].Equals(personal.Name.Trim())) { feedBack.ExceptionContent.Add("第" + num + "行记录 该证件号码与人员不符,请检查!"); } else { if (personal.PersonType.Equals("所外")) { feedBack.ExceptionContent.Add("第" + num + "行记录 该人员是所内人员,人员类型需要填写为【所内】!"); } } } } if (feedBack.ExceptionContent.Count > 0) { list.Add(feedBack); } //现金发放次数验证 /* * feedBack = new ImportFeedBack(); * feedBack.ExceptionType = "现金发放次数超过3次"; * int count = _TaxPerOrderRepository.GetCashCount(personal.CertificateID); * if (count >= 3) * { * feedBack.ExceptionContent.Add("第" + num + "行记录 该人员本月已发放3次现金,若需再次发放,需在支付方式为【银行转账】的申请单中填报!"); * } * if (feedBack.ExceptionContent.Count > 0) * { * list.Add(feedBack); * } * */ return(list); }