コード例 #1
0
        /// <summary>
        /// Filters the by applying value dictionary defaults.
        /// </summary>
        /// <param name="valueDictionary">
        /// The value dictionary.
        /// </param>
        /// <param name="defaults">
        /// if set to <c>true</c> [defaults].
        /// </param>
        /// <returns>
        /// filter configurations
        /// </returns>
        public UPConfigFilter FilterByApplyingValueDictionaryDefaults(Dictionary <string, object> valueDictionary, bool defaults)
        {
            if (!defaults)
            {
                return((UPConfigFilter)this.QueryByApplyingValueDictionary(valueDictionary));
            }

            var replacements = UPConditionValueReplacement.ReplacementsFromValueParameterDictionary(valueDictionary, true);

            return((UPConfigFilter)this.QueryByApplyingReplacements(replacements));
        }
コード例 #2
0
        private UPSESingleAdditionalItemInformation(UPSerialEntry _serialEntry, string _configName, string _keyColumnName,
                                                    Dictionary <string, object> filterParameters, UPSESingleAdditionalItemInformationDelegate theDelegate)
        {
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;
            SearchAndList           searchAndListConfiguration = configStore.SearchAndListByName(_configName);

            if (searchAndListConfiguration == null)
            {
                throw new Exception("Search & List Config is null");
            }

            this.FieldControl = configStore.FieldControlByNameFromGroup("List", searchAndListConfiguration.FieldGroupName);
            if (this.FieldControl == null)
            {
                throw new Exception("FieldControl is null");
            }

            if (searchAndListConfiguration.FilterName != null)
            {
                this.Filter = configStore.FilterByName(searchAndListConfiguration.FilterName);
                if (this.Filter != null && filterParameters != null)
                {
                    this.Filter = this.Filter.FilterByApplyingReplacements(UPConditionValueReplacement.ReplacementsFromValueParameterDictionary(filterParameters));
                }

                if (this.Filter == null)
                {
                    throw new Exception("Filter is null");
                }
            }

            UPConfigFieldControlField field = this.FieldControl.FieldWithFunction(_keyColumnName);

            if (field == null)
            {
                throw new Exception("Field is null");
            }

            this.keyColumnIndex = field.TabIndependentFieldIndex;
            this.SerialEntry    = _serialEntry;
            this.KeyColumnName  = _keyColumnName;
            this.TheDelegate    = theDelegate;
        }
コード例 #3
0
        /// <summary>
        /// Applies the filter on source query parameters.
        /// </summary>
        /// <param name="crmQuery">The CRM query.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns></returns>
        public bool ApplyFilterOnSourceQueryParameters(UPContainerMetaInfo crmQuery, Dictionary <string, object> parameters)
        {
            if (this.CrmFilter != null)
            {
                if (parameters.Count > 0)
                {
                    UPConfigFilter replacedFilter = this.CrmFilter.
                                                    FilterByApplyingReplacements(UPConditionValueReplacement.ReplacementsFromValueParameterDictionary(parameters));

                    crmQuery.ApplyFilter(replacedFilter);
                }
                else
                {
                    crmQuery.ApplyFilter(this.CrmFilter);
                }
            }

            return(true);
        }
コード例 #4
0
        /// <summary>
        /// Filters for name.
        /// </summary>
        /// <param name="filtername">The filtername.</param>
        /// <param name="filterParameters">The filter parameters.</param>
        /// <returns>Filter</returns>
        public static UPMFilter FilterForName(string filtername, Dictionary <string, object> filterParameters = null)
        {
            var       configStore  = ConfigurationUnitStore.DefaultStore;
            var       configFilter = configStore.FilterByName(filtername);
            UPMFilter filter       = null;

            if (configFilter != null)
            {
                var selectCondition = configFilter.ConditionWith("Parameter:Select", true);
                if (selectCondition != null)
                {
                    return(FilterForConfigFilter(configFilter, selectCondition.ValueAtIndex(0), filterParameters, false));
                }

                selectCondition = configFilter.ConditionWith("Parameter:SingleSelect");
                if (selectCondition != null)
                {
                    return(FilterForConfigFilter(configFilter, selectCondition.ValueAtIndex(0), filterParameters, true));
                }

                var replacements = UPConditionValueReplacement.ReplacementsFromValueParameterDictionary(filterParameters, true);
                configFilter = configFilter.FilterByApplyingReplacements(replacements);
                var parameters = configFilter?.Parameters();
                if (parameters?.NumberOfParameters > 0)
                {
                    filter = GetFilter(filtername, parameters);
                }
                else
                {
                    var identifier = FieldIdentifier.IdentifierWithInfoAreaIdRecordIdFieldId(configFilter.InfoAreaId, filtername, string.Empty);
                    filter = new UPMNoParamFilter(identifier);
                }

                if (filter != null)
                {
                    filter.Name        = filtername;
                    filter.DisplayName = !string.IsNullOrEmpty(configFilter?.DisplayName) ? configFilter.DisplayName : filtername;
                }
            }

            return(filter);
        }
コード例 #5
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"));
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Results for row.
        /// </summary>
        /// <param name="serialEntryRow">The serial entry row.</param>
        /// <returns></returns>
        public override UPSerialEntryInfoResult ResultForRow(UPSERow serialEntryRow)
        {
            string sourceRecordIdentification           = StringExtensions.InfoAreaIdRecordId(serialEntryRow.SerialEntry.SourceInfoAreaId, serialEntryRow.RowRecordId);
            UPSerialEntryInfoResultFromCRMResult result = this.cachedResults.ValueOrDefault(sourceRecordIdentification);

            if (result != null)
            {
                return(result);
            }

            UPContainerMetaInfo crmQuery = new UPContainerMetaInfo(this.FieldControl);

            if (!this.IgnoreSourceRecord)
            {
                crmQuery.SetLinkRecordIdentification(sourceRecordIdentification);
            }

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

            if (this.Filter != null)
            {
                Dictionary <string, object> parameterValues = serialEntryRow.SourceFunctionValues();
                if (this.SerialEntry.InitialFieldValuesForDestination.Count > 0)
                {
                    if (parameterValues.Count > 0)
                    {
                        Dictionary <string, object> dict = new Dictionary <string, object>(this.SerialEntry.InitialFieldValuesForDestination);
                        foreach (var entry in parameterValues)
                        {
                            dict[entry.Key] = entry.Value;
                        }

                        parameterValues = dict;
                    }
                    else
                    {
                        parameterValues = this.SerialEntry.InitialFieldValuesForDestination;
                    }
                }

                if (parameterValues.Count > 0)
                {
                    UPConfigFilter applyFilter = this.Filter.FilterByApplyingReplacements(UPConditionValueReplacement.ReplacementsFromValueParameterDictionary(parameterValues));
                    if (applyFilter != null)
                    {
                        crmQuery.ApplyFilter(applyFilter);
                    }
                }
                else
                {
                    crmQuery.ApplyFilter(this.Filter);
                }
            }

            UPCRMResult crmResult = crmQuery.Find();

            result = new UPSerialEntryInfoResultFromCRMResult(crmResult, this);
            if (this.cachedResults == null)
            {
                this.cachedResults = new Dictionary <string, UPSerialEntryInfoResultFromCRMResult> {
                    { sourceRecordIdentification, result }
                };
            }
            else
            {
                this.cachedResults[sourceRecordIdentification] = result;
            }

            return(result);
        }