/// <summary> /// Initializes a new instance of the <see cref="UPConfigExpandCondition"/> class. /// </summary> /// <param name="condition">The condition.</param> /// <param name="alternate">The alternate.</param> public UPConfigExpandCondition(UPConfigExpandCondition condition, UPConfigExpandAlternate alternate) { this.FieldId = condition.FieldId; this.Compare = condition.Compare; this.FieldValue = condition.FieldValue; this.Alternate = alternate; this.InitializeDependentFields(); }
/// <summary> /// Initializes a new instance of the <see cref="UPConfigExpandCondition"/> class. /// </summary> /// <param name="def">The definition.</param> /// <param name="alternate">The alternate.</param> public UPConfigExpandCondition(List <object> def, UPConfigExpandAlternate alternate) { this.FieldId = def[2].ToInt(); this.Compare = UPCRMField.ConditionOperatorFromString(def[1] as string); this.FieldValue = def[3] as string; this.Alternate = alternate; this.InitializeDependentFields(); }
/// <summary> /// Initializes a new instance of the <see cref="UPConfigExpandAlternate"/> class. /// </summary> /// <param name="source">The source.</param> /// <param name="crmQuery">The CRM query.</param> /// <param name="parentExpand">The parent expand.</param> /// <param name="parentList">The parent list.</param> public UPConfigExpandAlternate(UPConfigExpandAlternate source, UPContainerMetaInfo crmQuery, UPConfigExpand parentExpand, List <string> parentList) { this.ParentExpand = parentExpand; this.AlternateName = source.AlternateName; var conditionArray = new List <UPConfigExpandCondition>(source.Conditions.Count); foreach (var condition in source.Conditions) { conditionArray.Add(new UPConfigExpandConditionForQuery(condition, crmQuery, this)); } this.Conditions = conditionArray; this.CurrentExpand = ConfigurationUnitStore.DefaultStore.ExpandByName(this.AlternateName); if (this.CurrentExpand != null && this.CurrentExpand.AlternateExpands?.Count > 0) { var subSet = new List <string>(parentList) { this.AlternateName }; List <UPConfigExpandAlternate> _subAlternates = null; foreach (var subSource in this.CurrentExpand.AlternateExpands) { if (subSet.Contains(subSource.AlternateName)) { continue; } var subAlternate = new UPConfigExpandAlternate(subSource, crmQuery, this.CurrentExpand, subSet); if (_subAlternates == null) { _subAlternates = new List <UPConfigExpandAlternate> { subAlternate }; } else { _subAlternates.Add(subAlternate); } } this.AlternateExpands = _subAlternates; } }
/// <summary> /// Initializes a new instance of the <see cref="UPConfigExpandConditionForQuery"/> class. /// </summary> /// <param name="condition">The condition.</param> /// <param name="crmQuery">The CRM query.</param> /// <param name="alternate">The alternate.</param> public UPConfigExpandConditionForQuery(UPConfigExpandCondition condition, UPContainerMetaInfo crmQuery, UPConfigExpandAlternate alternate) : base(condition, alternate) { this.ResultPosition = crmQuery?.PositionForField(this.Field) ?? 0; if (!this.FieldValue.StartsWith("$cur") && !this.FieldValue.StartsWith("$par")) { return; } var dateFieldValue = this.FieldValue.ReplaceDateVariables(); if (dateFieldValue.StartsWith("$")) { var replaceValues = UPConditionValueReplacement.SessionParameterReplacements().ValueOrDefault(this.FieldValue); if (replaceValues != null && replaceValues.Count > 0) { this.FieldValue = replaceValues[0]; } } else { this.FieldValue = dateFieldValue; } }
/// <summary> /// Initializes a new instance of the <see cref="UPConfigExpand"/> class. /// </summary> /// <param name="defarray">The defarray.</param> public UPConfigExpand(List <object> defarray) { if (defarray == null || defarray.Count < 6) { return; } this.UnitName = (string)defarray[0]; this.InfoAreaId = (string)defarray[1]; this.FieldGroupName = (string)defarray[2]; this.HeaderGroupName = (string)defarray[3]; this.MenuLabel = (string)defarray[4]; this.TableCaptionName = (string)defarray[5]; if (defarray.Count > 6 && defarray[6] != null) { var conditionArray = (defarray[6] as JArray)?.ToObject <List <object> >(); List <object> currentConditions = null; List <UPConfigExpandAlternate> alternates = null; foreach (JArray conditionJDef in conditionArray) { var conditionDef = conditionJDef?.ToObject <List <object> >(); if (conditionDef == null) { continue; } var alternateName = (string)conditionDef[4]; if (alternateName == ".") { if (currentConditions == null) { currentConditions = new List <object> { conditionDef }; } else { currentConditions.Add(conditionDef); } } else { UPConfigExpandAlternate alternateExpand = null; if (currentConditions != null) { currentConditions.Add(conditionDef); alternateExpand = new UPConfigExpandAlternate(alternateName, currentConditions, this); currentConditions = null; } else { alternateExpand = new UPConfigExpandAlternate(alternateName, new List <object> { conditionDef }, this); } if (alternates == null) { alternates = new List <UPConfigExpandAlternate> { alternateExpand }; } else { alternates.Add(alternateExpand); } } } this.AlternateExpands = alternates; } if (defarray.Count > 8) { this.ColorKey = defarray[7] as string; this.ImageName = defarray[8] as string; } }