/// <summary>
 /// Initializes a new instance of the <see cref="AnalysisSourceField"/> class.
 /// </summary>
 /// <param name="analysisTable">Analysis table</param>
 /// <param name="field">Field</param>
 /// <param name="queryResultFieldIndex">Query result field index</param>
 /// <param name="subFieldQueryResultFieldIndices">Sub field query result field indices</param>
 public AnalysisSourceField(AnalysisTable analysisTable, UPConfigAnalysisField field, int queryResultFieldIndex, List <object> subFieldQueryResultFieldIndices)
     : base(analysisTable.Analysis, field.Key)
 {
     this.QueryResultFieldIndex           = queryResultFieldIndex;
     this.SubFieldQueryResultFieldIndices = subFieldQueryResultFieldIndices ?? new List <object>();
     this.ConfigField   = field;
     this.AnalysisTable = analysisTable;
     this.CrmFieldInfo  = UPCRMDataStore.DefaultStore.FieldInfoForInfoAreaFieldId(this.ConfigField.AnalysisTable.InfoAreaId, this.ConfigField.FieldId);
 }
示例#2
0
        private void ProcessConfigurationFields(
            UPConfigAnalysisTable analysisTable,
            Dictionary <string, object> sourceFieldDict,
            AnalysisTable table)
        {
            foreach (var field in analysisTable.Fields)
            {
                var fieldInfo = sourceFieldDict.ValueOrDefault(field.Key) as AnalysisMetaInfoFieldInfo;
                if (fieldInfo == null)
                {
                    continue;
                }

                List <object> subQueryFieldIndices = null;
                if (fieldInfo.SubFields?.Count > 0)
                {
                    subQueryFieldIndices = new List <object>();
                    foreach (AnalysisMetaInfoFieldInfo subInfo in fieldInfo.SubFields)
                    {
                        subQueryFieldIndices.Add(subInfo.FieldIndex);
                    }
                }

                var analysisSourceField =
                    new AnalysisSourceField(table, field, fieldInfo.FieldIndex, subQueryFieldIndices);
                this.fieldDict.SetObjectForKey(analysisSourceField, analysisSourceField.Key);
                this.sourceFields.Add(analysisSourceField);
                table.AddSourceField(analysisSourceField);
                this.ProcessCategory(analysisSourceField);

                this.ProcessXCategory(analysisSourceField);

                if (analysisSourceField.IsCurrency)
                {
                    this.SetCurrencyField(analysisSourceField);
                    this.hasCurrencyField = true;
                }
                else if (analysisSourceField.IsTableCurrency)
                {
                    table.AlternateCurrencyField = analysisSourceField;
                    this.hasCurrencyField        = true;
                }

                if (analysisSourceField.IsWeight)
                {
                    this.SetWeightField(analysisSourceField);
                }

                if (analysisSourceField.IsFilter)
                {
                    var analysisFilter = new AnalysisSourceFieldFilter(analysisSourceField);
                    this.filters.Add(analysisFilter);
                }
            }
        }
示例#3
0
        private void ProcessConfigurationTable()
        {
            foreach (var aTable in this.Analysis.Configuration.Tables)
            {
                var sourceTable = this.tablesForKey.ValueOrDefault(aTable.Key) as AnalysisMetaInfoTableInfo;
                if (sourceTable == null)
                {
                    continue;
                }

                var dataSourceTable = sourceTable.DataSourceTable;
                var table           = new AnalysisTable(this.Analysis, aTable, dataSourceTable.InfoAreaPositionInResult());
                this.tableDictByIndex.SetObjectForKey(table, aTable.TableNumber);
                this.tableDictByKey.SetObjectForKey(table, aTable.Key);
                var numberOfFields = dataSourceTable.NumberOfFields();
                this.fieldIndex = sourceTable.FirstFieldIndex;
                var sourceFieldDict = new Dictionary <string, object>();
                for (var index = 0; index < numberOfFields; index++)
                {
                    var sourceField = dataSourceTable.FieldAtIndex(index);
                    var fieldInfo   = new AnalysisMetaInfoFieldInfo(sourceTable, sourceField, this.fieldIndex++);
                    sourceFieldDict.SetObjectForKey(fieldInfo, fieldInfo.Key);
                }

                for (var index = 0; index < numberOfFields; index++)
                {
                    var sourceField = dataSourceTable.FieldAtIndex(index);
                    var fieldKey    = AnalysisMetaInfoFieldInfo.KeyForTableFieldId(sourceTable, sourceField.FieldId);
                    var fieldInfo   = sourceFieldDict.ValueOrDefault(fieldKey) as AnalysisMetaInfoFieldInfo;
                    if (fieldInfo == null)
                    {
                        continue;
                    }

                    var subFieldIndices = sourceField.SubFieldIndices();
                    if (subFieldIndices?.Count > 0)
                    {
                        foreach (var subFieldIndex in subFieldIndices)
                        {
                            var subFieldKey =
                                AnalysisMetaInfoFieldInfo.KeyForTableFieldId(sourceTable, subFieldIndex.ToInt());
                            var subFieldInfo = sourceFieldDict.ValueOrDefault(subFieldKey) as AnalysisMetaInfoFieldInfo;
                            if (subFieldInfo != null)
                            {
                                fieldInfo.AddSubField(subFieldInfo);
                            }
                        }
                    }
                }

                this.ProcessConfigurationFields(aTable, sourceFieldDict, table);
                var tableResultColumn = new AnalysisTableResultColumn(table);
                this.resultColumns.SetObjectForKey(tableResultColumn, table.Key);
            }
        }
示例#4
0
        /// <summary>
        /// Result column with table number field
        /// </summary>
        /// <param name="tableNumber">Table number</param>
        /// <param name="fieldId">Field id</param>
        /// <returns>Result column</returns>
        public AnalysisResultColumn ResultColumnWithTableNumberFieldId(int tableNumber, int fieldId)
        {
            string key;

            if (fieldId < 0)
            {
                AnalysisTable table = this.TableWithNumber(tableNumber);
                key = table.Key;
            }
            else
            {
                AnalysisField field = this.FieldWithTableNumberFieldId(tableNumber, fieldId);
                key = field.Key;
            }

            if (key?.Length > 0)
            {
                return(this.ResultColumnDictionary.ValueOrDefault(key) as AnalysisResultColumn);
            }

            return(null);
        }