private PivotReport BindDefaultData(bool isCalculatedField)
 {
     PivotReport pivotSetting = new PivotReport();
     if (isCalculatedField)
     {
         pivotSetting.PivotRows.Add(new PivotItem { FieldMappingName = "Date", FieldHeader = "Date", TotalHeader = "Total" });
         pivotSetting.PivotRows.Add(new PivotItem { FieldMappingName = "Product", FieldHeader = "Product", TotalHeader = "Total" });
         pivotSetting.PivotColumns.Add(new PivotItem { FieldMappingName = "Country", FieldHeader = "Country", TotalHeader = "Total" });
         pivotSetting.PivotCalculations.Add(new PivotComputationInfo { CalculationName = "Amount", Description = "Amount", FieldHeader = "Amount", FieldName = "Amount", Format = "C", SummaryType = Syncfusion.PivotAnalysis.Base.SummaryType.DoubleTotalSum });
         pivotSetting.PivotCalculations.Add(new PivotComputationInfo
         {
             CalculationName = "Price",
             FieldHeader = "Price",
             FieldName = "Price",
             CalculationType = CalculationType.Formula,
             Formula = "Amount + 12"
         });
     }
     else
     {
         pivotSetting.PivotRows.Add(new PivotItem { FieldMappingName = "Date", FieldHeader = "Date", TotalHeader = "Total" });
         pivotSetting.PivotRows.Add(new PivotItem { FieldMappingName = "Product", FieldHeader = "Product", TotalHeader = "Total" });
         pivotSetting.PivotColumns.Add(new PivotItem { FieldMappingName = "Country", FieldHeader = "Country", TotalHeader = "Total" });
         pivotSetting.PivotColumns.Add(new PivotItem { FieldMappingName = "State", FieldHeader = "State", TotalHeader = "Total" });
         pivotSetting.PivotCalculations.Add(new PivotComputationInfo { CalculationName = "Amount", Description = "Amount", FieldHeader = "Amount", FieldName = "Amount", Format = "C", SummaryType = Syncfusion.PivotAnalysis.Base.SummaryType.DoubleTotalSum });
     }
     return pivotSetting;
 }
Example #2
0
        public Dictionary <string, object> LoadReportFromDB(Dictionary <string, object> jsonResult)
        {
            PivotReport report = new PivotReport();
            string      operationalMode = jsonResult["operationalMode"].ToString(), analysisMode = jsonResult["analysisMode"].ToString();
            Dictionary <string, object> dictionary = new Dictionary <string, object>();
            string currentRptName                  = string.Empty;

            foreach (DataRow row in GetDataTable().Rows)
            {
                currentRptName = (row.ItemArray[0] as string).Replace("##" + operationalMode.ToLower() + "#>>#" + analysisMode.ToLower(), "");
                if (currentRptName.Equals(jsonResult["reportName"].ToString()))
                {
                    byte[] reportString = new byte[2 * 1024];
                    reportString = (row.ItemArray[1] as byte[]);
                    if (analysisMode.ToLower() == "pivot" && operationalMode.ToLower() == "servermode")
                    {
                        dictionary = pivotClient.GetJsonData("LoadReport", ProductSales.GetSalesData(), Encoding.UTF8.GetString(reportString));
                    }
                    else
                    {
                        dictionary.Add("report", Encoding.UTF8.GetString(reportString));
                    }
                    break;
                }
            }
            return(dictionary);
        }
        public Dictionary <string, object> LoadReportFromDB(Dictionary <string, object> jsonResult)
        {
            PivotReport report = new PivotReport();
            string      operationalMode = jsonResult["operationalMode"].ToString(), analysisMode = jsonResult["analysisMode"].ToString();
            Dictionary <string, object> dictionary = new Dictionary <string, object>();
            string currentRptName                  = string.Empty;

            foreach (DataRow row in GetDataTable().Rows)
            {
                currentRptName = (row.ItemArray[0] as string).Replace("##" + operationalMode.ToLower() + "#>>#" + analysisMode.ToLower(), "");
                if (currentRptName.Equals(jsonResult["reportName"].ToString()))
                {
                    byte[] reportString = new byte[2 * 1024];
                    reportString = (row.ItemArray[1] as byte[]);
                    if (operationalMode.ToLower() == "servermode" && analysisMode == "olap")
                    {
                        string          repCol      = Encoding.UTF8.GetString(reportString);
                        OlapDataManager DataManager = new OlapDataManager(connectionString);
                        if (repCol.IndexOf("<?xml version") == 0)
                        {
                            string reportStr = "";
                            reportStr           = Syncfusion.JavaScript.Olap.Utils.CompressData(row.ItemArray[1] as byte[]);
                            DataManager.Reports = olapClientHelper.DeserializedReports(reportStr);
                            DataManager.SetCurrentReport(DataManager.Reports[0]);
                            return(olapClientHelper.GetJsonData("toolbarOperation", DataManager, "Load Report", jsonResult["reportName"].ToString()));
                        }
                        else
                        {
                            dynamic customData = serializer.Deserialize <dynamic>(repCol.ToString());
                            DataManager.Reports = olapClientHelper.DeserializedReports(customData[customData[customData.Length - 1]["cubeIndex"]]["Reports"]);
                            DataManager.SetCurrentReport(DataManager.Reports[customData[customData[customData.Length - 1]["cubeIndex"]]["ReportIndex"]]);
                            dictionary = olapClientHelper.GetJsonData("toolbarOperation", DataManager, "Load Report", jsonResult["reportName"].ToString());
                            dictionary.Add("Collection", repCol);
                        }
                    }
                    else
                    {
                        if (analysisMode.ToLower() == "pivot" && operationalMode.ToLower() == "servermode")
                        {
                            dictionary = olapClientHelper.GetJsonData("LoadReport", ProductSales.GetSalesData(), Encoding.UTF8.GetString(reportString));
                        }
                        else
                        {
                            dictionary.Add("report", Encoding.UTF8.GetString(reportString));
                        }

                        break;
                    }
                }
            }
            return(dictionary);
        }
