/// <summary>
        /// Synchronizes the fixed catalogs.
        /// </summary>
        /// <param name="catalogDefs">
        /// The catalog defs.
        /// </param>
        /// <returns>
        /// 1 if failed, else 0
        /// </returns>
        public int SyncFixedCatalogs(List <object> catalogDefs)
        {
            if (catalogDefs == null)
            {
                return(0);
            }

            foreach (var catdef in catalogDefs)
            {
                var valDef = (catdef as JArray)?.ToObject <List <object> >();
                if (valDef == null)
                {
                    continue;
                }

                var ret = this.SyncFixedCatalogValues(
                    JObjectExtensions.ToInt(valDef[0]),
                    (valDef[1] as JArray)?.ToObject <List <object> >());
                if (ret == -1)
                {
                    ret = 0;
                }

                // ignore unknown catalogs
                if (ret > 0)
                {
                    continue;
                }
            }

            return(0);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPConfigTreeViewTable"/> class.
        /// </summary>
        /// <param name="definition">
        /// The definition.
        /// </param>
        /// <param name="treeView">
        /// The _tree view.
        /// </param>
        public UPConfigTreeViewTable(List <object> definition, UPConfigTreeView treeView)
        {
            if (definition == null)
            {
                return;
            }

            this.TreeView          = treeView;
            this.Nr                = JObjectExtensions.ToInt(definition[0]);
            this.InfoAreaId        = definition[2] as string;
            this.LinkId            = JObjectExtensions.ToInt(definition[3]);
            this.RelationName      = definition[4] as string;
            this.SearchAndListName = definition[5] as string;
            this.ExpandName        = definition[6] as string;
            this.TableCaptionName  = definition[7] as string;
            this.RootMenuLabel     = definition[8] as string;
            this.MenuLabel         = definition[9] as string;
            this.Flags             = (UPConfigTreeViewTableFlags)JObjectExtensions.ToInt(definition[10]);
            this.FilterName        = definition[11] as string;

            if (definition.Count > 12)
            {
                this.RecordCustomControl   = definition[12] as string;
                this.InfoAreaCustomControl = definition[13] as string;
            }

            if (definition.Count > 14)
            {
                this.RecordCount = JObjectExtensions.ToInt(definition[14]);
                this.Label       = definition[15] as string;
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="UPConfigResource"/> class.
 /// </summary>
 /// <param name="defArray">
 /// The definition array.
 /// </param>
 public UPConfigResource(List <object> defArray)
 {
     this.UnitName = defArray[0] as string;
     this.FileName = (string)defArray[1];
     this.Label    = (string)defArray[2];
     this.ConfigId = defArray.Count > 3 ? JObjectExtensions.ToInt(defArray[3]) : -1;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigFieldControlTabAttribute"/> class.
 /// </summary>
 /// <param name="definition">
 /// The definition.
 /// </param>
 public ConfigFieldControlTabAttribute(List <object> definition)
 {
     this.Key       = definition[0] as string;
     this.Value     = definition[1] as string;
     this.EditMode  = JObjectExtensions.ToInt(definition[2]);
     this.ValueType = definition[3] as string;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPConfigAnalysisCategory"/> class.
        /// </summary>
        /// <param name="definition">
        /// The definition.
        /// </param>
        public UPConfigAnalysisCategory(List <object> definition)
        {
            this.Name       = definition[0] as string;
            this.MultiValue = JObjectExtensions.ToInt(definition[1]);
            this.OtherMode  = JObjectExtensions.ToInt(definition[2]);
            this.Roll       = definition[3] as string;
            this.Label      = definition[4] as string;
            this.OtherLabel = definition[5] as string;
            if (string.IsNullOrEmpty(this.Label))
            {
                this.Label = this.Name;
            }

            var valueDefs = (definition[6] as JArray)?.ToObject <List <object> >();

            if (valueDefs == null || !valueDefs.Any())
            {
                return;
            }

            var values = new List <UPConfigAnalysisCategoryValue>(valueDefs.Count);

            foreach (JArray valueDef in valueDefs)
            {
                var value = new UPConfigAnalysisCategoryValue(valueDef?.ToObject <List <object> >());
                values.Add(value);
            }

            this.Values = values;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPConfigAnalysisCategoryValue"/> class.
        /// </summary>
        /// <param name="definition">
        /// The definition.
        /// </param>
        public UPConfigAnalysisCategoryValue(List <object> definition)
        {
            this.ValueNumber     = JObjectExtensions.ToInt(definition[0]);
            this.RefValue        = definition[1] as string;
            this.SubCategoryName = definition[2] as string;
            this.Label           = definition[3] as string;

            var conditionDefs = (definition[4] as JArray)?.ToObject <List <object> >();

            if (conditionDefs != null && conditionDefs.Any())
            {
                var _conditions = new List <UPConfigAnalysisCategoryCondition>(conditionDefs.Count);
                foreach (JArray conditionDef in conditionDefs)
                {
                    if (conditionDef == null)
                    {
                        continue;
                    }

                    var condition = new UPConfigAnalysisCategoryCondition(conditionDef?.ToObject <List <object> >());
                    _conditions.Add(condition);
                }

                this.Conditions = _conditions;
            }

            if (string.IsNullOrEmpty(this.Label))
            {
                this.Label = this.RefValue;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Options the is set.
        /// </summary>
        /// <param name="optionName">
        /// Name of the option.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool OptionIsSet(string optionName)
        {
            var o = this.Options?.ValueOrDefault(optionName);

            if (o == null)
            {
                return(false);
            }

            if (o is int)
            {
                return(JObjectExtensions.ToInt(o) != 0);
            }

            var p = o as string[];

            if (p != null && p.Length == 0)
            {
                return(true);
            }

            if (p == null)
            {
                return(false);
            }

            var p1 = p[0];

            return(p1 == "true" || JObjectExtensions.ToInt(p1) != 0);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPConfigHeader"/> class.
        /// </summary>
        /// <param name="defarray">
        /// The defarray.
        /// </param>
        public UPConfigHeader(List <object> defarray)
        {
            this.UnitName    = defarray[0] as string;
            this.InfoAreaId  = (string)defarray[1];
            this.ImageName   = (string)defarray[2];
            this.Label       = (string)defarray[3];
            this.Flags       = JObjectExtensions.ToInt(defarray[4]);
            this.ButtonNames = (defarray[5] as JArray)?.ToObject <List <string> >();

            var subviewarray = (defarray[6] as JArray)?.ToObject <List <object> >();

            if (subviewarray == null)
            {
                return;
            }

            this.SubViews = new List <UPConfigHeaderSubView>(subviewarray.Count);
            var subViewCount = 0;

            foreach (JArray subViewDef in subviewarray)
            {
                var def = subViewDef?.ToObject <List <object> >();
                if (def == null)
                {
                    continue;
                }

                this.SubViews.Add(new UPConfigHeaderSubView(def, $"{this.UnitName}:{subViewCount++}"));
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UPConfigAnalysisResultColumn"/> class.
 /// </summary>
 /// <param name="definition">
 /// The definition.
 /// </param>
 /// <param name="analysis">
 /// The analysis.
 /// </param>
 public UPConfigAnalysisResultColumn(List <object> definition, UPConfigAnalysis analysis)
 {
     this.FieldTableId    = JObjectExtensions.ToInt(definition[0]);
     this.FieldId         = JObjectExtensions.ToInt(definition[1]);
     this.AggregationType = definition[2] as string;
     this.CategoryName    = definition[3] as string;
     this.ValueName       = definition[4] as string;
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UPConfigAnalysis"/> class.
        /// </summary>
        /// <param name="definition">
        /// The definition.
        /// </param>
        public UPConfigAnalysis(List <object> definition)
        {
            this.QueryName = definition[1] as string;
            var tableDefs = (definition[2] as JArray)?.ToObject <List <object> >();

            if (tableDefs != null && tableDefs.Any())
            {
                var tables = new List <UPConfigAnalysisTable>(tableDefs.Count);
                foreach (JArray tableDef in tableDefs)
                {
                    var table = new UPConfigAnalysisTable(tableDef?.ToObject <List <object> >(), this);
                    tables.Add(table);
                }

                this.Tables = tables;
            }

            var valueDefs = (definition[4] as JArray)?.ToObject <List <object> >();

            if (valueDefs != null && valueDefs.Count > 0)
            {
                var values = new List <UPConfigAnalysisValue>(valueDefs.Count);
                foreach (JArray valueDef in valueDefs)
                {
                    var value = new UPConfigAnalysisValue(valueDef?.ToObject <List <object> >(), this);
                    values.Add(value);
                }

                this.Values = values;
            }

            var resultColumnDefs = (definition[3] as JArray)?.ToObject <List <object> >();

            if (resultColumnDefs != null && resultColumnDefs.Count > 0)
            {
                var resultColumns = new List <UPConfigAnalysisResultColumn>(resultColumnDefs.Count);
                foreach (JArray resultColumnDef in resultColumnDefs)
                {
                    var resultColumn = new UPConfigAnalysisResultColumn(resultColumnDef?.ToObject <List <object> >(), this);
                    resultColumns.Add(resultColumn);
                }

                this.ResultColumns = resultColumns;
            }

            if (definition.Count < 8)
            {
                this.MaxBars = 0;
                this.Options = 0;
                this.Flags   = 0;
            }
            else
            {
                this.MaxBars = JObjectExtensions.ToInt(definition[5]);
                this.Options = JObjectExtensions.ToInt(definition[6]);
                this.Flags   = JObjectExtensions.ToInt(definition[7]);
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UPConfigAnalysisValue"/> class.
 /// </summary>
 /// <param name="definition">
 /// The definition.
 /// </param>
 /// <param name="analysis">
 /// The analysis.
 /// </param>
 public UPConfigAnalysisValue(List <object> definition, UPConfigAnalysis analysis)
 {
     this.ValueNumber  = JObjectExtensions.ToInt(definition[0]);
     this.Name         = definition[1] as string;
     this.FixedType    = definition[2] as string;
     this.Label        = definition[3] as string;
     this.Parameter    = definition[4] as string;
     this.OptionString = definition[5] as string;
     this.Options      = this.StringFromOptionString(this.OptionString);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="QuickSearchEntry"/> class.
 /// </summary>
 /// <param name="def">
 /// The definition.
 /// </param>
 public QuickSearchEntry(List <object> def)
 {
     this.InfoAreaId = (string)def[0];
     this.FieldId    = JObjectExtensions.ToInt(def[1]);
     this.MenuName   = (string)def[2];
     if (string.IsNullOrWhiteSpace(this.MenuName))
     {
         this.MenuName = "SHOWRECORD";
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPConfigHeaderSubView"/> class.
        /// </summary>
        /// <param name="defarray">
        /// The defarray.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        public UPConfigHeaderSubView(List <object> defarray, string name)
        {
            this.Label = (string)defarray[0];
            var viewReferenceDef = (defarray[1] as JArray)?.ToObject <List <object> >();

            this.ViewReference = viewReferenceDef != null ? new ViewReference(viewReferenceDef, $"Tab:{name}") : null;

            this.InfoAreaId = (string)defarray[2];
            this.LinkId     = JObjectExtensions.ToInt(defarray[3]);
            this.Options    = (string)defarray[4];
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Alls the array fields are empty.
        /// </summary>
        /// <param name="fieldValues">
        /// The field values.
        /// </param>
        /// <returns>
        /// true if all fields are empty; else false
        /// </returns>
        public bool AllArrayFieldsAreEmpty(List <string> fieldValues)
        {
            foreach (var n in this.EmptyFieldArray)
            {
                var num = JObjectExtensions.ToInt(n);
                if (fieldValues.Count > num && !string.IsNullOrEmpty(fieldValues[num]))
                {
                    return(false);
                }
            }

            return(true);
        }
        /// <summary>
        /// Synchronizes the variable catalogs.
        /// </summary>
        /// <param name="catalogDefs">
        /// The catalog defs.
        /// </param>
        /// <returns>
        /// 1 if failed, else 0
        /// </returns>
        public int SyncVariableCatalogs(List <object> catalogDefs)
        {
            var    ret       = 0;
            var    first     = true;
            string timestamp = null;

            foreach (var catdef in catalogDefs)
            {
                var catdefArray = (catdef as JArray)?.ToObject <List <object> >();
                if (catdefArray == null)
                {
                    continue;
                }

                ret = this.SyncVariableCatalogValues(
                    JObjectExtensions.ToInt(catdefArray[0]),
                    (catdefArray[1] as JArray)?.ToObject <List <object> >());
                if (ret == -1)
                {
                    ret = 0;
                }

                // ignore unknown catalogs
                if (ret > 0)
                {
                    continue;
                }

                if (!first || catdefArray.Count <= 2)
                {
                    continue;
                }

                timestamp = catdefArray[2] as string;
                first     = false;
            }

            if (!string.IsNullOrEmpty(timestamp))
            {
                this.DataStore.ReportSyncWithDatasetRecordCountTimestampFullSyncInfoAreaId(
                    "VariableCatalogs",
                    0,
                    timestamp,
                    false,
                    null);
            }

            return(ret);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FieldControlSortField"/> class.
        /// </summary>
        /// <param name="def">
        /// The definition.
        /// </param>
        /// <param name="infoAreaId">
        /// The information area identifier.
        /// </param>
        public FieldControlSortField(List <object> def, string infoAreaId)
        {
            this.InfoAreaId = infoAreaId;
            this.FieldIndex = JObjectExtensions.ToInt(def[0]);
            this.Ascending  = JObjectExtensions.ToInt(def[1]) == 0;
            if (def.Count() > 2)
            {
                this.InfoAreaId = (string)def[2];
            }
            else
            {
                this.InfoAreaId = infoAreaId;
            }

            this.LinkId = -1;
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UPConfigAnalysisField"/> class.
        /// </summary>
        /// <param name="definition">
        /// The definition.
        /// </param>
        /// <param name="analysisTable">
        /// The analysis table.
        /// </param>
        public UPConfigAnalysisField(List <object> definition, UPConfigAnalysisTable analysisTable)
        {
            if (definition == null || definition.Count < 8)
            {
                return;
            }

            this.AnalysisTable = analysisTable;
            this.FieldId       = JObjectExtensions.ToInt(definition[0]);
            this.Flags         = JObjectExtensions.ToInt(definition[1]);
            this.DefaultValue  = definition[2] as string;
            this.DefaultEnd    = definition[3] as string;
            this.CategoryName  = definition[4] as string;
            this.ListColNr     = JObjectExtensions.ToInt(definition[5]);
            this.ListWidth     = JObjectExtensions.ToInt(definition[6]);
            this.Options       = definition[7] as string;
            this.Slices        = JObjectExtensions.ToInt(definition[8]);
        }
        /// <summary>
        /// Creates Image Field
        /// </summary>
        /// <param name="fieldAttributes">
        /// Field Configuration Attributes
        /// </param>
        /// <returns>
        /// Image <see cref="UPMEditField"/>.
        /// </returns>
        private UPMImageEditField CreateImageField(FieldAttributes fieldAttributes)
        {
            var imageEditField = new UPMImageEditField(FieldIdentifier);
            var attribute      = fieldAttributes.AttributForId((int)FieldAttr.Image);
            var previewWidth   = attribute.ValueOptionsForKey(KeyPreviewWidth);
            var previewHeight  = attribute.ValueOptionsForKey(KeyPreviewHeight);

            imageEditField.ImageDocumentMaxSize = new Size(176, 176);

            if (previewWidth != null && previewHeight != null)
            {
                var width  = JObjectExtensions.ToInt(previewWidth);
                var height = JObjectExtensions.ToInt(previewHeight);
                imageEditField.ImageDocumentMaxSize = new Size(width, height);
            }

            var explicitFileName = attribute.ValueOptionsForKey(KeyFileNamePattern) as string;

            if (explicitFileName != null)
            {
                imageEditField.ExplicitFileName = explicitFileName;
            }

            var documentKey = Value;

            if (!string.IsNullOrWhiteSpace(documentKey))
            {
                var documentManager = new DocumentManager();
                var documentData    = documentManager.DocumentForKey(documentKey);
                imageEditField.ImageDocument = new UPMDocument(
                    FieldIdentifier,
                    null,
                    null,
                    null,
                    null,
                    documentData?.Url ?? ServerSession.CurrentSession.DocumentRequestUrlForDocumentKey(documentKey),
                    documentData?.Title,
                    null,
                    null,
                    documentData?.UrlForD1RecordId());
            }

            return(imageEditField);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="UPConfigButton"/> class.
        /// </summary>
        /// <param name="defarray">
        /// The defarray.
        /// </param>
        public UPConfigButton(List <object> defarray)
        {
            if (defarray == null || defarray.Count < 4)
            {
                return;
            }

            this.UnitName  = (string)defarray[0];
            this.Label     = (string)defarray[1];
            this.ImageName = (string)defarray[2];

            var viewReferenceDef = (defarray[3] as JArray)?.ToObject <List <object> >();

            this.ViewReference = viewReferenceDef != null
                                     ? new ViewReference(viewReferenceDef, $"Button:{this.UnitName}")
                                     : null;

            this.Flags = defarray.Count < 5 ? 0 : (ConfigButtonFlags)JObjectExtensions.ToInt(defarray[4]);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UPConfigQueryTable"/> class.
        /// </summary>
        /// <param name="definition">
        /// The definition.
        /// </param>
        /// <param name="isQuery">
        /// if set to <c>true</c> [is query].
        /// </param>
        public UPConfigQueryTable(List <object> definition, bool isQuery)
        {
            this.InfoAreaId     = (string)definition[0];
            this.LinkId         = JObjectExtensions.ToInt(definition[1]);
            this.ParentRelation = (string)definition[2];
            if (!isQuery)
            {
                if (this.ParentRelation == "WITH")
                {
                    this.ParentRelation = "HAVING";
                }
                else if (this.ParentRelation == "WITHOPTIONAL")
                {
                    this.ParentRelation = "HAVINGOPTIONAL";
                }
            }

            var conditiondef = (definition[3] as JArray)?.ToObject <List <object> >();

            if (conditiondef != null)
            {
                this.Condition = new UPConfigQueryCondition(conditiondef, this.InfoAreaId);
            }

            var subtableDefs = (definition[4] as JArray)?.ToObject <List <object> >();

            if (subtableDefs != null)
            {
                var count = subtableDefs.Count;
                var arr   = new List <UPConfigQueryTable>(count);
                for (var i = 0; i < count; i++)
                {
                    arr.Add(new UPConfigQueryTable((subtableDefs[i] as JArray)?.ToObject <List <object> >(), isQuery));
                }

                this.SubTables = arr;
            }

            if (definition.Count > 5)
            {
                this.Alias = (string)definition[5];
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UPConfigAnalysisTable"/> class.
        /// </summary>
        /// <param name="definition">
        /// The definition.
        /// </param>
        /// <param name="analysis">
        /// The analysis.
        /// </param>
        public UPConfigAnalysisTable(List <object> definition, UPConfigAnalysis analysis)
        {
            if (definition == null)
            {
                return;
            }

            this.InfoAreaId  = definition[0] as string;
            this.Occurrence  = JObjectExtensions.ToInt(definition[1]);
            this.TableNumber = JObjectExtensions.ToInt(definition[2]);
            var fieldDefs = (definition[3] as JArray)?.ToObject <List <object> >();

            if (fieldDefs != null && fieldDefs.Count > 0)
            {
                var fields = new List <UPConfigAnalysisField>(fieldDefs.Count);
                foreach (JArray fieldDef in fieldDefs)
                {
                    var field = new UPConfigAnalysisField(fieldDef?.ToObject <List <object> >(), this);
                    fields.Add(field);
                }

                this.Fields = fields;
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UPCatalogValue"/> class.
        /// </summary>
        /// <param name="def">
        /// The definition.
        /// </param>
        public UPCatalogValue(List <object> def)
        {
            if (def == null)
            {
                return;
            }

            this.Code       = JObjectExtensions.ToInt(def[0]);
            this.Text       = (string)def[1];
            this.ExtKey     = (string)def[2];
            this.Tenant     = JObjectExtensions.ToInt(def[3]);
            this.ParentCode = def.Count > 4 ? JObjectExtensions.ToInt(def[4]) : 0;

            if (def.Count > 6)
            {
                this.Sortinfo = JObjectExtensions.ToInt(def[5]);
                this.Access   = JObjectExtensions.ToInt(def[6]);
            }
            else
            {
                this.Sortinfo = 0;
                this.Access   = 1;
            }
        }
        /// <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;
        }
        /// <summary>
        /// Parents the context changed value.
        /// </summary>
        /// <param name="parentContext">
        /// The parent context.
        /// </param>
        /// <param name="_value">
        /// The _value.
        /// </param>
        /// <returns>
        /// The <see cref="List"/>.
        /// </returns>
        public override List <IIdentifier> ParentContextChangedValue(UPEditFieldContext parentContext, string _value)
        {
            var intValue = JObjectExtensions.ToInt(_value);
            var values   = this.Catalog.SortedValuesForParentValueIncludeHidden(intValue, false);
            var field    = (UPMCatalogEditField)this.EditField;

            field.ResetPossibleValues();
            if (this.lockedCurrentValues?.Count > 0 && intValue == this.lockedParentValue)
            {
                var extendedArray = new List <UPCatalogValue>(values);
                extendedArray.AddRange(this.lockedCurrentValues);
                values = extendedArray;
            }

            var sortOrder         = new List <string>();
            var currentValue      = this.Value;
            var currentValueFound = false;

            // Leer Eintrag
            if (!this.MultiSelect)
            {
                var possibleValue = new UPMCatalogPossibleValue {
                    Key = "0"
                };
                var valueField = new UPMStringField(StringIdentifier.IdentifierWithStringId("x"))
                {
                    StringValue = string.Empty
                };

                possibleValue.TitleLabelField = valueField;
                field.AddPossibleValue(possibleValue);
                sortOrder.Add("0");
            }

            foreach (var value in values)
            {
                var possibleValue = new UPMCatalogPossibleValue
                {
                    Key             = value.CodeKey,
                    TitleLabelField = new UPMStringField(StringIdentifier.IdentifierWithStringId("x"))
                    {
                        StringValue = value.Text
                    }
                };

                field.AddPossibleValue(possibleValue);
                sortOrder.Add(value.CodeKey);
                if (value.CodeKey == currentValue)
                {
                    currentValueFound = true;
                }
            }

            field.ExplicitKeyOrder = sortOrder;
            if (!currentValueFound)
            {
                this.editField.FieldValue = !this.MultiSelect ? "0" : null;
            }

            return(this.editField.Identifier != null ? new List <IIdentifier> {
                this.editField.Identifier
            } : null);
        }
        /// <summary>
        /// Creates the edit field.
        /// </summary>
        /// <returns>
        /// The <see cref="UPMEditField"/>.
        /// </returns>
        public override UPMEditField CreateEditField()
        {
            var field = new UPMCatalogEditField(this.FieldIdentifier, this.MultiSelect);

            if (this.MultiSelect)
            {
                field.MultiSelectMaxCount = this.ChildFields.Count + 1;
            }

            var possibleValues   = this.Catalog?.TextValuesForFieldValues(true);
            var explicitKeyOrder = this.Catalog != null &&
                                   ConfigurationUnitStore.DefaultStore.ConfigValueIsSet("FixedCatalog.SortByCode")
                                       ? this.Catalog.ExplicitKeyOrderByCodeEmptyValueIncludeHidden(false, false)
                                       : this.Catalog?.ExplicitKeyOrderEmptyValueIncludeHidden(false, false);

            var attributes =
                ConfigurationUnitStore.DefaultStore.CatalogAttributesForInfoAreaIdFieldId(
                    this.FieldConfig.InfoAreaId,
                    this.FieldConfig.FieldId);
            var valueForCode0 = possibleValues.ValueOrDefault("0");

            if (string.IsNullOrEmpty(valueForCode0))
            {
                field.NullValueKey = "0";
            }
            else
            {
                field.NullValueText = valueForCode0;
            }

            foreach (var p in possibleValues ?? new Dictionary <string, string>())
            {
                var possibleValue = new UPMCatalogPossibleValue
                {
                    Key             = p.Key,
                    TitleLabelField = new UPMStringField(StringIdentifier.IdentifierWithStringId("x"))
                    {
                        StringValue = p.Value
                    }
                };

                if (!this.MultiSelect || !p.Key.Equals(field.NullValueKey))
                {
                    field.AddPossibleValue(possibleValue);
                }
            }

            var allKeys = field.AllKeysFromPossibleValues;

            foreach (var theObject in allKeys)
            {
                var temp = attributes?.ValuesByCode?.ValueOrDefault(JObjectExtensions.ToInt(theObject));
                if (temp == null)
                {
                    continue;
                }

                var possibleValue = field.PossibleValueForKey(theObject);
                var colorString   = temp.ColorKey;
                if (!string.IsNullOrEmpty(colorString))
                {
                    var color = AureaColor.ColorWithString(colorString);
                    possibleValue.IndicatorColor = color;
                }

                possibleValue.ImageString = temp.ImageName;
            }

            this.ApplyAttributesOnEditFieldConfig(field, this.FieldConfig);
            if (explicitKeyOrder != null)
            {
                field.ExplicitKeyOrder = explicitKeyOrder;
            }

            return(field);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UPConfigFieldControlField"/> class.
        /// </summary>
        /// <param name="def">
        /// The definition.
        /// </param>
        /// <param name="tabIndependentFieldIndex">
        /// Index of the tab independent field.
        /// </param>
        /// <param name="tabConfig">
        /// The tab configuration.
        /// </param>
        public UPConfigFieldControlField(List <object> def, int tabIndependentFieldIndex, FieldControlTab tabConfig)
        {
            var linkId = 0;

            if (def.Count > 7)
            {
                linkId = JObjectExtensions.ToInt(def[7]);
            }

            var fieldattributedef = (def[2] as JArray)?.ToObject <List <object> >();

            this.Attributes = fieldattributedef != null
                                  ? new FieldAttributes(fieldattributedef)
                                  : FieldAttributes.NoAttribute;

            UPCRMFieldParentLink fieldParentLink = null;
            var parentLinkString = this.Attributes.ExtendedOptionForKey("parentLink");

            if (!string.IsNullOrEmpty(parentLinkString))
            {
                fieldParentLink = UPCRMFieldParentLink.LinkFromString(parentLinkString);
            }

            if (fieldParentLink != null)
            {
                this.Field = new UPCRMField(
                    JObjectExtensions.ToInt(def[1]),
                    (string)def[0],
                    linkId > 0 ? linkId : -1,
                    fieldParentLink);
            }
            else if (linkId > 0)
            {
                this.Field = new UPCRMField(JObjectExtensions.ToInt(def[1]), (string)def[0], linkId);
            }
            else
            {
                this.Field = new UPCRMField(JObjectExtensions.ToInt(def[1]), (string)def[0]);
            }

            if (def.Count > 3)
            {
                this.TargetFieldNumber = JObjectExtensions.ToInt(def[3]);
            }

            var val = def[4] as string;

            if (val != null)
            {
                this.ExplicitLabel = val;
            }

            // val = [def objectAtIndex:5];
            // if (val != [NSNull null]) tooltip = (NSString *) val;
            if (def.Count() > 6)
            {
                val = def[6] as string;
                if (val != null)
                {
                    this.Function = val;
                }
            }

            this.TabConfig = tabConfig;
            this.TabIndependentFieldIndex = tabIndependentFieldIndex;
        }
        /// <summary>
        /// Adds the link to table information link definition.
        /// </summary>
        /// <param name="tableInfo">
        /// The table information.
        /// </param>
        /// <param name="linkDefArray">
        /// The link definition array.
        /// </param>
        private void AddLink(TableInfo tableInfo, JArray linkDefArray)
        {
            var sourceFieldId = -1;
            var destFieldId   = -1;
            int linkFlag;

            if (linkDefArray.Count > 4)
            {
                sourceFieldId = JObjectExtensions.ToInt(linkDefArray[4]);
                destFieldId   = JObjectExtensions.ToInt(linkDefArray[5]);
            }
            else
            {
                sourceFieldId = -1;
                destFieldId   = -1;
            }

            if (linkDefArray.Count > 7)
            {
                linkFlag = JObjectExtensions.ToInt(linkDefArray[7]);
            }
            else
            {
                linkFlag = 0;
            }

            var arr = linkDefArray.Count > 6 ? linkDefArray[6] as JArray : null;

            if (arr == null)
            {
                return;
            }

            var linkFieldCount          = arr.Count;
            var sourceFieldIds          = new int[linkFieldCount];
            var destinationFieldIds     = new int[linkFieldCount];
            var sourceValuesBuffer      = new string[linkFieldCount];
            var destinationValuesBuffer = new string[linkFieldCount];

            for (var i = 0; i < arr.Count; i++)
            {
                var fieldArray = arr[i] as JArray;
                sourceFieldIds[i]      = JObjectExtensions.ToInt(fieldArray?[0]);
                destinationFieldIds[i] = JObjectExtensions.ToInt(fieldArray?[1]);
                if (fieldArray.Count > 2)
                {
                    var sourceValue = fieldArray[2];
                    var destValue   = fieldArray[3];

                    sourceValuesBuffer[i]      = (string)sourceValue;
                    destinationValuesBuffer[i] = (string)destValue;
                }
                else
                {
                    sourceValuesBuffer[i]      = null;
                    destinationValuesBuffer[i] = null;
                }
            }

            var linkInfo = new LinkInfo(
                tableInfo.InfoAreaId,
                (string)linkDefArray[0],
                JObjectExtensions.ToInt(linkDefArray[1]),
                JObjectExtensions.ToInt(linkDefArray[2]),
                LinkInfo.ToLinkType((string)linkDefArray[3]),
                sourceFieldId,
                destFieldId,
                linkFieldCount,
                sourceFieldIds,
                destinationFieldIds,
                linkFlag,
                sourceValuesBuffer,
                destinationValuesBuffer);

            tableInfo.AddLinkInfoWithOwnership(linkInfo);
        }
        /// <summary>
        /// Adds the field to table information field definition.
        /// </summary>
        /// <param name="tableInfo">
        /// The table information.
        /// </param>
        /// <param name="fieldDefArray">
        /// The field definition array.
        /// </param>
        private void AddField(TableInfo tableInfo, List <object> fieldDefArray)
        {
            if (fieldDefArray == null)
            {
                return;
            }

            var rightsValue = 0;
            var formatValue = 0;

            if (fieldDefArray.Count > 8)
            {
                rightsValue = int.Parse(fieldDefArray[8].ToString());
            }

            if (fieldDefArray.Count > 9)
            {
                formatValue = int.Parse(fieldDefArray[9].ToString());
            }

            int arrayFieldCount;

            int[] arrayFieldIndices;
            if (fieldDefArray.Count > 10)
            {
                var arrayFieldIndicesArray = (fieldDefArray[10] as JArray)?.ToObject <List <object> >();
                arrayFieldCount = arrayFieldIndicesArray?.Count ?? 0;
                if (arrayFieldCount > 0)
                {
                    arrayFieldIndices = new int[arrayFieldCount];
                    for (var i = 0; i < arrayFieldCount; i++)
                    {
                        arrayFieldIndices[i] = JObjectExtensions.ToInt(arrayFieldIndicesArray[i]);
                    }
                }
                else
                {
                    arrayFieldIndices = null;
                }
            }
            else
            {
                arrayFieldCount   = 0;
                arrayFieldIndices = null;
            }

            var fieldInfo = new FieldInfo(
                tableInfo.InfoAreaId,
                JObjectExtensions.ToInt(fieldDefArray[0]),
                (string)fieldDefArray[1],
                (string)fieldDefArray[1],
                (char)fieldDefArray[2].ToInt(),
                JObjectExtensions.ToInt(fieldDefArray[5]),
                JObjectExtensions.ToInt(fieldDefArray[3]),
                JObjectExtensions.ToInt(fieldDefArray[4]),
                JObjectExtensions.ToInt(fieldDefArray[6]),
                (string)fieldDefArray[7],
                rightsValue,
                formatValue,
                arrayFieldCount,
                arrayFieldIndices);

            tableInfo.AddFieldInfoWithOwnership(fieldInfo);
        }
        /// <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;
        }
Ejemplo n.º 30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FieldAttribute"/> class.
 /// </summary>
 /// <param name="attrdef">
 /// The attrdef.
 /// </param>
 public FieldAttribute(List <object> attrdef)
 {
     this.Attrid   = JObjectExtensions.ToInt(attrdef[0]);
     this.Editmode = JObjectExtensions.ToInt(attrdef[1]);
     this.Value    = attrdef[2] as string;
 }