/// <summary> /// Results for row. /// </summary> /// <param name="row">The row.</param> /// <returns>the result for a row</returns> public virtual bool ResultForRow(UPCRMResultRow row) { var crmQuery = row?.Result?.MetaInfo; var resultPosition = crmQuery?.PositionForField(this.Field) ?? -1; return(resultPosition >= 0 && this.ResultForValue(row?.RawValueAtIndex(resultPosition))); }
private void ProcessOfflineRecords(IEnumerable <UPCRMRecord> offlineRecords, UPCRMResultRow resultRow) { foreach (var record in offlineRecords) { if (record.Mode == "NewOffline" || record.Mode == "Sync") { continue; } string participantsRecordIdentification = null; foreach (var link in record.Links) { if (link.RecordIdentification.InfoAreaId() == resultRow.RootRecordIdentification.InfoAreaId()) { continue; } participantsRecordIdentification = link.RecordIdentification; } if (!string.IsNullOrEmpty(participantsRecordIdentification)) { var participant = this.ParticipantsControl.AddLinkParticipantWithRecordIdentification(participantsRecordIdentification, null); if (this.firstItemOptions != null) { participant.Options = this.firstItemOptions; this.firstItemOptions = null; } } } }
/// <summary> /// Checks the specified row. /// </summary> /// <param name="row"> /// The row. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public override bool Check(UPCRMResultRow row) { return(this.Field.CheckValueMatchesValueCondition( row.RawValueAtIndex(this.ResultPosition), this.FieldValue, this.Condition)); }
private void ApplyQuotaResult(UPCRMResult result) { int count = result.RowCount; this.quotaDictionary = new Dictionary <string, UPSEQuota>(); for (int i = 0; i < count; i++) { UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(i); Dictionary <string, object> dict = row.ValuesWithFunctions(); string itemNumber = dict.ValueOrDefault(this.ItemNumberFunctionName) as string; if (string.IsNullOrEmpty(itemNumber)) { continue; } UPSEQuota quota = this.quotaDictionary.ValueOrDefault(itemNumber); if (quota == null) { quota = new UPSEQuota(itemNumber, this); this.quotaDictionary.SetObjectForKey(quota, itemNumber); } quota.ApplyRecordIdentificationValues(row.RootRecordIdentification, dict); } this.Finished(); }
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> /// The query table for result row. /// </summary> /// <param name="row"> /// The row. /// </param> /// <returns> /// The <see cref="UPConfigQueryTable"/>. /// </returns> public UPConfigQueryTable QueryTableForResultRow(UPCRMResultRow row) { var resultFieldMap = this.ResultFieldMap ?? this.ResultFeldMapFromCrmQuery(row.Result.MetaInfo); if (resultFieldMap == null) { return(null); } Dictionary <string, object> valueDictionary = new Dictionary <string, object>(resultFieldMap.Count); foreach (string key in resultFieldMap.Keys) { int position = resultFieldMap[key]; var value = position < 0 ? string.Empty : row.RawValueAtIndex(position); valueDictionary.Add(key, value); } UPConfigQueryTable foundTable = this.Filter.RootTable.QueryTableForValueDictionaryWithSubInfoAreas(valueDictionary, true); if (foundTable == null) { return(this.Filter.RootTable); } return(foundTable); }
/// <summary> /// Applies the result row. /// </summary> /// <param name="row">The row.</param> /// <returns></returns> public override UPMGroup ApplyResultRow(UPCRMResultRow row) { UPMGroup group = this.ApplyLinkRecordIdentification(row.RootRecordIdentification); group?.Actions.AddRange(this.BuildAdditionalActionsForRecordIdentification(row.RootRecordIdentification)); return(group); }
/// <summary> /// Tables the caption for result row result field map trim. /// </summary> /// <param name="row">The row.</param> /// <param name="resultFieldMap">The result field map.</param> /// <param name="trim">if set to <c>true</c> [trim].</param> /// <returns>table caption</returns> public string TableCaptionForResultRow(UPCRMResultRow row, List <UPContainerFieldMetaInfo> resultFieldMap, bool trim) { int count; var fieldValues = new List <string>(); var needsRawValues = this.FormatString.IndexOf("%r", StringComparison.Ordinal) > -1; var needsLabels = this.FormatString.IndexOf("{label:", StringComparison.Ordinal) > -1; if (this.SpecialDefArray != null) { count = this.SpecialDefArray.Count; for (var i = 0; !needsRawValues && i < count; i++) { var specialDef = this.SpecialDefArray[i]; needsRawValues = specialDef?.FormatString?.IndexOf("%r", StringComparison.Ordinal) > -1; needsLabels = specialDef?.FormatString?.IndexOf("{label:", StringComparison.Ordinal) > -1; } } count = this.Fields.Count; var rawFieldValues = needsRawValues ? new List <string>() : null; var fieldLabels = needsLabels ? new List <string>() : null; this.ProcessFields(rawFieldValues, fieldLabels, fieldValues, count, needsRawValues, needsLabels, resultFieldMap, row); return(this.GetTableCaption(fieldValues, needsLabels, fieldLabels, needsRawValues, rawFieldValues, trim, count)); }
private void SurveyAnswersLoaded(UPCRMResult result) { int count = result.RowCount; for (int i = 0; i < count; i++) { UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(i); Dictionary <string, object> valuesWithFunction = row.ValuesWithFunctions(); string questionKey = valuesWithFunction.ValueOrDefault(Constants.QuestionnaireQuestionNumber) as string; UPQuestionnaireQuestion question = this.Questionnaire?.QuestionForId(questionKey); if (question == null) { continue; } UPSurveyAnswer answer = null; if (question.Multiple) { answer = this.surveyAnswers.ValueOrDefault(questionKey); } if (answer == null) { answer = new UPSurveyAnswer(row.RootRecordIdentification, valuesWithFunction, question, this); this.surveyAnswers[questionKey] = answer; } else { answer.AddAnswer(valuesWithFunction, row.RootRecordIdentification); } } this.crmQuery = null; this.LoadFinished(); }
/// <summary> /// Creates the node from result row. /// </summary> /// <param name="row">The row.</param> /// <param name="currentDepth">The current depth.</param> /// <param name="expandChecker">The expand checker.</param> /// <param name="infoAreaConfigs">The information area configs.</param> /// <param name="infoAreaMapping">The information area mapping.</param> /// <returns></returns> public static UPMCoINode CreateNodeFromResultRow(UPCRMResultRow row, int currentDepth, UPConfigExpand expandChecker, List <CoITreeInfoAreaConfig> infoAreaConfigs, Dictionary <string, CoITreeInfoAreaConfig> infoAreaMapping) { string trgtNodeFieldSuffix = string.Empty; string recordIdentification = row.RootRecordIdentification; string rootInfoAreaId = recordIdentification.InfoAreaId(); if (infoAreaConfigs != null) { foreach (CoITreeInfoAreaConfig infoAreaConfig in infoAreaConfigs) { string linkRecordIdentifictaion = row.RecordIdentificationForLinkInfoAreaIdLinkId(infoAreaConfig.InfoAreaId, infoAreaConfig.LinkId); if (!string.IsNullOrEmpty(linkRecordIdentifictaion.RecordId())) { trgtNodeFieldSuffix = infoAreaConfig.FunctionNameSuffix; recordIdentification = linkRecordIdentifictaion; infoAreaMapping[recordIdentification] = infoAreaConfig; break; } } } string virtualInfoAreaId = row.RootVirtualInfoAreaId == rootInfoAreaId ? null : row.RootVirtualInfoAreaId; UPMCoINode node = CreateNodeFromResultRow(row, virtualInfoAreaId, recordIdentification, currentDepth, infoAreaConfigs == null, expandChecker, trgtNodeFieldSuffix, recordIdentification.InfoAreaId()); return(node); }
private void HandleOwnerResult(UPCRMResult result) { int count = result.RowCount; if (count > 0) { List <UPSEListingOwner> relatedOwnersForCurrentOwner = new List <UPSEListingOwner>(); for (int i = 0; i < count; i++) { UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(i); string recordIdentification = row.RecordIdentificationAtIndex(1); if (string.IsNullOrEmpty(recordIdentification)) { continue; } UPSEListingOwner relatedOwner = this.listingOwners.ValueOrDefault(row.RecordIdentificationAtIndex(1)); if (relatedOwner == null) { relatedOwner = new UPSEListingOwner((UPCRMResultRow)result.ResultRowAtIndex(i), 1, this.ListingOwnerMapping, this); this.loadQueue.Add(relatedOwner); this.listingOwners.SetObjectForKey(relatedOwner, relatedOwner.RecordIdentification); } relatedOwnersForCurrentOwner.Add(relatedOwner); } this.currentLoadedOwner.RelatedOwners = relatedOwnersForCurrentOwner; } this.LoadNextItemFromQueue(); }
private string PhysicalInfoArea(UPCRMResultRow row) { if (this.fiResultColumnIndex == -1) { this.fiResultColumnIndex = row.Result.MetaInfo.IndexOfResultInfoAreaIdLinkId("FI", 1); } if (this.kpResultColumnIndex == -1) { this.kpResultColumnIndex = row.Result.MetaInfo.IndexOfResultInfoAreaIdLinkId("KP", 1); } bool kpRow = false; string physicalInfoArea = null; if (this.kpResultColumnIndex != -1) { string recordIdentification = row.RecordIdentificationAtIndex(this.kpResultColumnIndex); if (recordIdentification?.Length > 3) { kpRow = true; physicalInfoArea = row.PhysicalInfoAreaIdAtIndex(this.kpResultColumnIndex); } } if (!kpRow && this.fiResultColumnIndex != -1) { physicalInfoArea = row.PhysicalInfoAreaIdAtIndex(this.fiResultColumnIndex); } return(physicalInfoArea); }
/// <summary> /// Initializes a new instance of the <see cref="UPSerialEntryParentInfoPanel"/> class. /// </summary> /// <param name="fieldControl">The field control.</param> /// <param name="resultRow">The result row.</param> public UPSerialEntryParentInfoPanel(FieldControl fieldControl, UPCRMResultRow resultRow) { int tabs = fieldControl.NumberOfTabs; List <UPSerialEntryParentInfoPanelCell> cells = new List <UPSerialEntryParentInfoPanelCell>(); for (int index = 0; index < tabs; index++) { FieldControlTab tabControl = fieldControl.TabAtIndex(index); if (tabControl.NumberOfFields > 0 && string.IsNullOrEmpty(tabControl.Type)) { UPSerialEntryParentInfoPanelCell cell = new UPSerialEntryParentInfoPanelCell(tabControl, resultRow); string ownImageName = fieldControl.ValueForAttribute($"ParentInfoImage{index}") ?? tabControl.ValueForAttribute("ParentInfoImage"); if (!string.IsNullOrEmpty(ownImageName)) { cell.ImageName = ownImageName; } int minFields = !string.IsNullOrEmpty(tabControl.Label) ? 1 : 0; if (cell.FieldValues.Count > minFields) { cells.Add(cell); } } } this.Cells = cells; }
/// <summary> /// Initializes a new instance of the <see cref="UPSerialEntryParentInfoPanelCell"/> class. /// </summary> /// <param name="fieldControlTab">The field control tab.</param> /// <param name="resultRow">The result row.</param> public UPSerialEntryParentInfoPanelCell(FieldControlTab fieldControlTab, UPCRMResultRow resultRow) { int numberOfFields = fieldControlTab.NumberOfFields; List <string> fields = new List <string>(); if (!string.IsNullOrEmpty(fieldControlTab.Label)) { fields.Add(fieldControlTab.Label); } for (int index = 0; index < numberOfFields; index++) { UPConfigFieldControlField field = fieldControlTab.FieldAtIndex(index); if (index == 0) { IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; this.ImageName = configStore.InfoAreaConfigById(field.InfoAreaId).ImageName; } int offset = 0; string value = resultRow.FormattedFieldValueAtIndex(index, offset, fieldControlTab); index += offset; if (!string.IsNullOrEmpty(value)) { fields.Add(value); } } this.FieldValues = fields; }
private void FillTimesVariantWithoutType(UPCRMResultRow resultRow, string timeType, string prefix) { var valuesWithFunctions = resultRow.ValuesWithFunctions(); UPMContactTime contactTime; string from = $"{prefix}FROM"; string to = $"{prefix}TO"; string afternoonFrom = $"{prefix}AFTERNOONFROM"; string afternoonTo = $"{prefix}AFTERNOONTO"; int weekDay = ((string)valuesWithFunctions.ValueOrDefault("DAYOFWEEK")).ToInt(); if (weekDay < 7) { weekDay++; } else { weekDay = 1; } if (valuesWithFunctions.ValueOrDefault(from) != null && valuesWithFunctions.ValueOrDefault(to) != null) { contactTime = CreateContactTime((string)valuesWithFunctions.ValueOrDefault(from), (string)valuesWithFunctions.ValueOrDefault(to), weekDay, timeType); this.contactTimesGroup.AddChild(contactTime); } if (valuesWithFunctions.ValueOrDefault(afternoonFrom) != null && valuesWithFunctions.ValueOrDefault(afternoonTo) != null) { contactTime = CreateContactTime((string)valuesWithFunctions.ValueOrDefault(afternoonFrom), (string)valuesWithFunctions.ValueOrDefault(afternoonTo), weekDay, timeType); this.contactTimesGroup.AddChild(contactTime); } }
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> /// Initializes a new instance of the <see cref="UPSEListingOwner"/> class. /// </summary> /// <param name="resultRow">The result row.</param> /// <param name="recordIndex">Index of the record.</param> /// <param name="mapping">The mapping.</param> /// <param name="listingController">The listing controller.</param> public UPSEListingOwner(UPCRMResultRow resultRow, int recordIndex, Dictionary <string, UPConfigFieldControlField> mapping, UPSEListingController listingController) { this.RecordIdentification = resultRow.RecordIdentificationAtIndex(recordIndex); this.ListingController = listingController; this.ValueDictionary = mapping.ValuesFromResultRow(resultRow); Dictionary <string, string> displayValueDictionary = mapping.DisplayValuesFromResultRow(resultRow); if (!string.IsNullOrEmpty(this.ListingController.ListingLabelFormat)) { this.Label = this.ListingController.ListingLabelFormat; foreach (string key in displayValueDictionary.Keys) { this.Label = this.Label.Replace($"%%{key}", displayValueDictionary[key]); } } else { this.Label = displayValueDictionary.ValueOrDefault("Name"); } if (!string.IsNullOrEmpty(this.Label)) { this.Label = this.RecordIdentification; } }
/// <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); }
/// <summary> /// Groups from row. /// </summary> /// <param name="resultRow">The result row.</param> /// <returns> /// The <see cref="UPMGroup" />. /// </returns> public override UPMGroup GroupFromRow(UPCRMResultRow resultRow) { UPMGroup group = base.GroupFromRow(resultRow); this.skipTemplateFilter = false; if (group != null) { if (this.emptyMustFieldCount < 0) { this.emptyMustFieldCount = 0; List <string> mustFieldFunctionNames = this.mustFieldDictionary.Keys.ToList(); foreach (string functionName in mustFieldFunctionNames) { UPEditFieldContext ctx = this.editFieldDictionary[functionName]; if (ctx.FieldConfig.IsEmptyValue(ctx.Value)) { this.emptyMustFieldCount++; this.mustFieldDictionary[functionName] = string.Empty; } else if (string.IsNullOrEmpty(ctx.Value)) { this.mustFieldDictionary[functionName] = "0"; } else { this.mustFieldDictionary[functionName] = ctx.Value; } } } this.Delegate.GroupModelControllerValueChanged(this, this.CurrentData); } return(group); }
/// <summary> /// Applies the result row. /// </summary> /// <param name="row">The row.</param> /// <returns></returns> public override UPMGroup ApplyResultRow(UPCRMResultRow row) { string recordIdentification = row.RootRecordIdentification; UPMGroup group = this.GroupFromRow(row); group?.Actions.AddRange(this.BuildAdditionalActionsForRecordIdentification(recordIdentification)); return(group); }
/// <summary> /// Initializes a new instance of the <see cref="UPChildEditContext"/> class. /// </summary> /// <param name="resultRow"> /// The result row. /// </param> /// <param name="fieldLabelPostfix"> /// The field label postfix. /// </param> public UPChildEditContext(UPCRMResultRow resultRow, string fieldLabelPostfix) { this.ResultRow = resultRow; this.RecordIdentification = resultRow?.RootRecordIdentification; this.EditFieldContext = new Dictionary <string, UPEditFieldContext>(); this.DeleteRecord = false; this.FieldLabelPostfix = fieldLabelPostfix; }
/// <summary> /// Creates the root node from result row. Called from PageModeController /// </summary> /// <param name="row">The row.</param> /// <param name="recordIdentification">The record identification.</param> /// <param name="currentDepth">The current depth.</param> /// <param name="expandChecker">The expand checker.</param> /// <returns></returns> public static UPMCoINode CreateRootNodeFromResultRow(UPCRMResultRow row, string recordIdentification, int currentDepth, UPConfigExpand expandChecker) { string virtualInfoArea = row.RootVirtualInfoAreaId; string infoAreaId = row.RootRecordIdentification.InfoAreaId(); virtualInfoArea = infoAreaId == virtualInfoArea ? null : infoAreaId; return(CreateNodeFromResultRow(row, virtualInfoArea, recordIdentification, 0, true, expandChecker, null, infoAreaId)); }
/// <summary> /// Filters for configuration filter. /// </summary> /// <param name="configFilter">The configuration filter.</param> /// <param name="searchAndListName">Name of the search and list.</param> /// <param name="filterParameters">The filter parameters.</param> /// <param name="singleSelect">if set to <c>true</c> [single select].</param> /// /// <returns>Filter</returns> public static UPMFilter FilterForConfigFilter(UPConfigFilter configFilter, string searchAndListName, Dictionary <string, object> filterParameters, bool singleSelect) { if (string.IsNullOrEmpty(searchAndListName)) { return(null); } IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; SearchAndList searchAndList = configStore.SearchAndListByName(searchAndListName); if (searchAndList != null) { return(null); } FieldControl listControl = configStore.FieldControlByNameFromGroup("List", searchAndList.FieldGroupName); if (listControl == null) { return(null); } UPContainerMetaInfo crmQuery = new UPContainerMetaInfo(searchAndListName, filterParameters); UPCRMResult result = crmQuery.Find(); int count = result.RowCount; if (count == 0) { return(null); } UPCRMListFormatter listFormatter = new UPCRMListFormatter(listControl.TabAtIndex(0)); StringIdentifier identifier = StringIdentifier.IdentifierWithStringId("SelectFilter"); UPMSelectCatalogFilter filter = new UPMSelectCatalogFilter(identifier); Dictionary <string, string> dict = new Dictionary <string, string>(count); Dictionary <string, UPCRMResultRow> rowDict = new Dictionary <string, UPCRMResultRow>(count); for (int i = 0; i < count; i++) { UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(i); string fieldValue = listFormatter.StringFromRowForPosition(row, 0); dict[row.RootRecordIdentification] = fieldValue; rowDict[row.RootRecordIdentification] = row; } filter.CrmResult = result; filter.FilterParameters = filterParameters; filter.ResultRowDictionary = rowDict; filter.ExplicitCatalogValues = dict; filter.ParameterName = "Select"; filter.Name = configFilter.UnitName; filter.DisplayName = !string.IsNullOrEmpty(configFilter.DisplayName) ? configFilter.DisplayName : configFilter.UnitName; filter.SingleSelect = singleSelect; return(filter); }
// 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 void FillPageWithResult(UPCRMResult result) { this.vistedNodes = new Dictionary <IIdentifier, UPMCoINode>(); this.nodeIdConfigDict = new Dictionary <IIdentifier, UPConfigTreeViewTable>(); // Root Node Query if (result.RowCount == 1) { UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(0); UPMCoINode rootNode = CoITreeNodeLoader.CreateNodeFromResultRow(row, 0, this.expandChecker, null, null); this.vistedNodes[rootNode.Identifier] = rootNode; this.nodeIdConfigDict[rootNode.Identifier] = this.rootTreeNode.RootNode; // Only root configured if (this.rootTreeNode.RootNode.ChildNodes.Count == 0) { UPMCircleOfInfluencePage newPage = this.CreatePageInstance(); newPage.RootNode = rootNode; newPage.Invalid = false; newPage.ConfigProvider = ((UPMCircleOfInfluencePage)this.Page).ConfigProvider; UPMCircleOfInfluencePage oldPage = (UPMCircleOfInfluencePage)this.Page; this.TopLevelElement = newPage; this.InformAboutDidChangeTopLevelElement(oldPage, newPage, null, null); } foreach (UPConfigTreeViewTable childTree in this.rootTreeNode.RootNode.ChildNodes) { CoITreeNodeLoader nodeLoader = new CoITreeNodeLoader(rootNode, childTree, this.ViewReference, 0, this.vistedNodes, this.nodeIdConfigDict, this.recordIdentifierInfoAreaConfigMapping); nodeLoader.TheDelegate = this; nodeLoader.Mode = CoINodeLoaderMode.InitialLoad; this.pendingNodeLoader.Add(nodeLoader); this.pendingNodeLoaderCount++; } // TODO: This is buggy and will be implemented in CRM-5621 /* * foreach (CoITreeNodeLoader _loader in this.pendingNodeLoader) * { * _loader.LoadNodeSubNodes(); * } */ } else { // Request Mode Offline and jump To Online Node if (result.RowCount == 0 && this.RequestOption == UPRequestOption.Offline) { // Offline Configured and Online Record UPMCircleOfInfluencePage newPage = this.CreatePageInstance(); newPage.Status = UPMMessageStatus.MessageStatusWithMessageDetails(string.Empty, LocalizedString.TextOfflineNotAvailable); UPMCircleOfInfluencePage oldPage = (UPMCircleOfInfluencePage)this.Page; this.TopLevelElement = newPage; this.InformAboutDidChangeTopLevelElement(oldPage, newPage, null, null); } } }
/// <summary> /// The buttons for result row. /// </summary> /// <param name="row"> /// The row. /// </param> /// <returns> /// The <see cref="IList"/>. /// </returns> public List <UPConfigButton> ButtonsForResultRow(UPCRMResultRow row) { UPConfigQueryTable matchingTable = this.QueryTableForResultRow(row); if (matchingTable != null) { List <UPConfigButton> matchingButtons = new List <UPConfigButton>(); UPConfigQueryCondition propertyCondition = matchingTable.PropertyConditions[@"Action"]; if (propertyCondition != null) { IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; foreach (string menuName in propertyCondition.FieldValues) { Menu menu = configStore.MenuByName(menuName); if (menu != null) { UPConfigButton button = new UPConfigButton( menu.DisplayName, menu.ImageName, menu.ViewReference); matchingButtons.Add(button); } else if (menuName.StartsWith(@"Button:")) { UPConfigButton button = configStore.ButtonByName(menuName.Substring(7)); if (button != null) { matchingButtons.Add(button); } } } } propertyCondition = matchingTable.PropertyConditions.ValueOrDefault("ButtonAction"); if (propertyCondition != null) { foreach (string buttonName in propertyCondition.FieldValues) { UPConfigButton button = ConfigurationUnitStore.DefaultStore.ButtonByName(buttonName); if (button != null) { matchingButtons.Add(button); } } } return(matchingButtons.Count > 0 ? matchingButtons : null); } return(null); }
private void HandleResult(UPCRMResult result) { this.currencyDictionary = new Dictionary <int, object>(); if (result != null && result.RowCount > 0) { UPConfigFieldControlField currencyField = null, baseCurrencyField = null, exchangeRateField = null, baseCurrency2Field = null, exchangeRate2Field = null; foreach (FieldControlTab tab in this.fieldControl.Tabs) { foreach (UPConfigFieldControlField field in tab.Fields) { if (field.Function == "Currency") { currencyField = field; } else if (field.Function == "BaseCurrency") { baseCurrencyField = field; } else if (field.Function == "ExchangeRate") { exchangeRateField = field; } else if (field.Function == "BaseCurrency2") { baseCurrency2Field = field; } else if (field.Function == "ExchangeRate2") { exchangeRate2Field = field; } } } if (currencyField != null && baseCurrencyField != null && exchangeRateField != null && result.RowCount > 0) { int i, count = result.RowCount; for (i = 0; i < count; i++) { UPCRMResultRow row = result.ResultRowAtIndex(i) as UPCRMResultRow; int code = row.RawValueAtIndex(currencyField.TabIndependentFieldIndex).ToInt(); int baseCurrencyValue = row.RawValueAtIndex(baseCurrencyField.TabIndependentFieldIndex).ToInt(); double exchangeRate = row.RawValueAtIndex(exchangeRateField.TabIndependentFieldIndex).ToDouble(); double exchangeRate2 = 0; int baseCurrency2Value = 0; if (baseCurrency2Field != null && exchangeRate2Field != null) { baseCurrency2Value = row.RawValueAtIndex(baseCurrency2Field.TabIndependentFieldIndex).ToInt(); exchangeRate2 = row.RawValueAtIndex(exchangeRate2Field.TabIndependentFieldIndex).ToDouble(); } this.AddCurrency(new Currency(code, baseCurrencyValue, exchangeRate, baseCurrency2Value, exchangeRate2)); } } } }
private bool FillGroupWithLocalDocumentsResult(UPMDocumentsGroup group, UPCRMResult result) { if (this._sendEmailFieldgroup != null) { this._linkedRecordId = this.RecordIdentification; } int count = result.RowCount; if (count == 0) { return(false); } if (this.MaxResults > 0 && count > this.MaxResults) { count = this.MaxResults; } DocumentInfoAreaManager documentInfoAreaManager; if (this.fieldControl.InfoAreaId == "D3" && this.TabConfig.Type.StartsWith("D1")) { documentInfoAreaManager = new DocumentInfoAreaManager(this.fieldControl.InfoAreaId, this.fieldControl, 1, null); } else { documentInfoAreaManager = new DocumentInfoAreaManager(this.fieldControl.InfoAreaId, this.fieldControl, null); } for (int i = 0; i < count; i++) { UPCRMResultRow resultRow = (UPCRMResultRow)result.ResultRowAtIndex(i); DocumentData documentData = documentInfoAreaManager.DocumentDataForResultRow(resultRow); UPMDocument document = new UPMDocument(documentData); if (this._sendEmailFieldgroup != null) { document.LinkedRecordId = this._linkedRecordId; document.EmailFieldgroup = this._sendEmailFieldgroup; } if (this.IsDocumentIncludedInGroup(document, group)) { group.AddField(document); } } if (group.Fields.Count == 0) { return(false); } return(true); }
/// <summary> /// The row from result row. /// </summary> /// <param name="crmRow"> /// The crm row. /// </param> /// <returns> /// The <see cref="UPMResultRow"/>. /// </returns> public virtual UPMResultRow RowFromResultRow(UPCRMResultRow crmRow) { RecordIdentifier identifier = new RecordIdentifier(crmRow.RecordIdentificationAtIndex(0)); UPMResultRow resultRow = new UPMResultRow(identifier) { Invalid = true, DataValid = true }; this.TheDelegate?.ResultRowProviderDidCreateRowFromDataRow(this, resultRow, crmRow); return(resultRow); }
/// <summary> /// Strings from row for position. /// </summary> /// <param name="row"> /// The row. /// </param> /// <param name="positionIndex"> /// Index of the position. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> public string StringFromRowForPosition(UPCRMResultRow row, int positionIndex) { if (positionIndex >= this._positions.Count) { return(string.Empty); } var position = this._positions[positionIndex]; return(position?.StringFromRowOptions(row, this._formatOptions) ?? string.Empty); }