Пример #1
0
        private void FillPage(Page pageObject)
        {
            var questionGroups = this.Survey.VisibleQuestionGroups;
            UPMQuestionnairePage page;

            if (pageObject is UPMQuestionnairePage)
            {
                page = (UPMQuestionnairePage)pageObject;
            }
            else
            {
                return;
            }

            page.Readonly = this.Readonly || this.ViewReference.ViewName == "QuestionnaireView";
            if (this.questionnaireConfirmed)
            {
                page.FinalizedText = this.ConfirmedFilter.DisplayName;
                if (string.IsNullOrEmpty(page.FinalizedText))
                {
                    page.FinalizedText = LocalizedString.TextProcessQuestionnaireFinalized;
                }
            }
            else if (this.ConfirmationButton != null)
            {
                var action = new UPMAction(StringIdentifier.IdentifierWithStringId("Action.Approve"))
                {
                    LabelText = this.ConfirmationButton.Label
                };
                if (string.IsNullOrEmpty(action.LabelText))
                {
                    action.LabelText = LocalizedString.TextProcessQuestionnaireFinalize;
                }

                action.SetTargetAction(this, this.FinalizeButtonClicked);
                page.FinalizeAction = action;
            }

            page.RemoveAllChildren();
            if (this.PortfolioMode)
            {
                this.portfolioGroup = this.PortfolioGroupForSurvey();
            }

            int index = 0;

            page.LabelText = this.Survey.Questionnaire.Label;
            foreach (var currentGroup in questionGroups)
            {
                ++index;
                this.ProcessGroup(page, index, currentGroup);
            }

            page.Status = null;
        }
        /// <summary>
        /// Creates the new search page with result.
        /// </summary>
        /// <param name="results">The results.</param>
        public virtual void CreateNewSearchPageWithResult(List <UPCRMResult> results)
        {
            UPMSearchPage newPage = new UPMSearchPage(this.Page.Identifier);

            newPage.CopyDataFrom(this.SearchPage);
            newPage.Invalid = false;
            int searchCount = this.PreparedSearches?.Count ?? 0;

            for (int i = 0; i < searchCount && i < results.Count; i++)
            {
                UPSearchPageModelControllerPreparedSearch preparedSearch = this.PreparedSearches[i];
                if (results[i] != null)
                {
                    UPCRMResult result = results[i];
                    if (result.RowCount > 0)
                    {
                        UPMResultSection section = this.ResultSectionForSearchResult(preparedSearch, result);
                        if (section != null)
                        {
                            newPage.AddResultSection(section);
                        }
                    }
                }
            }

            // Hardcoded Detail Action
            UPMAction switchToDetailAction = new UPMAction(null);

            switchToDetailAction.IconName = "arrow.png";
            switchToDetailAction.SetTargetAction(this, this.SwitchToDetail);
            newPage.RowAction = switchToDetailAction;

            UPMAction searchAction = new UPMAction(null);

            searchAction.SetTargetAction(this, this.Search);
            newPage.SearchAction = searchAction;

            UPMSearchPage oldSearchPage = this.SearchPage;

            this.TopLevelElement = newPage;
            SearchPageResultState state = SearchPageResultState.OfflineNoLokalData;

            foreach (UPCRMResult result in results)
            {
                if (result != null && result.RowCount > 0)
                {
                    state = SearchPageResultState.Ok;
                }
            }

            newPage.ResultState = state;
            this.InformAboutDidChangeTopLevelElement(oldSearchPage, newPage, null, null);
        }
Пример #3
0
        /// <summary>
        /// Instantiates the page.
        /// </summary>
        /// <returns></returns>
        public override Page InstantiatePage()
        {
            UPMDocumentPage page = this.Page != null
                ? new UPMDocumentPage(this.Page.Identifier)
                : new UPMDocumentPage(new RecordIdentifier(this.InfoAreaId, null));

            UPMAction searchAction = new UPMAction(null);

            searchAction.SetTargetAction(this, this.Search);
            page.SearchAction = searchAction;
            return(page);
        }
Пример #4
0
        /// <summary>
        /// Applies the link record identification.
        /// </summary>
        /// <param name="recordIdentification">The record identification.</param>
        /// <returns></returns>
        public UPMGroup ApplyLinkRecordIdentification(string recordIdentification)
        {
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            string menuName = this.TabConfig.Type.Substring(5);

            this.Menu = configStore.MenuByName(menuName);
            if (this.Menu == null || this.Menu.Items.Count == 0)
            {
                this.ControllerState = GroupModelControllerState.Error;
                base.Error           = new Exception("ConfigurationError");
                return(null);
            }

            UPMMenuGroup menuGroup  = null;
            uint         menuItemNr = 0;

            this.viewReferenceDictionary = new Dictionary <string, ViewReference>();
            foreach (string menuItemName in this.Menu.Items)
            {
                Menu menuItem = configStore.MenuByName(menuItemName);
                if (menuItem.ViewReference == null)
                {
                    continue;
                }

                if (menuGroup == null)
                {
                    menuGroup           = new UPMMenuGroup(this.TabIdentifierForRecordIdentification(recordIdentification));
                    menuGroup.LabelText = this.TabLabel;
                }

                string        identifierString        = $"menu_{menuItemNr++}_{ menuItem.UnitName}";
                IIdentifier   identifier              = StringIdentifier.IdentifierWithStringId(identifierString);
                UPMAction     menuAction              = new UPMAction(identifier);
                ViewReference linkRecordViewReference = menuItem.ViewReference.ViewReferenceWith(recordIdentification);
                this.viewReferenceDictionary[identifierString] = linkRecordViewReference;
                menuAction.SetTargetAction(this, this.PerformMenuAction);
                if (menuItem.ImageName != null)
                {
                    menuAction.IconName = menuItem.ImageName;
                }

                UPMLinkRecordField field = new UPMLinkRecordField(identifier, menuAction);
                field.LabelText   = menuItem.UnitName;
                field.StringValue = menuItem.DisplayName;
                menuGroup.AddField(field);
            }

            this.ControllerState = menuGroup != null ? GroupModelControllerState.Finished : GroupModelControllerState.Empty;
            this.Group           = menuGroup;
            return(menuGroup);
        }
