/// <summary> /// Applies the filter on source query parameters. /// </summary> /// <param name="crmQuery">The CRM query.</param> /// <param name="parameters">The parameters.</param> /// <returns></returns> public bool ApplyFilterOnSourceQueryParameters(UPContainerMetaInfo crmQuery, Dictionary <string, object> parameters) { if (this.CrmFilter != null) { if (parameters.Count > 0) { UPConfigFilter replacedFilter = this.CrmFilter. FilterByApplyingReplacements(UPConditionValueReplacement.ReplacementsFromValueParameterDictionary(parameters)); crmQuery.ApplyFilter(replacedFilter); } else { crmQuery.ApplyFilter(this.CrmFilter); } } return(true); }
/// <summary> /// CRMs the query for record identification. /// </summary> /// <param name="recordIdentification">The record identification.</param> /// <returns></returns> public UPContainerMetaInfo CrmQueryForRecordIdentification(string recordIdentification) { var crmQuery = new UPContainerMetaInfo(new List <UPCRMField>(), recordIdentification.InfoAreaId()); if (this.Filter != null) { crmQuery.ApplyFilter(this.Filter); } crmQuery.SetLinkRecordIdentification(recordIdentification); return(crmQuery); }
/// <summary> /// Creates the query. /// </summary> /// <param name="recordIdentifier">The record identifier.</param> /// <returns></returns> protected override UPContainerMetaInfo CreateQuery(string recordIdentifier) { IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; SearchAndList searchAndList = configStore.SearchAndListByName(this.configName); if (searchAndList == null) { return(null); } UPContainerMetaInfo query = this.CreateQueryLinkIdSearchAndList(recordIdentifier, -1, searchAndList); if (recordIdentifier.InfoAreaId() == "FI" && !string.IsNullOrEmpty(this.fiFilterName)) { query.ApplyFilter(configStore.FilterByName(this.fiFilterName)); } else if (recordIdentifier.InfoAreaId() == "KP" && !string.IsNullOrEmpty(this.kpFilterName)) { query.ApplyFilter(configStore.FilterByName(this.kpFilterName)); } return(query); }
private UPContainerMetaInfo LoadContainer() { if (this.fieldControl == null) { return(null); } UPContainerMetaInfo metaInfo = new UPContainerMetaInfo(this.fieldControl); if (this.filter != null) { metaInfo.ApplyFilter(this.filter); } return(metaInfo); }
/// <summary> /// Results for row row. /// </summary> /// <param name="_serialEntry">The serial entry.</param> /// <param name="row">The row.</param> /// <returns></returns> public UPCRMResult ResultForRowRow(UPSerialEntry _serialEntry, UPSERow row) { IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; FieldControl documentFieldControl = configStore.FieldControlByNameFromGroup("List", "D1DocData"); UPContainerMetaInfo crmQuery = new UPContainerMetaInfo(documentFieldControl); UPConfigFilter filter = configStore.FilterByName(this.FilterName); if (filter != null) { Dictionary <string, object> valuesForFunction = new Dictionary <string, object>(); Dictionary <string, UPSEColumn> columnsForFunction = _serialEntry.DestColumnsForFunction; foreach (string functionName in columnsForFunction.Keys) { UPSEColumn column = columnsForFunction.ValueOrDefault(functionName) ?? columnsForFunction.ValueOrDefault($"$par{functionName}"); if (column != null) { string value = row.StringValueAtIndex(column.Index); if (!string.IsNullOrEmpty(value)) { valuesForFunction.SetObjectForKey(value, functionName); } } } UPConfigFilter replacedFilter = filter.FilterByApplyingValueDictionaryDefaults(valuesForFunction, true); crmQuery.ApplyFilter(replacedFilter); } else { crmQuery.MaxResults = 10; } UPCRMResult crmResult = crmQuery.Find(); return(crmResult); }
private void ContinueLoadWithFieldValueDictionary(Dictionary <string, object> fieldValueDictionary) { IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; if (fieldValueDictionary != null) { if (this.copyFieldsDictionary == null) { this.copyFieldsDictionary = new Dictionary <string, Dictionary <string, object> >(); } this.copyFieldsDictionary.SetObjectForKey(fieldValueDictionary, this.currentSectionConfiguration.SourceFieldControl.UnitName); } this.currentCopyFields = null; FieldControl destinationFieldControl = this.currentSectionConfiguration.DestinationFieldControl; string destinationFilterName = this.currentSectionConfiguration.DestinationFilterName; UPConfigFilter companyRelatedFilter = null; if (this.companyRelated) { string companyFilterName = $"{destinationFieldControl.InfoAreaId}.CompanyRelated"; companyRelatedFilter = configStore.FilterByName(companyFilterName); } UPContainerMetaInfo container = new UPContainerMetaInfo(destinationFieldControl); container.SetLinkRecordIdentification(this.rootRecordIdentification); List <UPConfigFilter> appliedFilters = new List <UPConfigFilter>(); UPConfigFilter filter = configStore.FilterByName(destinationFilterName); if (filter != null) { filter = filter.FilterByApplyingReplacements(UPConditionValueReplacement.ReplacementsFromValueParameterDictionary(fieldValueDictionary)); container.ApplyFilter(filter); appliedFilters.Add(filter); } if (companyRelatedFilter != null && this.currentSectionConfiguration.SourceFieldControl != null) { companyRelatedFilter = companyRelatedFilter.FilterByApplyingReplacements(new UPConditionValueReplacement(fieldValueDictionary)); container.ApplyFilter(companyRelatedFilter); appliedFilters.Add(companyRelatedFilter); } this.objectivesForRecordOperation = null; this.rightFilterOperation = null; this.filterLoaded = true; if (this.RightsFilter != null && this.filterItemsResult == null) { this.filterLoaded = false; } if (this.currentSectionConfiguration.ExecuteActionFilter != null) { this.currentSectionConfiguration.ExecuteActionFilter = this.currentSectionConfiguration.ExecuteActionFilter.FilterByApplyingValueDictionaryDefaults(fieldValueDictionary, true); if (this.currentSectionConfiguration.ExecuteActionFilter != null) { this.currentSectionConfiguration.FilterBasedDecision = new UPCRMFilterBasedDecision(this.currentSectionConfiguration.ExecuteActionFilter); List <UPCRMField> fields = this.currentSectionConfiguration.FilterBasedDecision.FieldDictionary.Values.ToList(); if (fields.Count > 0) { container.AddCrmFields(fields); } this.currentSectionConfiguration.FilterBasedDecision.UseCrmQuery(container); } } this.objectivesForRecordOperation = container.Find(this.RequestOption, this); if (this.objectivesForRecordOperation == null) { SimpleIoc.Default.GetInstance <ILogger>().LogError("Could not create operation for loading objectives."); this.FailWithError(new Exception("ConnectionOfflineError")); } if (this.RightsFilter != null && this.filterItemsResult == null) { UPContainerMetaInfo clonedContainer = new UPContainerMetaInfo(new List <UPCRMField>(), destinationFieldControl.InfoAreaId); clonedContainer.SetLinkRecordIdentification(this.rootRecordIdentification); clonedContainer.ApplyFilter(this.RightsFilter); foreach (UPConfigFilter filter1 in appliedFilters) { clonedContainer.ApplyFilter(filter1); } this.rightFilterOperation = clonedContainer.Find(this.RequestOption, this); if (this.rightFilterOperation == null) { SimpleIoc.Default.GetInstance <ILogger>().LogError("Could not create operation for filtering objectives."); this.FailWithError(new Exception("ConnectionOfflineError")); } } }
/// <summary> /// Results for row. /// </summary> /// <param name="serialEntryRow">The serial entry row.</param> /// <returns></returns> public override UPSerialEntryInfoResult ResultForRow(UPSERow serialEntryRow) { string sourceRecordIdentification = StringExtensions.InfoAreaIdRecordId(serialEntryRow.SerialEntry.SourceInfoAreaId, serialEntryRow.RowRecordId); UPSerialEntryInfoResultFromCRMResult result = this.cachedResults.ValueOrDefault(sourceRecordIdentification); if (result != null) { return(result); } UPContainerMetaInfo crmQuery = new UPContainerMetaInfo(this.FieldControl); if (!this.IgnoreSourceRecord) { crmQuery.SetLinkRecordIdentification(sourceRecordIdentification); } if (this.MaxResults > 0) { crmQuery.MaxResults = this.MaxResults; } if (this.Filter != null) { Dictionary <string, object> parameterValues = serialEntryRow.SourceFunctionValues(); if (this.SerialEntry.InitialFieldValuesForDestination.Count > 0) { if (parameterValues.Count > 0) { Dictionary <string, object> dict = new Dictionary <string, object>(this.SerialEntry.InitialFieldValuesForDestination); foreach (var entry in parameterValues) { dict[entry.Key] = entry.Value; } parameterValues = dict; } else { parameterValues = this.SerialEntry.InitialFieldValuesForDestination; } } if (parameterValues.Count > 0) { UPConfigFilter applyFilter = this.Filter.FilterByApplyingReplacements(UPConditionValueReplacement.ReplacementsFromValueParameterDictionary(parameterValues)); if (applyFilter != null) { crmQuery.ApplyFilter(applyFilter); } } else { crmQuery.ApplyFilter(this.Filter); } } UPCRMResult crmResult = crmQuery.Find(); result = new UPSerialEntryInfoResultFromCRMResult(crmResult, this); if (this.cachedResults == null) { this.cachedResults = new Dictionary <string, UPSerialEntryInfoResultFromCRMResult> { { sourceRecordIdentification, result } }; } else { this.cachedResults[sourceRecordIdentification] = result; } return(result); }
/// <summary> /// The crm query for value. /// </summary> /// <param name="searchValue"> /// The search value. /// </param> /// <param name="filters"> /// The filters. /// </param> /// <param name="fullTextSearch"> /// The full text search. /// </param> /// <returns> /// The <see cref="UPContainerMetaInfo"/>. /// </returns> public UPContainerMetaInfo CrmQueryForValue( string searchValue, List <UPConfigFilter> filters, bool fullTextSearch) { if (this.CombinedControl == null) { return(null); } if (this.SearchCRMFields == null && this.MultiSearchCRMFields == null && this.SearchFieldControl?.Tabs?.Count > 0) { int tabCount = this.SearchFieldControl.Tabs.Count; List <UPCRMField> fieldArray = null; List <UPCRMField> multiFieldArray = null; for (int i = 0; i < tabCount; i++) { FieldControlTab tab = this.SearchFieldControl.TabAtIndex(i); if (tab.Fields == null || tab.Fields.Count == 0) { continue; } if (string.Compare(tab.Type, @"MULTI", StringComparison.OrdinalIgnoreCase) == 0) { UPCRMField multiField = tab.FieldAtIndex(0).Field; if (multiFieldArray == null) { multiFieldArray = new List <UPCRMField>(); } multiFieldArray.Add(multiField); } else { if (fieldArray == null) { fieldArray = new List <UPCRMField>(); } fieldArray.AddRange(tab.AllCRMFields()); } } this.SearchCRMFields = fieldArray; this.MultiSearchCRMFields = multiFieldArray; } IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; UPContainerMetaInfo container = new UPContainerMetaInfo(this.CombinedControl); if (!string.IsNullOrEmpty(this.DetailActionSwitchFilterName)) { this.DetailActionSwitchFilter = ConfigurationUnitStore.DefaultStore.FilterByName(this.DetailActionSwitchFilterName); if (this.DetailActionSwitchFilter != null) { this.DetailActionSwitchFilter = this.DetailActionSwitchFilter.FilterByApplyingValueDictionaryDefaults( this.FilterParameter, true); } if (this.DetailActionSwitchFilter != null) { this.FilterBasedDecision = new UPCRMFilterBasedDecision(this.DetailActionSwitchFilter); } } container.ReplaceCaseSensitiveCharacters = this.ReplaceCaseSensitiveCharacters; List <UPCRMField> additionalFields = null; if (this.ExpandSettings != null) { Dictionary <string, UPCRMField> alternateExpandFields = this.ExpandSettings.FieldsForAlternateExpands(true); List <UPCRMField> _additionalFields = this.AdditionalOutputFields != null ? new List <UPCRMField>(this.AdditionalOutputFields) : new List <UPCRMField>(); if (alternateExpandFields != null) { _additionalFields.AddRange(alternateExpandFields.Values.Where(field => container.ContainsField(field) == null)); } additionalFields = _additionalFields; } else if (this.AdditionalOutputFields?.Count > 0) { additionalFields = this.AdditionalOutputFields; } if (additionalFields != null && additionalFields.Count > 0) { container.AddCrmFields(additionalFields); } var checkFilterFields = this.FilterBasedDecision?.FieldDictionary.Values.Select(x => x).ToList(); if (checkFilterFields?.Count > 0) { container.AddCrmFields(checkFilterFields); this.FilterBasedDecision.UseCrmQuery(container); } if (this.ExpandSettings != null) { this.ExpandChecker = this.ExpandSettings.ExpandCheckerForCrmQuery(container); } if (!string.IsNullOrEmpty(this.LinkRecordIdentification)) { container.SetLinkRecordIdentification(this.LinkRecordIdentification); } if (this.SearchFieldControl != null) { container.SetSearchConditionsFor( searchValue, this.SearchCRMFields, this.MultiSearchCRMFields, fullTextSearch); } else if (this.QuickSearchEntries != null) { if (!string.IsNullOrEmpty(searchValue)) { List <UPCRMField> crmFields = this.QuickSearchEntries.Select(entry => entry.CrmField).ToList(); container.SetSearchConditionsFor(searchValue, crmFields, fullTextSearch); } } if (!string.IsNullOrEmpty(this.SearchConfiguration?.FilterName)) { UPConfigFilter filter = configStore.FilterByName(this.SearchConfiguration.FilterName); if (filter != null) { filter = filter.FilterByApplyingDefaultReplacements(); filter = filter.FilterByApplyingValueDictionary(this.FilterParameter); container.ApplyFilter(filter); } } if (this.FilterObject != null) { container.ApplyFilter(this.FilterObject); } else if (!string.IsNullOrEmpty(this.FilterName)) { UPConfigFilter filter = configStore.FilterByName(this.FilterName); if (filter != null) { filter = filter.FilterByApplyingDefaultReplacements(); filter = filter.FilterByApplyingValueDictionary(this.FilterParameter); container.ApplyFilter(filter); } } if (filters != null) { foreach (UPConfigFilter filter in filters) { if (this.FilterParameter != null) { container.ApplyFilterWithReplacementDictionary(filter, this.FilterParameter); } else { container.ApplyFilter(filter); } } } return(container); }
/// <summary> /// Loads the reps. /// </summary> public void LoadReps() { lock (this) { if (this.repDictionary != null) { return; } var configStore = ConfigurationUnitStore.DefaultStore; var repSearchAndList = configStore.SearchAndListByName("IDSystem"); FieldControl fieldControl; UPConfigFilter filter = null; if (repSearchAndList != null) { fieldControl = configStore.FieldControlByNameFromGroup("List", "IDSystem"); if (!string.IsNullOrEmpty(repSearchAndList.FilterName)) { filter = configStore.FilterByName(repSearchAndList.FilterName); } } else { fieldControl = configStore.FieldControlByNameFromGroup("List", "IDSystem"); } if (fieldControl == null) { return; } var metaInfo = new UPContainerMetaInfo(fieldControl); if (filter != null) { metaInfo.ApplyFilter(filter); } var result = metaInfo.Find(); var count = result != null ? result.RowCount : 0; if (count <= 0) { return; } var _repDictionary = new Dictionary <string, UPCRMRep>(count); var _repArray = new List <UPCRMRep>(count); for (var i = 0; i < count; i++) { var row = result.ResultRowAtIndex(i); var rep = new UPCRMRep( row.RawValueAtIndex(0), row.RawValueAtIndex(2), row.RawValueAtIndex(1), row.RootRecordId, this.RepTypeFromStringRepTypeId(row.RawValueAtIndex(3))); _repDictionary[rep.RepId] = rep; _repArray.Add(rep); } foreach (var rep in _repArray) { if (string.IsNullOrEmpty(rep.RepOrgGroupId)) { continue; } var parentRep = _repDictionary.ValueOrDefault(rep.RepOrgGroupId); parentRep?.AddChildRep(rep); } this.repDictionary = _repDictionary; this.repArray = _repArray; } }
/// <summary> /// Offlines the request data online context did finish with result. /// </summary> /// <param name="request">The request.</param> /// <param name="data">The data.</param> /// <param name="online">if set to <c>true</c> [online].</param> /// <param name="context">The context.</param> /// <param name="result">The result.</param> public void OfflineRequestDidFinishWithResult(UPOfflineRequest request, object data, bool online, object context, Dictionary <string, object> result) { if (this.uploadDocumentRequest != null) { this.uploadDocumentRequest = null; if (this.disable85106) { this.ApproveAction.PerformAction(this.approveActionDelegate); } this.pageBuilt = false; if (this.ParentOrganizerModelController is DetailOrganizerModelController) { ((DetailOrganizerModelController)this.ParentOrganizerModelController).RefreshAfterDocumentUploaded(this.RecordIdentification); } if (!this.disable85106) { this.ShouldWaitForPendingChanges = true; } } else { this.buttonRequest = null; this.pageBuilt = false; this.SerialEntryApproved = UPMSerialEntryState.Approved; if (!this.disable85106) { this.ShouldWaitForPendingChanges = false; } else { List <UPCRMRecord> records = (List <UPCRMRecord>)data; if (records.Count > 0) { UPCRMRecord record = records[0]; RecordIdentifier recordIdentifier = new RecordIdentifier(record.RecordIdentification); UPChangeManager.CurrentChangeManager.RegisterChanges(new List <IIdentifier> { recordIdentifier }); if (this.ParentOrganizerModelController is DetailOrganizerModelController) { List <IIdentifier> changes = UPChangeManager.CurrentChangeManager.ChangesToApplyForCurrentViewController(); if (this.sendByEmailFilter != null) { this.unreportedRecordChanges = changes; } else { this.ParentOrganizerModelController.ProcessChanges(changes); } } } if (this.sendByEmailFilter != null) { UPContainerMetaInfo _emailFilterQuery = new UPContainerMetaInfo(new List <UPCRMField>(), this.sendByEmailFilter.InfoAreaId); this.emailFilterQuery = _emailFilterQuery; _emailFilterQuery.ApplyFilter(this.sendByEmailFilter); _emailFilterQuery.SetLinkRecordIdentification(this.RecordIdentification); _emailFilterQuery.Find(UPRequestOption.FastestAvailable, this); } else { this.SetShouldWaitForPendingChangesWithoutPageUpdate(false, true); } } } }