/// <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); }
/// <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); UPObjectivesConfiguration groupConfiguration = this.Group.Configuration; if (groupConfiguration != null) { UPCRMListFormatter formatter = new UPCRMListFormatter(groupConfiguration.DestinationFieldControl); this.TitleField = formatter.FirstFieldForPosition(0); this.TitleFieldValue = formatter.StringFromRowForPosition(row, 0); this.SubTitleField = formatter.FirstFieldForPosition(1); this.SubTitelFieldValue = formatter.StringFromRowForPosition(row, 1); } if (this.AdditionalFields.Count > 0) { this.values = new List <string>(this.AdditionalFields.Count); foreach (UPConfigFieldControlField field in this.AdditionalFields) { this.values.Add(row.RawValueAtIndex(field.TabIndependentFieldIndex)); } } this.OriginalValues = new List <string>(this.values); this.completed = row.RawValueAtIndex(this.Group.Configuration.FieldForFunction(Constants.FieldCompletedFunction).TabIndependentFieldIndex).ToBoolWithDefaultValue(false); this.originalCompleted = this.completed; } else { this.Record = null; if (this.AdditionalFields.Count > 0) { this.values = new List <string>(this.AdditionalFields.Count); for (int i = 0; i < this.AdditionalFields.Count; i++) { this.values.Add(string.Empty); } } this.OriginalValues = null; this.completed = false; } this.Created = false; this.Deleted = false; this.Changed = false; }
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> /// Search operation did finish with result /// </summary> /// <param name="operation">Operation</param> /// <param name="result">Result</param> public override void SearchOperationDidFinishWithResult(Operation operation, UPCRMResult result) { UPCRMResultRow resultRow = (UPCRMResultRow)result.ResultRowAtIndex(0); this.resCount--; if (resultRow != null) { string recordIdent = resultRow.RootRecordIdentification; RecordIdentifier recordIdentifier = new RecordIdentifier(recordIdent.InfoAreaId(), recordIdent.RecordId()); UPMResultRow row = new UPMResultRow(new RecordIdentifier(recordIdent)); SearchAndList searchConfiguration = this.configStore.SearchAndListByName(recordIdent.InfoAreaId()); FieldControl listFieldControl = this.configStore.FieldControlByNameFromGroup("List", searchConfiguration.FieldGroupName); InfoArea configInfoArea = this.configStore.InfoAreaConfigById(recordIdent.InfoAreaId()); row.RowColor = AureaColor.ColorWithString(configInfoArea.ColorKey); UPCRMListFormatter listFormatter = new UPCRMListFormatter(listFieldControl); int fieldCount = listFormatter.PositionCount; List <UPMField> listFields = new List <UPMField>(fieldCount); for (int i = 0; i < fieldCount; i++) { UPConfigFieldControlField configField = listFormatter.FirstFieldForPosition(i); if (configField == null) { continue; } FieldAttributes attributes = configField.Attributes; if (attributes.Hide) { continue; } UPMStringField stringField = new UPMStringField(StringIdentifier.IdentifierWithStringId($"{recordIdent}-{i}")); string stringValue = listFormatter.StringFromRowForPosition(resultRow, i); if (attributes.Image) { DocumentManager documentManager = new DocumentManager(); string documentKey = stringValue; DocumentData documentData = documentManager.DocumentForKey(documentKey); if (documentData != null) { row.RecordImageDocument = new UPMDocument(documentData); } else { //row.RecordImageDocument = new UPMDocument(recordIdentifier, ServerSession.DocumentRequestUrlForDocumentKey(documentKey)); } continue; } if (!string.IsNullOrEmpty(stringValue)) { if (attributes.NoLabel && !string.IsNullOrEmpty(configField.Label)) { stringValue = $"{configField.Label} {stringValue}"; } stringField.StringValue = stringValue; stringField.SetAttributes(attributes); } listFields.Add(stringField); } row.OnlineData = resultRow.IsServerResponse; if (row.OnlineData) { //row.StatusIndicatorIcon = UIImage.UpXXImageNamed("crmpad-List-Cloud"); // CRM-5007 } foreach (HistoryEntry entry in this.historyManager.HistoryEntries) { if (entry.RecordIdentification == recordIdent) { this.rows.Add(row); if (this.pendingRecords.Contains(recordIdent)) { this.pendingRecords.Remove(recordIdent); } break; } } row.Fields = listFields; } if (this.resCount == 0) { this.DisplayPage(this.rows); } }