Beispiel #1
0
        public static string getDependantParameters(string path, string paramName, string paramValue, string[] visibleDependants)
        {
            try
            {
                var crcRepDef = GetReportDefinition(path);
                logger.DebugFormat("getDependantParameters: Report {0} User {1} base param {2} value {3} visible dependants {4}",
                                   crcRepDef.DisplayName, HttpContext.Current.User.Identity.Name, paramName, paramValue, string.Join(", ", visibleDependants));
                // map the parameter values onto the report definition
                var choiceFactory    = new CrcParameterChoiceFactory();
                var choiceCollection = choiceFactory.Create(paramValue);

                var crServices = new CrissCrossLib.CrissCrossServices();
                crServices.RefreshDependantParameters(crcRepDef, choiceCollection);
                // only return visible dependant params back to ui
                List <CrcParameterDefinition> paramsToReturn = crcRepDef.ParameterDefinitions
                                                               .Where(p => visibleDependants.Contains(p.Name)).ToList();

                string json = CrissCrossWebHelper.SerializeObjectIntoJson <List <CrcParameterDefinition> >(paramsToReturn);
                return(json);
            }
            catch (Exception e)
            {
                LogAjaxError(e, "getDependantParameters");
                throw e;
            }
        }
Beispiel #2
0
        public void PrepareReportDefn(string reportPath)
        {
            var crServices = new CrissCrossLib.CrissCrossServices();
            var crcRepDefn = crServices.GetReportDefn(reportPath, User.Identity.Name);

            if (!String.IsNullOrEmpty(this.InitialParameterString))
            {
                var choiceFactory    = new CrcParameterChoiceFactory();
                var choiceCollection = choiceFactory.Create(this.InitialParameterString);
                if (crcRepDefn.HasDependantParameters)
                {
                    crServices.RefreshDependantParameters(crcRepDefn, choiceCollection);
                }
                else
                {
                    var mapResult = crcRepDefn.MapParameterChoices(choiceCollection);
                    if (!mapResult.MappingValid)
                    {
                        throw new ApplicationException(String.Format("Could not apply parameters to report {0}. problems: {1}",
                                                                     crcRepDefn.DisplayName, String.Join(", ", mapResult.Complaints.ToArray())));
                    }
                }
            }

            uxReportName.Text = crcRepDefn.DisplayName;
            string combinedDesc = BuildCombinedDescription(crcRepDefn);

            if (!string.IsNullOrEmpty(combinedDesc))
            {
                uxReportHint.Text = combinedDesc;
            }
            else
            {
                uxReportDescriptionPanel.Visible = false;
            }

            uxReportFolderLink.Text        = crcRepDefn.GetReportFolder();
            uxReportFolderLink.NavigateUrl = string.Format("AllCatalog.aspx?Folder={0}",
                                                           Server.UrlEncode(crcRepDefn.GetReportFolder()));
            uxResultsPanel.Visible = false;
            // stash it in session
            Session[crcRepDefn.ReportPath] = crcRepDefn;
        }
Beispiel #3
0
        public void PrepareReportDefn(string reportPath)
        {
            var crServices = new CrissCrossLib.CrissCrossServices();
            var crcRepDefn = crServices.GetReportDefn(reportPath, User.Identity.Name);

            if (!String.IsNullOrEmpty(this.InitialParameterString))
            {
                var choiceFactory = new CrcParameterChoiceFactory();
                var choiceCollection = choiceFactory.Create(this.InitialParameterString);
                if (crcRepDefn.HasDependantParameters)
                    crServices.RefreshDependantParameters(crcRepDefn, choiceCollection);
                else
                {
                    var mapResult = crcRepDefn.MapParameterChoices(choiceCollection);
                    if (!mapResult.MappingValid)
                        throw new ApplicationException(String.Format("Could not apply parameters to report {0}. problems: {1}",
                            crcRepDefn.DisplayName, String.Join(", ", mapResult.Complaints.ToArray())));
                }
            }

            uxReportName.Text = crcRepDefn.DisplayName;
            string combinedDesc = BuildCombinedDescription(crcRepDefn);
            if (!string.IsNullOrEmpty(combinedDesc))
                uxReportHint.Text = combinedDesc;
            else
                uxReportDescriptionPanel.Visible = false;

            uxReportFolderLink.Text = crcRepDefn.GetReportFolder();
            uxReportFolderLink.NavigateUrl = string.Format("AllCatalog.aspx?Folder={0}",
                Server.UrlEncode(crcRepDefn.GetReportFolder()));
            uxResultsPanel.Visible = false;
            // stash it in session
            Session[crcRepDefn.ReportPath] = crcRepDefn;
        }
