private bool SetControlsFromParametersEditMode(Dictionary <string, object> parameters, bool editMode) { IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; string destinationFieldgroupParameterName = UPObjectivesConfiguration.CombineConfigurationNameWithSection(Constants.ParameterDestinationFieldGroupConfigurationName, this.SectionName); string configName = this.ContextValueForViewReferenceKeyParameters(this.ViewReference, destinationFieldgroupParameterName, parameters); if (!string.IsNullOrEmpty(configName)) { if (editMode) { FieldControl listFieldControl = configStore.FieldControlByNameFromGroup(Constants.ListConfigurationName, configName); this.DestinationFieldControl = configStore.FieldControlByNameFromGroup(Constants.EditConfigurationName, configName); if (listFieldControl?.CrmSortFields != null) { this.DestinationFieldControl = new FieldControl(this.DestinationFieldControl, listFieldControl); } } else { this.DestinationFieldControl = configStore.FieldControlByNameFromGroup(Constants.ListConfigurationName, configName); } } if (this.DestinationFieldControl == null) { return(false); } List <UPConfigFieldControlField> addFields = new List <UPConfigFieldControlField>(); Dictionary <string, UPConfigFieldControlField> tempFieldDictionary = new Dictionary <string, UPConfigFieldControlField>(); this.FieldsWithFunction = new Dictionary <string, UPConfigFieldControlField>(); foreach (FieldControlTab tab in this.DestinationFieldControl.Tabs) { foreach (UPConfigFieldControlField field in tab.Fields) { FieldAttributes fieldAttributes = field.Attributes; if (!fieldAttributes.Hide) { addFields.Add(field); } if (!string.IsNullOrEmpty(field.Function)) { tempFieldDictionary[field.Function] = field; } } this.FieldsWithFunction = new Dictionary <string, UPConfigFieldControlField>(tempFieldDictionary); this.AdditionalFields = new List <UPConfigFieldControlField>(addFields); } configName = this.ContextValueForViewReferenceKeyParameters(this.ViewReference, CombineConfigurationNameWithSection(Constants.ParameterSourceFieldControlConfigurationName, this.SectionName), parameters); if (!string.IsNullOrEmpty(configName)) { this.SourceFieldControl = configStore.FieldControlByNameFromGroup(Constants.ListConfigurationName, configName); } string destinationFilterParameterName = CombineConfigurationNameWithSection(Constants.ParameterDestinationFilterConfigurationName, this.SectionName); this.DestinationFilterName = this.ContextValueForViewReferenceKeyParameters(this.ViewReference, destinationFilterParameterName, parameters); UPConfigFilter filter = configStore.FilterByName(this.DestinationFilterName); if (filter != null) { this.SectionHeaderLabel = filter.DisplayName; } configName = this.ViewReference?.ContextValueForKey("ExecuteActionFilterName"); if (!string.IsNullOrEmpty(configName)) { this.ExecuteActionFilter = configStore.FilterByName(configName); } return(true); }
private bool SetControlsFromParameters() { ViewReference viewReference = null; if (this.Parameters.ContainsKey("viewReference")) { viewReference = (ViewReference)this.Parameters["viewReference"]; } // create rightsfilter string rightsFilterName = viewReference?.ContextValueForKey(Constants.RightsFilterConfigurationName); if (!string.IsNullOrEmpty(rightsFilterName)) { IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; this.RightsFilter = configStore.FilterByName(rightsFilterName); } if (this.RightsFilter != null) { #if PORTING NSDictionary filterParameters = (NSDictionary)viewReference.ContextValueForKey(Constants.RightsFilterCopyFieldConfigurationName); if (filterParameters != null) { UPConditionValueReplacement replacement = new UPConditionValueReplacement(filterParameters); this.RightsFilter = this.RightsFilter.FilterByApplyingReplacements(replacement); } else #endif { this.RightsFilter = this.RightsFilter.FilterByApplyingDefaultReplacements(); } } this.RequestOption = UPCRMDataStore.RequestOptionFromString(viewReference?.ContextValueForKey(Constants.RequestOptionConfigurationName), UPRequestOption.Offline); this.groupConfigurations = new List <UPObjectivesConfiguration>(); UPObjectivesConfiguration individualConfiguration = UPObjectivesConfiguration.Create(viewReference, Constants.IndividualSectionPostFix, this.Parameters, this.EditMode); if (individualConfiguration != null) { this.groupConfigurations.Add(individualConfiguration); } UPObjectivesConfiguration salesConfiguration = UPObjectivesConfiguration.Create(viewReference, Constants.SalesSectionPostFix, this.Parameters, this.EditMode); if (salesConfiguration != null) { this.groupConfigurations.Add(salesConfiguration); } List <string> additionalFieldGroups = this.StringsFromCommaSeparatedString(viewReference?.ContextValueForKey(Constants.AdditionalFieldgroupsConfigurationName)); // load additional sections if (additionalFieldGroups?.Count > 0) { List <string> additionalDestinationFilter = this.StringsFromCommaSeparatedString(viewReference?.ContextValueForKey(Constants.AdditionalFilterConfigurationName)); List <string> additionalSourceFieldControl = this.StringsFromCommaSeparatedString(viewReference?.ContextValueForKey(Constants.AdditionalSourceFieldControlConfigurationName)); if ((additionalDestinationFilter != null && additionalSourceFieldControl != null) && (additionalFieldGroups.Count == additionalDestinationFilter.Count) && (additionalDestinationFilter.Count == additionalSourceFieldControl.Count)) { Dictionary <string, object> additionalParameterDictionary = new Dictionary <string, object>(this.Parameters); for (int additionalSectionIndex = 0; additionalSectionIndex < additionalDestinationFilter.Count; additionalSectionIndex++) { string sectionName = $"AdditionalSection_{additionalSectionIndex}"; string destinationFieldGroupName = UPObjectivesConfiguration.CombineConfigurationNameWithSection(Constants.ParameterDestinationFieldGroupConfigurationName, sectionName); string destinationFilterName = UPObjectivesConfiguration.CombineConfigurationNameWithSection(Constants.ParameterDestinationFilterConfigurationName, sectionName); string sourceFieldControlName = UPObjectivesConfiguration.CombineConfigurationNameWithSection(Constants.ParameterSourceFieldControlConfigurationName, sectionName); additionalParameterDictionary[destinationFieldGroupName] = additionalFieldGroups[additionalSectionIndex]; additionalParameterDictionary[destinationFilterName] = additionalDestinationFilter[additionalSectionIndex]; additionalParameterDictionary.SetObjectForKey(additionalSourceFieldControl[additionalSectionIndex], sourceFieldControlName); UPObjectivesConfiguration additionalConfiguration = UPObjectivesConfiguration.Create(viewReference, sectionName, additionalParameterDictionary, this.EditMode); if (additionalConfiguration != null) { this.groupConfigurations.Add(additionalConfiguration); } } } } this.record = new UPCRMRecord(this.RecordIdentification); this.ParentLink = viewReference?.ContextValueForKey("ParentLink"); return(true); }