Exemplo n.º 1
0
        public ControlSystemViewModel(ControlSystemView view, int controlSystemId)
        {
            mControlSystemId = controlSystemId;
            CompositionInitializer.SatisfyImports(this);
            View = view;

            SaveCommand = new DelegateCommand<object>(SaveCommandHandler, CanModifyHandler);
            DeleteCommand = new DelegateCommand<object>(DeleteCommandHandler, CanDeleteHandler);
            ExportCommand = new DelegateCommand<object>(ExportCommandHandler, x => false);

            var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            cmsWebServiceClient.GetControlSystemCompleted +=
                (s, e) =>
                {
                    ControlSystem = e.Result;

                    LoadData();
                };
            cmsWebServiceClient.GetControlSystemAsync(controlSystemId);
        }
Exemplo n.º 2
0
        private void SaveControlSystem(Action<bool> saved)
        {
            var cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            cmsWebServiceClient.SaveControlSystemCompleted +=
                (s, e) =>
                {
                    if (e.Result.HasErrors)
                    {
                        View.ValidationPopup.Show(Utils.BuildValidationResultFromServerErrors("Save Failed", e.Result.ServerErrorMessages));
                        IsInSavingMode = false;
                    }
                    else
                    {
                        EventAggregator.GetEvent<PrismEvents.RefreshNavigationEvent>().Publish(new QuickControlSystem());
                        cmsWebServiceClient.GetControlSystemCompleted += (s1, e1) =>
                        {
                            ControlSystem = e1.Result;
                            LoadData();
                            RaiseLoaded();

                            Utils.ResetOriginalValues(View);
                            Utils.ResetOriginalValues((UserControl) View.ComponentsTab.Content);
                            Utils.ResetOriginalValues((UserControl) View.InterlocksTab.Content);
                            Utils.ResetOriginalValues((UserControl) View.DocumentsTab.Content);
                            Utils.ResetOriginalValues((UserControl) View.RelatedIssuesTab.Content);

                            //Clear all changes on the Tab
                            Utils.ClearAllChangeEvents(EventAggregator, ControlSystem);

                            //This will make sure that all componentes have Ids assigned after save
                            View.RevisionHistory.LoadRevisionHistory(CommonUtils.TabId.Control, ControlSystem.Id);
                            IsInSavingMode = false;
                        };
                        cmsWebServiceClient.GetControlSystemAsync(mControlSystemId);
                    }

                    if (saved != null)
                    {
                        saved(!e.Result.HasErrors);
                    }
                };
            cmsWebServiceClient.SaveControlSystemAsync(ControlSystem, CMS.User.Id);
        }