protected virtual PrintVM GetPrintVMFromReader(IDataReader reader) { EntityConverter <PrintVM> printVMEntity = new EntityConverter <PrintVM>(); PrintVM printVM = printVMEntity.Convert(reader); return(printVM); }
public ActionResult ReportCounter(string BillNo) { int BillNum = Convert.ToInt32(BillNo); var acc = db.Account.Find(BillNum); var cus = (from s in db.ServiceAssign from c in db.Customer from n in db.Service where s.NewspaperId == n.Id && s.CustomerId == c.Id && s.NewspaperId == acc.NewspaperId && s.CustomerId == acc.CustomerId select new { Customer = c, ServiceAssign = s, NewsPaper = n }).ToList().FirstOrDefault(); int billno = Convert.ToInt32(BillNum); Account objaccount = db.Account.FirstOrDefault(m => m.Id == billno); PrintVM objPrint = new PrintVM(); objPrint.Address = cus.Customer.Address; objPrint.Amount = cus.ServiceAssign.Amount; objPrint.AmountWord = NumToWords(/*cus.ServiceAssign.Quantity**/ (cus.ServiceAssign.Amount) - cus.ServiceAssign.DiscountAmount) + " मात्र"; objPrint.BankAcc = objaccount.BankAcc; objPrint.BankName = objaccount.BankName; objPrint.CustomerId = objaccount.CustomerId.ToString(); objPrint.CustomerName = cus.Customer.FirstName; objPrint.DiscountAmount = cus.ServiceAssign.DiscountAmount; objPrint.fiscalyear = acc.fiscalyear.NepYear; objPrint.EndedDate = cus.ServiceAssign.EndedDate.ToShortDateString(); objPrint.GrandTotal = objaccount.Amount; objPrint.NepaliDate = cus.ServiceAssign.NepaliDate; objPrint.NewspaperName = cus.NewsPaper.NewsPaperName; objPrint.Phone = cus.Customer.MPhone; objPrint.Quantity = cus.ServiceAssign.Quantity; objPrint.Remarks = ""; objPrint.StartDate = cus.ServiceAssign.PaperDispatchDate.ToShortDateString(); objPrint.Subject = ""; objPrint.BillNo = objaccount.BillNo.ToString(); return(View(objPrint)); }
public async Task <string> GetPrintDetailsByPrintTypeId(int printTypeId, string referenceId) { string ReturnValue = "0"; string htmlTemplate = ""; DBContext dBContext = new DBContext(); string connectionString = dBContext.GetConnectionString(); int purchaseOrderPrintTypeId = 1; var root = @"E:\DocumentPrint\"; PrintVM printVM = new PrintVM(); try { using (var sqlConnection = new SqlConnection(connectionString)) { var dynamicParameterlist = new DynamicParameters(); dynamicParameterlist.Add("@PrintTypeId", printTypeId); dynamicParameterlist.Add("@ReferenceId", referenceId); printVM = await sqlConnection.QuerySingleOrDefaultAsync <PrintVM>("pnt.AddPrintDetails", dynamicParameterlist, commandType : CommandType.StoredProcedure); } if (!Directory.Exists(root)) { Directory.CreateDirectory(root); } CustomAssemblyLoadContext context = new CustomAssemblyLoadContext(); var path = @"C:\Repos\Onimta\DevApi\OnimtaPrint\libwkhtmltox.dll"; var path1 = @"G:\Onimta\OnimtaDevApi\OnimtaPrint\libwkhtmltox.dll"; context.LoadUnmanagedLibrary(path); var pdfId = referenceId; string location = @"E:\DocumentPrint\" + pdfId + " Purchase Order Document.pdf"; if (printTypeId == purchaseOrderPrintTypeId) { htmlTemplate = PurchaseOrderTemplate.GetPurchaseOrderHTMLString(referenceId); } var objectSettings = new ObjectSettings { PagesCount = true, HtmlContent = htmlTemplate, WebSettings = { DefaultEncoding = "utf-8", UserStyleSheet = Path.Combine(Directory.GetCurrentDirectory(), "assets", "styles.css") }, HeaderSettings = { FontName = "Arial", FontSize = 9, Right = "Page [page] of [toPage]", Line = true }, FooterSettings = { FontName = "Arial", FontSize = 9, Line = true, Center = "Report Footer" } }; var globalSettings = new GlobalSettings { ColorMode = ColorMode.Color, Orientation = Orientation.Portrait, PaperSize = PaperKind.A4, Margins = new MarginSettings { Top = 10 }, DocumentTitle = "PDF Report", Out = location }; var pdf = new HtmlToPdfDocument() { GlobalSettings = globalSettings, Objects = { objectSettings } }; _converter.Convert(pdf); string a = @"F:\print\A.Pdf"; var response = new HttpResponseMessage(); response.Content = new StringContent("fg r fg fgf fg gf"); response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html"); var printJob = new Process { StartInfo = new ProcessStartInfo { FileName = a, UseShellExecute = true, Verb = "print", CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden, WorkingDirectory = Path.GetDirectoryName(a) } }; printJob.Start(); ReturnValue = "1"; } catch (Exception ex) { ReturnValue = ex.Message; } return(ReturnValue); }