예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UPConfigFieldControlField"/> class.
        /// </summary>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <param name="tabIndependentFieldIndex">
        /// Index of the tab independent field.
        /// </param>
        /// <param name="tabConfig">
        /// The tab configuration.
        /// </param>
        /// <param name="rootInfoAreaId">
        /// The root information area identifier.
        /// </param>
        /// <param name="rootLinkId">
        /// The root link identifier.
        /// </param>
        public UPConfigFieldControlField(
            UPConfigFieldControlField source,
            int tabIndependentFieldIndex,
            FieldControlTab tabConfig,
            string rootInfoAreaId,
            int rootLinkId)
        {
            if (rootInfoAreaId != null && rootInfoAreaId == source.Field.InfoAreaId && rootLinkId >= 0 && rootLinkId == source.Field.LinkId)
            {
                this.Field = UPCRMField.FieldWithFieldIdInfoAreaIdLinkId(source.Field.FieldId, source.Field.InfoAreaId, -1);
            }
            else
            {
                this.Field = source.Field;
            }

            this.TabIndependentFieldIndex = tabIndependentFieldIndex;
            this.Attributes        = source.Attributes;
            this.TargetFieldNumber = source.TargetFieldNumber;
            this.ExplicitLabel     = source.ExplicitLabel;
            this.Function          = source.Function;
            this.TabConfig         = tabConfig;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPConfigTableCaption"/> class.
        /// </summary>
        /// <param name="defArray">The definition array.</param>
        public UPConfigTableCaption(List <object> defArray)
        {
            if (defArray == null || defArray.Count < 6)
            {
                return;
            }

            this.UnitName     = defArray[0] as string;
            this.hasFieldMap  = false;
            this.InfoAreaId   = defArray[1] as string;
            this.PrefixString = defArray[2] as string;
            this.FormatString = defArray[3] as string;
            this.ImageName    = defArray[4] as string;

            var fielddefarray = (defArray[5] as JArray)?.ToObject <List <object> >();

            if (fielddefarray != null)
            {
                var count             = fielddefarray.Count;
                var arr               = new List <UPCRMField>(count);
                var currentArrayIndex = 1;
                for (var i = 0; i < count; i++)
                {
                    var fieldObject = (fielddefarray[i] as JArray)?.ToObject <List <object> >();
                    if (fieldObject == null)
                    {
                        continue;
                    }

                    var nr              = JObjectExtensions.ToInt(fieldObject[0]);
                    var fieldId         = JObjectExtensions.ToInt(fieldObject[1]);
                    var fieldInfoAreaId = fieldObject[2] as string;
                    var linkId          = JObjectExtensions.ToInt(fieldObject[3]);
                    if (this.hasFieldMap)
                    {
                        this.fieldMap.Add(nr);
                    }
                    else if (currentArrayIndex < nr)
                    {
                        this.fieldMap = new List <int>(count);
                        for (var j = 1; j < currentArrayIndex; j++)
                        {
                            this.fieldMap.Add(j);
                        }

                        this.hasFieldMap = true;
                        this.fieldMap.Add(nr);
                    }
                    else
                    {
                        ++currentArrayIndex;
                    }

                    arr.Add(UPCRMField.FieldWithFieldIdInfoAreaIdLinkId(fieldId, fieldInfoAreaId, linkId));
                }

                this.Fields = arr;
            }

            var specialdefs = defArray.Count > 6 ? (defArray[6] as JArray)?.ToObject <List <object> >() : null;

            if (specialdefs == null)
            {
                return;
            }

            var defCount = specialdefs.Count;
            var ar       = new List <UPConfigTableCaptionSpecialDefs>(defCount);

            for (var i = 0; i < defCount; i++)
            {
                ar.Add(new UPConfigTableCaptionSpecialDefs((specialdefs[i] as JArray)?.ToObject <List <object> >()));
            }

            this.SpecialDefArray = ar;
        }