Example #4
0
 public static Report Load(ReportSpec reportSpec)
 {
     SimpleReport simpleReport;
     if (reportSpec.CrossTabHeaders != null)
     {
         PivotReport pivotReport = new PivotReport
                                       {
                                           GroupByColumns = reportSpec.GroupBy,
                                           CrossTabHeaders = reportSpec.CrossTabHeaders,
                                           CrossTabValues = reportSpec.CrossTabValues
                                       };
         simpleReport = pivotReport;
     }
     else
     {
         simpleReport = new SimpleReport();
     }
     simpleReport.Columns = reportSpec.Select;
     return simpleReport;
 }
        public Dictionary <string, object> LoadReportFromDB(Dictionary <string, object> jsonResult)
        {
            byte[]      reportString = new byte[2 * 1024];
            PivotReport report       = new PivotReport();
            var         reports      = "";
            string      mode         = jsonResult["operationalMode"].ToString();
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            if (mode == "serverMode" && jsonResult.ContainsKey("clientReports"))
            {
                reports = jsonResult["clientReports"].ToString();
            }
            else
            {
                foreach (DataRow row in GetDataTable().Rows)
                {
                    if ((row.ItemArray[0] as string).Equals(jsonResult["reportName"].ToString()))
                    {
                        if (mode == "clientMode")
                        {
                            reportString = (row.ItemArray[1] as byte[]);
                            dictionary.Add("report", Encoding.UTF8.GetString(reportString));
                            break;
                        }
                        else if (mode == "serverMode")
                        {
                            reports = OLAPUTILS.Utils.CompressData(row.ItemArray[1] as byte[]);
                            break;
                        }
                    }
                }
            }
            if (reports != "")
            {
                report = htmlHelper.DeserializedReports(reports);
                htmlHelper.PivotReport = report;
                dictionary             = htmlHelper.GetJsonData("loadOperation", ProductSales.GetSalesData(), "Load Report", jsonResult["reportName"].ToString());
            }
            return(dictionary);
        }
        public Dictionary <string, object> LoadReportFromDB(string reportName, string operationalMode, string olapReport, string clientReports)
        {
            byte[]      reportString = new byte[2 * 1024];
            PivotReport report       = new PivotReport();
            var         reports      = "";
            string      mode         = operationalMode;
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            if (mode == "serverMode" && !string.IsNullOrEmpty(clientReports))
            {
                reports = clientReports;
            }
            else
            {
                foreach (DataRow row in GetDataTable().Rows)
                {
                    if ((row.ItemArray[0] as string).Equals(reportName))
                    {
                        if (mode == "clientMode")
                        {
                            reportString = (row.ItemArray[1] as byte[]);
                            dictionary.Add("report", Encoding.UTF8.GetString(reportString));
                            break;
                        }
                        else if (mode == "serverMode")
                        {
                            reports = OLAPUTILS.Utils.CompressData(row.ItemArray[1] as byte[]);
                            break;
                        }
                    }
                }
            }
            if (reports != "")
            {
                report = htmlHelper.DeserializedReports(reports);
                htmlHelper.PivotReport = report;
                dictionary             = htmlHelper.GetJsonData("loadOperation", ProductSales.GetSalesData(), "Load Report", reportName);
            }
            return(dictionary);
        }
        public Dictionary <string, object> LoadReportFromDB(string reportName, string operationalMode, string analysisMode, string olapReport, string clientReports)
        {
            PivotReport report = new PivotReport();
            Dictionary <string, object> dictionary = new Dictionary <string, object>();
            string currentRptName = string.Empty;

            foreach (DataRow row in GetDataTable().Rows)
            {
                currentRptName = (row.ItemArray[0] as string).Replace("##" + operationalMode.ToLower() + "#>>#" + analysisMode.ToLower(), "");
                if (currentRptName.Equals(reportName))
                {
                    if (operationalMode.ToLower() == "servermode" && analysisMode == "olap")
                    {
                        string          reportString = "";
                        OlapDataManager DataManager  = new OlapDataManager();
                        reportString        = OLAPUTILS.Utils.CompressData(row.ItemArray[1] as byte[]);
                        DataManager.Reports = pivotClient.DeserializedReports(reportString);
                        DataManager.SetCurrentReport(DataManager.Reports[0]);
                        return(pivotClient.GetJsonData("toolbarOperation", DataManager, "Load Report", reportName));
                    }
                    else
                    {
                        byte[] reportString = new byte[2 * 1024];
                        reportString = (row.ItemArray[1] as byte[]);
                        if (analysisMode.ToLower() == "pivot" && operationalMode.ToLower() == "servermode")
                        {
                            dictionary = pivotClient.GetJsonData("LoadReport", ProductSales.GetSalesData(), Encoding.UTF8.GetString(reportString));
                        }
                        else
                        {
                            dictionary.Add("report", Encoding.UTF8.GetString(reportString));
                        }

                        break;
                    }
                }
            }
            return(dictionary);
        }
