private static string FormattedValueForResultRowFieldControlTabFieldIndex(UPCRMResultRow row, FieldControlTab tabConfig, int fieldIndex)
        {
            bool            found           = false;
            FieldAttributes attributes      = tabConfig.FieldAtIndex(fieldIndex).Attributes;
            List <string>   fieldValueArray = new List <string>(attributes.FieldCount);
            int             lastIndex       = fieldIndex + attributes.FieldCount;

            for (int i = fieldIndex; i < lastIndex; i++)
            {
                UPConfigFieldControlField field = tabConfig.FieldAtIndex(i);
                if (field != null)
                {
                    string v = row.ValueAtIndex(field.TabIndependentFieldIndex);
                    if (v != null)
                    {
                        fieldValueArray.Add(v);
                        if (v.Length > 1)
                        {
                            found = true;
                        }
                    }
                    else
                    {
                        fieldValueArray.Add(string.Empty);
                    }
                }
            }

            return(found ? attributes.FormatValues(fieldValueArray) : string.Empty);
        }
예제 #2
0
        // functionName == nil => all Fields
        private static List <UPMStringField> FieldsForResultRow(UPCRMResultRow row, string functionName, int tabIndex, bool addHidden)
        {
            List <UPMStringField> fields             = new List <UPMStringField>();
            FieldControlTab       sourceFieldControl = row.Result.MetaInfo.SourceFieldControl.TabAtIndex(tabIndex);
            int offset     = tabIndex == 0 ? 0 : row.Result.MetaInfo.SourceFieldControl.TabAtIndex(0).Fields.Count;
            int fieldCount = tabIndex == 0 ? sourceFieldControl.Fields.Count : row.NumberOfColumns;

            for (int rowFieldIndex = 0; rowFieldIndex < fieldCount;)
            {
                string fieldFunctionNames = sourceFieldControl.FieldAtIndex(rowFieldIndex)?.Function ?? string.Empty;
                var    functionNames      = fieldFunctionNames.Split(',').ToList();
                functionNames = functionNames.Count == 0 ? new List <string> {
                    string.Empty
                } : functionNames;
                UPConfigFieldControlField configField = sourceFieldControl.FieldAtIndex(rowFieldIndex);
                FieldAttributes           attributes  = configField?.Attributes;
                bool found = false;
                foreach (string fieldFunctionName in functionNames)
                {
                    if (functionName == null || fieldFunctionName.StartsWith(functionName))
                    {
                        UPMStringField stringField = new UPMStringField(new FieldIdentifier(row.RecordIdentificationAtIndex(0), configField.Field.FieldIdentification));
                        stringField.Hidden = attributes.Hide;
                        if (attributes.FieldCount > 0)
                        {
                            List <string> combineFields = new List <string>();
                            for (int fieldIndex = 0; fieldIndex < attributes.FieldCount; fieldIndex++)
                            {
                                combineFields.Add(row.ValueAtIndex(rowFieldIndex + offset));
                                rowFieldIndex++;
                            }

                            stringField.StringValue = attributes.FormatValues(combineFields);
                        }
                        else
                        {
                            stringField.StringValue = row.ValueAtIndex(rowFieldIndex + offset);
                            rowFieldIndex++;
                        }

                        if (addHidden || !stringField.Hidden)
                        {
                            fields.Add(stringField);
                        }

                        found = true;
                    }
                }

                if (!found)
                {
                    rowFieldIndex++;
                }
            }

            return(fields);
        }
예제 #3
0
        /// <summary>
        /// The formatted field value at index.
        /// </summary>
        /// <param name="index">
        /// The index.
        /// </param>
        /// <param name="offset">
        /// The offset.
        /// </param>
        /// <param name="fieldControl">
        /// The field control.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public string FormattedFieldValueAtIndex(int index, int?offset, FieldControl fieldControl)
        {
            UPConfigFieldControlField configField     = fieldControl.FieldAtIndex(index);
            FieldAttributes           fieldAttributes = configField.Attributes;
            string result = null;
            int    innerOffset;

            innerOffset = offset ?? 0;

            if (fieldAttributes.FieldCount > 1)
            {
                List <string> values = !string.IsNullOrEmpty(fieldAttributes.ExtendedOptionForKey("GPS"))
                    ? new List <string> {
                    this.RawValueAtIndex(configField.TabIndependentFieldIndex)
                }
                    : new List <string> {
                    this.ValueAtIndex(configField.TabIndependentFieldIndex)
                };

                int k;
                for (k = 1; k < fieldAttributes.FieldCount; k++)
                {
                    UPConfigFieldControlField childfieldConfig = fieldControl.FieldAtIndex(index + ++innerOffset);
                    if (childfieldConfig != null)
                    {
                        string value = (!string.IsNullOrEmpty(fieldAttributes.ExtendedOptionForKey("GPS"))
                            ? this.RawValueAtIndex(childfieldConfig.TabIndependentFieldIndex)
                            : this.ValueAtIndex(childfieldConfig.TabIndependentFieldIndex)) ?? string.Empty;

                        values.Add(value);
                    }
                }

                if (!string.IsNullOrEmpty(fieldAttributes.ExtendedOptionForKey("GPS")))
                {
                    bool firstFieldLongtitude = fieldAttributes.ExtendedOptionForKey("GPS") == "X";
                    if (values.Count >= 2)
                    {
#if PORTING
                        int longtitudeNumberValue;
                        int latitudeNumberValue;
                        if (firstFieldLongtitude)
                        {
                            longtitudeNumberValue = values[0].GpsLongtitudeNumberValue();
                            latitudeNumberValue   = values[1].GpsLatitudeNumberValue();
                        }
                        else
                        {
                            longtitudeNumberValue = values[1].GpsLongtitudeNumberValue();
                            latitudeNumberValue   = values[0].GpsLatitudeNumberValue();
                        }

                        string longtitudeString = longtitudeNumberValue.FormatedLongtitudeValue();
                        string lattitudeString  = latitudeNumberValue.FormatedLatitudeValue();
                        result = $"{lattitudeString} / {longtitudeString}";
#endif
                    }
                }
                else
                {
                    result = fieldAttributes.FormatValues(values);
                }
            }
            else
            {
                result = this.ValueAtIndex(configField.TabIndependentFieldIndex);
            }

            return(result);
        }