public void CanSerializeWithParams() { var confTest = new CrcExtraConfiguration(); confTest.Version = 2; var repTest = new CrcReportConfig(); repTest.Path = "Test"; repTest.IsFeatured = true; var paramTest = new CrcReportConfig.CrcParamConfig(); paramTest.ParamName = "TestParam"; paramTest.ShowByDefault = true; repTest.CrcParamConfigs = new List <CrcReportConfig.CrcParamConfig>(); repTest.CrcParamConfigs.Add(paramTest); confTest.CrcReportConfigs = new List <CrcReportConfig>(); confTest.CrcReportConfigs.Add(repTest); CrcExtraConfiguration.Serialize("TestConfigWithParams.xml", confTest); }
public void CanSerializeAndDeserializeConfig() { var confTest = new CrcExtraConfiguration(); confTest.Version = 2; var repTest = new CrcReportConfig(); repTest.Path = "Test"; repTest.IsFeatured = true; confTest.CrcReportConfigs = new List <CrcReportConfig>(); confTest.CrcReportConfigs.Add(repTest); CrcExtraConfiguration.Serialize("TestConfig.xml", confTest); var getItBack = CrcExtraConfiguration.Deserialize("TestConfig.xml"); Assert.AreEqual(2, getItBack.Version); Assert.AreEqual(1, getItBack.CrcReportConfigs.Count()); Assert.AreEqual("Test", getItBack.CrcReportConfigs[0].Path); Assert.AreEqual(true, getItBack.CrcReportConfigs[0].IsFeatured); }
public void AddParameterDefinitions(rws.ReportParameter[] wsReportParameters, CrcReportDefinition repDef, CrcExtraConfiguration extraConfig, CrcReportConfig reportConfig) { List <string> showByDefault = new List <string>(); if (reportConfig != null) { showByDefault = reportConfig.GetParamsToShowByDefault(); } List <string> defaultEmptyEquivalents = new List <string>(); if (extraConfig != null && extraConfig.DefaultEmptyEquivalentValues != null) { defaultEmptyEquivalents = extraConfig.DefaultEmptyEquivalentValues; } foreach (var paramLoop in wsReportParameters) { CrcReportConfig.CrcParamConfig paramConfig = null; // get extra config for parameter, if there is any if (reportConfig != null) { paramConfig = reportConfig.CrcParamConfigs.FirstOrDefault(p => p.ParamName == paramLoop.Name); } var crcParam = new CrcParameterDefinition(); crcParam.Name = paramLoop.Name; crcParam.id = "param_" + paramLoop.Name.Replace(" ", "_"); crcParam.AllowNull = paramLoop.Nullable; crcParam.AllowBlank = paramLoop.AllowBlank; if (string.IsNullOrEmpty(paramLoop.Prompt)) { // if Prompt is null or empty, it means Parameter is 'Hidden' in SSRS crcParam.Hidden = true; crcParam.DisplayName = paramLoop.Name; } else { crcParam.DisplayName = paramLoop.Prompt; } if (string.IsNullOrEmpty(crcParam.DisplayName)) { crcParam.DisplayName = crcParam.Name; } // if PromptUser is false then Parameter is 'Internal' in SSRS if (!paramLoop.PromptUser) { crcParam.Hidden = true; } if (paramLoop.Type == rws.ParameterTypeEnum.DateTime) { crcParam.ParameterType = CrcParameterType.Date; } else if ((paramLoop.ValidValues != null && paramLoop.ValidValues.Count() > 0) || paramLoop.ValidValuesQueryBased) { if (paramLoop.MultiValue) { crcParam.ParameterType = CrcParameterType.MultiSelect; } else { crcParam.ParameterType = CrcParameterType.Select; } } else if (paramLoop.Type == rws.ParameterTypeEnum.Boolean) { crcParam.ParameterType = CrcParameterType.Boolean; } else { crcParam.ParameterType = CrcParameterType.Text; } if (paramLoop.ValidValues != null) { foreach (var valLoop in paramLoop.ValidValues) { crcParam.ValidValues.Add(new CrcValidValue() { Value = valLoop.Value, Label = valLoop.Label }); } if (crcParam.ValidValues.Count() > 10) { crcParam.AllowListSearch = true; } } // check config for dependencies if (paramConfig != null && paramConfig.DependantParams != null && paramConfig.DependantParams.Count() > 0) { logger.DebugFormat("Param {0} has extraconfig dependancies: {1}", paramLoop.Name, string.Join(", ", paramConfig.DependantParams.ToArray())); foreach (string dpname in paramConfig.DependantParams) { crcParam.DependantParameterNames.Add(dpname); } } foreach (string sloop in defaultEmptyEquivalents) { AddEmptyEquivalent(crcParam, sloop); } // check for specific empty equivalents for this parameter if (paramConfig != null && paramConfig.EmptyEquivalentValues != null) { foreach (string sloop in paramConfig.EmptyEquivalentValues) { AddEmptyEquivalent(crcParam, sloop); } } if (showByDefault.Contains(crcParam.Name)) { crcParam.AlwaysShow = true; } repDef.ParameterDefinitions.Add(crcParam); } }
public CrcReportDefinition Create(string reportPath, rws.CatalogItem reportCatItem, rws.ReportParameter[] wsReportParameters, CrcExtraConfiguration extraConfig) { var repDef = new CrcReportDefinition(); repDef.ReportPath = reportPath; if (reportCatItem != null) { repDef.DisplayName = reportCatItem.Name; repDef.Description = reportCatItem.Description; } if (string.IsNullOrEmpty(repDef.DisplayName)) { repDef.DisplayName = CrcReportDefinition.ReportNameFromPath(repDef.ReportPath); } CrcReportConfig repConfig = null; if (extraConfig != null) { repConfig = extraConfig.GetReportConfig(repDef.ReportPath); } if (repConfig != null) { repDef.ReportHint = repConfig.ReportHint; } AddParameterDefinitions(wsReportParameters, repDef, extraConfig, repConfig); bool readSsrsDependantParams = false; if (extraConfig == null || !extraConfig.IgnoreSsrsParameterDependencies) { readSsrsDependantParams = true; } if (repConfig != null && repConfig.DependantParamsSpecified) { readSsrsDependantParams = false; } if (readSsrsDependantParams) { AddSsrsDependentParams(wsReportParameters, repDef); } CrossReferenceDependantParameters(repDef); ApplyParameterDefaults(wsReportParameters, repDef); CheckRequiredFromUser(repDef); return(repDef); }
public CrcReportDefinition Create(string reportPath, rws.ReportParameter[] wsReportParameters, CrcExtraConfiguration extraConfig) { return(Create(reportPath, null, wsReportParameters, extraConfig)); }