Example #8
0
        public void TestIsotopeLabelPivot()
        {
            SrmDocument srmDocument = ResultsUtil.DeserializeDocument("silac_1_to_4.sky", GetType());

            using (Database database = new Database())
            {
                database.AddSrmDocument(srmDocument);
                PivotReport pivotReport = new PivotReport
                {
                    Columns = new[]
                    {
                        new ReportColumn(typeof(DbTransition), "Precursor", "Peptide",
                                         "Sequence"),
                        new ReportColumn(typeof(DbTransition), "Precursor", "Charge"),
                        new ReportColumn(typeof(DbTransition), "FragmentIon"),
                    },
                    GroupByColumns =
                        PivotType.ISOTOPE_LABEL.GetGroupByColumns(new[] { new ReportColumn(typeof(DbTransitionResult), "Id") }),
                    CrossTabHeaders = new[]
                    {
                        new ReportColumn(typeof(DbTransition), "Precursor", "IsotopeLabelType")
                    },
                    CrossTabValues = new[]
                    {
                        new ReportColumn(typeof(DbTransitionResult), "Area"),
                        new ReportColumn(typeof(DbTransitionResult), "Background")
                    }
                };
                ResultSet resultSet = pivotReport.Execute(database);
                Assert.AreEqual(7, resultSet.ColumnInfos.Count);
                // Assert that "light" appears earlier in the crosstab columns than "heavy".
                Assert.IsTrue(resultSet.ColumnInfos[3].Caption.ToLowerInvariant().StartsWith("light"));
                Assert.IsTrue(resultSet.ColumnInfos[4].Caption.ToLowerInvariant().StartsWith("light"));
                Assert.IsTrue(resultSet.ColumnInfos[5].Caption.ToLowerInvariant().StartsWith("heavy"));
                Assert.IsTrue(resultSet.ColumnInfos[6].Caption.ToLowerInvariant().StartsWith("heavy"));
                // TODO(nicksh): write asserts that the rows contain correct data.
            }
        }
        private PivotReport BindDefaultData()
        {
            PivotReport pivotSetting = new PivotReport();

            pivotSetting.PivotRows.Add(new PivotItem {
                FieldMappingName = "Date", FieldHeader = "Date", TotalHeader = "Total"
            });
            pivotSetting.PivotRows.Add(new PivotItem {
                FieldMappingName = "State", FieldHeader = "State", TotalHeader = "Total"
            });
            pivotSetting.PivotColumns.Add(new PivotItem {
                FieldMappingName = "Product", FieldHeader = "Product", TotalHeader = "Total", ShowSubTotal = false
            });
            pivotSetting.PivotColumns.Add(new PivotItem {
                FieldMappingName = "Country", FieldHeader = "Country", TotalHeader = "Total", ShowSubTotal = false
            });
            pivotSetting.PivotCalculations.Add(new PivotComputationInfo {
                CalculationName = "Amount", Description = "Amount", FieldHeader = "Amount", FieldName = "Amount", Format = "C", SummaryType = Syncfusion.PivotAnalysis.Base.SummaryType.DoubleTotalSum
            });
            pivotSetting.PivotCalculations.Add(new PivotComputationInfo {
                CalculationName = "Quantity", Description = "Quantity", FieldHeader = "Quantity", FieldName = "Quantity", SummaryType = Syncfusion.PivotAnalysis.Base.SummaryType.DoubleTotalSum
            });
            return(pivotSetting);
        }
