예제 #1
0
        /// <summary>
        /// Creates the query link identifier search and list.
        /// </summary>
        /// <param name="recordIdentifier">The record identifier.</param>
        /// <param name="linkId">The link identifier.</param>
        /// <param name="searchAndList">The search and list.</param>
        /// <returns></returns>
        protected UPContainerMetaInfo CreateQueryLinkIdSearchAndList(string recordIdentifier, int linkId, SearchAndList searchAndList)
        {
            if (searchAndList == null)
            {
                return(null);
            }

            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

            if (this.expandSettings == null)
            {
                this.expandSettings = configStore.ExpandByName(searchAndList.InfoAreaId);
            }

            FieldControl fieldControlList  = configStore.FieldControlByNameFromGroup("List", searchAndList.FieldGroupName);
            FieldControl fieldControlMini  = configStore.FieldControlByNameFromGroup("MiniDetails", searchAndList.FieldGroupName);
            FieldControl fieldControlCombi = new FieldControl(new List <FieldControl> {
                fieldControlList, fieldControlMini
            });
            UPContainerMetaInfo query = new UPContainerMetaInfo(fieldControlCombi);

            query.SetLinkRecordIdentification(recordIdentifier, linkId);
            if (this.expandSettings != null)
            {
                Dictionary <string, UPCRMField> alternateExpandFields = this.expandSettings.FieldsForAlternateExpands(true);
                List <UPCRMField> additionalFields = alternateExpandFields.Values.Where(field => query.ContainsField(field) == null).ToList();

                if (additionalFields.Count > 0)
                {
                    query.AddCrmFields(additionalFields);
                }

                this.expandChecker = this.expandSettings.ExpandCheckerForCrmQuery(query);
            }

            return(query);
        }
        /// <summary>
        /// Updates the page.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <returns></returns>
        protected override UPMCircleOfInfluencePage UpdatePage(UPMCircleOfInfluencePage page)
        {
            if (this.rootNodeFieldControl == null)
            {
                this.InformAboutDidFailTopLevelElement(page);
                return(page);
            }

            // Load Root Node
            if (page.Invalid || page.RootNode.Invalid)
            {
                UPContainerMetaInfo query = new UPContainerMetaInfo(this.rootNodeFieldControl);
                if (this.ExpandSettings != null)
                {
                    Dictionary <string, UPCRMField> alternateExpandFields = this.ExpandSettings.FieldsForAlternateExpands(true);
                    List <UPCRMField> additionalFields = alternateExpandFields?.Values.Where(field => query.ContainsField(field) == null).ToList();

                    if (additionalFields?.Count > 0)
                    {
                        query.AddCrmFields(additionalFields);
                    }

                    this.expandChecker = this.ExpandSettings.ExpandCheckerForCrmQuery(query);
                }

                Operation operation = query.ReadRecord(this.RootRecordIdentification, this.RequestOption, this);
                if (operation == null && this.RequestOption == UPRequestOption.Online)
                {
                    // Offline
                    UPMWatermarkStatus offlineStatus = UPMWatermarkStatus.WatermarkStatus();
                    page.Status = offlineStatus;
                    this.InformAboutDidChangeTopLevelElement(page, page, null, null);
                }
            }

            return(page);
        }
