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
        private void ShowReportLists()
        {
            var crcr = new CrissCrossServices();

            uxRecentListView.DataSource = crcr.GetUsersRecentRuns(uxHiddenFullUsername.Text, 200);
            uxRecentListView.DataBind();
        }
        public void CanGetReportDefn()
        {
            var mf = new TestDoubles.MockSsrsWebServiceFactory();
            var serviceMock = mf.MakeMockReportingService2005Soap(
                                    mf.MakeSimpleTestParameters());
            mf.SetListChildrenExpectation(serviceMock, @"/", new CatalogItem[] { new CatalogItem() {
                Path = "TestReport",
                Name = "TestReportName",
                Description = "TestReportDescription",
                Type = ItemTypeEnum.Report}});
            var soapClientFactory = mf.MakeMockSoapClientFactory(serviceMock);

            var cacheMock = MockRepository.GenerateMock<CrcCacheManager>();
            // return empty cache when asked
            cacheMock.Expect(m => m.AllReportsCacheByUsername).Return(new TimedCache<CatalogItem[]>("test1",10,10));
            var configMock = MockRepository.GenerateMock<CrcExtraConfiguration>();

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

            var repDefn = ccs.GetReportDefn("TestReport", "TestUser");

            Assert.IsNotNull(repDefn);
            Assert.AreEqual("TestReport", repDefn.ReportPath);
            Assert.AreEqual("TestReportName", repDefn.DisplayName);
            Assert.AreEqual("TestReportDescription", repDefn.Description);
            Assert.AreEqual(2, repDefn.ParameterDefinitions.Count());
            var p1check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamOne");
            Assert.IsNotNull(p1check);
            Assert.AreEqual(2, p1check.ValidValues.Count());
            var p2check = repDefn.ParameterDefinitions.FirstOrDefault(p => p.Name == "ParamTwo");
            Assert.IsNotNull(p2check);
            Assert.AreEqual(2, p2check.ValidValues.Count());
        }
Beispiel #4
0
        protected void uxGetHistory_Click(object sender, EventArgs e)
        {
            throw new NotImplementedException();
            string forUser = uxUsername.Text;
            var crcr = new CrissCrossServices();

            uxRecentListView.DataSource = crcr.GetUsersRecentRuns(forUser, 200);
            uxRecentListView.DataBind();
        }
Beispiel #5
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;
        }
        private void ShowReportLists(string showFolder, string username)
        {
            logger.DebugFormat("Showing hierarchical catalog for {0} initial folder {1}",
                username, showFolder);
            var crcr = new CrissCrossServices();

            var repFolderTree = crcr.GetAllReportsHierarchical(username);
            repFolderTree.FolderName = "All Reports";
            uxAllCatalogHierarchical.Text = string.Format("<div class=\"hierarchicalCatalog\">{0}</div>", HierarchicalCatalogView(repFolderTree, 0, showFolder));
        }
Beispiel #7
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 #8
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;
        }
        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"));
        }