Пример #1
0
        /// <summary>
        /// Adds the page model controllers.
        /// </summary>
        public override void AddPageModelControllers()
        {
            ViewReference pageViewReference;

            if (this.CopyFieldDictionary != null)
            {
                pageViewReference = this.ViewReference.ViewReferenceWith(new Dictionary <string, object> {
                    { "copyFields", this.CopyFieldDictionary }
                });
            }
            else
            {
                pageViewReference = this.ViewReference;
            }

            EditPageModelController editPageModelController = new EditPageModelController(pageViewReference, this.IsNew, this.InitialValueDictionary, null);

            editPageModelController.Delegate = this;
            Page overviewPage = editPageModelController.Page;

            if (editPageModelController.DisableRightActionItems || !(overviewPage.Status is UPMProgressStatus))
            {
                //this.EnableActionItemsDisableActionItems(this.LeftNavigationBarItems, this.RightNaviagtionBarItems);
            }

            this.AddPageModelController(editPageModelController);
            this.Organizer.AddPage(overviewPage);
            if (this.IsNew == false)
            {
                this.AddRemainingPageModelController();
            }
        }
Пример #2
0
        private UPSerialEntryFinalSaveResult ExecuteFinalSave()
        {
            this.ModelControllerDelegate?.StopAllEditing();
            if (this.finalSaveCalled)
            {
                return(UPSerialEntryFinalSaveResult.Finished);
            }

            bool hasViolations = false;

            foreach (UPPageModelController modelController in this.PageModelControllers)
            {
                EditPageModelController editModelController = modelController as EditPageModelController;
                if (editModelController == null)
                {
                    continue;
                }

                if (editModelController.UpdatePageWithViolations())
                {
                    hasViolations = true;
                }
            }

            if (hasViolations)
            {
                return(UPSerialEntryFinalSaveResult.Abort);
            }

            this.finalSaveCalled = true;
            this.DisableAllActionItems(true);
            if (this.currentModelController is SerialEntryPageModelController)
            {
                UPMProgressStatus stillLoadingError = new UPMProgressStatus(StringIdentifier.IdentifierWithStringId("savingIdentifier"));
                UPMStringField    statusField       = new UPMStringField(StringIdentifier.IdentifierWithStringId("statusFieldIdentifier"));
                statusField.FieldValue = LocalizedString.TextWaitForChanges;
                stillLoadingError.StatusMessageField = statusField;
                this.Organizer.Status = stillLoadingError;
                this.InformAboutDidChangeTopLevelElement(this.TopLevelElement, this.TopLevelElement, null, null);
            }

            bool noChanges = true;

            if (!this.IsNew || !this.created)
            {
                List <UPCRMRecord> changedRecords = this.ChangedRecords(false);
                if (changedRecords?.Count > 0)
                {
                    this.EditRecordRequest.TitleLine   = this.Organizer.TitleText;
                    this.EditRecordRequest.DetailsLine = this.Organizer.SubtitleText;
                    this.waitForSave = true;
                    noChanges        = false;
                    this.EditRecordRequest.StartRequest(UPOfflineRequestMode.OnlineConfirm, changedRecords, this);
                }
            }

            foreach (UPPageModelController modelController in this.PageModelControllers)
            {
                if (modelController is SerialEntryPageModelController)
                {
                    SerialEntryPageModelController serialEntryModelController = (SerialEntryPageModelController)modelController;
                    this.waitForSerialEntrySave = true;
                    this.isSaving = true;
                    if (!serialEntryModelController.SaveAll())
                    {
                        this.waitForSerialEntrySave = false;
                        this.isSaving = false;
                    }
                    else
                    {
                        noChanges = false;
                    }
                }
            }

            if (noChanges)
            {
                this.HandleChangeManager();
                this.HandleSaved();
                return(UPSerialEntryFinalSaveResult.Finished);
            }

            return(UPSerialEntryFinalSaveResult.Pending);
        }