private void actionPreviewRestoredData_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e) { ListPropertyEditor editor = (this.View as DetailView).FindItem("DeletedItems") as ListPropertyEditor; if (editor != null) { IObjectSpace space = Application.CreateObjectSpace(); RestoredObjectsParameters p = new RestoredObjectsParameters(); using (AuditTrailRestoreHelper helper = new AuditTrailRestoreHelper(space)) { foreach (RestoreItemDetails details in editor.ListView.SelectedObjects) { helper.RestoreObject(space.GetObject <AuditDataItemPersistent>(details.AuditTrailItem)); } foreach (object obj in helper.RestoredObjects) { p.ObjectsToRestore.Add(new RestoredObjectDetails() { Name = CaptionHelper.GetDisplayText(obj), Type = CaptionHelper.GetClassCaption(XafTypesInfo.Instance.FindTypeInfo(obj.GetType()).Type.FullName) }); } } IObjectSpace previewspace = Application.CreateObjectSpace(typeof(RestoredObjectsParameters)); e.View = Application.CreateDetailView(previewspace, p); e.DialogController.SaveOnAccept = false; } }
protected override void OnViewControlsCreated() { base.OnViewControlsCreated(); ListView listView = View as ListView; DetailView detailView = View as DetailView; if (listView != null) { IObjectSpace os = Application.CreateObjectSpace(); listView.CollectionSource.CriteriaApplied += (o, e) => { // Предварительная загрузка расписаний докторов var collectionSB = (CollectionSourceBase)o; if (collectionSB.Criteria != null) { var events = new List <DoctorEvent>(os.GetObjects <DoctorEvent>(collectionSB.Criteria[FILTERKEY])); eventsDict = events.ToDictionary(de => de.Oid, de => de); } }; SchedulerListEditor listEditor = ((ListView)View).Editor as SchedulerListEditor; if (listEditor != null) { SchedulerControl scheduler = listEditor.SchedulerControl; if (scheduler != null) { // Кастомизация надписи в расписании доктора scheduler.InitAppointmentDisplayText += (o, e) => { Guid guid = (Guid)e.Appointment.Id; if (eventsDict.ContainsKey(guid)) { var doctorEvent = eventsDict[guid]; e.Text = doctorEvent != null && doctorEvent.Pacient != null ? doctorEvent.Pacient.FullName : string.Empty; } }; #region Кастомизация Тултипа расписания доктора // https://documentation.devexpress.com/WindowsForms/118551/Controls-and-Libraries/Scheduler/Visual-Elements/Scheduler-Control/Appointment-Flyout scheduler.OptionsView.ToolTipVisibility = ToolTipVisibility.Always; scheduler.OptionsCustomization.AllowDisplayAppointmentFlyout = false; scheduler.ToolTipController = new ToolTipController(); scheduler.ToolTipController.ToolTipType = ToolTipType.SuperTip; scheduler.ToolTipController.BeforeShow += (o, e) => { var toolTipController = (ToolTipController)o; AppointmentViewInfo aptViewInfo = null; try { aptViewInfo = (AppointmentViewInfo)toolTipController.ActiveObject; } catch { return; } if (aptViewInfo == null) { return; } Guid guid = (Guid)aptViewInfo.Appointment.Id; if (!eventsDict.ContainsKey(guid)) { // В словаре нет ключа т.к. расписание было только что создано var events = new List <DoctorEvent>(ObjectSpace.GetObjects <DoctorEvent>(listView.CollectionSource.Criteria[FILTERKEY])); eventsDict = events.ToDictionary(de => de.Oid, de => de); } DoctorEvent doctorEvent = eventsDict[guid]; // Вид талона (метка) AppointmentLabel label = scheduler.Storage.Appointments.Labels.GetById(doctorEvent.Label); StringBuilder sb = new StringBuilder(); sb.AppendLine(string.Format("Время: с {0:HH:mm} по {1:HH:mm}", doctorEvent.StartOn, doctorEvent.EndOn)); sb.AppendLine(string.Format("Пациент: {0}", doctorEvent.Pacient != null ? doctorEvent.Pacient.FullName : null)); sb.AppendLine(string.Format("Кем создано: {0}", doctorEvent.CreatedBy != null ? doctorEvent.CreatedBy.FullName : null)); sb.AppendLine(string.Format("Кто записал: {0}", doctorEvent.EditedBy != null ? doctorEvent.EditedBy.FullName : null)); sb.AppendLine(string.Format("Вид талона: {0}", label.DisplayName)); if (doctorEvent.Pacient != null) { sb.AppendLine(string.Format("Источник записи: {0}", CaptionHelper.GetDisplayText(doctorEvent.SourceType))); } SuperToolTip SuperTip = new SuperToolTip(); SuperToolTipSetupArgs args = new SuperToolTipSetupArgs(); args.Contents.Text = sb.ToString(); args.Contents.Font = new Font("Times New Roman", 11); SuperTip.Setup(args); e.SuperTip = SuperTip; }; #endregion // Кастомизация коллекции меток var storage = scheduler.Storage; IAppointmentLabelStorage labelStorage = storage.Appointments.Labels; FillLabelStorage(labelStorage); #region Кастомизация всплывающего меню на расписании врача DoctorEvent recordedEvent = null; VisitCase visitCase = null; // Всплывающее меню на расписании врача scheduler.PopupMenuShowing += (o, e) => { Pacient pacient = listView.Tag as Pacient; AppointmentBaseCollection appoinments = (o as SchedulerControl).SelectedAppointments; Appointment appoinment = appoinments.Count == 1 ? appoinments[0] : null; if (appoinment == null) { return; } Guid key = (Guid)appoinment.Id; DoctorEvent dEvent = appoinment != null && eventsDict.ContainsKey(key) ? eventsDict[key] : null; if (e.Menu.Id != DevExpress.XtraScheduler.SchedulerMenuItemId.AppointmentMenu) { return; } if (pacient != null && dEvent.Pacient == null & recordedEvent == null && dEvent.StartOn > DateTime.Now) { e.Menu.Items.Insert(0, new SchedulerMenuItem("Записать пациента", (o_, e_) => { IObjectSpace dEventObjectSpace = XPObjectSpace.FindObjectSpaceByObject(dEvent); dEvent.Pacient = dEventObjectSpace.GetObject(pacient); dEventObjectSpace.CommitChanges(); // Обновление списочного представления listView.CollectionSource.Reload(); // Расписание на которое записан пациент recordedEvent = dEvent; // Создание посещения для пациента visitCase = VisitCase.CreateVisitCase(dEventObjectSpace, dEventObjectSpace.GetObject(pacient), dEvent.AssignedTo, dEvent.StartOn); dEventObjectSpace.CommitChanges(); })); } else if (dEvent != null && dEvent.Pacient != null) { e.Menu.Items.Insert(0, new SchedulerMenuItem("Отменить запись", (o_, e_) => { IObjectSpace dEventObjectSpace = XPObjectSpace.FindObjectSpaceByObject(dEvent); dEvent.Pacient = null; dEventObjectSpace.CommitChanges(); // Обновление списочного представления listView.CollectionSource.Reload(); // Отмена записи пациента на выбранное расписание if (recordedEvent != null && recordedEvent.Oid == dEvent.Oid) { recordedEvent = null; } if (visitCase != null) { dEventObjectSpace.Delete(visitCase); dEventObjectSpace.CommitChanges(); } })); } }; #endregion // Кастомизация цвета фона расписания: // Если выбранный пациент уже записан, то цвет расписания окрашивается в светло-розовый. // Если в расписании записан другой пациент, то цвет расписания окрашивается в морковный. scheduler.AppointmentViewInfoCustomizing += (o_, e_) => { Pacient pacient = listView.Tag as Pacient; if (pacient != null) { Guid guid = (Guid)e_.ViewInfo.Appointment.Id; if (eventsDict.ContainsKey(guid) && eventsDict[guid].Pacient != null) { e_.ViewInfo.Appearance.BackColor = eventsDict[guid].Pacient.Oid == pacient.Oid ? Color.FromArgb(255, 192, 192) : Color.FromArgb(255, 128, 0); } } }; } } } else if (detailView != null) { // Кастомизация коллекции меток foreach (SchedulerLabelPropertyEditor pe in ((DetailView)View).GetItems <SchedulerLabelPropertyEditor>()) { if (pe.Control != null) { ISchedulerStorage storage = ((AppointmentLabelEdit)pe.Control).Storage; IAppointmentLabelStorage labelStorage = storage.Appointments.Labels; FillLabelStorage(labelStorage); } } } }
public FlowInstance(Session s, 单据 form) : base(s) { this.form = form; var records = Session.Query <单据流程状态记录>().Where(t => t.业务项目 == form.业务项目); //var status = Session.Query<状态变更记录>().Where(t => t.单据.业务项目 == form.业务项目); _actions = new List <FlowInstanceAction>(); _nodes = new List <FlowInstanceNode>(); var nodes = records.Select(x => x.来源单据).Union(records.Select(t => t.目标单据)).OrderBy(x => x.创建时间).Distinct(); var y = 100; //先绘制单据结点 foreach (var item in nodes) { var fin = new FlowInstanceNode(Session); fin.Caption = CaptionHelper.GetDisplayText(item); fin.Width = 200; fin.Height = 30; fin.X = 100; fin.Y = y; fin.Key = item; fin.ImageName = CaptionHelper.ApplicationModel.BOModel.GetClass(item.GetType()).ImageName; _nodes.Add(fin); y += 100; var xl = 400; var status = item.状态记录.OrderBy(x => x.发生日期).Select(x => x.来源状态).Union(item.状态记录.Select(x => x.目标状态)).Where(x => x != null).Distinct(); foreach (var state in status) { var si = new FlowInstanceNode(Session); si.Caption = state.Caption; si.Width = 100; si.Height = 30; si.X = xl; si.Y = fin.Y; si.Key = state; si.Key2 = item; _nodes.Add(si); xl += 350; } foreach (var sa in item.状态记录) { if (sa.来源状态 != null) { var line = new FlowInstanceAction(Session); line.From = _nodes.Single(x => x.Key == sa.来源状态 && x.Key2 == item); line.To = _nodes.Single(x => x.Key == sa.目标状态 && x.Key2 == item); line.BeginItemPointIndex = 1; line.EndItemPointIndex = 3; line.Caption = sa.操作人 + " " + sa.发生日期.ToString("yyyy-MM-dd HH:mmss"); _actions.Add(line); } } if (status.Any()) { var f = status.FirstOrDefault(); var formToState = new FlowInstanceAction(Session); formToState.From = fin; formToState.To = _nodes.Single(x => x.Key == f && x.Key2 == item); formToState.BeginItemPointIndex = 1; formToState.EndItemPointIndex = 3; _actions.Add(formToState); } } foreach (var item in records) { var action = new FlowInstanceAction(Session); action.From = _nodes.Single(x => x.Key == item.来源单据); action.To = _nodes.Single(x => x.Key == item.目标单据); action.BeginItemPointIndex = 2; action.EndItemPointIndex = 0; _actions.Add(action); } ////取所有来源状态,目标状态,不为空的,取除重复。 //var stateNodes = status.GroupBy(x => x.单据).OrderBy(x => x.Min(t => t.发生日期)); ////按单据分组的状态数据 //var y = 50; //foreach (var g in stateNodes) //{ // var gStatus = g.OrderBy(x=>x.发生日期).Select(x => x.来源状态).Union(g.Select(x => x.目标状态)).Where(x => x != null).Distinct(); // xl = 100; // foreach (var item in gStatus) // { // var si = new FlowInstanceNode(Session); // si.Caption = item.Caption; // si.Width = 100; // si.Height = 30; // si.X = xl; // si.Y = y; // si.Key = item; // _nodes.Add(si); // xl += 150; // } // foreach (var item in g) // { // if (item.来源状态 != null) // { // var line = new FlowInstanceAction(Session); // line.From = _nodes.SingleOrDefault(x => x.Key == item.来源状态); // line.To = _nodes.SingleOrDefault(x => x.Key == item.目标状态); // line.BeginItemPointIndex = 1; // line.EndItemPointIndex = 3; // _actions.Add(line); // } // } // y += 100; //} //foreach (var item in status) //{ // var si = new FlowInstanceNode(Session); // if (item.来源状态 != null) // si.Caption = item.来源状态.Caption; // si.Width = 100; // si.Height = 30; // _nodes.Add(si); // var sit = new FlowInstanceNode(Session); // sit.Width = 100; // sit.Height = 30; // sit.Caption = item.目标状态.Caption; // _nodes.Add(sit); // _actions.Add(new FlowInstanceAction(Session) { From = si, To = sit }); //} //如何构建出结点和连接线? }
public void AcceptServiceTemplate() { if (ServiceTemplate != null) { string teethText = null; string milkbyteTeethText = null; if (Teeth != Enums.Teeth.None) { List <string> list = new List <string>(); foreach (Teeth tooth in Enum.GetValues(typeof(Teeth))) { if (tooth == Enums.Teeth.None) { continue; } if (Teeth.HasFlag(tooth)) { list.Add(CaptionHelper.GetDisplayText(tooth)); } } teethText = string.Join(", ", list); } if (MilkByteTeeth != Enums.MilkByteTeeth.None) { List <string> list = new List <string>(); foreach (MilkByteTeeth tooth in Enum.GetValues(typeof(MilkByteTeeth))) { if (tooth == Enums.MilkByteTeeth.None) { continue; } if (MilkByteTeeth.HasFlag(tooth)) { list.Add(CaptionHelper.GetDisplayText(tooth)); } } milkbyteTeethText = string.Join(", ", list); } string replacement = !string.IsNullOrEmpty(teethText) && !string.IsNullOrEmpty(milkbyteTeethText) ? string.Concat(teethText, ", ", milkbyteTeethText) : string.Concat(teethText, milkbyteTeethText); CommonProtocol.Anamnez = (serviceTemplate.Anamnez ?? string.Empty).Replace("{replacement}", replacement); CommonProtocol.Complain = (serviceTemplate.Complain ?? string.Empty).Replace("{replacement}", replacement); CommonProtocol.ObjectiveStatus = (serviceTemplate.ObjectiveStatus ?? string.Empty).Replace("{replacement}", replacement); CommonProtocol.Recommendation = (serviceTemplate.Recommendations ?? string.Empty).Replace("{replacement}", replacement); Usluga = serviceTemplate.Service; Diagnoses.Add(new MKBWithType(Session) { Diagnose = serviceTemplate.Diagnose }); OnChanged("CommonProtocol"); OnChanged("Usluga"); OnChanged("Diagnoses"); CommonProtocol.Save(); } }
public override object GetValue(object component) { var value = OriginalDescriptor.GetValue(component); return(CaptionHelper.GetDisplayText(value)); }