コード例 #1
0
        /// <summary>
        /// Filters the by appending or filter.
        /// </summary>
        /// <param name="mergeFilter">
        /// The merge filter.
        /// </param>
        /// <returns>
        /// filter configurations
        /// </returns>
        public UPConfigFilter FilterByAppendingOrFilter(UPConfigFilter mergeFilter)
        {
            var rootTable = this.RootTable.TableByAppendingTableOrRelation(mergeFilter.RootTable, true);

            if (this.RootTable != rootTable)
            {
                return(new UPConfigFilter(this.UnitName, rootTable));
            }

            return(this);
        }
コード例 #2
0
        /// <summary>
        /// Filters the by applying array of value dictionaries parameters.
        /// </summary>
        /// <param name="valueDictionaryArray">
        /// The value dictionary array.
        /// </param>
        /// <param name="valueDictionaryForAll">
        /// The value dictionary for all.
        /// </param>
        /// <returns>
        /// filter configurations
        /// </returns>
        public UPConfigFilter FilterByApplyingArrayOfValueDictionariesParameters(
            List <Dictionary <string, object> > valueDictionaryArray,
            Dictionary <string, object> valueDictionaryForAll)
        {
            if (valueDictionaryArray.Count == 0)
            {
                return(null);
            }

            UPConfigFilter resultFilter    = null;
            var            emptyDictionary = false;

            foreach (var valueDictionary in valueDictionaryArray)
            {
                Dictionary <string, object> currentDictionary;
                if (valueDictionary.Any())
                {
                    if (emptyDictionary)
                    {
                        continue;
                    }

                    emptyDictionary   = true;
                    currentDictionary = valueDictionaryForAll;
                }
                else if (valueDictionaryForAll.Any())
                {
                    var dict = new Dictionary <string, object>(valueDictionaryForAll);
                    dict.Append(valueDictionary);
                    currentDictionary = dict;
                }
                else
                {
                    currentDictionary = valueDictionary;
                }

                var currentFilter = this.FilterByApplyingValueDictionary(currentDictionary);
                resultFilter = resultFilter == null
                                   ? currentFilter
                                   : resultFilter.FilterByAppendingOrFilter(currentFilter);
            }

            return(resultFilter);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPConfigCatalogAttributes"/> class.
        /// </summary>
        /// <param name="filter">
        /// The filter.
        /// </param>
        public UPConfigCatalogAttributes(UPConfigFilter filter)
        {
            var rootTable = filter?.RootTable;
            var arr       = rootTable?.QueryConditions(string.Empty, false);

            if (arr == null || arr.Count != 1)
            {
                return;
            }

            var codeQueryCondition = arr[0];

            this.CrmField  = UPCRMField.FieldWithFieldIdInfoAreaId(codeQueryCondition.FieldId, rootTable.InfoAreaId);
            this.FieldInfo = UPCRMDataStore.DefaultStore.FieldInfoForField(this.CrmField);
            if (this.FieldInfo?.FieldType == "X")
            {
                this.FixedCatalog  = true;
                this.CatalogNumber = this.FieldInfo.CatNo;
            }
            else if (this.FieldInfo?.FieldType == "K")
            {
                this.FixedCatalog  = false;
                this.CatalogNumber = this.FieldInfo.CatNo;
            }
            else
            {
                this.FixedCatalog  = false;
                this.CatalogNumber = -1;
            }

            arr = rootTable.QueryConditions("Image", false);
            var imageQueryCondition = arr != null && arr.Count > 0 ? arr[0] : null;

            arr = rootTable.QueryConditions("Color", false);
            var colorKeyQueryCondition = arr != null && arr.Count > 0 ? arr[0] : null;

            var catCodes   = codeQueryCondition?.FieldValues;
            var imageNames = imageQueryCondition?.FieldValues;
            var colorKeys  = colorKeyQueryCondition?.FieldValues;

            var catCodesTemp = catCodes != null ? new List <object>(catCodes) : new List <object>();

            catCodesTemp.Remove(string.Empty);
            catCodes = catCodesTemp;

            int count = catCodes.Count, colorKeysCount = colorKeys?.Count ?? 0, imageNamesCount = imageNames?.Count ?? 0;

            var dict          = new Dictionary <int, UPConfigCatalogValueAttributes>(count);
            var rawDict       = new Dictionary <string, UPConfigCatalogValueAttributes>(count);
            var orderedValues = new List <UPConfigCatalogValueAttributes>(count);

            for (var i = 0; i < count; i++)
            {
                var image = i < imageNamesCount ? imageNames[i] as string : string.Empty;
                var color = i < colorKeysCount ? colorKeys[i] as string : string.Empty;
                if (image.StartsWith("#"))
                {
                    image = image.Substring(1);
                }

                if (color.StartsWith("#"))
                {
                    color = color.Substring(1);
                }

                var valueAttr = this.CatalogNumber >= 0
                                    ? new UPConfigCatalogValueAttributes(
                    JObjectExtensions.ToInt(catCodes[i]),
                    color,
                    image)
                                    : new UPConfigCatalogValueAttributes(
                    JObjectExtensions.ToInt(catCodes[i]),
                    color,
                    image);

                dict.SetObjectForKey(valueAttr, valueAttr.Code);
                rawDict.SetObjectForKey(valueAttr, valueAttr.RawValue);
                orderedValues.Add(valueAttr);
            }

            this.ValuesByCode     = dict;
            this.ValuesByRawValue = rawDict;
            this.ValueArray       = orderedValues;
        }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UPCRMFilterBasedDecision"/> class.
 /// </summary>
 /// <param name="filter">
 /// The filter.
 /// </param>
 /// <param name="filterParameters">
 /// The filter parameters.
 /// </param>
 public UPCRMFilterBasedDecision(UPConfigFilter filter, Dictionary <string, object> filterParameters)
     : this(filter.FilterByApplyingValueDictionaryDefaults(filterParameters, true))
 {
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UPCRMFilterBasedDecision"/> class.
 /// </summary>
 /// <param name="filter">
 /// The filter.
 /// </param>
 public UPCRMFilterBasedDecision(UPConfigFilter filter)
 {
     this.Filter          = filter;
     this.FieldDictionary = filter.FieldsFromConditionFieldsForInfoAreaId(filter.InfoAreaId, true);
 }
コード例 #6
0
 /// <summary>
 /// Catalogs the attributes by filter.
 /// </summary>
 /// <param name="filter">
 /// The filter.
 /// </param>
 /// <returns>
 /// Catalog attributes configurations
 /// </returns>
 public UPConfigCatalogAttributes CatalogAttributesByFilter(UPConfigFilter filter)
 {
     return(filter == null ? null : new UPConfigCatalogAttributes(filter));
 }