/// <summary> /// Initializes a new instance of the <see cref="UPMResultRowProviderForCalendarResult"/> class. /// </summary> /// <param name="theDelegate"> /// The the delegate. /// </param> /// <param name="context"> /// The context. /// </param> public UPMResultRowProviderForCalendarResult( IResultRowProviderDelegate theDelegate, UPCoreMappingResultContext context) : this(null, theDelegate, context) { this.resultRows = new List <ICalendarItem>(); this.resultContext = context; }
/// <summary> /// Initializes a new instance of the <see cref="UPMResultRowProviderForCalendarResult"/> class. /// </summary> /// <param name="result"> /// The result. /// </param> /// <param name="theDelegate"> /// The the delegate. /// </param> /// <param name="context"> /// The context. /// </param> public UPMResultRowProviderForCalendarResult( List <ICalendarItem> result, IResultRowProviderDelegate theDelegate, UPCoreMappingResultContext context) : base(theDelegate) { this.resultRows = result; this.resultContext = context; }
/// <summary> /// Check section index /// </summary> /// <param name="sectionIndex">Section index</param> /// <param name="context">Context</param> /// <returns><see cref="string"/></returns> private string CheckSectionIndex(string sectionIndex, UPCoreMappingResultContext context) { if (string.IsNullOrEmpty(sectionIndex)) { return(@"?"); } else if (!context.SectionFieldComplete) { #if PORTING NSRange range = [sectionIndex rangeOfCharacterFromSet: [NSCharacterSet alphanumericCharacterSet]];
/// <summary> /// Reset method, resets model controller with given reason /// </summary> /// <param name="reason">Reset reason</param> public override void ResetWithReason(ModelControllerResetReason reason) { base.ResetWithReason(reason); // Only if not visible if (this.ModelControllerDelegate != null) { this.ResultContext = null; } }
/// <summary> /// Results the section for search result. /// </summary> /// <param name="preparedSearch">The prepared search.</param> /// <param name="result">The result.</param> /// <returns></returns> public virtual UPMResultSection ResultSectionForSearchResult(UPSearchPageModelControllerPreparedSearch preparedSearch, UPCRMResult result) { var configStore = ConfigurationUnitStore.DefaultStore; var resultContext = new UPCoreMappingResultContext(result, preparedSearch.CombinedControl, preparedSearch.ListFieldControl.NumberOfFields); this.SectionContexts.SetObjectForKey(resultContext, preparedSearch.InfoAreaId); var resultSection = new UPMResultSection(StringIdentifier.IdentifierWithStringId($"Search_{preparedSearch.InfoAreaId}")); var infoAreaConfig = configStore.InfoAreaConfigById(preparedSearch.InfoAreaId); if (infoAreaConfig != null) { var colorKey = infoAreaConfig.ColorKey; if (!string.IsNullOrEmpty(colorKey)) { resultSection.BarColor = AureaColor.ColorWithString(colorKey); } var imageName = infoAreaConfig.ImageName; if (!string.IsNullOrEmpty(imageName)) { var fileResource = configStore.ResourceByName(imageName); if (fileResource != null) { resultSection.GlobalSearchIconName = fileResource.FileName; } } } resultSection.SectionField = new UPMField(StringIdentifier.IdentifierWithStringId("SectionLabel")); var sectionName = infoAreaConfig?.PluralName; if (string.IsNullOrEmpty(sectionName)) { var tableInfo = UPCRMDataStore.DefaultStore.TableInfoForInfoArea(preparedSearch.InfoAreaId); sectionName = tableInfo != null ? tableInfo.Label : preparedSearch.InfoAreaId; } resultSection.SectionField.FieldValue = sectionName; var count = result.RowCount; for (var j = 0; j < count; j++) { var dataRow = result.ResultRowAtIndex(j) as UPCRMResultRow; var identifier = new RecordIdentifier(preparedSearch.InfoAreaId, dataRow.RecordIdAtIndex(0)); var resultRow = new UPMResultRow(identifier); resultContext.RowDictionary.Add(resultRow.Key, new UPCoreMappingResultRowContext(dataRow, resultContext)); resultContext.ExpandMapper = preparedSearch.ExpandSettings; resultRow.Invalid = true; resultRow.DataValid = true; resultSection.AddResultRow(resultRow); } return(resultSection); }
/// <inheritdoc/> public override UPMResultSection ResultSectionForSearchResult(UPSearchPageModelControllerPreparedSearch preparedSearch, UPCRMResult result) { UPCoreMappingResultContext resultContext = new UPCoreMappingResultContext(result, preparedSearch.CombinedControl, preparedSearch.ListFieldControl.NumberOfFields); this.SectionContexts.SetObjectForKey(resultContext, preparedSearch.InfoAreaId); bool newSection = this.geoSection == null; if (newSection) { this.geoSection = new UPMResultSection(StringIdentifier.IdentifierWithStringId($"Search_{preparedSearch.InfoAreaId}")); } var count = result.RowCount; for (var j = 0; j < count; j++) { UPCRMResultRow dataRow = result.ResultRowAtIndex(j) as UPCRMResultRow; var identifier = new RecordIdentifier(preparedSearch.InfoAreaId, dataRow.RecordIdAtIndex(0)); UPMResultRow resultRow = new UPMResultRow(identifier); resultRow.DataValid = true; resultContext.RowDictionary.SetObjectForKey(new UPCoreMappingResultRowContext(dataRow, resultContext), resultRow.Key); resultContext.ExpandMapper = preparedSearch.ExpandSettings; resultRow = (UPMResultRow)this.UpdatedElement(resultRow); this.AddDistanceFieldToRow(resultRow); this.geoSection.AddResultRow(resultRow); if (resultRow.RecordImageDocument != null) { this.AnyResultWithImageField = true; } } List <GeoUPMResultRow> sortedArray = this.resultRowsToSort.OrderBy(a => a.Distance).ToList(); this.geoSection.RemoveAllChildren(); foreach (var row in sortedArray) { if (row.ResultRow != null) { this.geoSection.AddResultRow(row.ResultRow); } else { } } return(newSection ? this.geoSection : null); }
/// <summary> /// Adds the dropdown groups for result row. /// </summary> /// <param name="resultRow">The result row.</param> /// <param name="rowContext">The row context.</param> /// <param name="expand">The expand.</param> public override void AddDropdownGroupsForResultRow(UPMResultRow resultRow, UPCoreMappingResultRowContext rowContext, UPConfigExpand expand) { UPCoreMappingResultContext resultContext = rowContext.Context; if (resultContext.DropdownFields.Any()) { int detailFieldCount = resultContext.DropdownFields.Count; if (detailFieldCount > 0) { UPCRMResultRow row = rowContext.Row; string recordId = row.RecordIdentificationAtIndex(0); var detailGroupCol1 = new UPMTimelineDetailsGroup(FieldIdentifier.IdentifierWithInfoAreaIdRecordIdFieldId(this.InfoAreaId, recordId, "DetailField_Left")) { Invalid = true, ResultContext = resultContext }; resultRow.AddDetailGroup(detailGroupCol1); } } }
/// <summary> /// Builds standard search page with search page and result /// </summary> /// <param name="searchPage">Search page</param> /// <param name="result">Result</param> private void BuildStandardSearchPage(UPMSearchPage searchPage, UPCRMResult result) { if (result == null) { throw new ArgumentNullException(nameof(result)); } var count = result.RowCount; this.ResultContext = new UPCoreMappingResultContext( result, this.PreparedSearch.CombinedControl, this.PreparedSearch.ListFieldControl.NumberOfFields) { ExpandMapper = this.PreparedSearch.ExpandChecker }; this.SectionContexts[this.InfoAreaId] = this.ResultContext; var hasSections = !string.IsNullOrWhiteSpace(this.Sections); if (!hasSections && this.ResultContext.SectionField != null) { hasSections = true; } if (this.Sections == @"false") { hasSections = false; } var optimizeForSpeed = false; if (result.RowCount < 200) { // optimizeForSpeed can handle multipleRows with the same id. (PVCS 80132) optimizeForSpeed = this.SearchPageMode == SearchPageMode.ForceOptimizeForSpeed; } this.BuildStandardSearchPage(searchPage, result, count, hasSections, optimizeForSpeed); }
/// <summary> /// Updates the element for calendar group. /// </summary> /// <param name="origDetailGroup">The original detail group.</param> /// <returns></returns> public override UPMCalendarPopoverGroup UpdateElementForCalendarGroup(UPMCalendarPopoverGroup origDetailGroup) { if (!(origDetailGroup.Context is ResultRowCalendarItem)) { return(base.UpdateElementForCalendarGroup(origDetailGroup)); } if (origDetailGroup.Invalid) { ResultRowCalendarItem calendarItem = (ResultRowCalendarItem)origDetailGroup.Context; UPCoreMappingResultContext resultContext = calendarItem.ResultContext; TimelineSearch timelineSearch = (TimelineSearch)resultContext.Context; string sourceCopyFieldGroupName = timelineSearch.FieldGroupName; IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; FieldControl sourceFieldControl = configStore.FieldControlByNameFromGroup("Details", sourceCopyFieldGroupName) ?? configStore.FieldControlByNameFromGroup("MiniDetails", sourceCopyFieldGroupName); this.Loader = new UPCalendarPopoverLoader(this); this.Loader.LoadElementForCalendarGroupFieldControl(origDetailGroup, sourceFieldControl); } return(origDetailGroup); }
private List <ICalendarItem> CalendarItemsFromResult() { List <ICalendarItem> calendarItems = new List <ICalendarItem>(); IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; this.resultContexts = new List <UPCoreMappingResultContext>(); UPMAction goToAction = new UPMAction(StringIdentifier.IdentifierWithStringId("action")); goToAction.SetTargetAction(this, this.SwitchToDetail); goToAction.LabelText = LocalizedString.TextShowRecord; foreach (TimelineSearch timelineSearch in this.searches) { UPCRMResult result = timelineSearch.Result; int rowCount = result.RowCount; if (rowCount == 0) { continue; } UPConfigTableCaption tableCaption = configStore.TableCaptionByName(timelineSearch.TimelineInfoArea.ConfigName) ?? configStore.TableCaptionByName(timelineSearch.TimelineInfoArea.InfoAreaId); List <UPContainerFieldMetaInfo> tableCaptionResultFieldMap = tableCaption.ResultFieldMapFromMetaInfo(result.MetaInfo); if (tableCaptionResultFieldMap == null) { continue; } UPCRMResultCondition resultCondition = null; var functionNameFieldMapping = result.MetaInfo.SourceFieldControl.FunctionNames(); UPConfigFieldControlField fromField = functionNameFieldMapping["Date"]; if (fromField != null) { if (this.fromDate != null) { resultCondition = new UPCRMResultFieldCondition(fromField.Field, UPConditionOperator.GreaterEqual, this.fromDate.Value.CrmValueFromDate(), fromField.TabIndependentFieldIndex); } if (this.toDate != null) { UPConfigFieldControlField toField = (functionNameFieldMapping.ContainsKey("EndDate") ? functionNameFieldMapping["EndDate"] : null) ?? fromField; UPCRMResultCondition toCondition = new UPCRMResultFieldCondition(toField.Field, UPConditionOperator.LessEqual, this.toDate.Value.CrmValueFromDate(), toField.TabIndependentFieldIndex); resultCondition = resultCondition != null?resultCondition.ConditionByAppendingANDCondition(toCondition) : toCondition; } } UPCoreMappingResultContext resultContext = new UPCoreMappingResultContext(result, result.MetaInfo.SourceFieldControl, timelineSearch.PreparedSearch.ListFieldControl.NumberOfFields); resultContext.Context = timelineSearch; this.resultContexts.Add(resultContext); UPConfigExpand expand = configStore.ExpandByName(timelineSearch.TimelineInfoArea.ConfigName) ?? configStore.ExpandByName(timelineSearch.TimelineInfoArea.InfoAreaId); AureaColor defaultColor = null; if (!string.IsNullOrEmpty(timelineSearch.TimelineInfoArea.ColorString)) { defaultColor = AureaColor.ColorWithString(timelineSearch.TimelineInfoArea.ColorString); } if (defaultColor == null) { defaultColor = AureaColor.ColorWithString(expand.ColorKey); } for (int i = 0; i < rowCount; i++) { UPCRMResultRow row = (UPCRMResultRow)result.ResultRowAtIndex(i); if (resultCondition != null && !resultCondition.Check(row)) { continue; } ConfigTimelineCriteria matchingCriteria = timelineSearch.MatchingCriteriaForRow(row); AureaColor color = null; if (matchingCriteria.Setting1 != null) { color = AureaColor.ColorWithString(matchingCriteria.Setting1); } if (color == null) { color = defaultColor; } ICalendarItem calendarItem = new ResultRowCalendarItem(row, resultContext, new RecordIdentifier(row.RootRecordIdentification), tableCaption, tableCaptionResultFieldMap, null, color); calendarItem.GoToAction = goToAction; calendarItems.Add(calendarItem); } } if (this.fromDate != null && this.toDate != null && this.CalendarPage.IncludeSystemCalendar) { #if PORTING ArrayList localCalendarItems = ResultRowCalendarItem.EventsFromLocalCalendarFromToSearchTextCalenderIdentifiers(this.fromDate, this.toDate, null, null); if (localCalendarItems.Count) { calendarItems.AddRange(localCalendarItems); } #endif } return(calendarItems); }
/// <summary> /// Initializes a new instance of the <see cref="ResultRowCalendarItem" /> class. /// </summary> /// <param name="row">The row.</param> /// <param name="resultContext">The result context.</param> /// <param name="identifier">The identifier.</param> /// <param name="tableCaption">The table caption.</param> /// <param name="tableCaptionResultFieldMap">The table caption result field map.</param> /// <param name="attributes">The attributes.</param> /// <param name="color">The color.</param> /// <exception cref="Exception">StartDate is null</exception> public ResultRowCalendarItem(UPCRMResultRow row, UPCoreMappingResultContext resultContext, IIdentifier identifier, UPConfigTableCaption tableCaption, List <UPContainerFieldMetaInfo> tableCaptionResultFieldMap, UPConfigCatalogAttributes attributes, AureaColor color) : base(identifier) { this.ResultContext = resultContext; var fieldMapping = this.ResultContext.FieldControl.FunctionNames(); var dict = this.ResultContext.FieldControl.FunctionNames(row); string startDateString = dict.ValueOrDefault("Date") as string; string startTimeString = dict.ValueOrDefault("Time") as string; string endDateString = dict.ValueOrDefault("EndDate") as string; string endTimeString = dict.ValueOrDefault("EndTime") as string; UPConfigFieldControlField personLabelControlField = fieldMapping.ValueOrDefault("PersonLabel"); if (personLabelControlField != null) { this.PersonLabelField = UPMStringField.StringFieldWithIdentifierValue( new FieldIdentifier(row.RootRecordIdentification, personLabelControlField.Field.FieldIdentification), row.FormattedFieldValueAtIndex(personLabelControlField.TabIndependentFieldIndex, null, this.ResultContext.FieldControl)); } UPConfigFieldControlField companyLabelControlField = fieldMapping.ValueOrDefault("CompanyLabel"); if (companyLabelControlField != null) { this.CompanyLabelField = UPMStringField.StringFieldWithIdentifierValue( new FieldIdentifier(row.RootRecordIdentification, companyLabelControlField.Field.FieldIdentification), row.FormattedFieldValueAtIndex(companyLabelControlField.TabIndependentFieldIndex, null, this.ResultContext.FieldControl)); } UPConfigFieldControlField field = fieldMapping.ValueOrDefault("Status"); string status = dict.ValueOrDefault("Status") as string; if (field != null) { this.StatusLabelField = UPMStringField.StringFieldWithIdentifierValue( new FieldIdentifier(row.RootRecordIdentification, field.Field.FieldIdentification), field.Field.ValueForRawValueOptions(status, 0)); } string repLabel = dict.ValueOrDefault("RepLabel") as string; if (string.IsNullOrEmpty(repLabel)) { string repId = dict.ValueOrDefault("RepId") as string; if (!string.IsNullOrEmpty(repId)) { repLabel = UPCRMDataStore.DefaultStore.Reps.RepWithId(repId).RepName; } } this.RepLabelField = UPMStringField.StringFieldWithIdentifierValue(StringIdentifier.IdentifierWithStringId("rep"), repLabel); int iType = Convert.ToInt32(dict.ValueOrDefault("Type")); this.Type = (UPCalendarItemType)iType; this.StartDate = StringExtensions.DateFromStrings(startDateString, startTimeString); this.EndDate = StringExtensions.DateFromStrings(endDateString, endTimeString); this.Identification = identifier.IdentifierAsString; this.Color = color; this.RowColor = this.Color; this.CrmResultRow = row; this.IPadCalendarItem = null; this.HasTime = !string.IsNullOrEmpty(startTimeString); this.HasEndTime = !string.IsNullOrEmpty(endTimeString); UPConfigCatalogValueAttributes temp = attributes?.ValuesByCode[iType]; if (temp != null) { if (this.Color == null) { string colorString = temp.ColorKey; if (string.IsNullOrEmpty(colorString)) { this.Color = AureaColor.ColorWithString(colorString); } } this.ImageName = temp.ImageName; } if (tableCaption != null) { this.Subject = tableCaption.TableCaptionForResultRow(row, tableCaptionResultFieldMap); } else { this.Subject = dict.ValueOrDefault("Subject") as string; } if (this.StartDate == DateTime.MinValue) { throw new Exception("StartDate is null"); } if (this.EndDate == DateTime.MinValue) { this.EndDate = this.StartDate; } if (this.Type < UPCalendarItemType.Color0 || this.Type >= UPCalendarItemType.ColorCount) { this.Type = UPCalendarItemType.Color0; } //this.AllDay = this.DetermineIsAllDay(); }
/// <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)); }