Пример #5
0
        private void CopyFieldsLoaded(Dictionary <string, object> copyFieldsDictionary)
        {
            this.copyFieldsDictionary = copyFieldsDictionary;
            var page = this.CreatePageInstance();

            page.Invalid         = true;
            this.TopLevelElement = page;
            this.BuildPageDetails();
            UPMAction searchAction = new UPMAction(null);

            searchAction.SetTargetAction(this, this.Search);
            this.SearchPage.SearchAction = searchAction;
        }
Пример #6
0
        /// <summary>
        /// Search operation did finish with result
        /// </summary>
        /// <param name="operation">Operation</param>
        /// <param name="result">Result</param>
        public override void SearchOperationDidFinishWithResult(Operation operation, UPCRMResult result)
        {
            if (this.PageErrorDisplayed)
            {
                this.ReportError(null, true);
            }
            else if (operation != this.CurrentSearchOperation)
            {
                return;
            }

            this.CurrentSearchOperation = null;
            var oldSearchPage = this.SearchPage;
            var newPage       = this.CreatePageInstance(this.Page.Identifier);

            this.TopLevelElement = newPage;
            newPage.CopyDataFrom(oldSearchPage);

            newPage.Invalid = false;
            this.BuildStandardSearchPage(newPage, result);

            // Hardcoded Detail Action
            UPMAction switchToDetailAction = new UPMAction(null);

            switchToDetailAction.IconName = @"arrow.png";
            switchToDetailAction.SetTargetAction(this, this.SwitchToDetail);
            newPage.RowAction = switchToDetailAction;

            UPMAction searchAction = new UPMAction(null);

            searchAction.SetTargetAction(this, this.Search);
            newPage.SearchAction = searchAction;
            newPage.ResultState  = this.CountResultState(result);
            this.TopLevelElement = newPage;

            if (this.TestDelegate != null)
            {
                this.TestDelegate.ModelControllerReturnedPage(this, newPage);
                return;
            }

            if (this.ModelControllerDelegate == null)
            {
                this.SearchFinished();
            }
            else
            {
                this.ModelControllerDelegate.ModelControllerDidChange(this, oldSearchPage, newPage, null, null);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SerialEntryWebContentModelController"/> class.
        /// </summary>
        /// <param name="viewReference">The view reference.</param>
        /// <param name="disableSigning">if set to <c>true</c> [disable signing].</param>
        public SerialEntryWebContentModelController(ViewReference viewReference, bool disableSigning)
            : base(viewReference)
        {
            this.disableSigning = disableSigning;
            string buttonName            = viewReference.ContextValueForKey("ButtonName");
            string sendByEmailFilterName = viewReference.ContextValueForKey("SendByEmailFilter");

            if (!string.IsNullOrEmpty(sendByEmailFilterName))
            {
                this.sendByEmailFilter = ConfigurationUnitStore.DefaultStore.FilterByName(sendByEmailFilterName);
                if (this.sendByEmailFilter == null)
                {
                    this.Logger.LogError($"Filter {this.sendByEmailFilter} not found");
                    //DDLogError("Filter \"%@\" not found", sendByEmailFilterName);
                }
                else
                {
                    this.SendByEmailButtonIsShown = false;
                }
            }

            UPConfigButton button = null;

            if (!this.disableSigning && !string.IsNullOrEmpty(buttonName))
            {
                button = ConfigurationUnitStore.DefaultStore.ButtonByName(buttonName);
            }

            if (button != null)
            {
                this.buttonViewReference = button.ViewReference.ViewReferenceWith(viewReference.ContextValueForKey("RecordId"));
                if (this.buttonViewReference.ViewName != "Action:modifyRecord")
                {
                    button = null;
                }
            }

            if (button != null)
            {
                UPMAction action = new UPMAction(StringIdentifier.IdentifierWithStringId("Action.Approve"));
                action.LabelText = button.Label;
                action.SetTargetAction(this, this.Approve);
                this.ApproveAction = action;
            }

            this.UnknownApprovedStateText = "...";
            this.SerialEntryApproved      = UPMSerialEntryState.Unknown;
            this.RecordIdentification     = viewReference.ContextValueForKey("RecordId");
        }
        /// <summary>
        /// Searches the operation did finish with count.
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <param name="count">The count.</param>
        public void SearchOperationDidFinishWithCount(Operation operation, int count)
        {
            this.ControllerState = GroupModelControllerState.Finished;
            UPMInsightBoardItem item = (UPMInsightBoardItem)this.Group.Children[0];

            item.Countable = true;
            item.Count     = count;
            item.SortIndex = this.SortIndex;
            IConfigurationUnitStore configStore   = ConfigurationUnitStore.DefaultStore;
            SearchAndList           searchAndList = configStore.SearchAndListByName(this.searchAndListConfigurationName);

            this.infoAreaid = searchAndList.InfoAreaId;
            InfoArea infoAreaConfig = configStore.InfoAreaConfigById(this.infoAreaid);

            if (!string.IsNullOrEmpty(infoAreaConfig.ColorKey))
            {
                item.Color = AureaColor.ColorWithString(infoAreaConfig.ColorKey);
            }

            if (!string.IsNullOrEmpty(this.Menu.DisplayName))
            {
                item.Title = this.Menu.DisplayName;
            }
            else
            {
                item.Title = item.Count > 1 ? infoAreaConfig.PluralName : infoAreaConfig.SingularName;
            }

            item.ImageName = this.Menu.ImageName ?? infoAreaConfig.ImageName;
            UPMAction action = new UPMAction(null);

            if (count == 1)
            {
                this.crmQuery.Find(this.requestOption, this);
                action.SetTargetAction(this, this.SwitchToDetailOrganizer);
            }
            else
            {
                action.SetTargetAction(this, this.SwitchToListOrganizer);
            }

            item.Action = action;
            if (count != 1)
            {
                this.Delegate.GroupModelControllerFinished(this);
            }
        }
        private UPMStringField CreateStringField(
            UPConfigFieldControlField fieldConfig,
            FieldIdentifier fieldIdentifier,
            UPCRMResultRow resultRow,
            string recordIdentification,
            IConfigurationUnitStore configStore)
        {
            UPMStringField field;

            if (fieldConfig.IsLinkedField)
            {
                var fieldRecordIdentification = resultRow.PhysicalRecordIdentificationAtFieldIndex(fieldConfig.TabIndependentFieldIndex);
                if (!string.IsNullOrEmpty(fieldRecordIdentification))
                {
                    var linkRecordAction        = new UPMAction(StringIdentifier.IdentifierWithStringId("linkRecordActionId"));
                    var showRecordMenu          = configStore.DefaultMenuForInfoAreaId(fieldConfig.InfoAreaId);
                    var linkRecordViewReference = showRecordMenu.ViewReference.ViewReferenceWith(fieldRecordIdentification);
                    this.AddViewReferenceForActionKey(linkRecordViewReference, $"{fieldIdentifier}");
                    linkRecordAction.SetTargetAction(this, this.PerformLinkRecordAction);
                    field = new UPMLinkRecordField(fieldIdentifier, linkRecordAction);
                }
                else
                {
                    field = new UPMStringField(fieldIdentifier);
                }
            }
            else
            {
                var linkUrlAction = new UPMAction(StringIdentifier.IdentifierWithStringId("linkUrlActionId"));
                linkUrlAction.SetTargetAction(this, (sender) =>
                {
                    var url = (sender as UPMURLField)?.StringValue;
                    if (url != null && !url.Contains("://"))
                    {
                        url = "http://" + url;
                    }
                    var deviceService = SimpleIoc.Default.GetInstance <IDeviceService>();
                    deviceService?.OpenUri(new Uri(url));
                });
                field = new UPMURLField(fieldIdentifier, linkUrlAction);
            }

            return(field);
        }
        private UPMStringField CreateField(
            FieldAttributes fieldAttributes,
            FieldIdentifier fieldIdentifier,
            UPConfigFieldControlField fieldConfig,
            UPCRMResultRow resultRow,
            string recordIdentification,
            IConfigurationUnitStore configStore)
        {
            UPMStringField field = null;

            if (fieldAttributes.Email)
            {
                var linkEmailAction = new UPMAction(StringIdentifier.IdentifierWithStringId("linkEmailActionId"));
                linkEmailAction.SetTargetAction(this, (sender) =>
                {
                    var url           = "mailto://" + (sender as UPMEmailField)?.StringValue;
                    var deviceService = SimpleIoc.Default.GetInstance <IDeviceService>();
                    deviceService?.OpenUri(new Uri(url));
                });
                field = new UPMEmailField(fieldIdentifier, linkEmailAction);
            }
            else if (fieldAttributes.Phone)
            {
                field = CreatePhoneField(fieldAttributes, fieldIdentifier);
            }
            else if (fieldAttributes.Httplink)
            {
                field = this.CreateStringField(fieldConfig, fieldIdentifier, resultRow, recordIdentification, configStore);
            }
            else
            {
                field = CreateStringField(fieldAttributes, fieldIdentifier);
            }

            return(field);
        }
Пример #11
0
        public override UPMGroup ApplyContext(Dictionary <string, object> contextDictionary)
        {
            if (this.triggerActionGroup == null)
            {
                this.triggerActionGroup = new UPMTriggerActionGroup(this._identifier);
                string executeText     = LocalizationKeys.upTextProcessExecute;
                string descriptionText = String.Empty;
                string headText        = LocalizationKeys.upTextProcessAction;
                string executingText   = LocalizationKeys.upTextProcessExecuting;
                string doneText        = LocalizationKeys.upTextProcessDone;
                string retryText       = LocalizationKeys.upTextRetry;
                if (!string.IsNullOrEmpty(this.FormItem.Label))
                {
                    var textParts = this.FormItem.Label.Split(';');
                    if (textParts.Length > 2)
                    {
                        string part0 = textParts[0];
                        if (part0.Length > 0)
                        {
                            headText = part0;
                        }

                        string part1 = textParts[1];
                        if (part1.Length > 0)
                        {
                            executeText = part1;
                        }

                        if (textParts.Length > 3)
                        {
                            string part2 = textParts[2];
                            if (part2.Length > 0)
                            {
                                executingText = part2;
                            }

                            if (textParts.Length > 4)
                            {
                                string part3 = textParts[3];
                                if (part3.Length > 0)
                                {
                                    doneText = part3;
                                }

                                descriptionText = this.FormItem.Label.Substring(part0.Length + part1.Length + part2.Length + part3.Length + 4);
                            }
                            else
                            {
                                descriptionText = this.FormItem.Label.Substring(part0.Length + part1.Length + part2.Length + 3);
                            }
                        }
                        else
                        {
                            descriptionText = this.FormItem.Label.Substring(part0.Length + part1.Length + 2);
                        }
                    }
                    else if (textParts.Length > 1)
                    {
                        string part = textParts[0];
                        if (part.Length > 0)
                        {
                            executeText = part;
                        }

                        descriptionText = this.FormItem.Label.Substring(part.Length + 1);
                    }
                    else
                    {
                        descriptionText = this.FormItem.Label;
                    }
                }

                this.triggerActionGroup.ExecutionNote = descriptionText;
                this.triggerActionGroup.LabelText     = headText;
                this.triggerActionGroup.HtmlMode      = false;
                this.triggerActionGroup.ButtonText    = executeText;
                this.triggerActionGroup.ExecutingText = executingText;
                this.triggerActionGroup.DoneText      = doneText;
                this.triggerActionGroup.RetryText     = retryText;
                UPMAction menuAction = new UPMAction(this._identifier);
                this.LinkRecordIdentification = this.FormItem.ViewReference.ContextValueForKey("Func1");
                string v = contextDictionary.ValueOrDefault(this.LinkRecordIdentification) as string;
                if (!string.IsNullOrEmpty(v))
                {
                    this.LinkRecordIdentification = v;
                }

                this.ActionType   = this.FormItem.ViewReference.ContextValueForKey("Func2");
                this.ActionConfig = this.FormItem.ViewReference.ContextValueForKey("Func3");
                if (this.ActionType == "CopyRecord")
                {
                    menuAction.SetTargetAction(this, PerformCopyRecordAction);
                }
                else if (this.ActionType == "Workflow")
                {
                    menuAction.SetTargetAction(this, PerformWorkflowAction);
                }

                menuAction.LabelText = executeText;
                UPMLinkRecordField field = new UPMLinkRecordField(this._identifier, menuAction);
                field.LabelText   = executeText;
                field.StringValue = executeText;
                this.triggerActionGroup.AddField(field);
                this.ControllerState = GroupModelControllerState.Finished;
                this.Group           = this.triggerActionGroup;
                this.AddDependingKeysFromViewReference(this.FormItem.ViewReference);
            }

            /*
             * else if (Thread.IsMainThread() == false)
             * {
             *  this.PerformSelectorOnMainThreadWithObjectWaitUntilDone(@selector(applyContext:), contextDictionary, true);
             *  return this.triggerActionGroup;
             * }
             */

            Dictionary <string, object> paramDict = this.ParameterDictionary();

            this.triggerActionGroup.Disable = paramDict[".empty"] != null ? true : false;
            return(this.triggerActionGroup);
        }
        private UPMGroup BuildGroup(UPMGroup group)
        {
            Dictionary <string, string> infoAreaImageFileNames = new Dictionary <string, string>();
            IConfigurationUnitStore     configStore            = ConfigurationUnitStore.DefaultStore;
            UPConfigExpand repExpand = configStore.ExpandByName("ID");

            this.linkParticipantsViewReference = null;

            if (!string.IsNullOrEmpty(this.linkParticipantsName))
            {
                SearchAndList searchAndList = configStore.SearchAndListByName(this.linkParticipantsName);
                Menu          menu          = searchAndList != null?configStore.MenuByName(searchAndList.DefaultAction) : null;

                this.linkParticipantsViewReference = menu?.ViewReference;
            }

            if (this.acceptanceCatalogAttributes == null && this.recordParticipants.AcceptanceField != null)
            {
                this.acceptanceCatalogAttributes = configStore.CatalogAttributesForInfoAreaIdFieldId(this.recordParticipants.AcceptanceField.InfoAreaId, this.recordParticipants.AcceptanceField.FieldId);
            }

            foreach (UPCRMParticipant participant in this.recordParticipants.Participants)
            {
                bool           isRepParticipant = participant is UPCRMRepParticipant;
                IIdentifier    identifier       = StringIdentifier.IdentifierWithStringId(participant.Key);
                UPMListRow     listRow          = new UPMListRow(identifier);
                UPMStringField nameField        = new UPMStringField(StringIdentifier.IdentifierWithStringId("name"));
                nameField.StringValue = participant.Name;
                listRow.AddField(nameField);
                UPMStringField acceptanceField = new UPMStringField(StringIdentifier.IdentifierWithStringId("acceptance"));
                if (!isRepParticipant || this.recordParticipants.HasRepAcceptance)
                {
                    acceptanceField.StringValue = participant.AcceptanceDisplayText;
                    UPConfigCatalogValueAttributes configCatalogValueAttributes = this.acceptanceCatalogAttributes?.ValuesByCode[Convert.ToInt32(participant.AcceptanceText)];
                    string colorString = configCatalogValueAttributes?.ColorKey;
                    if (!string.IsNullOrEmpty(colorString))
                    {
                        listRow.RowColor = AureaColor.ColorWithString(colorString);
                    }
                }
                else
                {
                    acceptanceField.StringValue = string.Empty;
                }

                listRow.AddField(acceptanceField);
                UPMStringField requirementField = new UPMStringField(StringIdentifier.IdentifierWithStringId("requirement"));
                requirementField.StringValue = participant.RequirementDisplayText;
                listRow.AddField(requirementField);
                if (isRepParticipant)
                {
                    // listRow.Icon = UIImage.UpImageWithFileName(repExpand.ImageName);     // CRM-5007
                    listRow.RowAction = null;
                }
                else
                {
                    UPCRMLinkParticipant linkParticipant = (UPCRMLinkParticipant)participant;
                    string _infoAreaId = linkParticipant.LinkRecordIdentification.InfoAreaId();
                    string imageName   = infoAreaImageFileNames.ValueOrDefault(_infoAreaId);
                    if (imageName == null)
                    {
                        UPConfigExpand expand = configStore.ExpandByName(_infoAreaId);
                        imageName = expand.ImageName ?? string.Empty;

                        infoAreaImageFileNames.SetObjectForKey(imageName, _infoAreaId);
                    }

                    // listRow.Icon = UIImage.UpImageWithFileName(imageName);       // CRM-5007
                    listRow.OnlineData = !UPCRMDataStore.DefaultStore.RecordExistsOffline(linkParticipant.LinkRecordIdentification);

                    if (this.linkParticipantsViewReference != null)
                    {
                        UPMAction switchToOrganizerAction = new UPMAction(null);
                        switchToOrganizerAction.IconName = "arrow.png";
                        switchToOrganizerAction.SetTargetAction(this, this.SwitchToOrganizerForLinkParticipant);
                        listRow.RowAction = switchToOrganizerAction;
                    }
                }

                group.AddChild(listRow);
            }

            return(group);
        }
        /// <summary>
        /// The group from result.
        /// </summary>
        /// <param name="result">
        /// The result.
        /// </param>
        /// <returns>
        /// The <see cref="UPMGroup"/>.
        /// </returns>
        protected override UPMGroup GroupFromResult(UPCRMResult result)
        {
            int count = result.RowCount;

            if (this.MaxResults > 0 && count > this.MaxResults)
            {
                count = this.MaxResults;
            }

            if (count > 0)
            {
                var mapGroup = new UPMMapGroup(this.ExplicitTabIdentifier)
                {
                    LabelText = this.TabLabel
                };

                if (this.FormItem != null)
                {
                    var optionValue = this.FormItem.Options.ValueOrDefault("Interaction") as string;

                    mapGroup.UserInteractionOnlyEnabledInFullscreenMode = optionValue == "FullScreen";

                    mapGroup.RecommendedHeight = this.FormItem.CellAttributes.ValueOrDefault("Height").ToInt();
                }
                else
                {
                    mapGroup.RecommendedHeight = 350;
                }

                var tabConfig = this.FieldControl.TabAtIndex(0);

                for (var i = 0; i < count; i++)
                {
                    var resultRow   = (UPCRMResultRow)result.ResultRowAtIndex(i);
                    var geoLocation = UPGeoLocation.Create(resultRow, tabConfig);
                    if (geoLocation == null)
                    {
                        continue;
                    }

                    var identifier          = new RecordIdentifier(this.FieldControl.InfoAreaId, resultRow.RecordIdentificationAtIndex(0).RecordId());
                    var locationFieldAction = new UPMAction(identifier.IdentifierWithFieldId("locationActionId"));
                    locationFieldAction.SetTargetAction(this, this.PerformLocationFieldAction);
                    var locationField = new UPMLocationField(identifier, locationFieldAction);
                    if (geoLocation.ValidGPS)
                    {
                        locationField.Longitude = geoLocation.GpsXString;
                        locationField.Latitude  = geoLocation.GpsYString;
                    }

                    if (!string.IsNullOrEmpty(geoLocation.AddressTitle))
                    {
                        locationField.AddressTitle = geoLocation.AddressTitle;
                    }

                    if (!string.IsNullOrEmpty(geoLocation.Address))
                    {
                        locationField.Address = geoLocation.Address;
                    }

                    mapGroup.AddChild(locationField);
                }

                this.ControllerState = GroupModelControllerState.Finished;
                this.Group           = mapGroup;
                return(mapGroup);
            }

            this.ControllerState = GroupModelControllerState.Empty;
            this.Group           = null;
            return(null);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="UPMGridGroup"/> class.
 /// </summary>
 /// <param name="identifier">The identifier.</param>
 /// <param name="action">The action.</param>
 public UPMGridGroup(IIdentifier identifier, UPMAction action)
     : base(identifier, action)
 {
 }
        /// <summary>
        /// Continues the with record identification.
        /// </summary>
        /// <param name="_linkRecordIdentification">The link record identification.</param>
        private void ContinueWithRecordIdentification(string _linkRecordIdentification)
        {
            this.linkRecordIdentification = _linkRecordIdentification;
            if (this.countable)
            {
                IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
                this.crmQuery = !string.IsNullOrEmpty(this.searchAndListConfigurationName)
                    ? new UPContainerMetaInfo(this.searchAndListConfigurationName, this.parameters)
                    : new UPContainerMetaInfo(configStore.FieldControlByNameFromGroup("List", this.infoAreaid));

                if (!string.IsNullOrEmpty(this.linkRecordIdentification))
                {
                    this.crmQuery.SetLinkRecordIdentification(this.linkRecordIdentification);
                }

                if (!string.IsNullOrEmpty(this.filterName))
                {
                    if (this.crmQuery != null)
                    {
                        UPConfigFilter filter = configStore.FilterByName(this.filterName);
                        if (filter != null)
                        {
                            if (this.parameters?.Count > 0)
                            {
                                filter = filter.FilterByApplyingValueDictionaryDefaults(this.parameters, true);
                            }

                            this.crmQuery.ApplyFilter(filter);
                        }
                    }
                }

                Operation operation = this.crmQuery.CountTheDelegate(this.requestOption, this);
                if (operation == null)
                {
                    this.SearchOperationDidFinishWithCount(null, 0);
                }
            }
            else
            {
                UPMInsightBoardItem item = (UPMInsightBoardItem)this.Group.Children[0];
                item.Countable = false;
                item.Count     = 1;
                item.Title     = !string.IsNullOrEmpty(this.Menu.DisplayName) ? this.Menu.DisplayName : string.Empty;
                item.ImageName = this.Menu.ImageName;
                item.SortIndex = this.SortIndex;

                this.detailActionViewReference    = this.relevantViewReference;
                this.detailActionRecordIdentifier = this.linkRecordIdentification;

                UPMAction action = new UPMAction(null);
                if (this.forcedRecordListView)
                {
                    action.SetTargetAction(this, this.SwitchToListOrganizer);
                }
                else
                {
                    action.SetTargetAction(this, this.SwitchToDetailOrganizer);
                }

                item.Action          = action;
                this.ControllerState = GroupModelControllerState.Finished;
                this.Delegate.GroupModelControllerFinished(this);
            }
        }
Пример #16
0
        /// <summary>
        /// Populate Sub menus from parent menu
        /// </summary>
        /// <param name="menu">
        /// <see cref="Menu"/>
        /// </param>
        /// <param name="organizer">
        /// <see cref="UPMAdvancedSearchOrganizer"/>
        /// </param>
        private void PopulateSubMenusFromMenu(Menu menu, UPMAdvancedSearchOrganizer organizer)
        {
            var searchTypes = new List <UPMDetailSearch>();

            for (var index = 0; index < menu.NumberOfSubMenus; index++)
            {
                var menuItem = menu.SubMenuAtIndex(index);
                if (menuItem?.ViewReference != null)
                {
                    if (menuItem.UnitName == MenuItemHistorySearch)
                    {
                        var modelController = PageForViewReference(menuItem.ViewReference);
                        AddPageModelController(modelController);
                        organizer.AddPage(modelController.Page);
                        QuickHistorySearchModelController = (UPHistorySearchPageModelController)modelController;
                    }
                    else if (menuItem.ViewReference.ViewName == ViewRecordListView || menuItem.ViewReference.ViewName == ViewCalendarView ||
                             menuItem.ViewReference.ViewName == ViewDocumentView)
                    {
                        if (menuItem.UnitName == MenuItemGlobalSearch)
                        {
                            var modelController = PageForViewReference(menuItem.ViewReference);
                            AddPageModelController(modelController);
                            organizer.AddPage(modelController.Page);
                            QuickGlobalSearchModelController = (GlobalSearchPageModelController)modelController;
                        }
                        else if (menuItem.UnitName == MenuItemFavoriteSearch)
                        {
                            var modelController = PageForViewReference(menuItem.ViewReference);
                            AddPageModelController(modelController);
                            organizer.AddPage(modelController.Page);
                            QuickFavoriteSearchModelController = (UPMultiSearchPageModelController)modelController;
                        }
                        else
                        {
                            var itemViewReference = menuItem.ViewReference;
                            var infoArea          = itemViewReference.ContextValueForKey(KeyInfoArea);
                            if (menuItem.ViewReference.ViewName == ViewDocumentView && infoArea == null)
                            {
                                infoArea = InfoAreaD1;
                            }

                            var identifier       = StringIdentifier.IdentifierWithStringId(menu.UnitName);
                            var detailSearchType = new UPMDetailSearch(identifier)
                            {
                                TileField = new UPMStringField(StringIdentifier.IdentifierWithStringId($"{menuItem.UnitName}{IdentifierSuffixTitle}"))
                            };
                            detailSearchType.TileField.StringValue = menuItem.DisplayName;
                            detailSearchType.Color = ColorForInfoAreaWithId(infoArea);
                            searchTypes.Add(detailSearchType);
                            var action = new UPMAction(StringIdentifier.IdentifierWithStringId($"{IdentifierPrefixDetailAction} {menuItem.UnitName}"));
                            action.SetTargetAction(this, PerformDetailAction);
                            detailSearchType.SwitchToDetailSearchAction = action;
                            viewReferenceDict[action.Identifier]        = itemViewReference;
                        }
                    }
                }
            }

            organizer.DetailSearches = searchTypes;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="UPMLinkRecordField"/> class.
 /// </summary>
 /// <param name="identifier">
 /// The identifier.
 /// </param>
 /// <param name="action">
 /// The action.
 /// </param>
 public UPMLinkRecordField(IIdentifier identifier, UPMAction action)
     : base(identifier)
 {
     this.Action = action;
 }
Пример #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UPMListGroup"/> class.
 /// </summary>
 /// <param name="identifier">
 /// The identifier.
 /// </param>
 /// <param name="action">
 /// The action.
 /// </param>
 public UPMListGroup(IIdentifier identifier, UPMAction action)
     : base(identifier)
 {
     this.Action = action;
 }
Пример #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UPMLocationField"/> class.
 /// </summary>
 /// <param name="identifier">Identifier</param>
 /// <param name="action">Action</param>
 public UPMLocationField(IIdentifier identifier, UPMAction action)
     : base(identifier)
 {
     this.action = action;
 }
Пример #20
0
        /// <summary>
        /// Populate Sub menus
        /// </summary>
        /// <param name="organizer">
        /// <see cref="UPMAdvancedSearchOrganizer"/> object
        /// </param>
        /// <param name="store">
        /// <see cref="IConfigurationUnitStore"/> config store
        /// </param>
        /// <param name="startMenuName">
        /// starting menu
        /// </param>
        private void PopulateSubMenus(UPMAdvancedSearchOrganizer organizer, IConfigurationUnitStore store, string startMenuName)
        {
            var searchTypes = new List <UPMDetailSearch>();
            var menu        = Menu.MainMenu();

            for (var index = 0; index < menu.NumberOfSubMenus; index++)
            {
                var menuItem = menu.SubMenuAtIndex(index);
                if (menuItem?.ViewReference != null)
                {
                    if (startMenu == null)
                    {
                        startMenu = menuItem;
                    }

                    if (!string.IsNullOrWhiteSpace(startMenuName))
                    {
                        var startMenuItem = store.MenuByName(startMenuName);
                        if (startMenuItem != null && startMenuItem == menuItem)
                        {
                            startMenu = menuItem;
                        }
                    }

                    if (menuItem.ViewReference.ViewName == ViewHistoryListView)
                    {
                        var modelController = PageForViewReference(menuItem.ViewReference);
                        AddPageModelController(modelController);
                        organizer.AddPage(modelController.Page);
                        QuickHistorySearchModelController = (UPHistorySearchPageModelController)modelController;
                    }
                    else if (menuItem.ViewReference.ViewName == ViewRecordListView || menuItem.ViewReference.ViewName == ViewCalendarView ||
                             menuItem.ViewReference.ViewName == ViewDocumentView)
                    {
                        if (menuItem.ViewReference.ContextValueForKey(KeyModus) == KeyGlobalSearch)
                        {
                            var modelController = PageForViewReference(menuItem.ViewReference);
                            AddPageModelController(modelController);
                            organizer.AddPage(modelController.Page);
                            QuickGlobalSearchModelController = (GlobalSearchPageModelController)modelController;
                        }
                        else if (menuItem.ViewReference.ContextValueForKey(KeyModus) == KeyMultiSearch)
                        {
                            var modelController = PageForViewReference(menuItem.ViewReference);
                            AddPageModelController(modelController);
                            organizer.AddPage(modelController.Page);
                            QuickFavoriteSearchModelController = (UPMultiSearchPageModelController)modelController;
                        }
                        else
                        {
                            var itemViewReference = menuItem.ViewReference;
                            var infoArea          = itemViewReference.ContextValueForKey(KeyInfoArea);
                            if (menuItem.ViewReference.ViewName == ViewDocumentView && infoArea == null)
                            {
                                infoArea = InfoAreaD1;
                            }

                            var detailSearchType = new UPMDetailSearch(StringIdentifier.IdentifierWithStringId(menu.UnitName))
                            {
                                TileField = new UPMStringField(StringIdentifier.IdentifierWithStringId($"{menuItem.UnitName}{IdentifierSuffixTitle}"))
                                {
                                    StringValue = menuItem.DisplayName
                                },
                                Color = ColorForInfoAreaWithId(infoArea)
                            };
                            searchTypes.Add(detailSearchType);
                            var action = new UPMAction(StringIdentifier.IdentifierWithStringId($"{IdentifierPrefixDetailAction} {menuItem.UnitName}"));
                            action.SetTargetAction(this, PerformDetailAction);
                            detailSearchType.SwitchToDetailSearchAction = action;
                            viewReferenceDict[action.Identifier]        = itemViewReference;
                        }
                    }
                }
            }

            organizer.DetailSearches = searchTypes;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="UPMGridHeadOption"/> class.
 /// </summary>
 /// <param name="label">Label</param>
 /// <param name="action">Action</param>
 public UPMGridHeadOption(string label, UPMAction action)
 {
     this.Action = action;
     this.Label  = label;
 }
Пример #22
0
        private List <ICalendarItem> CalendarItemsFromResult()
        {
            List <ICalendarItem>    calendarItems = new List <ICalendarItem>();
            IConfigurationUnitStore configStore   = ConfigurationUnitStore.DefaultStore;

            this.resultContexts = new List <UPCoreMappingResultContext>();
            UPMAction goToAction = new UPMAction(StringIdentifier.IdentifierWithStringId("action"));

            goToAction.SetTargetAction(this, this.SwitchToDetail);
            goToAction.LabelText = LocalizedString.TextShowRecord;

            foreach (TimelineSearch timelineSearch in this.searches)
            {
                UPCRMResult result   = timelineSearch.Result;
                int         rowCount = result.RowCount;
                if (rowCount == 0)
                {
                    continue;
                }

                UPConfigTableCaption tableCaption = configStore.TableCaptionByName(timelineSearch.TimelineInfoArea.ConfigName) ??
                                                    configStore.TableCaptionByName(timelineSearch.TimelineInfoArea.InfoAreaId);

                List <UPContainerFieldMetaInfo> tableCaptionResultFieldMap = tableCaption.ResultFieldMapFromMetaInfo(result.MetaInfo);
                if (tableCaptionResultFieldMap == null)
                {
                    continue;
                }

                UPCRMResultCondition resultCondition = null;
                var functionNameFieldMapping         = result.MetaInfo.SourceFieldControl.FunctionNames();
                UPConfigFieldControlField fromField  = functionNameFieldMapping["Date"];
                if (fromField != null)
                {
                    if (this.fromDate != null)
                    {
                        resultCondition = new UPCRMResultFieldCondition(fromField.Field, UPConditionOperator.GreaterEqual,
                                                                        this.fromDate.Value.CrmValueFromDate(), fromField.TabIndependentFieldIndex);
                    }

                    if (this.toDate != null)
                    {
                        UPConfigFieldControlField toField = (functionNameFieldMapping.ContainsKey("EndDate")
                            ? functionNameFieldMapping["EndDate"]
                            : null) ?? fromField;

                        UPCRMResultCondition toCondition = new UPCRMResultFieldCondition(toField.Field, UPConditionOperator.LessEqual,
                                                                                         this.toDate.Value.CrmValueFromDate(), toField.TabIndependentFieldIndex);
                        resultCondition = resultCondition != null?resultCondition.ConditionByAppendingANDCondition(toCondition) : toCondition;
                    }
                }

                UPCoreMappingResultContext resultContext = new UPCoreMappingResultContext(result, result.MetaInfo.SourceFieldControl, timelineSearch.PreparedSearch.ListFieldControl.NumberOfFields);
                resultContext.Context = timelineSearch;
                this.resultContexts.Add(resultContext);

                UPConfigExpand expand = configStore.ExpandByName(timelineSearch.TimelineInfoArea.ConfigName) ??
                                        configStore.ExpandByName(timelineSearch.TimelineInfoArea.InfoAreaId);

                AureaColor defaultColor = null;
                if (!string.IsNullOrEmpty(timelineSearch.TimelineInfoArea.ColorString))
                {
                    defaultColor = AureaColor.ColorWithString(timelineSearch.TimelineInfoArea.ColorString);
                }

                if (defaultColor == null)
                {
                    defaultColor = AureaColor.ColorWithString(expand.ColorKey);
                }

                for (int i = 0; i < rowCount; i++)
                {
                    UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(i);
                    if (resultCondition != null && !resultCondition.Check(row))
                    {
                        continue;
                    }

                    ConfigTimelineCriteria matchingCriteria = timelineSearch.MatchingCriteriaForRow(row);
                    AureaColor             color            = null;
                    if (matchingCriteria.Setting1 != null)
                    {
                        color = AureaColor.ColorWithString(matchingCriteria.Setting1);
                    }

                    if (color == null)
                    {
                        color = defaultColor;
                    }

                    ICalendarItem calendarItem = new ResultRowCalendarItem(row, resultContext, new RecordIdentifier(row.RootRecordIdentification), tableCaption, tableCaptionResultFieldMap, null, color);
                    calendarItem.GoToAction = goToAction;
                    calendarItems.Add(calendarItem);
                }
            }

            if (this.fromDate != null && this.toDate != null && this.CalendarPage.IncludeSystemCalendar)
            {
#if PORTING
                ArrayList localCalendarItems = ResultRowCalendarItem.EventsFromLocalCalendarFromToSearchTextCalenderIdentifiers(this.fromDate, this.toDate, null, null);
                if (localCalendarItems.Count)
                {
                    calendarItems.AddRange(localCalendarItems);
                }
#endif
            }

            return(calendarItems);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="UPMURLField"/> class.
 /// </summary>
 /// <param name="identifier">
 /// The identifier.
 /// </param>
 public UPMURLField(IIdentifier identifier, UPMAction action = null)
     : base(identifier)
 {
     this.Action = action;
 }
Пример #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UPMGridCategory"/> class.
 /// </summary>
 /// <param name="label">Label</param>
 /// <param name="action">Action</param>
 /// <param name="isCurrentCategory">Is current category</param>
 public UPMGridCategory(string label, UPMAction action, bool isCurrentCategory)
 {
     this.Label             = label;
     this.Action            = action;
     this.IsCurrentCategory = isCurrentCategory;
 }