private void OnParseRawTextRecipientFinished(ParseRawTextRecipientFinishedPayload payload) { foreach (var item in payload.CnRecipientInfoList) { bool isDuplicateName = this.recipientList.Any(x => x.Name == item.Name); domain.Recipient newObject = new domain.Recipient(); newObject.ID = -1; newObject.Name = item.Name +( isDuplicateName ? "[有重复]" :string.Empty); newObject.CnAddress = item.Address; newObject.MainTel = item.TelList.FirstOrDefault(); newObject.OtherTels = string.Join(",", item.TelList.Skip(1)); newObject.PostCode = item.PostCode; newObject.ProviceCity = item.ProviceCity; var newVm = new RecipientItemViewModel(newObject); this.recipientList.Add(newVm); this.SelectedItem = newVm; } }
private void SaveRecipient(RecipientItemViewModel targetVM) { var target = targetVM.Model; if (target.MainTel.Trim().Length < 11) { this.ErrorMsg = "电话号码错误"; return; } if (target.PostCode.Trim().Length < 6) { this.ErrorMsg = "邮编错误"; return; } if (target.ProviceCity.Trim().Replace(",","").Length < 2) { this.ErrorMsg = "省市错误"; return; } List<string> missCopyWordList = new List<string>() { "地图","查看","在","拨号","电话","号码","邮编",":","是否" }; string text = target.ToString() + " " + target.FormatDisplay; foreach (var item in missCopyWordList) { if (text.Contains(item)) { this.ErrorMsg = "收件复制有误,请检查"; return; } } this.ErrorMsg = ""; if (target.ID != -1) this.recipientService.SaveRecipient(target); else this.recipientService.AddRecipient(target); targetVM.ID = target.ID; }
private bool CanExeciteSaveRecipient(RecipientItemViewModel target) { return this.selectedItem != null; }