// this method will get list of second headers for a report
        public static List <KPI> Getsecondtotals_ForReport(string name, string section)
        {
            IEnumerable <tbl_ReportTotal> reptotals = DbContext.tbl_ReportTotals.Where(s => s.Report_Name == name & s.Report_Type == section);

            List <KPI> KPi = new List <KPI>();

            foreach (tbl_ReportTotal t1 in reptotals)
            {
                foreach (string individual in t1.Report_SubTotals.ToString().Split('-'))
                {
                    KPI      c1        = new KPI();
                    string[] seperator = individual.Split('@', '#');
                    c1.KpiName      = seperator[0];
                    c1.KPiOperation = seperator[1];
                    c1.Columnnames  = seperator[2];
                    KPi.Add(c1);
                }
            }
            return(KPi);
        }
Пример #2
0
        // This method will create HTML file and inserts into portfolio reports.....
        public static void GenerateHTMLReport(Schedule report)
        {
            // Getting report data
            DataSet tables = ExtecuteReport(report);

            if (tables.Tables[0].Rows.Count >= 1 || report.StoredProcedureName.Contains("spSelectDepartmentalBreakdownreportLevel"))
            {
                TextWriter twWriter = new StreamWriter("c:\\temp\\" + report.Selectedname + "-" + report.ReportName + DateTime.Now.ToString("ddMMyy") + "-" + report.ID + ".html");
                string[]   filt     = report.ListofFilters.Split('=', ',');

                try
                {
                    twWriter.Write("<meta http-equiv='Content-Type' content='text/html'; charset='utf-8'>");
                    twWriter.Write("<script language='javascript' type='text/javascript' src='https://www.sentelsolutions.com/Scripts/jquery-1.4.2.min.js'></script>");
                    twWriter.Write("<link href='https://www.sentelsolutions.com/bootstrap/css/bootstrap.css' rel='stylesheet' />");
                    twWriter.Write("<script src='https://www.sentelsolutions.com/bootstrap/Scripts/bootstrap.min.js'></script>");
                    if (Otherreports(report.ReportingSection) == false)
                    {
                        twWriter.Write("</br>");
                        twWriter.Write("</br>");
                        twWriter.Write("<CENTER><h1>" + report.ReportName + "</h1></CENTER>");
                        twWriter.Write("</br>");
                        twWriter.Write("</br>");
                        twWriter.Write("<b>Schedule Name: " + " " + report.Selectedname + "</b>");
                        twWriter.Write("</br>");
                        twWriter.Write("</br>");
                        twWriter.Write("<b>Date range: " + " " + report.ListofFilters.Split('=', ',')[5].TrimStart('\'').TrimEnd('\'') + " TO " + report.ListofFilters.Split('=', ',')[7].TrimStart('\'').TrimEnd('\'') + "</b>");//"+ Fromdate.ToString()+" - " Todate.ToString()+"</b>");
                        twWriter.Write("</br>");
                        twWriter.Write("</br>");

                        twWriter.Write("<div id='Linearcalllist' runat='server' style='border: 1px solid black;overflow: auto;'>");
                        if (report.StoredProcedureName.Contains("spSelectDepartmentalBreakdownreportLevel"))
                        {   // The level is hardcodeed for debug ....
                            //twWriter.Write(HTMLReports.Departmentalreport(tables, GetColumns(report.Columns),"4"));
                            HTMLReports.Departmentalreport(twWriter, tables, GetColumns(report.Columns), report.ListofFilters.Split('=', ',')[93], GetLevels(tables), Listoftotals(report.Totals));
                        }
                        else
                        {
                            if (tables.Tables.Count >= 3)
                            {
                                int i = 0;
                                foreach (DataTable dt in tables.Tables)
                                {
                                    List <string> columns = new List <string>();
                                    foreach (DataColumn ds in dt.Columns)
                                    {
                                        columns.Add(ds.ColumnName);
                                    }
                                    twWriter.Write("<b>" + report.Columns.Split(',')[i] + "</b>");
                                    twWriter.Write(HTMLReports.BindHTMLdata(dt, columns, Listoftotals(report.Totals)));
                                    twWriter.Write("</br>");
                                    i++;
                                }
                            }
                            else
                            {
                                twWriter.Write(HTMLReports.BindHTMLdata(tables.Tables[0], GetColumns(report.Columns), Listoftotals(report.Totals)));
                            }
                        }
                        twWriter.Write("</div>");
                        if (report.GraphBindings != string.Empty)
                        {
                            int repid = 0;
                            foreach (string graph in report.GraphBindings.Split('-'))
                            {
                                GraphicalReport.GenerateGraph("Z:\\inetpub\\wwwroot\\proimages\\" + report.Selectedname + "-" + report.ReportName + DateTime.Now.ToString("ddMMyy") + repid.ToString() + "-" + report.ID + ".png", tables.Tables[0], graph, report.ReportName, report.Selectedname + "-" + report.ReportName + DateTime.Now.ToString("ddMMyy") + repid.ToString() + "-" + report.ID + ".png", report.GraphType);
                                twWriter.WriteLine("<div align='center'><img runat='server' width ='900px'  src='http://www.dev.sentelcallmanagerpro.com//images/" + report.Selectedname + "-" + report.ReportName + DateTime.Now.ToString("ddMMyy") + repid.ToString() + "-" + report.ID + ".png" + "'/></div>");
                                repid++;
                            }
                        }
                    }
                    else
                    {
                        switch (report.ReportingSection)
                        {
                            #region "KPI"
                        case "Kpi":
                            twWriter.Write("</br>");
                            twWriter.Write("</br>");
                            twWriter.Write("<CENTER><h1>" + report.ReportName + "</h1></CENTER>");
                            twWriter.Write("</br>");
                            twWriter.Write("</br>");
                            twWriter.Write("<b>Schedule Name: " + " " + report.Selectedname + "</b>");
                            twWriter.Write("</br>");
                            twWriter.Write("</br>");
                            twWriter.Write("<b>Date range: " + " " + report.ListofFilters.Split('=', ',')[5].TrimStart('\'').TrimEnd('\'') + " TO " + report.ListofFilters.Split('=', ',')[7].TrimStart('\'').TrimEnd('\'') + "</b>");    //"+ Fromdate.ToString()+" - " Todate.ToString()+"</b>");
                            twWriter.Write("</br>");
                            twWriter.Write("</br>");
                            // Header
                            twWriter.Write(Header.Createheader(tables, report.ReportName, "Kpi"));
                            //Sub headers...( this step is stopped for this release .....)
                            // twWriter.Write(Header.Secondheader(tables, report.ReportName, "Kpi"));

                            //Table body
                            twWriter.Write(HTMLReports.BindHTMLdata(tables.Tables[0], GetColumns(report.Columns), Listoftotals(report.Totals)));
                            // Performance Analysis
                            twWriter.Write(KPI.GenerateKPIReport(tables, report.ReportName, report.UserId));
                            // Graph
                            List <GraphHeaders> Grphe = Datamethods.GetGraphHeadernames(report.GraphHeaders);
                            if (Grphe.Count == 0)
                            {
                                int repid = 0;
                                foreach (string graph in report.GraphBindings.Split('-'))
                                {
                                    GraphicalReport.GenerateGraph("Z:\\inetpub\\wwwroot\\proimages\\" + report.Selectedname + "-" + report.ReportName + DateTime.Now.ToString("ddMMyy") + repid.ToString() + "-" + report.ID + ".png", tables.Tables[0], graph, report.ReportName, report.Selectedname + "-" + report.ReportName + DateTime.Now.ToString("ddMMyy") + repid.ToString() + "-" + report.ID + ".png", report.GraphType);
                                    twWriter.WriteLine("<div align='center'><img runat='server' width ='900px'  src='http://www.dev.sentelcallmanagerpro.com//images/" + report.Selectedname + "-" + report.ReportName + DateTime.Now.ToString("ddMMyy") + repid.ToString() + "-" + report.ID + ".png" + "'/></div>");
                                    repid++;
                                }
                            }
                            else
                            {
                                int repid = 0;
                                foreach (string graph in report.GraphBindings.Split('-'))
                                {
                                    foreach (GraphHeaders gr in Grphe)
                                    {
                                        if (graph.Contains(gr.ColumnName))
                                        {
                                            for (int i = 0; i < tables.Tables.Count; i++)
                                            {
                                                if (tables.Tables[i].Columns.Contains(gr.ColumnName))
                                                {
                                                    twWriter.WriteLine("<b>" + gr.Headername + "<b>");
                                                    GraphicalReport.GenerateGraph("Z:\\inetpub\\wwwroot\\proimages\\" + report.Selectedname + "-" + report.ReportName + DateTime.Now.ToString("ddMMyy") + repid.ToString() + "-" + report.ID + ".png", tables.Tables[i], graph, report.ReportName, report.Selectedname + "-" + report.ReportName + DateTime.Now.ToString("ddMMyy") + repid.ToString() + "-" + report.ID + ".png", report.GraphType);
                                                    twWriter.WriteLine("<div align='center'><img runat='server' width ='900px'  src='http://www.dev.sentelcallmanagerpro.com//images/" + report.Selectedname + "-" + report.ReportName + DateTime.Now.ToString("ddMMyy") + repid.ToString() + "-" + report.ID + ".png" + "'/></div>");
                                                }
                                            }
                                        }
                                        repid++;
                                    }
                                }
                            }
                            break;

                            #endregion
                            #region "Dashboard"
                        case "Dashboar":
                            twWriter.Write("</br>");
                            twWriter.Write("</br>");
                            twWriter.Write("<CENTER><h1>" + report.ReportName + "</h1></CENTER>");
                            twWriter.Write("</br>");
                            twWriter.Write("</br>");
                            twWriter.Write("<b>Schedule Name: " + " " + report.Selectedname + "</b>");
                            twWriter.Write("</br>");
                            twWriter.Write("</br>");
                            twWriter.Write("<b>Date range: " + " " + report.ListofFilters.Split('=', ',')[5].TrimStart('\'').TrimEnd('\'') + " TO " + report.ListofFilters.Split('=', ',')[7].TrimStart('\'').TrimEnd('\'') + "</b>");    //"+ Fromdate.ToString()+" - " Todate.ToString()+"</b>");
                            twWriter.Write("</br>");
                            twWriter.Write("</br>");
                            // Tables operation.......
                            tables = Tableoperations.Combinetables(tables, report.ReportName, "Dashboar");
                            // Header
                            twWriter.Write(Header.Createheader(tables, report.ReportName, "Dashboar"));
                            //
                            if (report.Columns.Length > 5)
                            {
                                twWriter.Write(HTMLReports.BindHTMLdata(tables.Tables[0], GetColumns(report.Columns), Listoftotals(report.Totals)));
                            }
                            List <GraphHeaders> Grphead = Datamethods.GetGraphHeadernames(report.GraphHeaders);
                            // Graph
                            if (report.GraphBindings != string.Empty)
                            {
                                int repid = 0;
                                foreach (string graph in report.GraphBindings.Split('-'))
                                {
                                    foreach (GraphHeaders gr in Grphead)
                                    {
                                        if (graph.Contains(gr.ColumnName))
                                        {
                                            for (int i = 0; i < tables.Tables.Count; i++)
                                            {
                                                if (tables.Tables[i].Columns.Contains(gr.ColumnName))
                                                {
                                                    string format = report.GraphType;
                                                    if (graph.Split(',').Count() > 2)
                                                    {
                                                        format = "Column";
                                                    }

                                                    twWriter.WriteLine("<b>" + gr.Headername + "<b>");
                                                    GraphicalReport.GenerateGraph("Z:\\inetpub\\wwwroot\\proimages\\" + report.Selectedname + "-" + report.ReportName + DateTime.Now.ToString("ddMMyy") + repid.ToString() + "-" + report.ID + ".png", tables.Tables[i], graph, report.ReportName, report.Selectedname + "-" + report.ReportName + DateTime.Now.ToString("ddMMyy") + repid.ToString() + "-" + report.ID + ".png", format);
                                                    twWriter.WriteLine("<div align='center'><img runat='server' width ='900px'  src='http://www.dev.sentelcallmanagerpro.com//images/" + report.Selectedname + "-" + report.ReportName + DateTime.Now.ToString("ddMMyy") + repid.ToString() + "-" + report.ID + ".png" + "'/></div>");
                                                }
                                            }
                                        }
                                        repid++;
                                    }
                                }
                            }

                            break;

                            #endregion
                            #region "Invoice"
                        case "Invoice":

                            // Generate Header

                            twWriter.Write(Invoice.GenerateUCDInvoiceHeader(tables, report));
                            // Generate Tables
                            twWriter.Write("<div id='Linearcalllist' runat='server' style='border: 1px solid black;overflow: auto;'>");
                            twWriter.Write(Invoice.GenerateUCDInvoiceReport(tables, report, Listoftotals(report.Totals)));
                            twWriter.Write("</div>");
                            break;
                            #endregion
                        }
                    }


                    SendEmail.InsertPortfoliodetails("c:\\temp\\" + report.Selectedname + "-" + report.ReportName + DateTime.Now.ToString("ddMMyy") + "-" + report.ID + ".html", report.EmailAddresses, report.Portfolioreportid, report.ID);
                }
                catch { ReportStatus(report.ID, "ERROR"); }

                finally { twWriter.Close(); }
            }
            else
            {
                // will send service team no data availabe message
                ReportStatus(report.ID, "No Data");
            }
        }