public static List <NJ_CallLogs> PrintCallLog(string Search = "", string SearchByName = "") { NJ_CallLogs obj = new NJ_CallLogs(); var Result = obj.CallLogs(Search, SearchByName); return(Result); }
public static List <NJ_CallLogs> CallLog(string Search = "", int PageIndex = 0, string SearchByName = "") { NJ_CallLogs obj = new NJ_CallLogs(); var Result = obj.CallLogs(Search, SearchByName); //for paging int PageSize = 15; int skip = PageIndex * PageSize; double PageCount = Convert.ToDouble(Math.Ceiling((double)((double)Result.Count() / (double)PageSize))); List <NJ_CallLogs> query = Result.Skip(skip).Take(PageSize).ToList(); return(query); }
public static string EmailTodayCallLogs(string Search = "") { NJ_CallLogs obj = new NJ_CallLogs(); var Result = obj.CallLogs(Search); var doc = new Document(PageSize.A4, 50, 50, 5, 5); string PathStart = System.Web.HttpContext.Current.Server.MapPath("/CallLogsPDF"); if (!System.IO.Directory.Exists(PathStart)) { System.IO.Directory.CreateDirectory(PathStart); } string FolderNameByDate = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString(); PdfWriter.GetInstance(doc, new System.IO.FileStream(System.Web.HttpContext.Current.Server.MapPath("/CallLogsPDF/" + "/" + "CallLog" + FolderNameByDate + ".pdf"), System.IO.FileMode.Create)); string Filepath = System.Web.HttpContext.Current.Server.MapPath("/CallLogsPDF/" + "/" + "CallLog" + FolderNameByDate + ".pdf"); doc.SetPageSize(iTextSharp.text.PageSize.A4.Rotate()); doc.Open(); string row = ""; foreach (var item in Result) { row = row + @"<tr> <td align='center' style="" font-size: 11px;"" colspan=""2""> " + item.FirstName + @" </td> <td align='center' style="" font-size: 11px;"" colspan=""2""> " + item.LastName + @" </td> <td align='center' style="" font-size: 11px;"" colspan=""2""> " + item.Phone + @" </td> <td align='center' style="" font-size: 11px;"" colspan=""2""> " + item.Notes + @"</td> <td align='center' style="" font-size: 11px;"" colspan=""2""> " + item.AddedName + @"</td> <td align='center' style="" font-size:11px;"" colspan=""2""> " + item.Users + @"</td> </tr>"; } string footer = @"</tbody> </table > <table style='width:100%;'> <thead> </thead> <tbody> </table> </div> </body> <html>"; string htmlText = @"<html><title></title> <p> <table style='width:100%;'> <thead> </thead> <tbody> <tr><td>.</td></tr> <tr> <td style=""font-weight:bold"" colspan=""4""align='center'>Call Log Report of " + DateTime.Now.ToShortDateString() + @"</td> </tr> <tr > <td colspan=""4"">.</td> </tr> </tbody> </table> <head> </head> <body> <p> <div><table border=""1"" style='width:100%;'> <thead> </thead> <tbody> <tr > <td align='center' colspan=""2"" style=""font-weight:bold; font-size: 11px;""> FirstName</td> <td align='center' colspan=""2"" style=""font-weight:bold; font-size: 11px;""> LastName</td> <td align='center' colspan=""2"" style=""font-weight:bold; font-size: 11px;"">Phone</td> <td align='center' colspan=""2"" style=""font-weight:bold; font-size:11px;"">Notes</td> <td align='center' colspan=""2"" style=""font-weight:bold; font-size: 11px;"">AddedBy</td> <td align='center' colspan=""2"" style=""font-weight:bold; font-size: 11px;"">Mail Sent To</td> </tr>" + row + footer; iTextSharp.text.html.simpleparser.HTMLWorker hw = new iTextSharp.text.html.simpleparser.HTMLWorker(doc); hw.Parse(new System.IO.StringReader(htmlText)); doc.Close(); CallLogs objCalllog = new CallLogs(); string Emailresult = objCalllog.SendCalllogsEmail(Filepath); // string Emailresult = objCalllog.SendEmail(Filepath); return(Emailresult); }