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 AddRecipient() { this.configurationService.AddOrUpdate("LatestNewAddedRecipients", this.AddRecipientRawContent); string input = this.AddRecipientRawContent; if (input.Trim().Length == 0) return; var lines = input.ToLines(); List<string> NotOkLines = new List<string>(); List<CnRecipientInfo> cnRecipientInfoList = new List<CnRecipientInfo>(); foreach (var item in lines) { if (item.Trim().IsNullOrEmpty()) continue; try { var ret = this.cnRecipientParser.Parse(item); cnRecipientInfoList.Add(ret); } catch { NotOkLines.Add(item.Trim()); MessageBox.Show("Error Format ==> {0}".FormatAs(item)); continue; } } var payLoad = new ParseRawTextRecipientFinishedPayload(cnRecipientInfoList); this.eventAggregator.GetEvent<ParseRawTextRecipientFinishedEvent>().Publish(payLoad); this.AddRecipientRawContent = string.Join(Environment.NewLine, NotOkLines); }