void DoImport(string text) { var lines = text.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Where(s => !s.StartsWith("#")).ToArray(); if (lines.IsEmpty()) { this.Information("没有可以导入的乘客信息..."); return; } if (_passengerAnalyzeReg.IsMatch(lines[0])) { DoImport(lines.Select(s => { var m = _passengerAnalyzeReg.Match(s); if (!m.Success) { return(null); } var m1 = new Entity.Web.Passenger(); m1.Name = m.Groups[2].Value; m1.Type = ParamData.GetPassengerTypeByName(m.Groups[1].Value); m1.SetId(ParamData.GetPassengerIdTypeCodeByName(m.Groups[3].Value), m.Groups[5].Value); m1.MobileNo = m.Groups[6].Value; return(m1.IdTypeCode == '\0' || m1.Type == 0 ? null : m1); }).ExceptNull().ToArray()); return; } this.Information("很抱歉,暂时无法支持您尝试导入的数据。\n如果您尝试导入的数据是其他软件生成的,请向作者反应,并附上导出的数据。"); }
/// <summary> /// 创建 <see cref="PassengerLabel" /> 的新实例(PassengerLabel) /// </summary> public PassengerLabel(Entity.Web.Passenger passenger) { Passenger = passenger; AutoSize = false; Size = new Size(60, 20); Text = passenger.Name; TextAlign = ContentAlignment.MiddleCenter; }
ListViewItem CreateItem(Entity.Web.Passenger p) { var lvi = new ListViewItem(p.Name) { ImageIndex = 0, UseItemStyleForSubItems = true }; if (p.IdTypeCode == '0' || p.IdTypeCode == '1') { var isFemale = (p.IdNo[p.IdNo.Length - 2] - '0') % 2 == 0; lvi.ImageIndex = isFemale ? 2 : 1; } lvi.SubItems.Add(ParamData.PassengerType[p.Type]); lvi.SubItems.Add(ParamData.PassengerIdType.GetValue(p.IdTypeCode).DefaultForEmpty("无效证件类型")); lvi.SubItems.Add(p.IdNo); lvi.SubItems.Add(p.MobileNo); //删除信息 var deleteTime = p.DeleteTime; var deleteMsg = deleteTime == null ? "<请刷新列表>" : deleteTime.Value < DateTime.Today ? "可以删除" : $"{deleteTime.Value.ToString("yyyy年MM月dd日")}可删"; //审核状态 var status = p.Verification; if (status.Verified == null) { lvi.SubItems.Add("待校验"); lvi.SubItems.Add(deleteMsg); lvi.SubItems.Add(status.VerifyMessage); lvi.ForeColor = Color.PaleVioletRed; } else if (status.Verified == true) { lvi.SubItems.Add("已通过"); lvi.SubItems.Add(deleteMsg); lvi.SubItems.Add(status.VerifyMessage); lvi.ForeColor = Color.Green; } else { lvi.SubItems.Add("未通过"); lvi.SubItems.Add(deleteMsg); lvi.SubItems.Add(status.VerifyMessage); lvi.ForeColor = Color.Red; } lvi.Tag = p; UiUtility.ApplySubStyle(lvi); return(lvi); }
void tsAdd_Click(object sender, EventArgs e) { var p = new Entity.Web.Passenger() { AddDate = DateTime.Now }; var ad = new Dialogs.Passenger.AddPassenger(p); if (ad.ShowDialog() != DialogResult.OK) { return; } //添加联系人 var dlg = new YetAnotherWaitingDialog(); var result = ""; dlg.Title = "正在记录中, 请稍等."; dlg.WorkCallback = () => { result = _manager.AddPassenger(p); }; dlg.ShowDialog(); if (result.IsNullOrEmpty()) { //添加 AppContext.HostForm.ShowSuccessToastMini("已记录在案..."); } else { AppContext.HostForm.ShowErrorToastMini("添加联系人可耻地失败了:" + result); } }