public static ImageModel GenerateRunTimeImageBlobByComputerAccount(WhitmanEntepriseMasterVehicleInfo vehicle) { var imageModel = new ImageModel(); WebsitesScreenshot.WebsitesScreenshot _Obj = null; WebsitesScreenshot.WebsitesScreenshot _BottomObj = null; try { if (vehicle.DealerId != 18498) { _Obj = new WebsitesScreenshot.WebsitesScreenshot( System.Configuration.ConfigurationManager.AppSettings["WebScreenShotSerialKey"].ToString (CultureInfo.InvariantCulture)); _BottomObj = new WebsitesScreenshot.WebsitesScreenshot( System.Configuration.ConfigurationManager.AppSettings["WebScreenShotSerialKey"].ToString (CultureInfo.InvariantCulture)); //Dynamic FTP ACCOUNT WebsitesScreenshot.WebsitesScreenshot.Result _Result; WebsitesScreenshot.WebsitesScreenshot.Result _BottomResult; if (vehicle.DealerId == 113738 || vehicle.DealerId == 3738) { var firstImageString = ComputerAccountHelper.GenerateHtmlImageCodeForAudiByComputerAccount( vehicle); _Result = _Obj.CaptureHTML("<html><body>" + firstImageString + "</body></html>"); var secondImageString = ComputerAccountHelper.GenerateHtmlImageCodeForSecondBottomImage( vehicle); if (!String.IsNullOrEmpty(secondImageString)) { _BottomResult = _BottomObj.CaptureHTML("<html><body>" + secondImageString + "</body></html>"); } else { _BottomResult = _BottomObj.CaptureHTML("<html><body>" + firstImageString + "</body></html>"); } } else { var firstImageString = ComputerAccountHelper.GenerateHTMLImageCode( vehicle); _Result = _Obj.CaptureHTML("<html><body>" + firstImageString + "</body></html>"); var secondImageString = ComputerAccountHelper.GenerateHtmlImageCodeForSecondBottomImage( vehicle); if (!String.IsNullOrEmpty(secondImageString)) { _BottomResult = _BottomObj.CaptureHTML("<html><body>" + secondImageString + "</body></html>"); } else { _BottomResult = _BottomObj.CaptureHTML("<html><body>" + firstImageString + "</body></html>"); } } if (_Result == WebsitesScreenshot.WebsitesScreenshot.Result.Captured && _BottomResult == WebsitesScreenshot.WebsitesScreenshot.Result.Captured) { _Obj.ImageFormat = WebsitesScreenshot. WebsitesScreenshot.ImageFormats.JPG; _BottomObj.ImageFormat = WebsitesScreenshot. WebsitesScreenshot.ImageFormats.JPG; _Obj.DelaySeconds = 10; _BottomObj.DelaySeconds = 10; var _Image = _Obj.GetImage(); var _BottomImage = _BottomObj.GetImage(); var stream = new MemoryStream(); var bottomStream = new MemoryStream(); _Image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); _BottomImage.Save(bottomStream, System.Drawing.Imaging.ImageFormat.Jpeg); var bytes = stream.ToArray(); var bottombytes = bottomStream.ToArray(); imageModel.BottomImage = bottombytes; imageModel.TopImage = bytes; stream.Dispose(); stream.Close(); bottomStream.Dispose(); bottomStream.Close(); _Obj.Dispose(); _BottomObj.Dispose(); } } else { _BottomObj = new WebsitesScreenshot.WebsitesScreenshot( System.Configuration.ConfigurationManager.AppSettings["WebScreenShotSerialKey"].ToString (CultureInfo.InvariantCulture)); WebsitesScreenshot.WebsitesScreenshot.Result _BottomResult; _BottomResult = _BottomObj.CaptureHTML("<html><body>" + ComputerAccountHelper.GenerateHtmlImageCodeForSecondBottomImage( vehicle) + "</body></html>"); if (_BottomResult == WebsitesScreenshot.WebsitesScreenshot.Result.Captured) { _BottomObj.ImageFormat = WebsitesScreenshot. WebsitesScreenshot.ImageFormats.JPG; _BottomObj.DelaySeconds = 5; var _BottomImage = _BottomObj.GetImage(); var htmlToImageConverter = new HtmlToImage(); htmlToImageConverter.SerialNumber = ConfigurationManager.AppSettings["PDFSerialNumber"]; // set browser width htmlToImageConverter.BrowserWidth = 1200; // set HTML Load timeout htmlToImageConverter.HtmlLoadedTimeout = 5; // set whether the resulted image is transparent htmlToImageConverter.TransparentImage = false; System.Drawing.Image imageObject = null; string htmlCode = ComputerAccountHelper.GenerateHtmlImageCodeForCaliforniaBeemerByComputerAccount(vehicle); imageObject = htmlToImageConverter.ConvertHtmlToImage(htmlCode, null)[0]; var stream = new MemoryStream(); var bottomStream = new MemoryStream(); imageObject.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); _BottomImage.Save(bottomStream, System.Drawing.Imaging.ImageFormat.Jpeg); var bytes = stream.ToArray(); var bottombytes = bottomStream.ToArray(); imageModel.BottomImage = bottombytes; imageModel.TopImage = bytes; stream.Dispose(); stream.Close(); bottomStream.Dispose(); bottomStream.Close(); imageObject.Dispose(); _BottomObj.Dispose(); } } } catch (Exception ex) { imageModel.BottomImage = null; imageModel.TopImage = null; return(imageModel); } return(imageModel); }
public static ImageModel GenerateRunTimeImageBlob(VehicleInfo vehicle, City city, Template temp, bool hasPrice, string dealerTitle) { var imageModel = new ImageModel(); try { WebsitesScreenshot.WebsitesScreenshot _Obj; WebsitesScreenshot.WebsitesScreenshot _BottomObj; _Obj = new WebsitesScreenshot.WebsitesScreenshot( ConfigurationManager.AppSettings["WebScreenShotSerialKey"].ToString( CultureInfo.InvariantCulture)); _BottomObj = new WebsitesScreenshot.WebsitesScreenshot( ConfigurationManager.AppSettings["WebScreenShotSerialKey"].ToString( CultureInfo.InvariantCulture)); WebsitesScreenshot.WebsitesScreenshot.Result _Result; WebsitesScreenshot.WebsitesScreenshot.Result _BottomResult; string firstImageString = CommonHelper.GenerateHtmlImageCode(vehicle, temp.Outlook, temp.BackGround, temp.Insert, hasPrice, dealerTitle); _Result = _Obj.CaptureHTML("<html><body>" + firstImageString + "</body></html>"); string secondImageString = CommonHelper.GenerateHtmlImageCodeForSecondBottomImage(vehicle, temp.Outlook, temp.BackGround, temp.Insert, hasPrice, dealerTitle); if (!String.IsNullOrEmpty(secondImageString)) { _BottomResult = _BottomObj.CaptureHTML("<html><body>" + secondImageString + "</body></html>"); } else { _BottomResult = _BottomObj.CaptureHTML("<html><body>" + firstImageString + "</body></html>"); } if (_Result == WebsitesScreenshot.WebsitesScreenshot.Result.Captured && _BottomResult == WebsitesScreenshot.WebsitesScreenshot.Result.Captured) { _Obj.ImageFormat = WebsitesScreenshot.WebsitesScreenshot.ImageFormats.JPG; _BottomObj.ImageFormat = WebsitesScreenshot.WebsitesScreenshot.ImageFormats.JPG; _Obj.DelaySeconds = 7; _BottomObj.DelaySeconds = 7; Bitmap _Image = _Obj.GetImage(); Bitmap _BottomImage = _BottomObj.GetImage(); var stream = new MemoryStream(); var bottomStream = new MemoryStream(); _Image.Save(stream, ImageFormat.Jpeg); _BottomImage.Save(bottomStream, ImageFormat.Jpeg); byte[] bytes = stream.ToArray(); byte[] bottombytes = bottomStream.ToArray(); imageModel.BottomImage = bottombytes; imageModel.TopImage = bytes; stream.Dispose(); stream.Close(); stream.Close(); bottomStream.Close(); _Obj.Dispose(); _BottomObj.Dispose(); } } catch (Exception ex) { return(imageModel); } return(imageModel); }
public void PrintWebControl(Control ControlToPrint) { StringWriter stringWrite = new StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite); if (ControlToPrint is WebControl) { Unit w = new Unit(100, UnitType.Percentage); ((WebControl)ControlToPrint).Width = w; } Page pg = new Page(); pg.EnableEventValidation = false; HtmlForm frm = new HtmlForm(); pg.Controls.Add(frm); frm.Attributes.Add("runat", "server"); frm.Controls.Add(ControlToPrint); pg.DesignerInitialize(); pg.RenderControl(htmlWrite); string strHTML = stringWrite.ToString(); string wstawka = Server.MapPath("~").ToString(); string path = String.Format("{0}\\Images\\Rezerwacje\\{1}.gif", Server.MapPath("~"), Session["ZamowienieId"]); //korzystanie z biblioteki websiteScreenshote WebsitesScreenshot.WebsitesScreenshot _Obj = new WebsitesScreenshot.WebsitesScreenshot(); WebsitesScreenshot.WebsitesScreenshot.Result _Result = _Obj.CaptureHTML(htmlToImage(strHTML, zmianaAdresu(wstawka))); if (_Result == WebsitesScreenshot.WebsitesScreenshot.Result.Captured) { _Obj.ImageFormat = WebsitesScreenshot.WebsitesScreenshot.ImageFormats.GIF; _Obj.SaveImage(path); } _Obj.Dispose(); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(strHTML); Session[Cart.Ident] = null; HttpContext.Current.Response.Write("<script>window.print();</script>"); HttpContext.Current.Response.End(); Response.Redirect("~/ListaImprez.aspx"); }
public static ImageModel GenerateRunTimeImageBlobByComputerAccount(WhitmanEntepriseMasterVehicleInfo vehicle) { var imageModel = new ImageModel(); try { WebsitesScreenshot.WebsitesScreenshot bottomObj = null; if (vehicle.DealerId != 17716 && vehicle.DealerId != 14853) { var _Obj = new WebsitesScreenshot.WebsitesScreenshot( ConfigurationManager.AppSettings["WebScreenShotSerialKey"].ToString (CultureInfo.InvariantCulture)); bottomObj = new WebsitesScreenshot.WebsitesScreenshot( ConfigurationManager.AppSettings["WebScreenShotSerialKey"].ToString (CultureInfo.InvariantCulture)); WebsitesScreenshot.WebsitesScreenshot.Result result; WebsitesScreenshot.WebsitesScreenshot.Result bottomResult; if (vehicle.DealerId == 113738 || vehicle.DealerId == 3738) { var firstImageString = ComputerAccountHelper.GenerateHtmlImageCodeForAudiByComputerAccount( vehicle); result = _Obj.CaptureHTML("<html><body>" + firstImageString + "</body></html>"); var secondImageString = ComputerAccountHelper.GenerateHtmlImageCodeForSecondBottomImage( vehicle); if (!String.IsNullOrEmpty(secondImageString)) { bottomResult = bottomObj.CaptureHTML("<html><body>" + secondImageString + "</body></html>"); } else { bottomResult = bottomObj.CaptureHTML("<html><body>" + firstImageString + "</body></html>"); } } else { var firstImageString = ComputerAccountHelper.GenerateHtmlImageCode( vehicle); result = _Obj.CaptureHTML("<html><body>" + firstImageString + "</body></html>"); var secondImageString = ComputerAccountHelper.GenerateHtmlImageCodeForSecondBottomImage( vehicle); if (!String.IsNullOrEmpty(secondImageString)) { bottomResult = bottomObj.CaptureHTML("<html><body>" + secondImageString + "</body></html>"); } else { bottomResult = bottomObj.CaptureHTML("<html><body>" + firstImageString + "</body></html>"); } } if (result == WebsitesScreenshot.WebsitesScreenshot.Result.Captured && bottomResult == WebsitesScreenshot.WebsitesScreenshot.Result.Captured) { _Obj.ImageFormat = WebsitesScreenshot. WebsitesScreenshot.ImageFormats.JPG; bottomObj.ImageFormat = WebsitesScreenshot. WebsitesScreenshot.ImageFormats.JPG; _Obj.DelaySeconds = 10; bottomObj.DelaySeconds = 10; var _Image = _Obj.GetImage(); var _BottomImage = bottomObj.GetImage(); var stream = new MemoryStream(); var bottomStream = new MemoryStream(); _Image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); _BottomImage.Save(bottomStream, System.Drawing.Imaging.ImageFormat.Jpeg); var bytes = stream.ToArray(); var bottombytes = bottomStream.ToArray(); imageModel.BottomImage = bottombytes; imageModel.TopImage = bytes; stream.Dispose(); stream.Close(); bottomStream.Dispose(); bottomStream.Close(); _Obj.Dispose(); bottomObj.Dispose(); } } else { bottomObj = new WebsitesScreenshot.WebsitesScreenshot( System.Configuration.ConfigurationManager.AppSettings["WebScreenShotSerialKey"].ToString (CultureInfo.InvariantCulture)); WebsitesScreenshot.WebsitesScreenshot.Result _BottomResult; _BottomResult = bottomObj.CaptureHTML("<html><body>" + ComputerAccountHelper.GenerateHtmlImageCodeForSecondBottomImage( vehicle) + "</body></html>"); if (_BottomResult == WebsitesScreenshot.WebsitesScreenshot.Result.Captured) { bottomObj.ImageFormat = WebsitesScreenshot. WebsitesScreenshot.ImageFormats.JPG; bottomObj.DelaySeconds = 5; var bottomImage = bottomObj.GetImage(); var htmlToImageConverter = new HtmlToImage(); htmlToImageConverter.SerialNumber = ConfigurationManager.AppSettings["PDFSerialNumber"]; // set browser width htmlToImageConverter.BrowserWidth = 1200; // set HTML Load timeout htmlToImageConverter.HtmlLoadedTimeout = 5; // set whether the resulted image is transparent htmlToImageConverter.TransparentImage = false; System.Drawing.Image imageObject = null; string htmlCode = ComputerAccountHelper.GenerateHtmlImageCodeForCaliforniaBeemerByComputerAccount(vehicle); imageObject = htmlToImageConverter.ConvertHtmlToImage(htmlCode, null)[0]; var stream = new MemoryStream(); var bottomStream = new MemoryStream(); imageObject.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); bottomImage.Save(bottomStream, System.Drawing.Imaging.ImageFormat.Jpeg); var bytes = stream.ToArray(); var bottombytes = bottomStream.ToArray(); imageModel.BottomImage = bottombytes; imageModel.TopImage = bytes; stream.Dispose(); stream.Close(); bottomStream.Dispose(); bottomStream.Close(); imageObject.Dispose(); bottomObj.Dispose(); } } } catch (Exception ex) { //string body = "Error = " + ex.Message + ex.Source + ex.InnerException + ex.TargetSite + ex.StackTrace + // "**************************************************************************************" + // _subMasterVehicleList.ElementAt(0).ListingId + "----" + // _subMasterVehicleList.ElementAt(0).DealerId; //if (_subMasterVehicleList.Any()) // _subMasterVehicleList.RemoveAt(0); //timerPostAccount.Enabled = true; //return imageModel; } return(imageModel); }
protected void btnWysliMail_Click(object sender, EventArgs e) { UkryjKontrolkeWListView("SelectButton"); btnAkceptuj.Visible = false; btnWysliMail.Visible = false; Label1.Visible = false; string path = String.Format("{0}\\Images\\Rezerwacje\\{1}.gif", Server.MapPath("~"), Session["ZamowienieId"]); //----------------------wstawka----------------------------------- -------------------- btnAkceptuj.Visible = false; Session["ctrl"] = Panel1; Control ctrl = (Control)Session["ctrl"]; StringWriter stringWrite = new StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite); if (ctrl is WebControl) { Unit w = new Unit(100, UnitType.Percentage); ((WebControl)ctrl).Width = w; } Page pg = new Page(); pg.EnableEventValidation = false; HtmlForm frm = new HtmlForm(); pg.Controls.Add(frm); frm.Attributes.Add("runat", "server"); frm.Controls.Add(ctrl); pg.DesignerInitialize(); pg.RenderControl(htmlWrite); string strHTML = stringWrite.ToString(); string wstawka = Server.MapPath("~").ToString(); //korzystanie z biblioteki websiteScreenshote WebsitesScreenshot.WebsitesScreenshot _Obj = new WebsitesScreenshot.WebsitesScreenshot(); WebsitesScreenshot.WebsitesScreenshot.Result _Result = _Obj.CaptureHTML(htmlToImage(strHTML, zmianaAdresu(wstawka))); if (_Result == WebsitesScreenshot.WebsitesScreenshot.Result.Captured) { _Obj.ImageFormat = WebsitesScreenshot.WebsitesScreenshot.ImageFormats.GIF; _Obj.SaveImage(path); } _Obj.Dispose(); //----------------------wstawka----------------------------------- ----------------------------------------------- StringBuilder emailMessage = new StringBuilder(); emailMessage.Append("Przesyłamy twoje Rezerwacje w załączniku."); emailMessage.Append("<br />"); emailMessage.Append("Wydrukuj plik gif, aby okazać go przy wejściu na impreze"); MailMessage email = new MailMessage(); email.From = new MailAddress("*****@*****.**"); email.To.Add(new MailAddress(tdEmail.InnerText)); email.Subject = "Twoje rezerwacje"; email.Body = emailMessage.ToString(); email.IsBodyHtml = true; email.Attachments.Add(new System.Net.Mail.Attachment(path)); SmtpClient client = new SmtpClient(); try { client.Send(email); } catch (Exception ex) { } finally { Session[Cart.Ident] = null; Session[Cart.ZamowienieId] = null; Session[Potwierdzenie] = 1; Response.Redirect("~/RezerwacjeWyslane.aspx"); } }