private void RemoveButtonHandler(object parameter)
 {
     var popupDialog = new AddInstrumentRevisionHistoryDialog(Instrument.Id, Instrument.Name);
     popupDialog.Show();
     popupDialog.Closed +=
         (s2, e2) =>
         {
             if (popupDialog.DialogResult.HasValue && popupDialog.DialogResult.Value)
             {
                 var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
                 cmsWebServiceClient.SaveIsActiveEquipmentStateCompleted += (s1, e1) =>
                 {
                     //Calls mainpage.CloseTab();
                     EventAggregator.GetEvent<PrismEvents.CloseTabPrismEvent>().Publish(new QuickInstrument {Id = Instrument.Id, Name = Instrument.Name});
                     EventAggregator.GetEvent<PrismEvents.RefreshNavigationEvent>().Publish(new QuickInstrument());
                 };
                 cmsWebServiceClient.SaveIsActiveEquipmentStateAsync(CommonUtils.ModelType.Instrument, Instrument.Id, false, CMS.User.Id);
             }
         };
 }
Пример #2
0
        public bool Save(Action<bool> saved)
        {
            var validationErrors = GetErrors();
            if (validationErrors.Any())
            {
                ValidationPopup.Show(validationErrors);
                return false;
            }

            EquipmentControl.saveButton.IsEnabled = false;
            var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            var dialog = new AddInstrumentRevisionHistoryDialog(mEquipmentId, ViewModel.Instrument.Name);
            dialog.Show();

            dialog.Closed +=
                (s1, e1) =>
                {
                    if (dialog.DialogResult.HasValue && dialog.DialogResult.Value)
                    {
                        var componentsControl = ComponentsTab.Content as InstrumentComponentsControl;
                        //SAVE COMP
                        cmsWebServiceClient.SaveInstrumentComponentsCompleted += (s2, e2) =>
                        {
                            if (e2.Result.HasErrors)
                            {
                                //val popup..
                                ValidationPopup.Show(Utils.BuildValidationResultFromServerErrors("Move Component Failed", e2.Result.ServerErrorMessages));
                            }
                            else
                            {
                                BuildMoveComponentRevisionHistory(componentsControl);
                                //save actual equipment 2nd
                                SaveInstrument(saved, cmsWebServiceClient);
                            }
                        };

                        //save any component moves 1st
                        cmsWebServiceClient.SaveInstrumentComponentsAsync(componentsControl.Model.MovedComponents, CMS.User.Id);
                    }

                    EquipmentControl.saveButton.IsEnabled = true;
                };

            return true;
        }