public static void GenerateGraph(string file, DataTable dt, string graphbind, string name, string filepath, string format) { try { Chart chart = new Chart(); chart.Legends.Add("Legend1"); chart.Width = 700; chart.Height = 360; chart.ChartAreas.Add("ChartArea1"); chart.Palette = ChartColorPalette.SemiTransparent; chart.BackColor = System.Drawing.ColorTranslator.FromHtml("#3B414D"); chart.BackGradientStyle = GradientStyle.DiagonalLeft; chart.BorderlineColor = Color.DarkSalmon; //chart.gr.BackGradientEndColor = "White"; Color[] seriescolurs = new Color[] { System.Drawing.Color.MidnightBlue, //dashboard System.Drawing.Color.LightSeaGreen, //Landline System.Drawing.Color.Firebrick, //Tariff System.Drawing.Color.Goldenrod, //assert System.Drawing.Color.DarkSalmon, //bill val System.Drawing.Color.OrangeRed, //KPI System.Drawing.Color.Crimson, //Inventory System.Drawing.Color.Gold, //mobile System.Drawing.Color.DarkRed, System.Drawing.Color.Cyan, //Admin System.Drawing.Color.Tomato, //Trend System.Drawing.Color.MediumSeaGreen //Reporting }; string[] ax = graphbind.Split('#'); string xaxis = ax[0].Split('@')[0]; if (chart.Series.Count() >= 0) { chart.Series.Clear(); } bool Durationformat = false; Series ser; int i = 0; foreach (string s in ax[1].Split(',')) { if (s != string.Empty) { ser = new Series(); ser.Name = s.Split('@')[0]; ser.XValueMember = xaxis; ser.YValueMembers = s.Split('@')[0]; ser.YValueType = ChartValueType.Double; SetGraphtype(format, ser); ser.BorderWidth = 0; ser.BorderColor = Color.Gray; ser.Color = seriescolurs[i]; chart.Series.Add(ser); if (s.Split('@')[0].Contains("Duration")) { Durationformat = true; } i++; } } chart.Titles.Clear(); chart.Titles.Add(name); chart.ChartAreas["ChartArea1"].AxisY.Title = "Calls"; chart.BackColor = Color.Empty; chart.ChartAreas["ChartArea1"].BorderWidth = 0; chart.ChartAreas["ChartArea1"].BackColor = Color.Gray; chart.ChartAreas["ChartArea1"].ShadowColor = Color.Transparent; chart.ChartAreas["ChartArea1"].AxisX.Interval = 1; chart.ChartAreas["ChartArea1"].AxisX.LineColor = Color.Gray; chart.ChartAreas["ChartArea1"].AxisX.TitleFont = new Font("Century Gothic", 8.25f, FontStyle.Bold); chart.ChartAreas["ChartArea1"].AxisX.MajorGrid.LineColor = Color.Gray; chart.ChartAreas["ChartArea1"].AxisX.Title = xaxis; chart.ChartAreas["ChartArea1"].AxisX.LabelStyle.Angle = 45; chart.ChartAreas["ChartArea1"].AxisY.LineColor = Color.Gray; chart.ChartAreas["ChartArea1"].AxisY.TitleFont = new Font("Century Gothic", 8.25f, FontStyle.Bold); chart.ChartAreas["ChartArea1"].AxisY.MajorGrid.LineColor = Color.Gray; chart.ChartAreas["ChartArea1"].BackGradientStyle = GradientStyle.TopBottom; chart.ChartAreas["ChartArea1"].BackHatchStyle = ChartHatchStyle.None; chart.BorderSkin.BackColor = Color.LightSkyBlue; chart.BorderSkin.PageColor = Color.Transparent; chart.BorderSkin.SkinStyle = BorderSkinStyle.Emboss; if (Durationformat == false) { chart.DataSource = dt.AsEnumerable().Take(12); } else { DataTable dc = new DataTable(); dc.Columns.Add(xaxis); foreach (string s in ax[1].Split(',')) { dc.Columns.Add(s.Split('@')[0]); } var result = from db in dt.AsEnumerable() select new { Period = db.Field <string>("Period"), AvgRing = GenerateReports.GetDurationinsec(db.Field <string>("Avg Ring")), AvgCallDuration = GenerateReports.GetDurationinsec(db.Field <string>("Avg Call Duration")), AvgAbandonedTime = GenerateReports.GetDurationinsec(db.Field <string>("Avg Abandoned Time")), }; foreach (var v in result) { dc.Rows.Add(v.Period, v.AvgRing, v.AvgCallDuration, v.AvgAbandonedTime); } chart.DataSource = dc.AsEnumerable().Take(12); } chart.DataBind(); chart.SaveImage(file, ChartImageFormat.Png); } catch { } }
public static void send(string Email, List <string> report, int id, IEnumerable <int> reportid) { //create the email message MailMessage mmAutomatedMessage = new MailMessage(); //create a reply to address mmAutomatedMessage.ReplyTo = new MailAddress("*****@*****.**"); //set the priority of the mail message to high to make sure it goes out at quickest possible speed mmAutomatedMessage.Priority = MailPriority.High; //put a read receipt on each report. Can monitor who is looking at their reports mmAutomatedMessage.Headers.Add("Disposition-Notification-To", "*****@*****.**"); //create From address mmAutomatedMessage.From = new MailAddress("*****@*****.**"); //[email protected] 20190611 string sendEmailsFrom = "*****@*****.**"; string sendEmailsFromPassword = "******"; //string sendEmailsFrom = "*****@*****.**"; //string sendEmailsFromPassword = "******"; NetworkCredential cred = new NetworkCredential(sendEmailsFrom, sendEmailsFromPassword); mmAutomatedMessage.To.Add(Email); //create subject mmAutomatedMessage.Subject = "Pro Automated Report" + " - " + DbContext.tbl_Portfoilolinks.Where(s => s.Protfolio_ID == id).Select(s => s.Protfolio_Name ?? "").SingleOrDefault(); //create the plain text version of the email string strBodyText = @"Dear Customer, Please open all image attachments prior to the HTML report in order to cache the charts. Please find enclosed your automated report as requested: Many Thanks, Pro Team Sentel Indepedant Ltd 15 Mckibbin House Eastbank Road Carryduff Belfast BT8 8BD T: +44 (0)28 9081 5555 F: +44 (0)28 9081 1055 E: [email protected] Keep up to date on http://www.sentel.co.uk Follow us on twitter at http://twitter.com/Sentel_Ind Follow us on facebook at http://www.facebook.com/pages/Belfast/Sentel-Independent/249597243565"; //create the media type for the plain text string strMediaType = "text/plain"; //create an alternative view AlternateView avPlainText = AlternateView.CreateAlternateViewFromString(strBodyText, null, strMediaType); //create the html version of the email strBodyText = @"<font face ='verdana' size='3'><p>Dear <b><i>Customer</i></b>,</p> <p>Please find enclosed your automated report as requested:</p> <p>Many Thanks,</p> <p><b>Pro Team</b></p> <p>Sentel <br />15 McKibbin House <br />Eastbank Road <br />Carryduff <br />Belfast <br />BT8 8BD </p> <p><font face ='verdana' size='2'>T: +44 (0)28 9081 5555 <br />F: +44 (0)28 9081 1055 <br />E: [email protected] </font> </p></font> <font face ='verdana' size='1'> <p> <a href='http://www.sentel.co.uk'>www.Sentel.co.uk</a> <br /><img src='http://www.sentelcallmanagerpro.com//images//SentelLogo.png' alt='Sentel' title='Sentel' /> </p> <p> Follow Sentel on Twitter <br /><img src='http://www.sentelcallmanagerpro.com//images//twitter.png' alt='Twitter' title='Twitter' /> <br />Ask us a question or keep up to date with our latest business news and events using Twitter <br /><a href='http://twitter.com/Sentel_Ind'>Sentel on Twitter</a> </p> <p> Follow Sentel on Facebook <br /><img src='http://www.sentelcallmanagerpro.com//images//facebook.png' alt='Facebook' title='FaceBook' /> <br />Add us to get all the latest upgrade news and developments on our products using Facebook <br /><a href='http://www.facebook.com/pages/Belfast/Sentel-Independent/249597243565'>Sentel on Facebook</a> </p> </font>"; //create the media type for the html strMediaType = "text/html"; //create an alternative view AlternateView avHTML = AlternateView.CreateAlternateViewFromString(strBodyText, null, strMediaType); //add both views to the collection mmAutomatedMessage.AlternateViews.Add(avPlainText); mmAutomatedMessage.AlternateViews.Add(avHTML); //Attache the report/error log try { Attachment attach; for (int i = 0; i < report.Count(); i++) { attach = new Attachment(report[i]); mmAutomatedMessage.Attachments.Add(attach); } SmtpClient client = new SmtpClient(MailClient); client.Timeout = 40000; client.Credentials = cred; client.Send(mmAutomatedMessage); DbContext.tbl_PortfolioReports.Where(s => s.PortfolioReport_Email == Email).ToList().ForEach(s => s.PortfolioReport_Status = true); DbContext.SubmitChanges(); } catch { foreach (int v in reportid) { GenerateReports.ReportStatus(v, "ErrEmail"); } } //ProgressText.Append("Email sent to '" + Email + "'. Completed \r\n"); //tbProgress.Text = ProgressText.ToString(); ; }
public static void GeneratePDFDashboardData(DataSet tables, Schedule report, Document pdfDoc) { pdfDoc.Open(); Font link = FontFactory.GetFont("TIMES_ROMAN", 10, Font.BOLD, BaseColor.BLACK); Anchor click = new Anchor("Report Name:" + "-" + report.ReportName, link); click.Reference = "www.sentelsolutions.com"; Paragraph p1 = new Paragraph(); p1.Add(click); pdfDoc.Add(p1); //pdfDoc.Add(new iTextSharp.text.Paragraph("Report Name:" + "-" + report.ReportName, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 10, iTextSharp.text.Font.BOLD, BaseColor.BLACK))); pdfDoc.Add(new iTextSharp.text.Paragraph(" ")); pdfDoc.Add(new iTextSharp.text.Paragraph("Schedule Name:" + "-" + report.Selectedname, new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 9, iTextSharp.text.Font.BOLD, BaseColor.BLACK))); pdfDoc.Add(new iTextSharp.text.Paragraph(" ")); pdfDoc.Add(new iTextSharp.text.Paragraph("Date range:" + report.ListofFilters.Split('=', ',')[5].TrimStart('\'').TrimEnd('\'') + " TO " + report.ListofFilters.Split('=', ',')[7].TrimStart('\'').TrimEnd('\''), new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 9, iTextSharp.text.Font.BOLD, BaseColor.BLACK))); switch (report.ReportName) { case "Operator Performance": int repid = 0; List <iTextSharp.text.Image> ImgList = new List <Image>(); foreach (DataRow dr in tables.Tables[0].Rows) { GraphicalReport.GenerateCircularGauge("Z:\\inetpub\\wwwroot\\proimages\\" + report.Selectedname + "-" + report.ReportName + DateTime.Now.ToString("ddMMyy") + repid.ToString() + "-" + report.ID + ".png", Convert.ToDouble(dr["Target"]), Convert.ToDouble(dr["_Avg"]), Convert.ToDouble(dr["_Bad"]), Convert.ToDouble(dr["Ring"]), dr[0].ToString(), dr["_Back"].ToString()); ImgList.Add(iTextSharp.text.Image.GetInstance("Z:\\inetpub\\wwwroot\\proimages\\" + report.Selectedname + "-" + report.ReportName + DateTime.Now.ToString("ddMMyy") + repid.ToString() + "-" + report.ID + ".png")); repid++; } List <int> numbers = new List <int>(); for (int i = 3; i < ImgList.Count; i += 3) { numbers.Add(i); } numbers.Add(numbers.Last() + 3); for (int i = ImgList.Count(); i <= numbers.Last(); i++) { ImgList.Add(iTextSharp.text.Image.GetInstance("Z:\\inetpub\\wwwroot\\proimages\\EmptySpace.png")); } var table1 = new PdfPTable(3); //table1 table1.HorizontalAlignment = Element.ALIGN_MIDDLE; table1.SpacingBefore = 20; table1.DefaultCell.Border = 0; //table1.WidthPercentage = 20; foreach (Image img in ImgList) { PdfPCell cell = new PdfPCell(img); table1.AddCell(cell); } pdfDoc.Add(table1); PDFReports.BindPDFdataWithKPIIndication(pdfDoc, tables.Tables[0], tables.Tables[0].Columns.Cast <DataColumn>().Where(s => !s.ColumnName.Contains("_") && s.ColumnName != "DrillDown").Select(x => x.ColumnName).ToList(), GenerateReports.Listoftotals(report.Totals), "Ring", "_Back"); break; } pdfDoc.Close(); }
public static void Undoreport(Schedule report) { try { DateTime From = DateTime.Now, To = DateTime.Now; try { From = Convert.ToDateTime(report.ListofFilters.Split('=', ',')[5].TrimStart('\'').TrimEnd('\'')); To = Convert.ToDateTime(report.ListofFilters.Split('=', ',')[7].TrimStart('\'').TrimEnd('\'')); } catch { } string inter = ""; switch (report.Frequency) { case "hourly": if (Starttime != 17) { inter = report.ListofFilters.Replace(report.ListofFilters.Split('=', ',')[5], "'" + From.AddHours(1).ToString("yyyy-MM-dd HH:mm:ss") + "'"); report.ListofFilters = inter.Replace(report.ListofFilters.Split('=', ',')[7], "'" + To.AddHours(1).ToString("yyyy-MM-dd HH:mm:ss") + "'"); } else { inter = report.ListofFilters.Replace(report.ListofFilters.Split('=', ',')[5], "'" + From.AddHours(16).ToString("yyyy-MM-dd HH:mm:ss") + "'"); report.ListofFilters = inter.Replace(report.ListofFilters.Split('=', ',')[7], "'" + To.AddHours(16).ToString("yyyy-MM-dd HH:mm:ss") + "'"); } break; case "fixed": inter = report.ListofFilters.Replace(report.ListofFilters.Split('=', ',')[5], "'" + From.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss") + "'"); report.ListofFilters = inter.Replace(report.ListofFilters.Split('=', ',')[7], "'" + To.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss") + "'"); break; case "daily": inter = report.ListofFilters.Replace(report.ListofFilters.Split('=', ',')[5], "'" + From.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss") + "'"); report.ListofFilters = inter.Replace(report.ListofFilters.Split('=', ',')[7], "'" + To.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss") + "'"); break; case "weekly": inter = report.ListofFilters.Replace(report.ListofFilters.Split('=', ',')[5], "'" + From.AddDays(-7).ToString("yyyy-MM-dd HH:mm:ss") + "'"); report.ListofFilters = inter.Replace(report.ListofFilters.Split('=', ',')[7], "'" + To.AddDays(-7).ToString("yyyy-MM-dd HH:mm:ss") + "'"); break; case "monthly": inter = report.ListofFilters.Replace(report.ListofFilters.Split('=', ',')[5], "'" + From.AddMonths(-1).ToString("yyyy-MM-dd HH:mm:ss") + "'"); report.ListofFilters = inter.Replace(report.ListofFilters.Split('=', ',')[7], "'" + From.AddMonths(-2).AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss") + "'"); break; case "quaterly": inter = report.ListofFilters.Replace(report.ListofFilters.Split('=', ',')[5], "'" + From.AddMonths(-3).ToString("yyyy-MM-dd HH:mm:ss") + "'"); report.ListofFilters = inter.Replace(report.ListofFilters.Split('=', ',')[7], "'" + From.AddMonths(-3).AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss") + "'"); report.CreatedDate = report.CreatedDate.AddMonths(3); break; case "yearly": inter = report.ListofFilters.Replace(report.ListofFilters.Split('=', ',')[5], "'" + From.AddYears(-1).ToString("yyyy-MM-dd HH:mm:ss") + "'"); report.ListofFilters = inter.Replace(report.ListofFilters.Split('=', ',')[7], "'" + To.AddYears(-1).ToString("yyyy-MM-dd HH:mm:ss") + "'"); break; } // Need an update statement here..... var rep = DbContext.tbl_automatedreports.Where(s => s.schedule_id_PK == report.ID).SingleOrDefault(); rep.schedule_filters = report.ListofFilters; rep.schedule_createddate = report.CreatedDate; DbContext.SubmitChanges(); } catch { GenerateReports.ReportStatus(report.ID, "Erro Updating Report"); } }