Exemplo n.º 1
0
        public void CartDWPdfGenerationforEmail(int cartDWID)
        {
            // Render the view html to a string.
            _shoppingCartSrv.UserVM = UserVM;
            CartDWPdfModel orderVM  = _shoppingCartSrv.GetQuotePdfDetails(cartDWID);
            string         htmlText = (this._htmlViewRenderer.RenderViewToString(this, "../TCPViews/DWCartPdfGenerationWithHTML", orderVM));
            Document       document = new Document(PageSize.A4, 40f, 30f, 20f, 30f);
            string         fname    = cartDWID + ".pdf";

            PdfWriter.GetInstance(document, new FileStream(ConfigurationManager.AppSettings["PdfPath"] + fname, FileMode.Create));
            document.Open();
            iTextSharp.text.Image pdfImage = iTextSharp.text.Image.GetInstance(Server.MapPath("~/Images/PenWorthyLogo.jpg"));
            pdfImage.ScaleToFit(150, 70);
            pdfImage.Alignment = iTextSharp.text.Image.UNDERLYING; pdfImage.SetAbsolutePosition(200, 600);
            document.Add(pdfImage);
            HTMLWorker hw = new HTMLWorker(document);

            hw.Parse(new StringReader(htmlText));
            document.Close();
            Response.ClearContent();
            Response.ClearHeaders();
            Response.AddHeader("Content-Disposition", "inline;filename=" + fname);
            Response.ContentType = "application/pdf";
            Response.WriteFile(ConfigurationManager.AppSettings["PdfPath"] + fname);
            Response.Flush();
            Response.Clear();
            string        toEmail  = UserVM != null ? UserVM.CRMModelProperties.CustEmail : string.Empty;
            List <string> FilePath = Directory.GetFiles(ConfigurationManager.AppSettings["PdfPath"], fname).ToList();

            _emailservice.SendMail("Pdf Attachment", "Thank you for your Order", true, true, FilePath, null, null, toEmail, null, cartDWID);
            // _emailservice.SendTestMail("Pdf Attachment", "Thank you for your Order", true, true, null, null, null, toEmail, null, cartDWID, null, 0, null);
            Response.End();
        }
Exemplo n.º 2
0
        public ActionResult CartDWPdfGeneration(int cartDWID)
        {
            var pdf = new RazorPDF.PdfResult();

            _shoppingCartSrv.UserVM = UserVM;
            CartDWPdfModel orderVM = _shoppingCartSrv.GetQuotePdfDetails(cartDWID);

            pdf = new RazorPDF.PdfResult(orderVM, "../TCPViews/DWCartPdfGeneration");
            pdf.ViewBag.Title = "Attachment";
            //CartDWPdfGenerationforEmail(cartDWID);
            return(pdf);
        }