예제 #3
0
        private void ContinueLoadWithFieldValueDictionary(Dictionary <string, object> fieldValueDictionary)
        {
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

            if (fieldValueDictionary != null)
            {
                if (this.copyFieldsDictionary == null)
                {
                    this.copyFieldsDictionary = new Dictionary <string, Dictionary <string, object> >();
                }

                this.copyFieldsDictionary.SetObjectForKey(fieldValueDictionary, this.currentSectionConfiguration.SourceFieldControl.UnitName);
            }

            this.currentCopyFields = null;
            FieldControl   destinationFieldControl = this.currentSectionConfiguration.DestinationFieldControl;
            string         destinationFilterName   = this.currentSectionConfiguration.DestinationFilterName;
            UPConfigFilter companyRelatedFilter    = null;

            if (this.companyRelated)
            {
                string companyFilterName = $"{destinationFieldControl.InfoAreaId}.CompanyRelated";
                companyRelatedFilter = configStore.FilterByName(companyFilterName);
            }

            UPContainerMetaInfo container = new UPContainerMetaInfo(destinationFieldControl);

            container.SetLinkRecordIdentification(this.rootRecordIdentification);
            List <UPConfigFilter> appliedFilters = new List <UPConfigFilter>();
            UPConfigFilter        filter         = configStore.FilterByName(destinationFilterName);

            if (filter != null)
            {
                filter = filter.FilterByApplyingReplacements(UPConditionValueReplacement.ReplacementsFromValueParameterDictionary(fieldValueDictionary));
                container.ApplyFilter(filter);
                appliedFilters.Add(filter);
            }

            if (companyRelatedFilter != null && this.currentSectionConfiguration.SourceFieldControl != null)
            {
                companyRelatedFilter = companyRelatedFilter.FilterByApplyingReplacements(new UPConditionValueReplacement(fieldValueDictionary));
                container.ApplyFilter(companyRelatedFilter);
                appliedFilters.Add(companyRelatedFilter);
            }

            this.objectivesForRecordOperation = null;
            this.rightFilterOperation         = null;
            this.filterLoaded = true;
            if (this.RightsFilter != null && this.filterItemsResult == null)
            {
                this.filterLoaded = false;
            }

            if (this.currentSectionConfiguration.ExecuteActionFilter != null)
            {
                this.currentSectionConfiguration.ExecuteActionFilter = this.currentSectionConfiguration.ExecuteActionFilter.FilterByApplyingValueDictionaryDefaults(fieldValueDictionary, true);
                if (this.currentSectionConfiguration.ExecuteActionFilter != null)
                {
                    this.currentSectionConfiguration.FilterBasedDecision = new UPCRMFilterBasedDecision(this.currentSectionConfiguration.ExecuteActionFilter);
                    List <UPCRMField> fields = this.currentSectionConfiguration.FilterBasedDecision.FieldDictionary.Values.ToList();
                    if (fields.Count > 0)
                    {
                        container.AddCrmFields(fields);
                    }

                    this.currentSectionConfiguration.FilterBasedDecision.UseCrmQuery(container);
                }
            }

            this.objectivesForRecordOperation = container.Find(this.RequestOption, this);
            if (this.objectivesForRecordOperation == null)
            {
                SimpleIoc.Default.GetInstance <ILogger>().LogError("Could not create operation for loading objectives.");
                this.FailWithError(new Exception("ConnectionOfflineError"));
            }

            if (this.RightsFilter != null && this.filterItemsResult == null)
            {
                UPContainerMetaInfo clonedContainer = new UPContainerMetaInfo(new List <UPCRMField>(), destinationFieldControl.InfoAreaId);
                clonedContainer.SetLinkRecordIdentification(this.rootRecordIdentification);
                clonedContainer.ApplyFilter(this.RightsFilter);
                foreach (UPConfigFilter filter1 in appliedFilters)
                {
                    clonedContainer.ApplyFilter(filter1);
                }

                this.rightFilterOperation = clonedContainer.Find(this.RequestOption, this);
                if (this.rightFilterOperation == null)
                {
                    SimpleIoc.Default.GetInstance <ILogger>().LogError("Could not create operation for filtering objectives.");
                    this.FailWithError(new Exception("ConnectionOfflineError"));
                }
            }
        }
 /* make sure to pass the return value of this function to tableCaptionForResultRow! */
 public List <UPContainerFieldMetaInfo> AddTableCaptionFieldsToCrmQuery(UPContainerMetaInfo crmQuery)
 => crmQuery?.AddCrmFields(this.Fields);