Example #10
0
 public void TestIsotopeLabelPivot()
 {
     SrmDocument srmDocument = ResultsUtil.DeserializeDocument("silac_1_to_4.sky", GetType());
     using (Database database = new Database())
     {
         database.AddSrmDocument(srmDocument);
         PivotReport pivotReport = new PivotReport
         {
             Columns = new[]
                         {
                             new ReportColumn(typeof(DbTransition), "Precursor", "Peptide",
                                            "Sequence"),
                             new ReportColumn(typeof(DbTransition), "Precursor", "Charge"),
                             new ReportColumn(typeof(DbTransition), "FragmentIon"),
                         },
             GroupByColumns =
                       PivotType.ISOTOPE_LABEL.GetGroupByColumns(new[] { new ReportColumn(typeof(DbTransitionResult), "Id") }),
             CrossTabHeaders = new[]
                                 {
                                     new ReportColumn(typeof(DbTransition), "Precursor", "IsotopeLabelType")
                                 },
             CrossTabValues = new[]
                                {
                                    new ReportColumn(typeof(DbTransitionResult), "Area"),
                                    new ReportColumn(typeof(DbTransitionResult), "Background")
                                }
         };
         ResultSet resultSet = pivotReport.Execute(database);
         Assert.AreEqual(7, resultSet.ColumnInfos.Count);
         // Assert that "light" appears earlier in the crosstab columns than "heavy".
         Assert.IsTrue(resultSet.ColumnInfos[3].Caption.ToLowerInvariant().StartsWith("light"));
         Assert.IsTrue(resultSet.ColumnInfos[4].Caption.ToLowerInvariant().StartsWith("light"));
         Assert.IsTrue(resultSet.ColumnInfos[5].Caption.ToLowerInvariant().StartsWith("heavy"));
         Assert.IsTrue(resultSet.ColumnInfos[6].Caption.ToLowerInvariant().StartsWith("heavy"));
         // TODO(nicksh): write asserts that the rows contain correct data.
     }
 }