/// <summary> /// Creates the index for. /// </summary> /// <param name="crmField"> /// The CRM field. /// </param> /// <param name="namePrefix"> /// The name prefix. /// </param> public void CreateIndexFor(UPCRMField crmField, string namePrefix) { var infoAreaId = crmField.InfoAreaId; var tableInfo = this.DatabaseInstance.GetTableInfoByInfoArea(infoAreaId); if (tableInfo == null) { return; } var databaseTableName = tableInfo.DatabaseTableName; var databaseFieldName = tableInfo.GetFieldName((int)crmField.FieldId); string databaseIndexName = $"INDEX_{namePrefix}_{databaseTableName}_{databaseFieldName}"; if (this.DatabaseInstance.ExistsIndex(databaseIndexName)) { return; } Logger.LogDebug($"Creating index for quicksearch definition table {databaseTableName}, field {databaseFieldName}", LogFlag.LogStatements); var createIndexStatement = $"CREATE INDEX {databaseIndexName} ON {databaseTableName}({databaseFieldName}) "; this.DatabaseInstance.Execute(createIndexStatement); }
/// <summary> /// Builds the page. /// </summary> protected override void BuildPage() { ViewReference documentUploadViewReference = this.DetermineDocumentUploadViewReference(); if (documentUploadViewReference != null) { int fieldId = -1; fieldId = this.DetermineFieldIdDocumentUploadViewReference(fieldId, documentUploadViewReference); if (fieldId >= 0) { string infoAreaIdForQuery = this.ViewReference.ContextValueForKey("RecordId").InfoAreaId(); UPCRMField field = new UPCRMField(fieldId, infoAreaIdForQuery); this.documentQuery = new UPContainerMetaInfo(new List <UPCRMField> { field }, infoAreaIdForQuery); this.documentQuery.SetLinkRecordIdentification(this.RecordIdentification); string filterName = documentUploadViewReference.ContextValueForKey("FilterName"); if (!string.IsNullOrEmpty(filterName)) { UPConfigFilter filter = ConfigurationUnitStore.DefaultStore.FilterByName(filterName); if (filter != null) { this.documentQuery.ApplyFilter(filter); } } if (this.documentQuery.Find(UPRequestOption.FastestAvailable, this) != null) { return; } } } base.BuildPage(); }
private void HandleDependentFieldsSectionCounterItemCounter(Dictionary <string, UPEditFieldContext> editFields, int sectionCounter, int itemCounter) { List <UPEditFieldContext> parentFieldContextArray = new List <UPEditFieldContext>(); foreach (UPEditFieldContext fieldContext in editFields.Values) { UPCRMField parentField = fieldContext.ParentField; if (parentField != null) { UPEditFieldContext parentFieldContext = this.editPageContext.EditFields.ValueOrDefault(this.FieldIdentificationSectionCounterItemCounter(parentField, sectionCounter, itemCounter)); if (parentFieldContext != null) { parentFieldContext.AddDependentFieldContext(fieldContext); if (parentFieldContextArray.Contains(parentFieldContext) == false) { parentFieldContextArray.Add(parentFieldContext); } } } } foreach (UPEditFieldContext parentFieldContext in parentFieldContextArray) { parentFieldContext.NotifyDependentFields(); } }
/// <summary> /// Applies the time zone. /// </summary> /// <param name="timeZone"> /// The time zone. /// </param> /// <param name="addedFields"> /// The added fields. /// </param> public void ApplyTimeZone(UPCRMTimeZone timeZone, List <UPContainerFieldMetaInfo> addedFields) { if (this.Fields != null) { var currentFields = new List <UPContainerFieldMetaInfo>(this.Fields); foreach (var fieldMetaInfo in currentFields) { if (fieldMetaInfo.IsDateField && fieldMetaInfo.OtherDateTimeField == null) { var timeFieldId = fieldMetaInfo.CrmFieldInfo.TimeFieldId; if (timeFieldId < 0) { continue; } var field = new UPCRMField(timeFieldId, this.InfoAreaId); if (field.FieldInfo == null) { continue; } var otherInfo = new UPContainerFieldMetaInfo(field); this.AddNewFieldToArray(otherInfo, addedFields); } else if (fieldMetaInfo.IsTimeField && fieldMetaInfo.OtherDateTimeField == null) { var dateFieldId = fieldMetaInfo.CrmFieldInfo?.DateFieldId ?? 0; if (dateFieldId == 0) { continue; } var field = new UPCRMField(dateFieldId, this.InfoAreaId); if (field.FieldInfo == null) { continue; } var otherInfo = new UPContainerFieldMetaInfo(field); this.AddNewFieldToArray(otherInfo, addedFields); } } } var dateTimeCondition = this.Condition?.DateTimeConditionForInfoAreaParent(this, null); dateTimeCondition?.ApplyTimeZone(timeZone); if (this.subTables == null) { return; } foreach (var subInfos in this.subTables) { subInfos?.ApplyTimeZone(timeZone, addedFields); } }
/// <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="UPCRMResultFieldCondition"/> class. /// </summary> /// <param name="field"> /// The field. /// </param> /// <param name="condition"> /// The condition. /// </param> /// <param name="fieldValue"> /// The field value. /// </param> /// <param name="resultPosition"> /// The result position. /// </param> public UPCRMResultFieldCondition( UPCRMField field, UPConditionOperator condition, string fieldValue, int resultPosition) { this.Field = field; this.ResultPosition = resultPosition; this.FieldValue = fieldValue; this.Condition = condition; }
/// <summary> /// Initializes a new instance of the <see cref="UPContainerFieldMetaInfo"/> class. /// </summary> /// <param name="crmField"> /// The CRM field. /// </param> /// <param name="functionName"> /// Name of the function. /// </param> /// <param name="fieldFormat"> /// The field format. /// </param> public UPContainerFieldMetaInfo(UPCRMField crmField, string functionName, object fieldFormat) { this.CrmField = crmField; this.CrmFieldInfo = UPCRMDataStore.DefaultStore.FieldInfoForField(this.CrmField); this.catalog = null; #if PORTING FieldFormat = fieldFormat; #endif this.FunctionName = functionName; this.resultValueMapperInitialized = false; }
private void InitializeAndLoadForeignFields() { List <UPQuestionnaireQuestion> foreignFieldQuestions = this.Questionnaire.ForeignFieldQuestions; Dictionary <string, UPSurveyForeignField> foreignFieldDictionary = new Dictionary <string, UPSurveyForeignField>(foreignFieldQuestions.Count); List <UPCRMField> fieldArray = new List <UPCRMField>(foreignFieldQuestions.Count); string recordInfoAreaId = this.RootRecordIdentification.InfoAreaId(); foreach (UPQuestionnaireQuestion question in foreignFieldQuestions) { UPSurveyForeignField foreignField = new UPSurveyForeignField(question); UPSurveyForeignField existingForeignField = foreignFieldDictionary.ValueOrDefault(foreignField.Key); if (existingForeignField != null) { existingForeignField.AddQuestion(question); } else { foreignFieldDictionary[foreignField.Key] = foreignField; if (!string.IsNullOrEmpty(recordInfoAreaId)) { bool addField = true; UPCRMField field = UPCRMField.FieldFromFieldInfo(foreignField.FieldInfo); if (recordInfoAreaId != field.InfoAreaId) { if (!UPCRMDataStore.DefaultStore.InfoAreaIdLinkIdIsParentOfInfoAreaId(recordInfoAreaId, -1, field.InfoAreaId)) { addField = false; } } if (addField) { foreignField.PositionInResult = fieldArray.Count; fieldArray.Add(UPCRMField.FieldFromFieldInfo(foreignField.FieldInfo)); } } } } this.ForeignFields = foreignFieldDictionary; if (string.IsNullOrEmpty(this.RootRecordIdentification)) { this.ForeignFieldsLoaded(null); } this.crmQuery = new UPContainerMetaInfo(fieldArray, this.RootRecordIdentification.InfoAreaId()); this.crmQuery.SetLinkRecordIdentification(this.RootRecordIdentification); this.loadStep = 4; this.crmQuery.Find(this.SourceRequestOption, this); }
/// <summary> /// Matchings the criteria for row. /// </summary> /// <param name="row">The row.</param> /// <returns></returns> public ConfigTimelineCriteria MatchingCriteriaForRow(UPCRMResultRow row) { foreach (ConfigTimelineCriteria crit in this.TimelineInfoArea.ColorCriteria) { string value = row.RawValueForFieldIdInfoAreaIdLinkId(crit.FieldId, this.TimelineInfoArea.InfoAreaId, this.TimelineInfoArea.LinkId); if (!string.IsNullOrEmpty(value)) { bool checkresult = UPCRMField.ResultForValue(value, crit.CompareOperator, crit.CompareValue, crit.CompareValueTo, false, false, false); if (checkresult) { return(crit); } } } return(null); }
/// <summary> /// Initializes the dependent fields. /// </summary> private void InitializeDependentFields() { this.Field = UPCRMField.FieldWithFieldIdInfoAreaId(this.FieldId, this.Alternate.ParentExpand.InfoAreaId); this.boolEmptyCheck = this.Field.FieldType == "B"; this.numericEmptyCheck = this.Field.IsNumericField || this.Field.IsCatalogField; if (string.IsNullOrEmpty(this.FieldValue)) { this.EmptyFieldValue = true; } else if (this.numericEmptyCheck && this.FieldValue == "0") { this.EmptyFieldValue = true; } else if (this.boolEmptyCheck && this.FieldValue == "false") { this.EmptyFieldValue = true; } }
/// <summary> /// Catalogs for CRM field. /// </summary> /// <param name="crmField"> /// The CRM field. /// </param> /// <returns> /// The <see cref="UPCatalog"/>. /// </returns> public UPCatalog CatalogForCrmField(UPCRMField crmField) { var fieldInfo = this.FieldInfoForField(crmField); if (fieldInfo == null) { return(null); } if (fieldInfo.FieldType == "K") { return(this.CatalogForVariableCatalogId(fieldInfo.CatNo)); } if (fieldInfo.FieldType == "X") { return(this.CatalogForFixedCatalogId(fieldInfo.CatNo)); } return(null); }
/// <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> /// Fields the information for field. /// </summary> /// <param name="field"> /// The field. /// </param> /// <returns> /// The <see cref="UPCRMFieldInfo"/>. /// </returns> public UPCRMFieldInfo FieldInfoForField(UPCRMField field) { return(UPCRMFieldInfo.Create(field, this)); }
/// <summary> /// Initializes a new instance of the <see cref="UPSearchPageModelControllerPreparedSearch"/> class. /// </summary> /// <param name="timelineInfoAreaConfiguration"> /// The timeline info area configuration. /// </param> public UPSearchPageModelControllerPreparedSearch(ConfigTimelineInfoArea timelineInfoAreaConfiguration) { this.InfoAreaId = timelineInfoAreaConfiguration.InfoAreaId; this.ConfigName = timelineInfoAreaConfiguration.ConfigName; this.TimelineConfiguration = timelineInfoAreaConfiguration; if (string.IsNullOrEmpty(this.ConfigName)) { this.ConfigName = this.InfoAreaId; } IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; this.SearchConfiguration = configStore.SearchAndListByName(this.ConfigName); string fieldGroupName; if (this.SearchConfiguration != null) { if (this.SearchConfiguration.DefaultAction != null) { this.DetailAction = configStore.MenuByName(this.SearchConfiguration.DefaultAction); } if (this.DetailAction == null) { InfoArea infoAreaConfig = configStore.InfoAreaConfigById(this.InfoAreaId); if (!string.IsNullOrEmpty(infoAreaConfig.DefaultAction)) { this.DetailAction = configStore.MenuByName(infoAreaConfig.DefaultAction); } } fieldGroupName = this.SearchConfiguration.FieldGroupName; } else { fieldGroupName = this.ConfigName; } this.FilterName = timelineInfoAreaConfiguration.FilterName; this.ListFieldControl = configStore.FieldControlByNameFromGroup(@"List", fieldGroupName); if (this.ListFieldControl != null) { this.DropdownFieldControl = configStore.FieldControlByNameFromGroup(@"MiniDetails", fieldGroupName); if (this.DropdownFieldControl == null) { this.DropdownFieldControl = configStore.FieldControlByNameFromGroup(@"Details", fieldGroupName); if (this.DropdownFieldControl != null) { this.DropdownFieldControl = this.DropdownFieldControl.FieldControlWithSingleTab(0); } } this.CombinedControl = this.DropdownFieldControl == null ? this.ListFieldControl : new FieldControl( new List <FieldControl> { this.ListFieldControl, this.DropdownFieldControl }); } if (this.TimelineConfiguration.ColorCriteria.Count > 0) { Dictionary <string, UPCRMField> additionalFieldDictionary = null; foreach (ConfigTimelineCriteria criteria in this.TimelineConfiguration.ColorCriteria) { if (criteria.FieldId < 0) { continue; } UPCRMField field = new UPCRMField(criteria.FieldId, this.TimelineConfiguration.InfoAreaId); string key = field.FieldId.ToString(); if (additionalFieldDictionary == null) { additionalFieldDictionary = new Dictionary <string, UPCRMField>(); } if (!additionalFieldDictionary.ContainsKey(key)) { additionalFieldDictionary.Add(key, field); } } this.AdditionalOutputFields = additionalFieldDictionary.Values.Select(x => x).ToList(); } if (this.DetailAction == null) { this.DetailAction = configStore.MenuByName(@"SHOWRECORD"); } this.ReplaceCaseSensitiveCharacters = configStore.ConfigValueIsSet(@"Search.ReplaceCaseSensitiveCharacters"); }
/// <summary> /// The crm query for value. /// </summary> /// <param name="searchValue"> /// The search value. /// </param> /// <param name="filters"> /// The filters. /// </param> /// <param name="fullTextSearch"> /// The full text search. /// </param> /// <returns> /// The <see cref="UPContainerMetaInfo"/>. /// </returns> public UPContainerMetaInfo CrmQueryForValue( string searchValue, List <UPConfigFilter> filters, bool fullTextSearch) { if (this.CombinedControl == null) { return(null); } if (this.SearchCRMFields == null && this.MultiSearchCRMFields == null && this.SearchFieldControl?.Tabs?.Count > 0) { int tabCount = this.SearchFieldControl.Tabs.Count; List <UPCRMField> fieldArray = null; List <UPCRMField> multiFieldArray = null; for (int i = 0; i < tabCount; i++) { FieldControlTab tab = this.SearchFieldControl.TabAtIndex(i); if (tab.Fields == null || tab.Fields.Count == 0) { continue; } if (string.Compare(tab.Type, @"MULTI", StringComparison.OrdinalIgnoreCase) == 0) { UPCRMField multiField = tab.FieldAtIndex(0).Field; if (multiFieldArray == null) { multiFieldArray = new List <UPCRMField>(); } multiFieldArray.Add(multiField); } else { if (fieldArray == null) { fieldArray = new List <UPCRMField>(); } fieldArray.AddRange(tab.AllCRMFields()); } } this.SearchCRMFields = fieldArray; this.MultiSearchCRMFields = multiFieldArray; } IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; UPContainerMetaInfo container = new UPContainerMetaInfo(this.CombinedControl); if (!string.IsNullOrEmpty(this.DetailActionSwitchFilterName)) { this.DetailActionSwitchFilter = ConfigurationUnitStore.DefaultStore.FilterByName(this.DetailActionSwitchFilterName); if (this.DetailActionSwitchFilter != null) { this.DetailActionSwitchFilter = this.DetailActionSwitchFilter.FilterByApplyingValueDictionaryDefaults( this.FilterParameter, true); } if (this.DetailActionSwitchFilter != null) { this.FilterBasedDecision = new UPCRMFilterBasedDecision(this.DetailActionSwitchFilter); } } container.ReplaceCaseSensitiveCharacters = this.ReplaceCaseSensitiveCharacters; List <UPCRMField> additionalFields = null; if (this.ExpandSettings != null) { Dictionary <string, UPCRMField> alternateExpandFields = this.ExpandSettings.FieldsForAlternateExpands(true); List <UPCRMField> _additionalFields = this.AdditionalOutputFields != null ? new List <UPCRMField>(this.AdditionalOutputFields) : new List <UPCRMField>(); if (alternateExpandFields != null) { _additionalFields.AddRange(alternateExpandFields.Values.Where(field => container.ContainsField(field) == null)); } additionalFields = _additionalFields; } else if (this.AdditionalOutputFields?.Count > 0) { additionalFields = this.AdditionalOutputFields; } if (additionalFields != null && additionalFields.Count > 0) { container.AddCrmFields(additionalFields); } var checkFilterFields = this.FilterBasedDecision?.FieldDictionary.Values.Select(x => x).ToList(); if (checkFilterFields?.Count > 0) { container.AddCrmFields(checkFilterFields); this.FilterBasedDecision.UseCrmQuery(container); } if (this.ExpandSettings != null) { this.ExpandChecker = this.ExpandSettings.ExpandCheckerForCrmQuery(container); } if (!string.IsNullOrEmpty(this.LinkRecordIdentification)) { container.SetLinkRecordIdentification(this.LinkRecordIdentification); } if (this.SearchFieldControl != null) { container.SetSearchConditionsFor( searchValue, this.SearchCRMFields, this.MultiSearchCRMFields, fullTextSearch); } else if (this.QuickSearchEntries != null) { if (!string.IsNullOrEmpty(searchValue)) { List <UPCRMField> crmFields = this.QuickSearchEntries.Select(entry => entry.CrmField).ToList(); container.SetSearchConditionsFor(searchValue, crmFields, fullTextSearch); } } if (!string.IsNullOrEmpty(this.SearchConfiguration?.FilterName)) { UPConfigFilter filter = configStore.FilterByName(this.SearchConfiguration.FilterName); if (filter != null) { filter = filter.FilterByApplyingDefaultReplacements(); filter = filter.FilterByApplyingValueDictionary(this.FilterParameter); container.ApplyFilter(filter); } } if (this.FilterObject != null) { container.ApplyFilter(this.FilterObject); } else if (!string.IsNullOrEmpty(this.FilterName)) { UPConfigFilter filter = configStore.FilterByName(this.FilterName); if (filter != null) { filter = filter.FilterByApplyingDefaultReplacements(); filter = filter.FilterByApplyingValueDictionary(this.FilterParameter); container.ApplyFilter(filter); } } if (filters != null) { foreach (UPConfigFilter filter in filters) { if (this.FilterParameter != null) { container.ApplyFilterWithReplacementDictionary(filter, this.FilterParameter); } else { container.ApplyFilter(filter); } } } return(container); }
/// <summary> /// Results for value pattern. /// </summary> /// <param name="value">The value.</param> /// <param name="fieldValue">The field value.</param> /// <returns>the result of the value pattern</returns> public bool ResultForValuePattern(string value, string fieldValue) { return(UPCRMField.ResultForValue(value, this.Compare, fieldValue, null, this.numericEmptyCheck, this.boolEmptyCheck, this.EmptyFieldValue)); }
/// <summary> /// Initializes a new instance of the <see cref="UPCRMSortField"/> class. /// </summary> /// <param name="field"> /// The field. /// </param> /// <param name="ascending"> /// if set to <c>true</c> [ascending]. /// </param> public UPCRMSortField(UPCRMField field, bool ascending) : this(field.FieldId, field.InfoAreaId, field.LinkId, ascending) { }
private UPMEditField CreateDependEditField(IIdentifier participantIdentifier, UPCatalog catalog, UPMGroup editGroup) { UPCRMField field = null; if (catalog == this.ParticipantsControl.RequirementCatalog) { field = this.ParticipantsControl.RequirementField; } else if (catalog == this.ParticipantsControl.AcceptanceCatalog) { field = this.ParticipantsControl.AcceptanceField; } var editField = new UPMParticipantCatalogEditField(StringIdentifier.IdentifierWithStringId( field != null ? $"dependField_{participantIdentifier}_{field.InfoAreaId}_{field.FieldId}" : $"dependField_{participantIdentifier}_(null)_0")) { GroupModelController = this, Group = editGroup }; if (catalog != null) { var possibleValues = catalog.Values; List <string> explicitKeyOrder; var possibleValuesAsString = catalog.TextValuesForFieldValues(false); var configStore = ConfigurationUnitStore.DefaultStore; var acceptanceCatalogAttributes = configStore.CatalogAttributesForInfoAreaIdFieldId(field.InfoAreaId, field.FieldId); foreach (var catalogValue in possibleValues) { var possibleValue = new UPMCatalogPossibleValue { TitleLabelField = new UPMStringField(StringIdentifier.IdentifierWithStringId("x")) { StringValue = catalogValue.Text } }; var configCatalogValueAttributes = acceptanceCatalogAttributes.ValuesByCode.ValueOrDefault(catalogValue.CodeKey.ToInt()); if (configCatalogValueAttributes != null) { var colorString = configCatalogValueAttributes.ColorKey; if (!string.IsNullOrEmpty(colorString)) { possibleValue.IndicatorColor = AureaColor.ColorWithString(colorString); } possibleValue.ImageString = configCatalogValueAttributes.ImageName; } possibleValue.Key = catalogValue.CodeKey; editField.AddPossibleValue(possibleValue); } if (string.IsNullOrEmpty(possibleValuesAsString.ValueOrDefault("0"))) { editField.NullValueKey = "0"; } if (acceptanceCatalogAttributes != null && !ConfigurationUnitStore.DefaultStore.ConfigValueIsSet("FixedCatalog.SortByAttributeFilter")) { explicitKeyOrder = this.ExplicitKeyOrderByCatalogAttributeCodeOrder(acceptanceCatalogAttributes, catalog.ExplicitKeyOrderByCodeEmptyValueIncludeHidden(false, false)); } else if (ConfigurationUnitStore.DefaultStore.ConfigValueIsSet("FixedCatalog.SortByCode")) { explicitKeyOrder = catalog.ExplicitKeyOrderByCodeEmptyValueIncludeHidden(false, false); } else { explicitKeyOrder = catalog.ExplicitKeyOrderEmptyValueIncludeHidden(false, false); } if (explicitKeyOrder != null) { editField.ExplicitKeyOrder = explicitKeyOrder; } editField.ContinuousUpdate = true; editField.DisplayValues = possibleValuesAsString.Values.ToList(); } return(editField); }
/// <summary> /// Fields the with information area identifier. /// </summary> /// <param name="infoAreaId">The information area identifier.</param> /// <returns></returns> public virtual UPCRMField FieldWithInfoAreaId(string infoAreaId) { return(UPCRMField.EmptyFieldWithInfoArea(infoAreaId)); }
/// <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; }
private string FieldIdentificationSectionCounterItemCounter(UPCRMField field, int sectionCounter, int itemCounter) { return($"{field.FieldIdentification}-{sectionCounter}-{itemCounter}"); }
/// <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> /// Loads this instance. /// </summary> /// <returns></returns> public bool Load() { bool isRecordLink = false; if (string.IsNullOrEmpty(this.QuestionnaireLinkName)) { this.QuestionnaireLinkName = "RecordLink"; } this.loadStep = 1; this.crmQuery = this.SourceCopyFieldGroup != null ? new UPContainerMetaInfo(this.SourceCopyFieldGroup) : new UPContainerMetaInfo(new List <UPCRMField>(), this.RecordIdentification.InfoAreaId()); if (this.QuestionnaireLinkName == "RecordLink") { isRecordLink = true; UPQuestionnaireManager questionnaireManager = null; //ServerSession.CurrentSession.QuestionnaireManager; if (this.SourceRequestOption == UPRequestOption.Offline || ((this.SourceRequestOption == UPRequestOption.FastestAvailable || this.SourceRequestOption == UPRequestOption.Default) && UPCRMDataStore.DefaultStore.RecordExistsOffline(this.RecordIdentification))) { UPCRMLinkField questionnairelinkField = new UPCRMLinkField(questionnaireManager.QuestionnaireList.InfoAreaId, -1, this.RecordIdentification.InfoAreaId()); List <UPContainerFieldMetaInfo> fieldMetaInfos = this.crmQuery.AddCrmFields(new List <UPCRMField> { questionnairelinkField }); if (fieldMetaInfos.Count > 0) { this.questionnairelinkFieldMetaInfo = fieldMetaInfos[0]; } } else { UPCRMField questionnairelinkField = new UPCRMField(0, questionnaireManager?.QuestionnaireList.InfoAreaId, -1); UPContainerInfoAreaMetaInfo subInfoAreaMetaInfo = this.crmQuery.RootInfoAreaMetaInfo.SubTableForInfoAreaIdLinkId(questionnaireManager?.QuestionnaireList.InfoAreaId, -1); if (subInfoAreaMetaInfo == null) { this.crmQuery.RootInfoAreaMetaInfo.AddTable(new UPContainerInfoAreaMetaInfo(questionnaireManager?.QuestionnaireList.InfoAreaId, -1)); } this.crmQuery.AddCrmFields(new List <UPCRMField> { questionnairelinkField }); } } this.crmQuery.SetLinkRecordIdentification(this.RecordIdentification); if (isRecordLink && this.SourceRequestOption == UPRequestOption.BestAvailable) { this.loadStep = 11; if (this.crmQuery.Find(UPRequestOption.Online, this) == null) { this.TrySourceCopyFieldGroupOfflineWithRecordLink(); } } else { this.crmQuery.Find(this.SourceRequestOption, this); } return(true); }