示例#1
0
        public ActionResult Header(string id)
        {
            var connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

            string sql = String.Format(@"SELECT * FROM tblLevo2Reports WHERE jsonId='{0}'", id);
            //  Get a json-object associated with an ID passed via URL
            string finalResult_str = string.Empty;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Connection.Open();

                SqlDataReader dt = cmd.ExecuteReader();
                if (dt.HasRows)
                {
                    while (dt.Read())
                    {
                        finalResult_str = dt.GetString(1);
                    }
                }
            }

            rgi_cl = Newtonsoft.Json.JsonConvert.DeserializeObject <ReportGeneratorInfo>(finalResult_str);

            //Console.WriteLine(rgi_cl);

            Header certainReportHeader = new Header();

            PopulateHeaderForCertainReport(certainReportHeader);
            report.header_cl = certainReportHeader;
            Console.WriteLine(report);
            return(View("PartialHeader", report));
        }
示例#2
0
        void GenerateCertainReport(string id)
        {
            //  to get the stored procedure parameters
            var connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

            string sql = String.Format(@"SELECT * FROM tblLevo2Reports WHERE jsonId='{0}'", id);
            //  Get a json-object associated with an ID passed via URL
            string finalResult_str = string.Empty;

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Connection.Open();

                SqlDataReader dt = cmd.ExecuteReader();
                if (dt.HasRows)
                {
                    while (dt.Read())
                    {
                        finalResult_str = dt.GetString(1);
                    }
                }
            }

            Console.WriteLine(finalResult_str);

            //  Check if what was sent is a report of stored procedure parameter
            //  dont forget to add parameters

            if (finalResult_str.Contains("iri_list") && finalResult_str.Contains("rp_cl"))
            {
                //  since we can have several
                rgi_cl = JsonConvert.DeserializeObject <ReportGeneratorInfo>(finalResult_str);

                //  save report name and its page size for rotativa for later
                TempData.Put("rotativaReportSizeType_str", rgi_cl.rp_cl.rotativaReportSizeType_str.ToString());
                TempData.Put("rotativaReportName_str", rgi_cl.rp_cl.rotativaReportName_str);
                TempData.Put("rotativaReportPageOrientation_str", rgi_cl.rp_cl.rotativaReportPageOrientation_str);
                TempData.Put("footerHotelName_str", rgi_cl.rp_cl.footerHotelName_str);



                //  there's only one header
                headerDisplayedOnEachPage_bool = rgi_cl.rp_cl.headerDisplayedOnEachPage_bool;

                Header reportHeader = new Header();

                PopulateHeaderForCertainReport(reportHeader);
                ViewBag.ReportType = "Combined report";
                report.header_cl   = reportHeader;



                List <IndividualTable> tables_list = new List <IndividualTable>();

                foreach (IndividualReportInfo iri_cl in rgi_cl.iri_list)
                {
                    IndividualTable reportTable = new IndividualTable();

                    TableValues tv_cl = new TableValues();

                    //  save stuff for splitting the table
                    tv_cl.splitTableInSeveral_bool = iri_cl.shouldSplitTableIntoSeveral_bool;
                    if (tv_cl.splitTableInSeveral_bool == true)
                    {
                        tv_cl.whenSplitWhichHeadersAreStatic_list = iri_cl.staticHeaders_list;
                    }

                    //  save stuff for the summary
                    tv_cl.summaryExists_bool = iri_cl.summaryExists_bool;
                    if (tv_cl.summaryExists_bool == true)
                    {
                        if (iri_cl.summaryName_str != null)
                        {
                            tv_cl.summaryName_str = iri_cl.summaryName_str;
                        }
                        tv_cl.summaryValueHeaders_list = iri_cl.headersNotMentionedInSummaryIfExists_list;
                    }

                    PopulateTableCertainReport(reportTable, iri_cl.storedProcedureName_str, iri_cl.storedProcedureParameters_dict, tv_cl, iri_cl.tableName_str);

                    tables_list.Add(reportTable);
                    report.listOfTables_list = tables_list;


                    //  summary + split
                    //CheckingForSummaryAndSplitting();
                }
                //ViewBag.reportGot = JsonConvert.SerializeObject(report);
            }
            else if (finalResult_str.Contains("header_cl") && finalResult_str.Contains("listOfTables_list") && finalResult_str.Contains("rp_cl"))
            {
                report = JsonConvert.DeserializeObject <Report>(finalResult_str);

                TempData.Put("rotativaReportSizeType_str", report.rp_cl.rotativaReportSizeType_str.ToString());
                TempData.Put("rotativaReportName_str", report.rp_cl.rotativaReportName_str);
                TempData.Put("rotativaReportPageOrientation_str", report.rp_cl.rotativaReportPageOrientation_str);
                TempData.Put("footerHotelName_str", report.rp_cl.footerHotelName_str);



                //  there's only one header
                headerDisplayedOnEachPage_bool = report.rp_cl.headerDisplayedOnEachPage_bool;
            }
            //  check all this stuff for all Individual tables at once
            CheckingForSummaryAndSplitting();
        }