예제 #5
0
        /// <summary>
        /// Records the identification for link information area identifier link identifier.
        /// </summary>
        /// <param name="infoAreaId">
        /// The information area identifier.
        /// </param>
        /// <param name="linkId">
        /// The link identifier.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public string RecordIdentificationForLinkInfoAreaIdLinkId(string infoAreaId, int linkId)
        {
            var position = this.Result.MetaInfo.IndexOfResultInfoAreaIdLinkId(infoAreaId, linkId);

            if (position >= 0)
            {
                return(this.RecordIdentificationAtIndex(position));
            }

            var rootInfoAreaId = this.PhysicalInfoAreaIdAtIndex(0);
            var tableInfo      = UPCRMDataStore.DefaultStore.TableInfoForInfoArea(rootInfoAreaId);
            var linkInfo       = tableInfo.LinkInfoForTargetInfoAreaIdLinkId(infoAreaId, linkId);

            if (linkInfo == null)
            {
                return(null);
            }

            if (linkInfo.IsFieldLink && linkInfo.LinkFieldArray?.Count == 1)
            {
                var arNoString = this.RawValueForFieldIdInfoAreaIdLinkId(
                    linkInfo.FirstField.FieldId,
                    linkInfo.InfoAreaId,
                    -1);
                if (string.IsNullOrEmpty(arNoString))
                {
                    return(null);
                }

                var crmQuery         = new UPContainerMetaInfo(new List <UPCRMField>(), linkInfo.TargetInfoAreaId);
                var infoAreaMetaInfo = crmQuery.RootInfoAreaMetaInfo;
                infoAreaMetaInfo.Condition = new UPInfoAreaConditionLeaf(
                    linkInfo.TargetInfoAreaId,
                    linkInfo.FirstField.TargetFieldId,
                    "=",
                    arNoString);
                var res = crmQuery.Find();
                if (res.RowCount > 0)
                {
                    return(res.ResultRowAtIndex(0).RootRecordIdentification);
                }
            }
            else if (linkInfo.HasColumn && !this.IsNewRow &&
                     !ConfigurationUnitStore.DefaultStore.ConfigValueIsSet("Disable.82339"))
            {
                var crmQuery = new UPContainerMetaInfo(new List <UPCRMField>(), rootInfoAreaId);
                crmQuery.AddCrmFields(
                    new List <UPCRMField>
                {
                    new UPCRMLinkField(linkInfo.TargetInfoAreaId, linkInfo.LinkId, rootInfoAreaId)
                });
                crmQuery.SetLinkRecordIdentification(this.RootRecordIdentification);
                var res = crmQuery.Find();
                if (res.RowCount != 1)
                {
                    return(null);
                }

                var linkRecordId = res.ResultRowAtIndex(0).RawValueAtIndex(0);
                if (!string.IsNullOrEmpty(linkRecordId))
                {
                    return(linkInfo.TargetInfoAreaId.InfoAreaIdRecordId(linkRecordId));
                }
            }

            SimpleIoc.Default.GetInstance <ILogger>().LogWarn($"RecordSelector: could not determine linkRecord for infoArea:{infoAreaId} linkId:{linkId}");
            return(null);
        }
        /// <summary>
        /// The crm query for value.
        /// </summary>
        /// <param name="searchValue">
        /// The search value.
        /// </param>
        /// <param name="filters">
        /// The filters.
        /// </param>
        /// <param name="fullTextSearch">
        /// The full text search.
        /// </param>
        /// <returns>
        /// The <see cref="UPContainerMetaInfo"/>.
        /// </returns>
        public UPContainerMetaInfo CrmQueryForValue(
            string searchValue,
            List <UPConfigFilter> filters,
            bool fullTextSearch)
        {
            if (this.CombinedControl == null)
            {
                return(null);
            }

            if (this.SearchCRMFields == null && this.MultiSearchCRMFields == null &&
                this.SearchFieldControl?.Tabs?.Count > 0)
            {
                int tabCount = this.SearchFieldControl.Tabs.Count;

                List <UPCRMField> fieldArray      = null;
                List <UPCRMField> multiFieldArray = null;

                for (int i = 0; i < tabCount; i++)
                {
                    FieldControlTab tab = this.SearchFieldControl.TabAtIndex(i);
                    if (tab.Fields == null || tab.Fields.Count == 0)
                    {
                        continue;
                    }

                    if (string.Compare(tab.Type, @"MULTI", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        UPCRMField multiField = tab.FieldAtIndex(0).Field;

                        if (multiFieldArray == null)
                        {
                            multiFieldArray = new List <UPCRMField>();
                        }

                        multiFieldArray.Add(multiField);
                    }
                    else
                    {
                        if (fieldArray == null)
                        {
                            fieldArray = new List <UPCRMField>();
                        }

                        fieldArray.AddRange(tab.AllCRMFields());
                    }
                }

                this.SearchCRMFields      = fieldArray;
                this.MultiSearchCRMFields = multiFieldArray;
            }

            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            UPContainerMetaInfo     container   = new UPContainerMetaInfo(this.CombinedControl);

            if (!string.IsNullOrEmpty(this.DetailActionSwitchFilterName))
            {
                this.DetailActionSwitchFilter = ConfigurationUnitStore.DefaultStore.FilterByName(this.DetailActionSwitchFilterName);

                if (this.DetailActionSwitchFilter != null)
                {
                    this.DetailActionSwitchFilter =
                        this.DetailActionSwitchFilter.FilterByApplyingValueDictionaryDefaults(
                            this.FilterParameter,
                            true);
                }

                if (this.DetailActionSwitchFilter != null)
                {
                    this.FilterBasedDecision = new UPCRMFilterBasedDecision(this.DetailActionSwitchFilter);
                }
            }

            container.ReplaceCaseSensitiveCharacters = this.ReplaceCaseSensitiveCharacters;

            List <UPCRMField> additionalFields = null;

            if (this.ExpandSettings != null)
            {
                Dictionary <string, UPCRMField> alternateExpandFields =
                    this.ExpandSettings.FieldsForAlternateExpands(true);
                List <UPCRMField> _additionalFields = this.AdditionalOutputFields != null
                                                         ? new List <UPCRMField>(this.AdditionalOutputFields)
                                                         : new List <UPCRMField>();

                if (alternateExpandFields != null)
                {
                    _additionalFields.AddRange(alternateExpandFields.Values.Where(field => container.ContainsField(field) == null));
                }

                additionalFields = _additionalFields;
            }
            else if (this.AdditionalOutputFields?.Count > 0)
            {
                additionalFields = this.AdditionalOutputFields;
            }

            if (additionalFields != null && additionalFields.Count > 0)
            {
                container.AddCrmFields(additionalFields);
            }

            var checkFilterFields = this.FilterBasedDecision?.FieldDictionary.Values.Select(x => x).ToList();

            if (checkFilterFields?.Count > 0)
            {
                container.AddCrmFields(checkFilterFields);
                this.FilterBasedDecision.UseCrmQuery(container);
            }

            if (this.ExpandSettings != null)
            {
                this.ExpandChecker = this.ExpandSettings.ExpandCheckerForCrmQuery(container);
            }

            if (!string.IsNullOrEmpty(this.LinkRecordIdentification))
            {
                container.SetLinkRecordIdentification(this.LinkRecordIdentification);
            }

            if (this.SearchFieldControl != null)
            {
                container.SetSearchConditionsFor(
                    searchValue,
                    this.SearchCRMFields,
                    this.MultiSearchCRMFields,
                    fullTextSearch);
            }
            else if (this.QuickSearchEntries != null)
            {
                if (!string.IsNullOrEmpty(searchValue))
                {
                    List <UPCRMField> crmFields = this.QuickSearchEntries.Select(entry => entry.CrmField).ToList();

                    container.SetSearchConditionsFor(searchValue, crmFields, fullTextSearch);
                }
            }

            if (!string.IsNullOrEmpty(this.SearchConfiguration?.FilterName))
            {
                UPConfigFilter filter = configStore.FilterByName(this.SearchConfiguration.FilterName);

                if (filter != null)
                {
                    filter = filter.FilterByApplyingDefaultReplacements();
                    filter = filter.FilterByApplyingValueDictionary(this.FilterParameter);
                    container.ApplyFilter(filter);
                }
            }

            if (this.FilterObject != null)
            {
                container.ApplyFilter(this.FilterObject);
            }
            else if (!string.IsNullOrEmpty(this.FilterName))
            {
                UPConfigFilter filter = configStore.FilterByName(this.FilterName);
                if (filter != null)
                {
                    filter = filter.FilterByApplyingDefaultReplacements();
                    filter = filter.FilterByApplyingValueDictionary(this.FilterParameter);
                    container.ApplyFilter(filter);
                }
            }

            if (filters != null)
            {
                foreach (UPConfigFilter filter in filters)
                {
                    if (this.FilterParameter != null)
                    {
                        container.ApplyFilterWithReplacementDictionary(filter, this.FilterParameter);
                    }
                    else
                    {
                        container.ApplyFilter(filter);
                    }
                }
            }

            return(container);
        }