/// <summary> /// Loads this instance. /// </summary> /// <returns></returns> public bool Load() { IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; SearchAndList searchAndList = configStore.SearchAndListByName(this.SearchAndListConfigName); UPConfigFilter filter = null; if (searchAndList != null) { filter = configStore.FilterByName(searchAndList.FilterName); } if (searchAndList == null) { return(false); } this.fieldControl = configStore.FieldControlByNameFromGroup("List", searchAndList.FieldGroupName); if (this.fieldControl != null) { this.crmQuery = new UPContainerMetaInfo(this.fieldControl, filter, null); } if (this.crmQuery == null) { return(false); } var result = this.crmQuery.Find(); this.HandleResult(result); return(true); }
/// <summary> /// Loads the specified the delegate. /// </summary> /// <param name="theDelegate">The delegate.</param> /// <returns></returns> public bool Load(IQuestionnaireDelegate theDelegate) { if (this.LoadDelegate != null) { return(false); } this.LoadDelegate = theDelegate; this.currentQuery = new UPContainerMetaInfo(this.Manager.QuestionnaireList); if (!string.IsNullOrEmpty(this.RecordIdentification)) { this.currentQuery.SetLinkRecordIdentification(this.RecordIdentification); } else { UPConfigFilter filter = ConfigurationUnitStore.DefaultStore.FilterByName(this.Manager.QuestionnaireSearchAndList.FilterName); filter = filter.FilterByApplyingValueDictionary( new Dictionary <string, object> { { Constants.QuestionnaireQuestionnaireID, this.CatalogCode.ToString() } }); if (filter != null) { this.currentQuery.ApplyFilter(filter); } } this.requestOption = this.Manager.QuestionnaireRequestOption; this.loadStep = 0; this.currentQuery.Find(this.requestOption, this); return(true); }
/// <summary> /// Builds the page. /// </summary> protected override void BuildPage() { ViewReference documentUploadViewReference = this.DetermineDocumentUploadViewReference(); if (documentUploadViewReference != null) { int fieldId = -1; fieldId = this.DetermineFieldIdDocumentUploadViewReference(fieldId, documentUploadViewReference); if (fieldId >= 0) { string infoAreaIdForQuery = this.ViewReference.ContextValueForKey("RecordId").InfoAreaId(); UPCRMField field = new UPCRMField(fieldId, infoAreaIdForQuery); this.documentQuery = new UPContainerMetaInfo(new List <UPCRMField> { field }, infoAreaIdForQuery); this.documentQuery.SetLinkRecordIdentification(this.RecordIdentification); string filterName = documentUploadViewReference.ContextValueForKey("FilterName"); if (!string.IsNullOrEmpty(filterName)) { UPConfigFilter filter = ConfigurationUnitStore.DefaultStore.FilterByName(filterName); if (filter != null) { this.documentQuery.ApplyFilter(filter); } } if (this.documentQuery.Find(UPRequestOption.FastestAvailable, this) != null) { return; } } } base.BuildPage(); }
/// <summary> /// Loads the specified request option. /// </summary> /// <param name="requestOption">The request option.</param> /// <param name="currencyDelegate">The currency delegate.</param> /// <returns></returns> public bool Load(UPRequestOption requestOption, ICurrencyConversionDelegate currencyDelegate) { if (this.CurrencyDelegate != null) { return(false); } this.CurrencyDelegate = currencyDelegate; IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; SearchAndList searchAndList = configStore.SearchAndListByName(this.SearchAndListConfigName); UPConfigFilter filter = null; if (searchAndList != null) { filter = configStore.FilterByName(searchAndList.FilterName); } this.fieldControl = configStore.FieldControlByNameFromGroup("List", searchAndList.FieldGroupName); if (this.fieldControl != null) { this.crmQuery = new UPContainerMetaInfo(this.fieldControl, filter, null); } if (this.crmQuery == null) { this.CurrencyDelegate = null; this.crmQuery = null; currencyDelegate.CurrencyConversionDidFailWithError(this, new Exception($"invalid searchAndList configuration {this.SearchAndListConfigName}")); return(true); } this.crmQuery.Find(requestOption, this); return(true); }
private void LoadConfigFieldControlForFieldGroup(string fieldGroup) { IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; SearchAndList searchAndListConfig = configStore.SearchAndListByName(fieldGroup); FieldControl configFieldControl; UPConfigFilter configFilter = null; if (searchAndListConfig != null) { configFieldControl = configStore.FieldControlByNameFromGroup("List", fieldGroup); if (!string.IsNullOrEmpty(searchAndListConfig.FilterName)) { configFilter = configStore.FilterByName(searchAndListConfig.FilterName); } } else { configFieldControl = configStore.FieldControlByNameFromGroup("List", fieldGroup); } if (configFieldControl != null) { this.fieldControl = configFieldControl; } if (configFilter != null) { this.filter = configFilter; } }
private void ContinueLoadRecordData() { this.crmQuery = new UPContainerMetaInfo(this.DestinationFieldControl); this.currentQueryType = 2; if (!string.IsNullOrEmpty(this.DestinationFilterName)) { UPConfigFilter destinationFilter = ConfigurationUnitStore.DefaultStore.FilterByName(this.DestinationFilterName); if (destinationFilter != null) { this.crmQuery.ApplyFilter(destinationFilter); } } if (this.RecordIdentification.InfoAreaId() == "FI") { string companyFilterName = $"{this.DestinationFieldControl.InfoAreaId}.CompanyRelated"; UPConfigFilter companyFilter = ConfigurationUnitStore.DefaultStore.FilterByName(companyFilterName); if (companyFilter != null) { this.crmQuery.ApplyFilter(companyFilter); } } this.crmQuery.SetLinkRecordIdentification(this.RecordIdentification); this.crmQuery.Find(this.DestinationRequestOption, this); }
/// <summary> /// Offlines the record for count. /// </summary> /// <param name="count">The count.</param> /// <returns></returns> public UPCRMRecord OfflineRecordForCount(int count) { if (this.QuotaHandler.QuotaEditFieldControl == null) { return(null); } UPCRMRecord record; if (!string.IsNullOrEmpty(this.RecordIdentification)) { record = new UPCRMRecord(this.RecordIdentification, "UpdateOffline", null); } else { record = UPCRMRecord.CreateNew(this.QuotaHandler.QuotaEditFieldControl.InfoAreaId); record.Mode = "NewOffline"; UPConfigFilter templateFilter = this.QuotaHandler.QuotaTemplateFilter; if (templateFilter != null && this.QuotaHandler.FilterParameters.Count > 0) { templateFilter = templateFilter.FilterByApplyingValueDictionaryDefaults(this.QuotaHandler.FilterParameters, true); } if (templateFilter != null) { record.ApplyValuesFromTemplateFilter(templateFilter); } foreach (UPConfigFieldControlField field in this.QuotaHandler.QuotaEditFieldControl.Fields) { if (field.Function == "StartDate") { string dateString = StringExtensions.CrmValueFromDate(this.FirstStartDate != null ? this.QuotaStartDateForPeriod() : DateTime.UtcNow); record.AddValue(new UPCRMFieldValue(dateString, record.InfoAreaId, field.FieldId)); } else if (field.Function == "EndDate") { string dateString = StringExtensions.CrmValueFromDate(this.QuotaEndDateForPeriod()); record.AddValue(new UPCRMFieldValue(dateString, record.InfoAreaId, field.FieldId)); } else if (field.Function == this.QuotaHandler.ItemNumberFunctionName) { record.AddValue(new UPCRMFieldValue(this.ItemNumber, record.InfoAreaId, field.FieldId)); } } record.AddLink(new UPCRMLink(this.QuotaHandler.LinkRecord.RecordIdentification, this.QuotaHandler.QuotaLinkId)); } foreach (UPConfigFieldControlField field in this.QuotaHandler.QuotaEditFieldControl.Fields) { if (field.Function == "Items" || field.Function.StartsWith("Items:")) { record.AddValue(new UPCRMFieldValue(count.ToString(), record.InfoAreaId, field.FieldId, true)); } } return(record); }
private static UPConfigFilter QueryForDate(UPConfigFilter configFilter, UPConfigFilterParameters parameters, UPMFilter upmFilter) { if (!(parameters?.NumberOfParameters > 0)) { return(configFilter); } if (parameters.NumberOfParameters == parameters.NumberOfUnnamedParameters) { var unnmaedParameters = parameters.UnnamedParameters; var rawValues = upmFilter.RawValues; var valueCount = rawValues.Count; for (var i = 0; i < parameters.NumberOfUnnamedParameters; i++) { var param = unnmaedParameters[i]; if (valueCount > i) { param.Value = rawValues[i]; } } return((UPConfigFilter)configFilter.QueryByApplyingFilterParameters(parameters)); } var firstParameter = parameters.FirstParameter(); firstParameter.Values = upmFilter.RawValues; return((UPConfigFilter)configFilter.QueryByApplyingFilterParameter(firstParameter)); }
/// <summary> /// Starts the with source record identification. /// </summary> /// <param name="sourceRecordIdentification">The source record identification.</param> /// <param name="destRecordIdentification">The dest record identification.</param> /// <param name="_parameters">The parameters.</param> /// <returns></returns> public bool StartWithSourceRecordIdentification(string sourceRecordIdentification, string destRecordIdentification, Dictionary <string, object> _parameters) { if (this.running) { return(false); } this.running = true; this.parameters = _parameters; this.replacedFilter = this.TemplateFilter.FilterByApplyingValueDictionaryDefaults(this.parameters, true); UPCRMRecord destinationRootRecord = new UPCRMRecord(destRecordIdentification); int count = this.replacedFilter.RootTable.NumberOfSubTables; this.recordArray = new List <UPCRMRecord>(); this.stepQueue = new List <UPRecordCopyStep>(); for (int i = 0; i < count; i++) { UPConfigQueryTable currentTable = this.replacedFilter.RootTable.SubTableAtIndex(i); UPRecordCopyStep recordStep = new UPRecordCopyStep(); recordStep.SourceRecordIdentification = sourceRecordIdentification; recordStep.QueryTable = currentTable; recordStep.DestinationRecord = destinationRootRecord; this.ConfigForStepFromQueryTable(recordStep, currentTable); this.stepQueue.Add(recordStep); } this.ExecuteNextStep(); return(true); }
/// <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> /// Initializes a new instance of the <see cref="EditChildrenGroupModelController"/> class. /// </summary> /// <param name="fieldControl">The field control.</param> /// <param name="tabIndex">Index of the tab.</param> /// <param name="editPageContext">The edit page context.</param> /// <param name="theDelegate">The delegate.</param> /// <exception cref="Exception"> /// TabConfig is null /// or /// ChildFieldControl is null /// </exception> public EditChildrenGroupModelController(FieldControl fieldControl, int tabIndex, UPEditPageContext editPageContext, IGroupModelControllerDelegate theDelegate) : base(fieldControl, tabIndex, editPageContext, theDelegate) { FieldControlTab tabConfig = fieldControl.TabAtIndex(tabIndex); if (tabConfig == null) { throw new Exception("TabConfig is null"); } var typeParts = tabConfig.Type.Split('_'); if (typeParts.Length > 1) { string detailsConfigurationName = (string)typeParts[1]; var configNameParts = detailsConfigurationName.Split('#'); if (configNameParts.Length > 1) { this.LinkId = Convert.ToInt32(configNameParts[1]); detailsConfigurationName = configNameParts[0]; } IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; this.ChildFieldControl = configStore.FieldControlByNameFromGroup("Edit", detailsConfigurationName); if (this.ChildFieldControl.NumberOfTabs > 1) { this.ChildFieldControl = this.ChildFieldControl.FieldControlWithSingleTab(0); } this.ChildInfoAreaId = this.ChildFieldControl.InfoAreaId; if (typeParts.Length > 2) { UPConfigFilter templateFilter = configStore.FilterByName((string)typeParts[2]); if (templateFilter != null) { templateFilter = templateFilter.FilterByApplyingReplacements(UPConditionValueReplacement.DefaultParameters); this.initialValues = templateFilter.FieldsWithConditions(false); } } } else if (tabConfig.NumberOfFields > 0) { UPConfigFieldControlField childField = tabConfig.FieldAtIndex(0); this.ChildInfoAreaId = childField.InfoAreaId; this.LinkId = childField.LinkId; this.ChildFieldControl = fieldControl.FieldControlWithSingleTabRootInfoAreaIdRootLinkId(tabIndex, this.ChildInfoAreaId, this.LinkId); } else { this.ChildFieldControl = null; } if (this.ChildFieldControl == null) { throw new Exception("ChildFieldControl is null"); } }
/// <summary> /// Initializes a new instance of the <see cref="UPCRMFavorites"/> class. /// </summary> /// <param name="offlineRequestMode">The offline request mode.</param> /// <param name="theDelegate">The delegate.</param> public UPCRMFavorites(UPOfflineRequestMode offlineRequestMode, UPCRMFavoritesDelegate theDelegate) { this.OfflineRequestMode = offlineRequestMode; this.TheDelegate = theDelegate; this.RepFilter = ConfigurationUnitStore.DefaultStore.FilterByName(Constants.FAVORITES_FILTERNAME); this.RepFilter = this.RepFilter?.FilterByApplyingReplacements(UPConditionValueReplacement.DefaultParameters); this.TemplateFilter = ConfigurationUnitStore.DefaultStore.FilterByName(Constants.FAVORITES_TEMPLATEFILTERNAME); this.TemplateFilter = this.TemplateFilter?.FilterByApplyingReplacements(UPConditionValueReplacement.DefaultParameters); }
/// <summary> /// Initializes a new instance of the <see cref="UPRightsChecker"/> class. /// </summary> /// <param name="filter">The filter.</param> public UPRightsChecker(UPConfigFilter filter) { this.Filter = filter; this.ForbiddenMessage = this.Filter?.DisplayName; if (string.IsNullOrEmpty(this.ForbiddenMessage)) { this.ForbiddenMessage = "ErrorRightsFilter"; } }
/// <summary> /// Applies the context. /// </summary> /// <param name="contextDictionary">The context dictionary.</param> /// <returns></returns> public override UPMGroup ApplyContext(Dictionary <string, object> contextDictionary) { UPMGroup returnGroup; base.ApplyContext(contextDictionary); if (!this.skipTemplateFilter) { string templateFilterName = this.FormItem.ViewReference.ContextValueForKey("Func1"); Dictionary <string, object> initialValues = null; if (!string.IsNullOrEmpty(templateFilterName)) { UPConfigFilter templateFilter = ConfigurationUnitStore.DefaultStore.FilterByName(templateFilterName); if (templateFilter != null) { Dictionary <string, object> dict = contextDictionary["$_copyFields"] as Dictionary <string, object>; templateFilter = templateFilter.FilterByApplyingValueDictionaryDefaults(dict, true); initialValues = templateFilter.FieldsWithValues(true, true); } } this.EditPageContext = new UPEditPageContext(this.FieldControl.InfoAreaId, true, initialValues, null, null); returnGroup = this.ApplyResultRow(null); this.skipTemplateFilter = true; } else { returnGroup = this.Group; } if (this.dependentFieldDictionary != null) { foreach (string dependentKey in this.dependentFieldDictionary.Keys) { if (contextDictionary.Keys.Contains(dependentKey)) { string depVal = contextDictionary[dependentKey] as string; if (!string.IsNullOrEmpty(depVal)) { UPEditFieldContext editFieldContext = this.editFieldDictionary[this.dependentFieldDictionary[dependentKey]]; if (editFieldContext != null) { editFieldContext.Value = depVal; if (editFieldContext.EditField != null) { this.SimpleChangedValue(editFieldContext.EditField); } } } } } } return(returnGroup); }
private void LoadItems() { IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; if (this.ItemSearchAndListControl != null) { this.ItemFieldControl = configStore.FieldControlByNameFromGroup("List", this.ItemSearchAndListControl.FieldGroupName); UPConfigFilter filter = null; UPConfigFilter groupFilter = null; if (!string.IsNullOrEmpty(this.GroupSearchAndListControl?.FilterName)) { groupFilter = configStore.FilterByName(this.GroupSearchAndListControl.FilterName); if (groupFilter != null && this.sourceFieldDictionary != null) { groupFilter = groupFilter.FilterByApplyingReplacements(new UPConditionValueReplacement(this.sourceFieldDictionary)); } } if (!string.IsNullOrEmpty(this.ItemSearchAndListControl.FilterName)) { filter = configStore.FilterByName(this.ItemSearchAndListControl.FilterName); if (filter != null && this.sourceFieldDictionary != null) { filter = filter.FilterByApplyingReplacements(new UPConditionValueReplacement(this.sourceFieldDictionary)); } } UPConfigFieldControlField groupField = this.ItemFieldControl.FieldWithFunction(Constants.FieldGroupString); UPConfigFieldControlField itemField = this.ItemFieldControl.FieldWithFunction(Constants.FieldItemString); if (this.ItemFieldControl != null && groupField != null && itemField != null) { this.crmQuery = new UPContainerMetaInfo(this.ItemFieldControl); if (groupFilter != null) { this.crmQuery.ApplyFilter(groupFilter); } if (filter != null) { this.crmQuery.ApplyFilter(filter); } this.currentQueryType = 1; this.crmQuery.Find(this.SourceRequestOption, this); } else { this.HandleGroupsWithAllItems(this.Groups); } } else { this.HandleGroupsWithAllItems(this.Groups); } }
/// <summary> /// Builds this instance. /// </summary> public virtual void Build() { var parentRecordIdentification = string.Empty; var linkInfoAreaId = this.Definition?.ValueOrDefault(KeyLinkInfoArea) as string; var noLink = linkInfoAreaId == KeyNoLink; if (!noLink) { noLink = this.Definition.ValueOrDefault(KeyNoLink).ToInt() != 0; } if (!noLink) { if (this.ProcessNoLink(linkInfoAreaId, ref parentRecordIdentification)) { return; } } var templateFilterName = this.Definition?.ValueOrDefault(KeyTemplateFilter) as string; if (!string.IsNullOrEmpty(templateFilterName)) { this.TemplateFilter = ConfigurationUnitStore.DefaultStore.FilterByName(templateFilterName); } var listConfigurations = (List <object>) this.Definition?.ValueOrDefault(KeyListConfigs); var firstConfig = this.Definition?.ValueOrDefault(KeySearchAndListName) as string; if (firstConfig != null) { if (listConfigurations == null) { listConfigurations = new List <object> { firstConfig }; } else { var combinedConfig = new List <object> { firstConfig }; combinedConfig.AddRange(listConfigurations); listConfigurations = combinedConfig; } } if (listConfigurations == null) { return; } this.ProcessConfiguration(listConfigurations, noLink, parentRecordIdentification); }
private void LoadGroups() { this.Groups = new List <UPCharacteristicsGroup>(); this.groupDict = new Dictionary <string, UPCharacteristicsGroup>(); IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; if (this.GroupSearchAndListControl != null) { this.GroupFieldControl = configStore.FieldControlByNameFromGroup("List", this.GroupSearchAndListControl.FieldGroupName); UPConfigFilter filter = null; if (!string.IsNullOrEmpty(this.GroupSearchAndListControl.FilterName)) { filter = configStore.FilterByName(this.GroupSearchAndListControl.FilterName); if (filter != null && this.sourceFieldDictionary != null) { filter = filter.FilterByApplyingReplacements(new UPConditionValueReplacement(this.sourceFieldDictionary)); } } UPConfigFieldControlField groupField = this.GroupFieldControl.FieldWithFunction(Constants.FieldGroupString); if (this.GroupFieldControl != null && groupField != null) { this.crmQuery = new UPContainerMetaInfo(this.GroupFieldControl); if (filter != null) { this.crmQuery.ApplyFilter(filter); } this.currentQueryType = 0; this.crmQuery.Find(this.SourceRequestOption, this); } } else { bool showAdditionalFields = !configStore.ConfigValueIsSet("Characteristics.HideAdditionalFields"); bool showExpanded = !configStore.ConfigValueIsSet("Characteristics.CollapseGroups"); UPCatalog catalog = UPCRMDataStore.DefaultStore.CatalogForCrmField(this.DestinationGroupField.Field); foreach (string key in catalog.SortedValues) { UPCharacteristicsGroup group = new UPCharacteristicsGroup(catalog.TextValueForKey(key), key, false, this, showExpanded); if (showAdditionalFields) { group.ShowAdditionalFields = true; } this.groupDict[key] = group; this.Groups.Add(group); } this.LoadItems(); } }
/// <summary> /// Applies the filter. /// </summary> /// <param name="filter"> /// The filter. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool ApplyFilter(UPConfigFilter filter) { var rootTable = filter.RootTable; if (this.InfoAreaId == rootTable.InfoAreaId) { this.AddConditions(rootTable); int i, subTableIndex = rootTable.NumberOfSubTables; var hasOptional = false; var filterHasOptional = false; foreach (var subTable in this.subTables ?? new List <UPContainerInfoAreaMetaInfo>()) { if (subTable.ParentRelation.IndexOf("OPTIONAL", StringComparison.Ordinal) <= 0) { continue; } hasOptional = true; break; } if (hasOptional) { for (i = 0; !filterHasOptional && i < subTableIndex; i++) { if (rootTable.SubTableAtIndex(i).ParentRelation.IndexOf("OPTIONAL", StringComparison.Ordinal) > 0) { filterHasOptional = true; } } } if (hasOptional && filterHasOptional) { this.AddSubTableRelation(rootTable, "HAVING"); } else { for (i = 0; i < subTableIndex; i++) { this.AddSubTable(rootTable.SubTableAtIndex(i)); } } } else { this.AddSubTableRelation(rootTable, "HAVING"); } return(true); }
/// <summary> /// Initializes a new instance of the <see cref="SerialEntryWebContentModelController"/> class. /// </summary> /// <param name="viewReference">The view reference.</param> /// <param name="disableSigning">if set to <c>true</c> [disable signing].</param> public SerialEntryWebContentModelController(ViewReference viewReference, bool disableSigning) : base(viewReference) { this.disableSigning = disableSigning; string buttonName = viewReference.ContextValueForKey("ButtonName"); string sendByEmailFilterName = viewReference.ContextValueForKey("SendByEmailFilter"); if (!string.IsNullOrEmpty(sendByEmailFilterName)) { this.sendByEmailFilter = ConfigurationUnitStore.DefaultStore.FilterByName(sendByEmailFilterName); if (this.sendByEmailFilter == null) { this.Logger.LogError($"Filter {this.sendByEmailFilter} not found"); //DDLogError("Filter \"%@\" not found", sendByEmailFilterName); } else { this.SendByEmailButtonIsShown = false; } } UPConfigButton button = null; if (!this.disableSigning && !string.IsNullOrEmpty(buttonName)) { button = ConfigurationUnitStore.DefaultStore.ButtonByName(buttonName); } if (button != null) { this.buttonViewReference = button.ViewReference.ViewReferenceWith(viewReference.ContextValueForKey("RecordId")); if (this.buttonViewReference.ViewName != "Action:modifyRecord") { button = null; } } if (button != null) { UPMAction action = new UPMAction(StringIdentifier.IdentifierWithStringId("Action.Approve")); action.LabelText = button.Label; action.SetTargetAction(this, this.Approve); this.ApproveAction = action; } this.UnknownApprovedStateText = "..."; this.SerialEntryApproved = UPMSerialEntryState.Unknown; this.RecordIdentification = viewReference.ContextValueForKey("RecordId"); }
/// <summary> /// Initializes a new instance of the <see cref="UPCalendarSearch"/> class. /// </summary> /// <param name="preparedSearch"> /// The prepared search. /// </param> public UPCalendarSearch(UPSearchPageModelControllerPreparedSearch preparedSearch) { this.PreparedSearch = preparedSearch; ViewReference viewRef = preparedSearch.CalendarPageInfoArea.ViewReference; if (viewRef != null) { IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; string repFilterName = viewRef.ContextValueForKey("RepFilter"); this.RepFilter = configStore.FilterByName(repFilterName); var filterIndexMapping = new Dictionary <string, UPConfigFilter>(); for (int i = 1; i < 6; i++) { string filterName = viewRef.ContextValueForKey($"Filter{i}"); if (!string.IsNullOrEmpty(filterName)) { UPConfigFilter filter = configStore.FilterByName(filterName); if (filter != null) { filterIndexMapping[i.ToString()] = filter; } } } string addIndex = viewRef.ContextValueForKey("AdditionalFilter"); if (!string.IsNullOrEmpty(addIndex)) { int filterIndex = 6; var parts = addIndex.Split(';'); foreach (string part in parts) { if (part.Length > 0) { UPConfigFilter filter = configStore.FilterByName(part); if (filter != null) { filterIndexMapping[filterIndex.ToString()] = filter; } } ++filterIndex; } } this.FilterIndexMapping = filterIndexMapping; } }
private bool UpdateReportButtonState() { string filterName = this.ViewReference.ContextValueForKey("ButtonShowFilter"); UPConfigButton button = null; string buttonName = this.ViewReference.ContextValueForKey("ButtonName"); if (!string.IsNullOrEmpty(buttonName)) { button = ConfigurationUnitStore.DefaultStore.ButtonByName(buttonName); } UPConfigFilter buttonFilter = ConfigurationUnitStore.DefaultStore.FilterByName(filterName); if (buttonFilter != null || this.sendByEmailFilter != null) { this.shouldWaitForPendingChanges = true; if (buttonFilter != null) { this.ApprovedText = buttonFilter.DisplayName; if (string.IsNullOrEmpty(button?.Label)) { this.ApprovedText = LocalizedString.TextProcessOrderWasApproved; } this.currentQuery = new UPContainerMetaInfo(new List <UPCRMField>(), buttonFilter.InfoAreaId); this.currentQuery.ApplyFilter(buttonFilter); this.currentQuery.SetLinkRecordIdentification(this.RecordIdentification); } else { this.SerialEntryApproved = UPMSerialEntryState.NotApproved; } if (this.sendByEmailFilter != null) { this.emailFilterQuery = new UPContainerMetaInfo(new List <UPCRMField>(), this.sendByEmailFilter.InfoAreaId); this.emailFilterQuery.ApplyFilter(this.sendByEmailFilter); this.emailFilterQuery.SetLinkRecordIdentification(this.RecordIdentification); } UPContainerMetaInfo queryToExecute = this.currentQuery ?? this.emailFilterQuery; queryToExecute.Find(UPRequestOption.FastestAvailable, this); return(true); } this.SerialEntryApproved = UPMSerialEntryState.NotApproved; return(false); }
private void CopyFieldsLoaded() { string filterName = this.ViewReference.ContextValueForKey("TemplateFilter"); if (!string.IsNullOrEmpty(filterName)) { UPConfigFilter filter = ConfigurationUnitStore.DefaultStore.FilterByName(filterName); if (filter.NeedsLocation) { //UPLocationProvider.Current().RequestLocationForObject(this); return; } } this.ContinueTemplateFilterGeoChecked(); }
private void ContinueTemplateFilterGeoChecked() { bool checkExisting = this.ViewReference.ContextValueIsSet("CheckExisting") || this.ViewReference.ContextValueIsSet("ExistsAction"); if (!checkExisting) { this.ContinueRecordDoesNotExist(); return; } string requestModeString = this.ViewReference.ContextValueForKey("RequestMode"); UPRequestOption requestOption = UPCRMDataStore.RequestOptionFromString(requestModeString, UPRequestOption.Online); string filterName = this.ViewReference.ContextValueForKey("TemplateFilter"); string infoAreaId = this.ViewReference.ContextValueForKey("InfoAreaId"); string linkIdString = this.ViewReference.ContextValueForKey("LinkId"); if (string.IsNullOrEmpty(infoAreaId)) { this.ModelController.HandleOrganizerActionError(LocalizedString.TextErrorConfiguration, string.Format(LocalizedString.TextErrorParameterEmpty, "InfoAreaId"), true); return; } UPConfigFilter filter = ConfigurationUnitStore.DefaultStore.FilterByName(filterName); filter = filter.FilterByApplyingValueDictionaryDefaults(this.sourceCopyFields, true); this.CrmQuery = new UPContainerMetaInfo(null, infoAreaId); if (this.CrmQuery == null) { this.ModelController.HandleOrganizerActionError(LocalizedString.TextErrorConfiguration, string.Format(LocalizedString.TextErrorParameterEmpty, "crmQuery"), true); return; } this.CrmQuery.ApplyFilter(filter); if (!string.IsNullOrEmpty(this.LinkRecordIdentification)) { int linkId = -1; if (!string.IsNullOrEmpty(linkIdString)) { linkId = Convert.ToInt32(linkIdString); } this.CrmQuery.SetLinkRecordIdentification(this.LinkRecordIdentification, linkId); } this.CrmQuery.Find(requestOption, this); }
private UPContainerMetaInfo BuildCrmQuery() { if (this.fieldControl != null) { this.crmQuery = new UPContainerMetaInfo(this.fieldControl); if (this.searchAndList?.FilterName?.Length > 0) { UPConfigFilter filter = ConfigurationUnitStore.DefaultStore.FilterByName(this.searchAndList.FilterName); if (filter != null) { this.crmQuery.ApplyFilter(filter); } } } return(this.crmQuery); }
/// <summary> /// Approves the specified dummy. /// </summary> /// <param name="dummy">The dummy.</param> public void Approve(object dummy) { if (this.disableSigning) { return; } string recordIdentification = this.buttonViewReference.ContextValueForKey("RecordId"); string filterName = this.buttonViewReference.ContextValueForKey("TemplateFilter"); if (string.IsNullOrEmpty(recordIdentification)) { this.ParentOrganizerModelController.HandleOrganizerActionError( LocalizedString.TextErrorConfiguration, string.Format(LocalizedString.TextErrorParameterEmpty, "RecordId"), true); return; } UPConfigFilter filter = ConfigurationUnitStore.DefaultStore.FilterByName(filterName); if (filter == null) { this.HandlePageErrorDetails(LocalizedString.TextErrorConfiguration, string.Format(LocalizedString.TextErrorFilterMissing, filterName)); return; } filter = filter.FilterByApplyingValueDictionaryDefaults(this.FieldValueDictionary, true); UPCRMRecord record = new UPCRMRecord(recordIdentification); record.ApplyValuesFromTemplateFilter(filter); UPOfflineEditRecordRequest request = new UPOfflineEditRecordRequest(0); this.buttonRequest = request; string requestOptionString = this.buttonViewReference.ContextValueForKey("RequestOption"); UPOfflineRequestMode requestMode = UPOfflineRequest.RequestModeFromString(requestOptionString, UPOfflineRequestMode.OnlineConfirm); if (request.StartRequest(requestMode, new List <UPCRMRecord> { record }, this) == false) { this.buttonRequest = null; } else { this.ShouldWaitForPendingChanges = true; } }
/// <summary> /// Initializes a new instance of the <see cref="UPSerialEntryDocuments"/> class. /// </summary> /// <param name="_name">The name.</param> /// <param name="_filterName">Name of the filter.</param> /// <param name="_style">The style.</param> /// <param name="_addPhotoDirectButtonName">Name of the add photo direct button.</param> /// <param name="_hasDocumentsColumnFunctionName">Name of the has documents column function.</param> /// <param name="_hasDocumentsColumnValue">The has documents column value.</param> /// <param name="_serialEntry">The serial entry.</param> UPSerialEntryDocuments(string _name, string _filterName, string _style, string _addPhotoDirectButtonName, string _hasDocumentsColumnFunctionName, string _hasDocumentsColumnValue, UPSerialEntry _serialEntry) { this.Name = _name; this.SerialEntry = _serialEntry; this.FilterName = _filterName; this.Style = _style; this.AddPhotoDirectButtonName = _addPhotoDirectButtonName; this.HasDocumentsColumnFunctionName = _hasDocumentsColumnFunctionName; this.HasDocumentsColumnValue = _hasDocumentsColumnValue; IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; UPConfigFilter filter = configStore.FilterByName(this.FilterName); if (!string.IsNullOrEmpty(filter?.DisplayName)) { this.Label = filter.DisplayName; } }
/// <summary> /// Saves the and confirm. /// </summary> /// <param name="viewReference">The view reference.</param> public void SaveAndConfirm(ViewReference viewReference) { UPConfigFilter rootTemplateFilter = null, baseTemplateFilter = null; string templateFilterName = viewReference.ContextValueForKey("ConfirmFilter"); if (!string.IsNullOrEmpty(templateFilterName)) { rootTemplateFilter = ConfigurationUnitStore.DefaultStore.FilterByName(templateFilterName); } templateFilterName = viewReference.ContextValueForKey("BaseRecordConfirmFilter"); if (!string.IsNullOrEmpty(templateFilterName)) { baseTemplateFilter = ConfigurationUnitStore.DefaultStore.FilterByName(templateFilterName); } this.SaveRootTemplateFilterBaseTemplateFilter(null, rootTemplateFilter, baseTemplateFilter); }
private static UPConfigFilter QueryForDistance(UPConfigFilter configFilter, UPConfigFilterParameters parameters, UPMFilter upmFilter) { var distanceFilter = (UPMDistanceFilter)upmFilter; parameters.SetValuesName(new List <string> { distanceFilter.GetGPSXMin.ToString() }, "$parGPSXmin"); parameters.SetValuesName(new List <string> { distanceFilter.GetGPSXMax.ToString() }, "$parGPSXmax"); parameters.SetValuesName(new List <string> { distanceFilter.GetGPSYMin.ToString() }, "$parGPSYmin"); parameters.SetValuesName(new List <string> { distanceFilter.GetGPSYMax.ToString() }, "$parGPSYmax"); return((UPConfigFilter)configFilter.QueryByApplyingFilterParameters(parameters)); }
/// <summary> /// Initializes a new instance of the <see cref="UPCRMRecordTile"/> class. /// </summary> /// <param name="tiles">The tiles.</param> /// <param name="viewReference">The view reference.</param> /// <param name="parameters">The parameters.</param> /// <param name="menuAction">The menu action.</param> /// <exception cref="Exception"> /// RecordIdentification is null /// or /// TableCaptionName is null /// </exception> public UPCRMRecordTile(UPCRMTiles tiles, ViewReference viewReference, Dictionary <string, object> parameters, Menu menuAction) : base(tiles, viewReference, parameters, menuAction) { this.tableCaptionName = this.ViewReference.ContextValueForKey("tableCaption"); this.recordIdentification = this.ViewReference.ContextValueForKey("uid"); string imageMapFilterName = this.ViewReference.ContextValueForKey("imageMapFilter"); IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; if (string.IsNullOrEmpty(this.recordIdentification)) { throw new Exception("RecordIdentification is null"); } if (!string.IsNullOrEmpty(this.tableCaptionName)) { this.tableCaption = configStore.TableCaptionByName(this.tableCaptionName); } if (this.tableCaption == null) { if (string.IsNullOrEmpty(this.tableCaptionName)) { throw new Exception("TableCaptionName is null"); } } if (!string.IsNullOrEmpty(imageMapFilterName)) { this.imageFilter = configStore.FilterByName(imageMapFilterName); this.imageFilter = this.imageFilter?.FilterByApplyingValueDictionaryDefaults(this.Parameters, true); if (this.imageFilter != null) { this.catalogAttributes = configStore.CatalogAttributesByFilter(this.imageFilter); if (this.catalogAttributes != null) { this.crmQuery?.AddCrmFields(new List <UPCRMField> { this.catalogAttributes.CrmField }); } } } }
private List <UPCRMRecord> ChangedRecordsWithRootTemplateFilter(UPConfigFilter rootTemplateFilter, UPConfigFilter baseTemplateFilter, bool ignoreDefault) { List <UPCRMRecord> changedRecordArray = null; UPSurvey survey = null; foreach (UPPageModelController pageModelController in this.PageModelControllers) { List <UPCRMRecord> cr; var questionnaireEditPageModelController = pageModelController as QuestionnaireEditPageModelController; if (ignoreDefault && questionnaireEditPageModelController != null) { cr = questionnaireEditPageModelController.ChangedRecordsIgnoreDefaultWithRootTemplateFilterBaseTemplateFilter(rootTemplateFilter, baseTemplateFilter); } else if (!ignoreDefault && questionnaireEditPageModelController != null) { cr = questionnaireEditPageModelController.ChangedRecordsWithRootTemplateFilterBaseTemplateFilter(rootTemplateFilter, baseTemplateFilter); } else { cr = pageModelController.ChangedRecords(); } if (cr?.Count > 0) { if (changedRecordArray == null) { changedRecordArray = new List <UPCRMRecord>(cr); } else { changedRecordArray.AddRange(cr); } } if (survey == null && questionnaireEditPageModelController != null) { survey = questionnaireEditPageModelController.Survey; } } return(changedRecordArray); }