// 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); }
private UPMGroup GroupFromRow(UPCRMResultRow resultRow) { UPMDocumentsGroup docGroup = null; string recordIdentification = resultRow.RootRecordIdentification; int fieldCount = this.TabConfig.NumberOfFields; DocumentManager documentManager = new DocumentManager(); for (int j = 0; j < fieldCount; j++) { UPConfigFieldControlField fieldConfig = this.TabConfig.FieldAtIndex(j); string documentKey = resultRow.ValueAtIndex(fieldConfig.TabIndependentFieldIndex); if (!string.IsNullOrEmpty(documentKey)) { DocumentData documentData = documentManager.DocumentForKey(documentKey); if (documentData != null) { if (docGroup == null) { docGroup = new UPMDocumentsGroup(this.TabIdentifierForRecordIdentification(recordIdentification)); docGroup.LabelText = this.TabLabel; } UPMDocument document = new UPMDocument(new RecordIdentifier(recordIdentification), fieldConfig.Label, documentData.DateString, documentData.SizeString, null, documentData.Url, documentData.Title, documentData.ServerUpdateDate, documentData.DisplayText, null); docGroup.AddField(document); } } } this.ControllerState = docGroup != null ? GroupModelControllerState.Finished : GroupModelControllerState.Empty; this.Group = docGroup; return(docGroup); }
/// <summary> /// Functions the names. /// </summary> /// <param name="row"> /// The row. /// </param> /// <param name="fieldOffset"> /// The field offset. /// </param> /// <param name="displayPrefix"> /// The display prefix. /// </param> /// <returns> /// Function names lookup /// </returns> public Dictionary <string, object> FunctionNames(UPCRMResultRow row, int fieldOffset = 0, string displayPrefix = null) { if (row == null) { return(null); } var dictionary = new Dictionary <string, object>(); foreach (var tab in this.Tabs) { if (tab?.Fields == null) { continue; } foreach (var field in tab.Fields) { if (string.IsNullOrEmpty(field.Function)) { continue; } dictionary[field.Function] = row.RawValueAtIndex(field.TabIndependentFieldIndex + fieldOffset); if (!string.IsNullOrWhiteSpace(displayPrefix)) { dictionary[$"{displayPrefix}{field.Function}"] = row.ValueAtIndex(field.TabIndependentFieldIndex + fieldOffset); } } } return(dictionary); }
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); }
/// <summary> /// Initializes a new instance of the <see cref="UPSelectorOption"/> class. /// </summary> /// <param name="row"> /// The row. /// </param> /// <param name="fieldControl"> /// The field control. /// </param> public UPSelectorOption(UPCRMResultRow row, FieldControl fieldControl) { string firstFieldName = null; var first = true; var dictionary = new Dictionary <string, object>(); var displayDictionary = new Dictionary <string, string>(); foreach (var tab in fieldControl.Tabs ?? new List <FieldControlTab>()) { if (tab?.Fields == null) { continue; } foreach (var field in tab.Fields) { if (first) { firstFieldName = row.ValueAtIndex(field.TabIndependentFieldIndex); first = false; } if (field.Function == "Name") { this.Name = row.ValueAtIndex(field.TabIndependentFieldIndex); firstFieldName = null; } else if (!string.IsNullOrEmpty(field.Function)) { dictionary[field.Function] = row.RawValueAtIndex(field.TabIndependentFieldIndex); displayDictionary[field.Function] = row.ValueAtIndex(field.TabIndependentFieldIndex); } } } if (this.Name == null) { this.Name = firstFieldName; if (string.IsNullOrEmpty(this.Name)) { this.Name = "?"; } } this.FieldValues = dictionary; this.DisplayFieldValues = displayDictionary; }
/// <summary> /// Initializes a new instance of the <see cref="UPSerialEntryInfoRowFromCRMResultRow"/> class. /// </summary> /// <param name="row">The row.</param> /// <param name="result">The result.</param> public UPSerialEntryInfoRowFromCRMResultRow(UPCRMResultRow row, UPSerialEntryInfoResult result) : base(result) { int cellCount = result.Info.ColumnNames.Count; List <string> cells = new List <string>(result.Info.ColumnNames.Count); for (int i = 0; i < cellCount; i++) { cells.Add(row.ValueAtIndex(i)); } this.Cells = cells; }
/// <summary> /// Displays the values from result row. /// </summary> /// <param name="self">The self.</param> /// <param name="row">The row.</param> /// <returns></returns> public static Dictionary <string, string> DisplayValuesFromResultRow(this Dictionary <string, UPConfigFieldControlField> self, UPCRMResultRow row) { if (row == null) { return(null); } Dictionary <string, string> valueDictionary = new Dictionary <string, string>(); foreach (string key in self.Keys) { UPConfigFieldControlField field = self[key]; valueDictionary[key] = row.ValueAtIndex(field.TabIndependentFieldIndex); } return(valueDictionary); }
private void HandleItemResult(UPCRMResult result) { int count = result.RowCount; UPConfigFieldControlField groupField = this.ItemFieldControl.FieldWithFunction(Constants.FieldGroupString); UPConfigFieldControlField itemField = this.ItemFieldControl.FieldWithFunction(Constants.FieldItemString); UPConfigFieldControlField destinationShowAdditionalFieldsField = this.ItemFieldControl.FieldWithFunction(Constants.FieldShowAdditionalFieldsString); List <UPCharacteristicsGroup> groupsWithAllItems = new List <UPCharacteristicsGroup>(); for (int i = 0; i < count; i++) { UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(i); string groupKey = row.RawValueAtIndex(groupField.TabIndependentFieldIndex); UPCharacteristicsGroup group = this.groupDict.ValueOrDefault(groupKey); if (group != null) { string itemKey = row.RawValueAtIndex(itemField.TabIndependentFieldIndex); bool showAdditionalFields = false; if (destinationShowAdditionalFieldsField != null) { showAdditionalFields = row.RawValueAtIndex(destinationShowAdditionalFieldsField.TabIndependentFieldIndex).ToBoolWithDefaultValue(false); } if (itemKey == "0") { group.ShowAdditionalFields = showAdditionalFields; if (!groupsWithAllItems.Contains(group)) { groupsWithAllItems.Add(group); } } else { group.AddItem(new UPCharacteristicsItem(row.ValueAtIndex(itemField.TabIndependentFieldIndex), itemKey, group, showAdditionalFields ? this.AdditionalFields : null)); } } } this.HandleGroupsWithAllItems(groupsWithAllItems); }
private void HandleGroupResult(UPCRMResult result) { int count = result.RowCount; UPConfigFieldControlField groupField = this.GroupFieldControl.FieldWithFunction(Constants.FieldGroupString); UPConfigFieldControlField singleField = this.GroupFieldControl.FieldWithFunction(Constants.FieldSingleString); UPConfigFieldControlField showGroupExpandedField = this.GroupFieldControl.FieldWithFunction(Constants.FieldShowGroupExpandedString); for (int i = 0; i < count; i++) { UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(i); string key = row.RawValueAtIndex(groupField.TabIndependentFieldIndex); if (!this.groupDict.ContainsKey(key)) { bool singleSelection = false; if (singleField != null) { string singleFieldValue = row.RawValueAtIndex(singleField.TabIndependentFieldIndex); if (singleFieldValue == "true") { singleSelection = true; } } bool showGroupExpanded = true; if (showGroupExpandedField != null) { showGroupExpanded = row.RawValueAtIndex(showGroupExpandedField.TabIndependentFieldIndex).ToBoolWithDefaultValue(true); } UPCharacteristicsGroup group = new UPCharacteristicsGroup(row.ValueAtIndex(groupField.TabIndependentFieldIndex), key, singleSelection, this, showGroupExpanded); this.groupDict[key] = group; this.Groups.Add(group); } } this.LoadItems(); }
/// <summary> /// Strings from row data provider value array options. /// </summary> /// <param name="row"> /// The row. /// </param> /// <param name="dataProvider"> /// The data provider. /// </param> /// <param name="valueArray"> /// The value array. /// </param> /// <param name="options"> /// The options. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> public string StringFromRowDataProviderValueArrayOptions( UPCRMResultRow row, UPCRMListFormatterFunctionDataProvider dataProvider, List <string> valueArray, UPFormatOption options) { string result = null; var colSpanFieldCount = 0; UPConfigFieldControlField colSpanField = null; List <string> colSpanFieldValues = null; string combineString = null; foreach (var field in this._fields) { var rawColumnValue = string.Empty; var columnValue = string.Empty; if (dataProvider != null) { if (!string.IsNullOrEmpty(field?.Function)) { rawColumnValue = dataProvider.RawValueForFunctionName(field.Function); if (!string.IsNullOrEmpty(rawColumnValue)) { columnValue = field.ValueFromRawValueOptions(rawColumnValue, options); } } } else if (valueArray != null) { columnValue = valueArray.Count > field.TabIndependentFieldIndex ? valueArray[field.TabIndependentFieldIndex] : string.Empty; rawColumnValue = columnValue; } else { rawColumnValue = row.RawValueAtIndex(field.TabIndependentFieldIndex); columnValue = row.ValueAtIndex(field.TabIndependentFieldIndex); } bool emptyColumnValue = false; if (field.Field.FieldType == "F") { if (field.Attributes.ExtendedOptionIsSetToFalse("supportsDecimals") && !string.IsNullOrWhiteSpace(rawColumnValue) && decimal.TryParse(rawColumnValue, out var value)) { const string noDecimalPlacesFormat = "F0"; columnValue = value.ToString(noDecimalPlacesFormat); } if (string.IsNullOrEmpty(rawColumnValue) || field.Field.IsEmptyValue(rawColumnValue)) { columnValue = !options.HasFlag(UPFormatOption.Show0Float) ? string.Empty : StringExtensions.FloatDisplayTextFromFloat(0); emptyColumnValue = true; } } else if (field.Field.IsNumericField) { if (string.IsNullOrEmpty(rawColumnValue) || field.Field.IsEmptyValue(rawColumnValue)) { columnValue = !options.HasFlag(UPFormatOption.Show0) ? string.Empty : StringExtensions.IntegerDisplayTextFromInteger(0); emptyColumnValue = true; } } else if (string.IsNullOrEmpty(rawColumnValue) || field.Field.IsEmptyValue(rawColumnValue)) { if (field.Field.FieldType == "B") { if (string.IsNullOrEmpty(columnValue) || columnValue.Equals(this.ListFormatter.DisplayNo)) { columnValue = string.Empty; emptyColumnValue = true; } } else { if (!options.HasFlag(UPFormatOption.Show0) || columnValue != "0") { columnValue = string.Empty; } emptyColumnValue = true; } } var currentCombineString = field.Attributes.CombineString; var range = 0; if (!field.Attributes.NoPlaceHoldersInCombineString && !field.Attributes.CombineWithIndices && !string.IsNullOrEmpty(currentCombineString)) { range = currentCombineString.IndexOf("v", StringComparison.Ordinal); if (range > 0 && !string.IsNullOrEmpty(columnValue)) { columnValue = currentCombineString.Replace("v", columnValue); } else if (range == -1) { range = currentCombineString.IndexOf("n", StringComparison.Ordinal); if (range > 0) { columnValue = emptyColumnValue ? string.Empty : currentCombineString.Replace("n", columnValue); } } } if (colSpanFieldCount > 0) { colSpanFieldValues.Add(!string.IsNullOrEmpty(columnValue) ? columnValue : string.Empty); if (--colSpanFieldCount == 0) { columnValue = colSpanField?.Attributes?.FormatValues(colSpanFieldValues); } } else if (field.Attributes.FieldCount > 1) { colSpanFieldCount = field.Attributes.FieldCount - 1; colSpanField = field; colSpanFieldValues = new List <string> { columnValue }; } if (colSpanFieldCount == 0 && !string.IsNullOrEmpty(columnValue)) { if (string.IsNullOrEmpty(result)) { result = columnValue; } else { if (!string.IsNullOrEmpty(combineString)) { result += $"{combineString}{columnValue}"; } else if (range > 0) { result += columnValue; } else { result += $" {columnValue}"; } } combineString = range <= 0 ? currentCombineString : string.Empty; } } return(options.HasFlag(UPFormatOption.DontRemoveLineBreak) ? result : result?.SingleLineString()); }
/// <summary> /// Section key for row /// </summary> /// <param name="dataRow">Data row</param> /// <param name="context">Context</param> /// <returns><see cref="string"/></returns> private string SectionKeyForRow(UPCRMResultRow dataRow, UPCoreMappingResultContext context) { var sectionIndex = dataRow.ValueAtIndex(context.SectionField?.TabIndependentFieldIndex ?? 0); return(this.CheckSectionIndex(sectionIndex, context)); }
private void ProcessFields( ICollection <string> rawFieldValues, ICollection <string> fieldLabels, ICollection <string> fieldValues, int count, bool needsRawValues, bool needsLabels, IReadOnlyList <UPContainerFieldMetaInfo> resultFieldMap, UPCRMResultRow row) { var nextIndex = 1; for (var i = 0; i < count; i++) { var fieldIndexInTableCaption = this.hasFieldMap ? this.fieldMap[i].ToInt() : i + 1; while (nextIndex < fieldIndexInTableCaption) { fieldValues.Add(string.Empty); if (needsRawValues) { rawFieldValues.Add(string.Empty); } ++nextIndex; } string val, rawValue = null; if (resultFieldMap != null) { var fieldMetaInfo = resultFieldMap[i]; if (fieldMetaInfo != null) { val = row.ValueForField(fieldMetaInfo); if (needsRawValues) { rawValue = row.RawValueForField(fieldMetaInfo); } if (needsLabels) { var fieldLabel = fieldMetaInfo.CrmField?.Label; fieldLabels.Add(fieldLabel ?? string.Empty); } } else { val = string.Empty; rawValue = string.Empty; } } else { val = row.ValueAtIndex(i); if (needsRawValues) { rawValue = row.RawValueAtIndex(i); } } fieldValues.Add(val == null ? string.Empty : val.SingleLineString()); if (needsRawValues) { rawFieldValues.Add(rawValue ?? string.Empty); } ++nextIndex; } }
/// <summary> /// Edits the contexts for result row. /// </summary> /// <param name="resultRow">The result row.</param> /// <param name="tabConfig">The tab configuration.</param> /// <param name="editFieldDictionary">The edit field dictionary.</param> /// <param name="initialValues">The initial values.</param> /// <param name="fieldPostfix">The field postfix.</param> /// <param name="initialRecords">The initial records.</param> /// <returns></returns> public List <object> EditContextsForResultRow(UPCRMResultRow resultRow, FieldControlTab tabConfig, Dictionary <string, UPEditFieldContext> editFieldDictionary, Dictionary <string, object> initialValues, string fieldPostfix, List <UPCRMRecord> initialRecords) { var recordIdentification = resultRow?.RecordIdentificationAtIndex(0); var fieldArray = new List <object>(); UPCRMRecord offlineRootRecord = null; if (initialRecords?.Count > 0) { offlineRootRecord = initialRecords.FirstOrDefault(); } var identifierPrefix = recordIdentification; if (string.IsNullOrEmpty(identifierPrefix)) { identifierPrefix = $"{this.TabConfig.FieldControl.UnitName}_{this.TabIndex}"; } var fieldCount = tabConfig?.NumberOfFields ?? 0; for (var j = 0; j < fieldCount; j++) { var fieldConfig = tabConfig?.FieldAtIndex(j); if (fieldConfig == null) { continue; } var fieldAttributes = fieldConfig.Attributes; var currentInfoAreaId = fieldConfig.InfoAreaId; var currentLinkId = fieldConfig.LinkId; var fieldIdentifier = FieldIdentifier.IdentifierWithRecordIdentificationFieldId(identifierPrefix, fieldConfig.Identification); UPSelector selector = null; var selectorDef = fieldConfig.Attributes?.Selector; if (selectorDef != null) { var filterParameters = this.EditPageContext?.ViewReference?.ContextValueForKey("copyFields")?.JsonDictionaryFromString(); if (resultRow?.Result != null && resultRow.IsNewRow) { selector = UPSelector.SelectorFor( resultRow.RootRecordIdentification?.InfoAreaId(), resultRow.Result.ParentRecordIdentification, resultRow.Result.LinkId, selectorDef, filterParameters, fieldConfig); } else { selector = UPSelector.SelectorFor(resultRow?.RootRecordIdentification, selectorDef, filterParameters, fieldConfig); } selector.Build(); if (selector.OptionCount == 0 && selector.IsStaticSelector) { selector = null; } } var isEditField = this.enableLinkedEditFields || selector != null || (tabConfig.FieldControl.InfoAreaId == currentInfoAreaId && currentLinkId <= 0); var isHidden = fieldAttributes.Hide; var isReadOnly = isEditField && fieldAttributes.ReadOnly; var rawFieldValue0 = resultRow?.RawValueAtIndex(fieldConfig.TabIndependentFieldIndex); var fieldInfo = fieldConfig.Field.FieldInfo; if (isEditField && !isReadOnly && !(selector is UPRecordSelector && ((UPRecordSelector)selector).IgnoreFieldInfo)) { if (fieldInfo.IsReadOnly) { isReadOnly = true; } else if (resultRow?.IsNewRow == true || string.IsNullOrEmpty(rawFieldValue0)) { if (fieldInfo.LockedOnNew) { isReadOnly = true; } } else if (fieldInfo.LockedOnUpdate && !fieldInfo.IsEmptyValue(rawFieldValue0)) { isReadOnly = true; } } string offlineValue = null; bool offlineChanged; string rawFieldValue; UPEditFieldContext editFieldContext; if (isEditField) { List <UPEditFieldContext> childFields = null; if (fieldAttributes.FieldCount > 1 && selector == null) { childFields = new List <UPEditFieldContext>(); for (var k = 1; k < fieldAttributes.FieldCount; k++) { var childFieldConfig = tabConfig.FieldAtIndex(++j); if (childFieldConfig != null) { rawFieldValue = resultRow.RawValueAtIndex(childFieldConfig.TabIndependentFieldIndex); if (initialValues != null) { rawFieldValue = this.ValueByApplyingInitialValuesForField(rawFieldValue, childFieldConfig, initialValues); } offlineChanged = false; if (offlineRootRecord != null) { offlineValue = offlineRootRecord.StringFieldValueForFieldIndex(childFieldConfig.FieldId); if (offlineValue != null && !offlineValue.Equals(rawFieldValue)) { offlineChanged = true; } } editFieldContext = UPEditFieldContext.ChildFieldContextForFieldConfigValue(childFieldConfig, rawFieldValue); if (offlineChanged) { editFieldContext.SetOfflineChangeValue(offlineValue); } childFields.Add(editFieldContext); } } } var markAsChanged = false; rawFieldValue = rawFieldValue0; if (initialValues != null) { string initialValue = this.ValueByApplyingInitialValuesForField(rawFieldValue, fieldConfig, initialValues); if (!rawFieldValue.Equals(initialValue)) { markAsChanged = true; rawFieldValue = initialValue; } } offlineChanged = false; offlineValue = null; if (offlineRootRecord != null) { offlineValue = offlineRootRecord.StringFieldValueForFieldIndex(fieldConfig.FieldId); if (offlineValue != null && !offlineValue.Equals(rawFieldValue)) { offlineChanged = true; } } if (selector != null) { // Sometimes it makes sense to add the Link field , so you have the link information on the EditPage , but the field is not displayed . // Thus, the field is interpreted as EditField Selector must be set. if (isHidden) { editFieldContext = UPEditFieldContext.HiddenFieldFor(fieldConfig, fieldIdentifier, rawFieldValue); } else if (isReadOnly && ConfigurationUnitStore.DefaultStore.ConfigValueIsSet("Disable.82213")) { editFieldContext = UPEditFieldContext.ReadonlyFieldFor(fieldConfig, fieldIdentifier, rawFieldValue); } else { editFieldContext = UPEditFieldContext.FieldContextFor(fieldConfig, fieldIdentifier, rawFieldValue, selector); } } else { if (isHidden) { editFieldContext = UPEditFieldContext.HiddenFieldFor(fieldConfig, fieldIdentifier, rawFieldValue); } else if (isReadOnly) { editFieldContext = UPEditFieldContext.ReadonlyFieldFor(fieldConfig, fieldIdentifier, rawFieldValue); } else { editFieldContext = UPEditFieldContext.FieldContextFor(fieldConfig, fieldIdentifier, rawFieldValue, childFields as List <UPEditFieldContext>); } } if (fieldInfo.DateFieldId >= 0 && tabConfig.FieldControl.InfoAreaId == currentInfoAreaId) { editFieldContext.DateOriginalValue = resultRow?.RawValueForFieldIdInfoAreaIdLinkId(fieldInfo.DateFieldId, currentInfoAreaId, -1); } else if (fieldInfo.TimeFieldId >= 0 && tabConfig.FieldControl.InfoAreaId == currentInfoAreaId) { editFieldContext.TimeOriginalValue = resultRow?.RawValueForFieldIdInfoAreaIdLinkId(fieldInfo.TimeFieldId, currentInfoAreaId, -1); } if (offlineChanged) { editFieldContext.SetOfflineChangeValue(offlineValue); } else if (markAsChanged) { editFieldContext.SetChanged(true); } if (editFieldContext != null) { if (!string.IsNullOrEmpty(fieldPostfix)) { editFieldContext.FieldLabelPostfix = fieldPostfix; } if (editFieldDictionary != null) { editFieldDictionary.SetObjectForKey(editFieldContext, fieldConfig.Identification); if (childFields != null) { foreach (var childFieldContext in childFields) { editFieldDictionary.SetObjectForKey(childFieldContext, childFieldContext.FieldConfig.Identification); } } } fieldArray.Add(editFieldContext); } } else { string fieldValue; if (fieldAttributes.FieldCount > 1) { fieldValue = resultRow?.ValueAtIndex(fieldConfig.TabIndependentFieldIndex); if (string.IsNullOrEmpty(fieldValue)) { fieldValue = this.ValueForLinkFieldFromInitialValues(fieldConfig, initialValues); } var values = !string.IsNullOrEmpty(fieldValue) ? new List <string> { fieldValue } : new List <string>(); for (var k = 1; k < fieldAttributes.FieldCount; k++) { var childfieldConfig = tabConfig.FieldAtIndex(++j); if (childfieldConfig == null) { continue; } fieldValue = resultRow?.ValueAtIndex(childfieldConfig.TabIndependentFieldIndex); if (string.IsNullOrEmpty(fieldValue)) { fieldValue = this.ValueForLinkFieldFromInitialValues(childfieldConfig, initialValues); } if (string.IsNullOrEmpty(fieldValue)) { fieldValue = string.Empty; } values.Add(fieldValue); } fieldValue = fieldAttributes.FormatValues(values); } else { fieldValue = resultRow?.ValueAtIndex(fieldConfig.TabIndependentFieldIndex); if (string.IsNullOrEmpty(fieldValue)) { fieldValue = this.ValueForLinkFieldFromInitialValues(fieldConfig, initialValues); } } UPMField field; if (!isHidden && !string.IsNullOrEmpty(fieldValue)) { field = new UPMStringField(fieldIdentifier); ((UPMStringField)field).StringValue = fieldValue; } else { field = null; } if (field != null) { if (!fieldConfig.Attributes.NoLabel) { field.LabelText = fieldConfig.Label; } SetAttributesOnField(fieldAttributes, field); fieldArray.Add(field); } } } return(fieldArray); }
/// <summary> /// Applies the result row. /// </summary> /// <param name="resultRow">The result row.</param> /// <returns></returns> public override UPMGroup ApplyResultRow(UPCRMResultRow resultRow) { this.ExplicitTabIdentifier = this.TabIdentifierForRecordIdentification(resultRow.RootRecordIdentification); int fieldCount = this.TabConfig.NumberOfFields; UPConfigFieldControlField participantsField = null; for (int i = 0; i < fieldCount; i++) { UPConfigFieldControlField fieldConfig = this.TabConfig.FieldAtIndex(i); if (fieldConfig.Field.FieldInfo.IsParticipantsField) { participantsField = fieldConfig; break; } } var tabTypeParts = this.TabConfig.Type.Split('_'); this.linkParticipantsName = null; if (tabTypeParts.Length > 1) { this.linkParticipantsName = tabTypeParts[1]; var configParts = this.linkParticipantsName.Split('#'); if (configParts.Length > 1) { this.linkParticipantsName = configParts[0]; } } this.recordParticipants = !string.IsNullOrEmpty(this.linkParticipantsName) ? new UPCRMRecordParticipants(resultRow.RootRecordIdentification, this.linkParticipantsName, -1, this) : new UPCRMRecordParticipants(resultRow.RootRecordIdentification, this); if (this.linkParticipantsName != null && !this.recordParticipants.SetFieldsFromSearchAndListConfigurationName(this.linkParticipantsName)) { this.linkParticipantsName = null; } if (participantsField != null) { this.recordParticipants.AddParticipantsFromString(resultRow.ValueAtIndex(participantsField.TabIndependentFieldIndex)); } //2019-07-22 Rep Selection - Reverted if condition //if (!string.IsNullOrEmpty(this.linkParticipantsName)) //{ // this.Group = null; // this.ControllerState = GroupModelControllerState.Pending; // this.recordParticipants.LinkParticipantsRequestOption = this.RequestOption; // this.recordParticipants.Load(); //} //else //{ // this.Group = this.CreateGroup(); // this.ControllerState = GroupModelControllerState.Finished; //} if (string.IsNullOrEmpty(this.linkParticipantsName)) { this.Group = null; this.ControllerState = GroupModelControllerState.Pending; this.recordParticipants.LinkParticipantsRequestOption = this.RequestOption; this.recordParticipants.Load(); } else { this.Group = this.CreateGroup(); this.ControllerState = GroupModelControllerState.Finished; } // this.signalFinished = true; return(this.Group); }
private UPMGroup AddFieldsToDetailGroup(UPMGroup upmGroup, string recordIdentification, UPCRMResultRow resultRow, out string documentKey, out UPConfigFieldControlField documentFieldConfig) { var configStore = ConfigurationUnitStore.DefaultStore; var hideEmptyFields = configStore.ConfigValueIsSet("View.HideEmptyFields"); documentKey = string.Empty; documentFieldConfig = null; var listFormatter = new UPCRMListFormatter(this.TabConfig, false); var fieldCount = listFormatter.PositionCount; var detailGroup = upmGroup; for (var j = 0; j < fieldCount; j++) { var fieldConfig = listFormatter.FirstFieldForPosition(j); var fieldAttributes = fieldConfig.Attributes; var fieldIdentifier = FieldIdentifier.IdentifierWithRecordIdentificationFieldId(recordIdentification, fieldConfig.Identification); var hasFieldValue = false; if (fieldAttributes.Image) { documentKey = resultRow.ValueAtIndex(fieldConfig.TabIndependentFieldIndex); documentFieldConfig = fieldConfig; if (!string.IsNullOrEmpty(documentKey) && fieldCount == 1) { detailGroup = this.AddFieldToDetailGroup(detailGroup, fieldIdentifier, recordIdentification); } continue; } if (fieldAttributes.Hide) { continue; } if (fieldAttributes.Empty) { detailGroup = this.AddFieldToDetailGroup(detailGroup, recordIdentification, fieldIdentifier, fieldAttributes); continue; } string fieldValue = null; try { fieldValue = listFormatter.StringFromRowForPosition(resultRow, j); } catch (Exception error) { SimpleIoc.Default.GetInstance <ILogger>().LogError(error); } if (!string.IsNullOrEmpty(fieldValue)) { hasFieldValue = true; } if (!hasFieldValue && hideEmptyFields && !this.columnStyle) { if (!(detailGroup is UPMCalendarPopoverGroup) || j > 3) { continue; } } if (fieldAttributes.MultiLine && j + 1 == fieldCount && detailGroup == null) { var multiLineGroup = this.CreateMultilineGroup(recordIdentification, CreateStringField(fieldIdentifier, fieldAttributes, fieldValue), fieldConfig); this.ControllerState = GroupModelControllerState.Finished; this.Group = multiLineGroup; return(multiLineGroup); } var field = this.CreateField(fieldAttributes, fieldIdentifier, fieldConfig, resultRow, recordIdentification, configStore); if (field == null) { continue; } UpdateField(field, fieldAttributes, fieldConfig, fieldValue); if (string.IsNullOrWhiteSpace(field.LabelText) && string.IsNullOrEmpty(fieldValue)) { continue; } detailGroup = this.AddFieldToDetailGroup(detailGroup, fieldAttributes, field, recordIdentification); } return(detailGroup); }
/// <summary> /// Sets from result row. /// </summary> /// <param name="row">The row.</param> public void SetFromResultRow(UPCRMResultRow row) { if (row != null) { this.Record = new UPCRMRecord(row.RootRecordIdentification); this.values = new List <string>(); if (this.AdditionalFields?.Count > 0) { if (this.Group.Characteristics.EditMode == false) { foreach (UPConfigFieldControlField field in this.AdditionalFields) { string value = row.RawValueAtIndex(field.TabIndependentFieldIndex); this.values.Add(field.IsEmptyValue(value) ? string.Empty : row.ValueAtIndex(field.TabIndependentFieldIndex)); } } else { foreach (UPConfigFieldControlField field in this.AdditionalFields) { this.values.Add(row.RawValueAtIndex(field.TabIndependentFieldIndex)); } } } this.OriginalValues = new List <string>(this.values); } else { this.Record = null; if (this.AdditionalFields?.Count > 0) { this.values = new List <string>(); for (int i = 0; i < this.AdditionalFields.Count; i++) { this.values.Add(string.Empty); } } this.OriginalValues = null; } this.Created = false; this.Deleted = false; this.Changed = false; }
private bool FillPageWithDocumentsResult(UPMDocumentPage page, UPCRMResult result) { int count = result?.RowCount ?? 0; if (count == 0) { return(false); } UPMDocumentSection lastSection = null; int groupingIndex = -1; for (int i = 0; i < result.ColumnCount; i++) { if (result.ColumnFieldMetaInfoAtIndex(i).FunctionName == "groupingKey") { groupingIndex = i; break; } } page.AvailableGrouping = groupingIndex != -1; DocumentInfoAreaManager documentInfoAreaManager = new DocumentInfoAreaManager(this.preparedSearch.CombinedControl.InfoAreaId, this.preparedSearch.CombinedControl, null); Dictionary <string, UPMDocumentSection> groupDictionary = new Dictionary <string, UPMDocumentSection>(); for (int i = 0; i < count; i++) { UPCRMResultRow resultRow = (UPCRMResultRow)result.ResultRowAtIndex(i); DocumentData documentData = documentInfoAreaManager.DocumentDataForResultRow(resultRow); string groupValue = string.Empty; if (groupingIndex != -1) { groupValue = resultRow.ValueAtIndex(groupingIndex); } UPMDocumentSection section; bool isLastSection; if (string.IsNullOrEmpty(groupValue)) { groupValue = "#"; isLastSection = true; section = lastSection; } else { isLastSection = false; section = groupDictionary.ValueOrDefault(groupValue); } if (section == null) { section = new UPMDocumentSection(StringIdentifier.IdentifierWithStringId(groupValue)) { GroupName = new UPMStringField(StringIdentifier.IdentifierWithStringId(groupValue)) { StringValue = groupValue } }; if (isLastSection) { lastSection = section; // Dont add to page here # should always be the last } else { groupDictionary.SetObjectForKey(section, groupValue); page.AddChild(section); } } UPMDocument document = new UPMDocument(documentData); section.AddChild(document); } if (lastSection != null) { page.AddChild(lastSection); } return(true); }
/// <summary> /// Values for item key result position. /// </summary> /// <param name="itemkey">The itemkey.</param> /// <param name="resultPosition">The result position.</param> /// <returns></returns> public string ValueForItemKeyResultPosition(string itemkey, int resultPosition) { UPCRMResultRow row = this.rowFromItemKey.ValueOrDefault(itemkey); return(row != null?row.ValueAtIndex(resultPosition) : string.Empty); }
UPMGroup GroupFromRow(UPCRMResultRow resultRow) { if (resultRow.IsNewRow()) { this.ParticipantsControl = new UPCRMMutableParticipants(null, resultRow.RootRecordIdentification.InfoAreaId(), null, -1, null, this); NSDictionary parentInitialValues = this.EditPageContext.initialValues; string childGroupKey = this.ChildGroupKey(); ArrayList parentInitialValueDictionaries = parentInitialValues.ObjectForKey(childGroupKey); if (parentInitialValueDictionaries.Count > 0) { if (parentInitialValueDictionaries != null) { foreach (NSDictionary parentInitialValueForChild in parentInitialValueDictionaries) { string value = null; NSDictionary options = null; foreach (string key in parentInitialValueForChild) { if (key.IsEqualToString(".Options")) { ArrayList optionStringArray = parentInitialValueForChild.ObjectForKey(key); options = UPEditChildrenGroupModelControllerBase.OptionsFromStringArray(optionStringArray); } else if (value == null) { value = parentInitialValueForChild.ObjectForKey(key); } } if (value.Length > 0) { this.ParticipantsControl.AddRepParticipantWithRepIdWithOptions(value, options); } else { firstItemOptions = options; } } } } if (this.ParticipantsField != null) { editFieldContext = new UPParticipantsEditFieldContext(this.ParticipantsField, null, string.Empty, null); } } else if (this.ParticipantsField != null) { this.LinkRecordIdentification = resultRow.RootRecordIdentification(); string participantsString = resultRow.ValueAtIndex(this.ParticipantsField.TabIndependentFieldIndex); this.ParticipantsControl = new UPCRMMutableParticipants(null, null, null, -1, resultRow.RootRecordIdentification(), this); editFieldContext = new UPParticipantsEditFieldContext(this.ParticipantsField, null, participantsString, null); this.ParticipantsControl.AddParticipantsFromString(participantsString); } else { this.Group = null; this.ControllerState = UPGroupModelControllerStateEmpty; return(this.Group); } if (editFieldContext != null) { editFieldContext.GroupModelController = this; this.EditPageContext.EditFields.SetObjectForKey(editFieldContext, editFieldContext.Key); } if (this.LinkParticipantsName.Length) { this.ParticipantsControl.SetFieldsFromSearchAndListConfigurationName(this.LinkParticipantsName); } if (this.AddRecordEnabled || this.ParticipantsControl.Participants.Count > 0) { this.ControllerState = UPGroupModelControllerStatePending; this.ParticipantsControl.Load(); } else { this.Group = null; this.ControllerState = UPGroupModelControllerStateEmpty; } signalFinished = true; return(this.Group); }
private UPMGroup GroupFromRow(UPCRMResultRow resultRow) { if (resultRow.IsNewRow) { this.ParticipantsControl = new UPCRMMutableParticipants( null, resultRow.RootRecordIdentification.InfoAreaId(), resultRow.RootRecordIdentification, null, -1, this); var parentInitialValues = this.EditPageContext.InitialValues; var childGroupKey = this.ChildGroupKey; var parentInitialValueDictionaries = parentInitialValues.ValueOrDefault(childGroupKey) as List <Dictionary <string, object> >; if (parentInitialValueDictionaries?.Count > 0) { foreach (var parentInitialValueForChild in parentInitialValueDictionaries) { string value = null; Dictionary <string, object> options = null; foreach (var key in parentInitialValueForChild.Keys) { if (key == ".Options") { var optionStringArray = parentInitialValueForChild.ValueOrDefault(key) as List <string>; options = OptionsFromStringArray(optionStringArray); } else if (value == null) { value = parentInitialValueForChild.ValueOrDefault(key) as string; } } if (!string.IsNullOrEmpty(value)) { this.ParticipantsControl.AddRepParticipantWithRepId(value, options); } else { this.firstItemOptions = options; } } } if (this.ParticipantsField != null) { this.editFieldContext = new UPParticipantsEditFieldContext(this.ParticipantsField, null, string.Empty, null); } } else if (this.ParticipantsField != null) { this.LinkRecordIdentification = resultRow.RootRecordIdentification; var participantsString = resultRow.ValueAtIndex(this.ParticipantsField.TabIndependentFieldIndex); this.ParticipantsControl = new UPCRMMutableParticipants(null, null, resultRow.RootRecordIdentification, null, -1, this); this.editFieldContext = new UPParticipantsEditFieldContext(this.ParticipantsField, null, participantsString, null); this.ParticipantsControl.AddParticipantsFromString(participantsString); } else { this.Group = null; this.ControllerState = GroupModelControllerState.Empty; return(this.Group); } if (this.editFieldContext != null) { this.editFieldContext.GroupModelController = this; this.EditPageContext.EditFields.SetObjectForKey(this.editFieldContext, this.editFieldContext.Key); } if (!string.IsNullOrEmpty(this.LinkParticipantsName)) { this.ParticipantsControl?.SetFieldsFromSearchAndListConfigurationName(this.LinkParticipantsName); } if (this.AddRecordEnabled || this.ParticipantsControl?.Participants.Count > 0) { this.ControllerState = GroupModelControllerState.Pending; this.ParticipantsControl?.Load(); } else { this.Group = null; this.ControllerState = GroupModelControllerState.Empty; } this.signalFinished = true; return(this.Group); }
/// <summary> /// Creates the specified row. /// </summary> /// <param name="row">The row.</param> /// <param name="tabConfig">The tab configuration.</param> /// <returns></returns> public static UPGeoLocation Create(UPCRMResultRow row, FieldControlTab tabConfig) { try { string gpsXString = null, gpsYString = null, addressTitle = null; var currentFieldIndex = 0; var found = false; var numberOfFields = tabConfig.NumberOfFields; var address = new StringBuilder(); while (currentFieldIndex + 1 < numberOfFields) { gpsXString = row.RawValueAtIndex(tabConfig.FieldAtIndex(currentFieldIndex++).TabIndependentFieldIndex); gpsYString = row.RawValueAtIndex(tabConfig.FieldAtIndex(currentFieldIndex++).TabIndependentFieldIndex); if (string.IsNullOrEmpty(gpsXString) || Convert.ToDecimal(gpsXString, System.Globalization.CultureInfo.InvariantCulture) == 0m || string.IsNullOrEmpty(gpsYString) || Convert.ToDecimal(gpsYString) == 0m) { gpsXString = gpsYString = string.Empty; } else { found = true; } if (currentFieldIndex < numberOfFields) { UPConfigFieldControlField addressNameField = tabConfig.FieldAtIndex(currentFieldIndex++); int fieldCount = addressNameField.Attributes.FieldCount; if (fieldCount <= 1) { addressTitle = row.ValueAtIndex(addressNameField.TabIndependentFieldIndex); } else { addressTitle = FormattedValueForResultRowFieldControlTabFieldIndex(row, tabConfig, currentFieldIndex + 1); currentFieldIndex += fieldCount - 1; } } if (currentFieldIndex < numberOfFields) { UPConfigFieldControlField addressField = tabConfig.FieldAtIndex(currentFieldIndex++); int fieldCount = addressField.Attributes.FieldCount; if (fieldCount <= 1) { address.Append(row.ValueAtIndex(addressField.TabIndependentFieldIndex)); } else { address.Append(FormattedValueForResultRowFieldControlTabFieldIndex(row, tabConfig, currentFieldIndex - 1)); currentFieldIndex += fieldCount - 1; } if (address.Length > 1) { found = true; break; } } } if (found) { while (currentFieldIndex + 1 < numberOfFields) { if (currentFieldIndex < numberOfFields) { UPConfigFieldControlField addressField = tabConfig.FieldAtIndex(currentFieldIndex++); int fieldCount = addressField.Attributes.FieldCount; if (fieldCount <= 1) { address.Append($" , {row.ValueAtIndex(addressField.TabIndependentFieldIndex)}"); } else { address.Append($" , {FormattedValueForResultRowFieldControlTabFieldIndex(row, tabConfig, currentFieldIndex - 1)}"); currentFieldIndex += fieldCount - 1; } } } return(new UPGeoLocation(gpsXString, gpsYString, addressTitle, address.ToString())); } } catch (Exception error) { SimpleIoc.Default.GetInstance <ILogger>().LogError(error); } return(null); }