Beispiel #4
0
        public static string getDependantParameters(string path, string paramName, string paramValue, string[] visibleDependants)
        {
            try
            {
                var crcRepDef = GetReportDefinition(path);
                logger.DebugFormat("getDependantParameters: Report {0} User {1} base param {2} value {3} visible dependants {4}",
                    crcRepDef.DisplayName, HttpContext.Current.User.Identity.Name, paramName, paramValue, string.Join(", ",visibleDependants));
                // map the parameter values onto the report definition
                var choiceFactory = new CrcParameterChoiceFactory();
                var choiceCollection = choiceFactory.Create(paramValue);

                var crServices = new CrissCrossLib.CrissCrossServices();
                crServices.RefreshDependantParameters(crcRepDef, choiceCollection);
                // only return visible dependant params back to ui
                List<CrcParameterDefinition> paramsToReturn = crcRepDef.ParameterDefinitions
                    .Where(p => visibleDependants.Contains(p.Name)).ToList();

                string json = CrissCrossWebHelper.SerializeObjectIntoJson<List<CrcParameterDefinition>>(paramsToReturn);
                return json;
            }
            catch (Exception e)
            {
                LogAjaxError(e, "getDependantParameters");
                throw e;
            }
        }
        public void CanRefreshDependantParameters_Simple()
        {
            // make report defn
            var repDefn = new CrcReportDefinition();
            repDefn.ReportPath = "Test/Report";
            var pd1 = new CrcParameterDefinition();
            pd1.Name = "ParamOne";
            pd1.ValidValues.Add(new CrcValidValue() { Label = "Label1", Value = "Value1" });
            pd1.ValidValues.Add(new CrcValidValue() { Label = "Label2", Value = "Value2" });
            pd1.ValidValues.Add(new CrcValidValue() { Label = "Label3", Value = "Value3" });
            pd1.DependantParameterNames.Add("ParamTwo");
            var pd2 = new CrcParameterDefinition();
            pd2.Name = "ParamTwo";
            pd2.ValidValues.Add(new CrcValidValue() { Label = "SubLabel1_1", Value = "SubValue1_1" });
            pd2.ValidValues.Add(new CrcValidValue() { Label = "SubLabel1_2", Value = "SubValue1_2" });
            pd2.ValidValues.Add(new CrcValidValue() { Label = "SubLabel2_1", Value = "SubValue2_1" });
            pd2.ValidValues.Add(new CrcValidValue() { Label = "SubLabel2_2", Value = "SubValue2_2" });
            pd2.ValidValues.Add(new CrcValidValue() { Label = "SubLabel3_1", Value = "SubValue3_1" });
            repDefn.ParameterDefinitions.Add(pd1);
            repDefn.ParameterDefinitions.Add(pd2);

            // make choice collection
            var choiceCollection = new CrcParameterChoiceCollection();
            var paramChoice = new CrcParameterChoice("ParamOne");
            paramChoice.Values.Add("Value2");
            choiceCollection.ParameterChoiceList.Add( paramChoice);

            // make server side params to return
            ReportParameter p1 = new ReportParameter();
            p1.Name = "ParamOne";
            p1.ValidValues = new ValidValue[]{ new ValidValue(){Label = "Label1", Value = "Value1"},
                                    new ValidValue(){Label = "Label2", Value = "Value2"},
                                    new ValidValue(){Label = "Label3", Value = "Value3"}};
            p1.DefaultValues = new string[] { };
            ReportParameter p2 = new ReportParameter();
            p2.Name = "ParamTwo";
            p2.ValidValues = new ValidValue[]{ new ValidValue(){Label = "SubLabel2_1", Value = "SubValue2_1"},
                                    new ValidValue(){Label = "SubLabel2_2", Value = "SubValue2_2"}};
            p2.DefaultValues = new string[] { };
            ReportParameter[] paramArrayToReturn = new ReportParameter[] { p1, p2 };

            // make mocks for ccs
            var mf = new TestDoubles.MockSsrsWebServiceFactory();
            var soapClientFactory = mf.MakeMockSoapClientFactory(
                        mf.MakeMockReportingService2005Soap("Value2", paramArrayToReturn));

            var cacheMock = MockRepository.GenerateMock<CrcCacheManager>();
            var configMock = MockRepository.GenerateMock<CrcExtraConfiguration>();

            // make ccs
            var ccs = new CrissCrossServices(soapClientFactory, cacheMock, configMock, null);

            ccs.RefreshDependantParameters(repDefn, choiceCollection);

            Assert.AreEqual(2,repDefn.ParameterDefinitions.Count());
            var pd1check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamOne");
            Assert.IsNotNull(pd1check);
            Assert.AreEqual("Value2", pd1check.ParameterChoice.SingleValue);
            var pd2check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamTwo");
            Assert.IsNotNull(pd2check);
            Assert.AreEqual(2, pd2check.ValidValues.Count());
            Assert.IsNotNull(pd2check.ValidValues.FirstOrDefault( vv => vv.Value == "SubValue2_1"));
            Assert.IsNotNull(pd2check.ValidValues.FirstOrDefault( vv => vv.Value == "SubValue2_2"));
        }