Exemplo n.º 3
0
        public CartDWPdfModel GetQuotePdfDetails(int quoteid)
        {
            CartDWPdfModel quotePdfVM = new CartDWPdfModel();
            Quote          quote      = _Context.Quote.GetSingle(e => e.QuoteID == quoteid);

            if (quote != null)
            {
                quotePdfVM.QuoteID = quoteid;
                quotePdfVM.IncludeCatalogStatus = quote.IncludeCatalogStatus != null ? (bool)quote.IncludeCatalogStatus : false;
                List <Item> lstItem       = quote.QuoteDetails.Select(e => e.Item).ToList();
                string      taxschuduleID = quote.User.Customer != null ? quote.User.Customer.TaxScheduleID : null;
                if (string.IsNullOrEmpty(taxschuduleID) || taxschuduleID == "NONTAX")
                {
                    quotePdfVM.SalesTax = 0;
                }
                else
                {
                    quotePdfVM.SalesTax = Convert.ToDecimal(_Context.TaxSchedule.GetSingle(e => e.TaxScheduleID == taxschuduleID).TaxRate);
                }

                string statusenumB = Convert.ToString((char)ItemStatusEnum.OnListButNotPreViewable);
                string statusenumD = Convert.ToString((char)ItemStatusEnum.OnListAndPreViewable);
                quotePdfVM.CartListView = quote.QuoteDetails.Where(e => e.Item.Status == statusenumB || e.Item.Status == statusenumD).Select(c => new CartViewModel
                {
                    Title         = c.Item.Title,
                    Author        = c.Item.Author == null ? "" : c.Item.Author.AuthorName,
                    ISBN          = c.Item.ISBN,
                    AR            = c.Item.ARLevel,
                    Lexile        = c.Item.Lexile,
                    ItemPrice     = (double)c.Item.Price,
                    ItemId        = c.Item.ItemID,
                    DwstatusID    = c.DWSelectionID.ToString(),
                    Quantity      = c.Quantity,
                    Series        = c.Item.SeriesAndCharacter1 == null ? "" : c.Item.SeriesAndCharacter1.SCText,
                    QuoteDetailID = c.QuoteDetailID,
                    AcRcLevelText = (c.Item.ARLevel != null && Convert.ToDouble(c.Item.ARLevel) > 0 ? "AR" : "") + (c.Item.ARLevel != null && c.Item.RCLevel != null && Convert.ToDouble(c.Item.ARLevel) > 0 && Convert.ToDouble(c.Item.RCLevel) > 0 ? "," : "") + (c.Item.RCLevel != null && Convert.ToDouble(c.Item.RCLevel) > 0 ? "RC" : ""),
                    Type          = string.Empty
                }).OrderBy(e => e.Title).ToList();

                if ((bool)quotePdfVM.IncludeCatalogStatus == true)
                {
                    List <FlatFileDetailModel> lstCatalogInfo = GetCatalogInfoData(UserVM.CRMModelProperties.CustAutoID, quoteid, "Cart");
                    quotePdfVM.CartListView.AddRange(lstCatalogInfo.Select(c => new CartViewModel
                    {
                        Title          = c.ItemNumber,
                        Author         = string.Empty,
                        ISBN           = string.Empty,
                        AR             = null,
                        Lexile         = string.Empty,
                        ItemId         = c.ItemCode,
                        Quantity       = c.Quantity,
                        ItemPrice      = c.ItemPrice,
                        Price          = c.Price,
                        IncludeCatalog = c.ItemNumber == "Special Bulk Charge" ? false : true,
                        Type           = "Catalog",
                    }).ToList());
                }

                quotePdfVM.QuoteTypeID     = Convert.ToInt32(quote.QuoteTypeID);
                quotePdfVM.RepoAddress     = new CRMModel();
                quotePdfVM.CustomerAddress = new AddressBaseModel();
                quotePdfVM.QuoteID         = quoteid;
                RepUser repoAddress = null;
                if (quote.User.Customer.CustomerRep != null)
                {
                    repoAddress = quote.User.Customer.CustomerRep.RepUser != null ? quote.User.Customer.CustomerRep.RepUser : null;
                }
                else
                {
                    repoAddress = _Context.RepUser.GetSingle(e => e.RepID == 302); //Default Rep
                }
                quotePdfVM.RepoAddress.RepName   = repoAddress.User != null ? repoAddress.User.FirstName + "  " + repoAddress.User.LastName : string.Empty;
                quotePdfVM.RepoAddress.RepEmail  = repoAddress.User != null ? repoAddress.User.Email : string.Empty;
                quotePdfVM.RepoAddress.Persphone = repoAddress != null ? repoAddress.PhoneCustomerService : string.Empty;
                quotePdfVM.PONo     = quote.QuoteSubmitSaveInfo != null ? quote.QuoteSubmitSaveInfo.PoNo : quote.POText;
                quotePdfVM.Comments = quote.QuoteSubmitSaveInfo != null ? quote.QuoteSubmitSaveInfo.QuoteSubmitComments : quote.Comments;
                CustomerAddress customeraddress = quote.User.Customer.CustomerAddress != null ? quote.User.Customer.CustomerAddress : null;
                quotePdfVM.CustomerAddress.CustomerName = quote.User != null ? quote.User.Customer != null ? quote.User.Customer.CustomerName : string.Empty : string.Empty;;
                quotePdfVM.CustomerAddress.CustomerNo   = customeraddress.Customer.CustomerNO != null ? customeraddress.Customer.CustomerNO : string.Empty;
                if (customeraddress != null)
                {
                    quotePdfVM.CustomerAddress.AddressLine1 = customeraddress.AddressLine1 != null ? customeraddress.AddressLine1 : string.Empty;
                    quotePdfVM.CustomerAddress.AddressLine2 = customeraddress.AddressLine2 != null ? customeraddress.AddressLine2 : string.Empty;
                    quotePdfVM.CustomerAddress.AddressLine3 = customeraddress.AddressLine3 != null ? customeraddress.AddressLine3 : string.Empty;
                    quotePdfVM.CustomerAddress.City         = customeraddress.City != null ? customeraddress.City : string.Empty;
                    quotePdfVM.CustomerAddress.CountryCode  = customeraddress.CountryCode != null ? customeraddress.CountryCode : string.Empty;
                    quotePdfVM.CustomerAddress.State        = customeraddress.State != null ? customeraddress.State : string.Empty;
                    quotePdfVM.CustomerAddress.TelephoneNo  = customeraddress.TelephoneNo != null ? customeraddress.TelephoneNo : string.Empty;
                    quotePdfVM.CustomerAddress.ZipCode      = customeraddress.ZipCode != null ? customeraddress.ZipCode : string.Empty;
                    quotePdfVM.CustomerAddress.CustomerName = customeraddress.Customer.CustomerName != null ? customeraddress.Customer.CustomerName : string.Empty;
                    quotePdfVM.CustomerAddress.CustomerNo   = customeraddress.Customer.CustomerNO != null ? customeraddress.Customer.CustomerNO : string.Empty;
                }
            }
            quotePdfVM.UserVM = UserVM;
            quotePdfVM.UserVM.CRMModelProperties.LoggedINCustomerUserID = quote.UserID;
            // quotePdfVM.UserVM.SCCount = quote.QuoteDetails.Sum(e => e.Quantity);

            return(quotePdfVM);
        }