void DownLoadList(LeaveToObserveEngineViewModel viewModel) { Application.Current.Dispatcher.Invoke(() => { var collection = viewModel.Collection.OrderBy(l => l.CreateTime.ToInt()).ToList(); viewModel.Collection.Clear(); foreach (var item in collection) { viewModel.Collection.Add(item); } }); }
void Register(ChildInfo c, LeaveToObserveEngineViewModel viewModel) { // Todo :发送登记信息 Application.Current.Dispatcher.Invoke(() => { viewModel.Message.Insert(0, "儿童:" + c.Name + "预防接种登记成功"); this.DownLoadList(viewModel); // Todo :更新列表 LeaveToObserveItemViewModel observeitem = new LeaveToObserveItemViewModel(); observeitem.Seq = c.ID; observeitem.Name = c.Name; observeitem.Sex = "男"; observeitem.StartTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); observeitem.CreateTime = "30"; viewModel.Collection.Add(observeitem); }); //MessageProvider.Instance.ShowWithLog("儿童:" + c.Name + "预防接种登记成功"); }
/// <summary> 执行工作流 </summary> public void DoWork(string str, LeaveToObserveEngineViewModel viewModel) { string code = this.GetServiceCode(str); if (string.IsNullOrEmpty(code)) { MessageProvider.Instance.ShowWithLog("儿童预防接种本条码扫描失败!"); return; } ChildInfo child = this.GetChild(code); if (child == null) { MessageProvider.Instance.ShowWithLog("儿童预防接种本条码扫描失败!"); return; } child.ID = str; child.Name = str; // Todo :没有登记 if (!this.IsRegister(child)) { MessageProvider.Instance.ShowWithLog("儿童预防接种本信息未登记,请先到预检台进行登记;"); return; } var item = viewModel.Collection.ToList().Find(l => l.Seq == child.ID); if (item != null) { if (item.State == LeaveState.Running) { if (item.CreateTime == "0") { item.State = LeaveState.Ending; item.LeaveTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //MessageProvider.Instance.ShowWithLog("儿童:" + child.Name + "预防接种留观结束"); Application.Current.Dispatcher.Invoke(() => viewModel.Message.Insert(0, "儿童:" + child.Name + "预防接种留观结束")); ; } else { MessageProvider.Instance.ShowWithLog("儿童预防接种留观还未结束,请继续等待"); } return; } if (item.State == LeaveState.Ending) { item.LeaveTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); MessageProvider.Instance.ShowWithLog("儿童预防接种留观已结束,感谢您的配合!"); return; } } else { // Todo :更新列表 this.DownLoadList(viewModel); } // Todo :开始登记 this.Register(child, viewModel); }