public static List <WhitmanEntepriseMasterVehicleInfo> PopulateEmailHavingRenewAds() { var context = new whitmanenterprisecraigslistEntities() { CommandTimeout = 18000 }; var bufferMasterVehicleList = new List <WhitmanEntepriseMasterVehicleInfo>(); //var dtCompare = DateTime.Now.AddHours(-55); var checkList = from a in context.vincontrolcraigslisttrackings from b in context.vinclappemailaccounts where a.EmailAccount == b.AccountName && a.CLPostingId > 0 select new { a.TrackingId, a.ListingId, a.CityId, a.CLPostingId, a.ShowAd, a.EmailAccount, a.DealerId, b.AccountPassword, b.Phone, a.AddedDate, a.ExpirationDate, a.HtmlCraigslistUrl }; var hashSet = new HashSet <string>(); foreach (var ads in checkList.OrderBy(x => x.EmailAccount)) { if (!hashSet.Contains(ads.EmailAccount)) { var addCar = new WhitmanEntepriseMasterVehicleInfo() { AutoID = bufferMasterVehicleList.Count + 1, CraigslistAccountName = ads.EmailAccount, CraigslistAccountPassword = ads.AccountPassword, }; bufferMasterVehicleList.Add(addCar); } hashSet.Add(ads.EmailAccount); } return(bufferMasterVehicleList); }
public static List <WhitmanEntepriseMasterVehicleInfo> PopulateAvailableRenewAds() { var context = new whitmanenterprisecraigslistEntities() { CommandTimeout = 18000 }; var bufferMasterVehicleList = new List <WhitmanEntepriseMasterVehicleInfo>(); var dtCompare = DateTime.Now.AddHours(-72); var cityList = context.whitmanenterprisecraigslistcities.ToList(); var checkList = from a in context.vincontrolcraigslisttrackings from b in context.vinclappemailaccounts where a.EmailAccount == b.AccountName && a.AddedDate <= dtCompare && a.CLPostingId > 0 select new { a.TrackingId, a.ListingId, a.CityId, a.CLPostingId, a.ShowAd, a.EmailAccount, a.DealerId, b.AccountPassword, b.Phone, a.AddedDate, a.ExpirationDate, a.HtmlCraigslistUrl }; foreach (var ads in checkList.OrderBy(x => x.EmailAccount)) { var addCar = new WhitmanEntepriseMasterVehicleInfo() { AutoID = bufferMasterVehicleList.Count + 1, CraigslistUrl = ads.HtmlCraigslistUrl, CraigslistAccountName = ads.EmailAccount, CraigslistAccountPassword = ads.AccountPassword, CraigslistAccountPhone = ads.Phone, CLPostingId = ads.CLPostingId.GetValueOrDefault(), AdTrackingId = ads.TrackingId, CraigslistCityUrl = cityList.First(x => x.CityID == ads.CityId).CraigsListCityURL }; bufferMasterVehicleList.Add(addCar); } return(bufferMasterVehicleList); }
public static List <WhitmanEntepriseMasterVehicleInfo> PopulateAvailableClickThroughAds() { var context = new whitmanenterprisecraigslistEntities() { CommandTimeout = 18000 }; var bufferMasterVehicleList = new List <WhitmanEntepriseMasterVehicleInfo>(); var cityList = context.whitmanenterprisecraigslistcities.ToList(); var checkList = from a in context.vincontrolcraigslisttrackings where a.DealerId == 3738 || a.DealerId == 113738 || a.DealerId == 115896 || a.DealerId == 44670 || a.DealerId == 144670 || a.DealerId == 15896 || a.DealerId == 11828 || a.DealerId == 111828 || a.DealerId == 7180 || a.DealerId == 112650 || a.DealerId == 2650 || a.DealerId == 15986 || a.DealerId == 115986 select new { a.TrackingId, a.ListingId, a.CityId, a.CLPostingId, a.ShowAd, a.EmailAccount, a.DealerId, a.AddedDate, a.ExpirationDate, a.HtmlCraigslistUrl }; foreach (var ads in checkList.OrderBy(x => x.EmailAccount)) { var addCar = new WhitmanEntepriseMasterVehicleInfo() { AutoID = bufferMasterVehicleList.Count + 1, CraigslistUrl = ads.HtmlCraigslistUrl, CraigslistAccountName = ads.EmailAccount, CLPostingId = ads.CLPostingId.GetValueOrDefault(), AdTrackingId = ads.TrackingId, CraigslistCityUrl = cityList.First(x => x.CityID == ads.CityId).CraigsListCityURL }; bufferMasterVehicleList.Add(addCar); } return(bufferMasterVehicleList.Where(x => !String.IsNullOrEmpty(x.CraigslistUrl)).ToList()); }
public static List <WhitmanEntepriseMasterVehicleInfo> PopulateTodayNewPostAdsForReport() { var context = new whitmanenterprisecraigslistEntities() { CommandTimeout = 18000 }; var bufferMasterVehicleList = new List <WhitmanEntepriseMasterVehicleInfo>(); var dtCompare = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddHours(8); var cityList = context.whitmanenterprisecraigslistcities.ToList(); var checkList = context.vincontrolcraigslisttrackings.Where( a => a.CLPostingId > 0 && a.AddedDate >= dtCompare && a.Renew == false).Select(a => new { a.TrackingId, a.CityId, a.CLPostingId, a.Computer, a.ShowAd, a.CheckDate, a.AddedDate, a.HtmlCraigslistUrl }); foreach (var ads in checkList) { var addCar = new WhitmanEntepriseMasterVehicleInfo() { AutoID = bufferMasterVehicleList.Count + 1, CLPostingId = ads.CLPostingId.GetValueOrDefault(), AdTrackingId = ads.TrackingId, CraigslistCityUrl = cityList.First(x => x.CityID == ads.CityId).CraigsListCityURL, CraigslistUrl = ads.HtmlCraigslistUrl }; bufferMasterVehicleList.Add(addCar); } return(bufferMasterVehicleList); }
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 GenerateRunTimePhysicalImageByComputerAccount(WhitmanEntepriseMasterVehicleInfo vehicle) { var imageModel = new ImageModel { PhysicalImageUrl = new List <string>() }; var random = new Random(); string[] carImage = vehicle.CarImageUrl.Split(new[] { ",", "|" }, StringSplitOptions.RemoveEmptyEntries); var request = new WebClient(); var number = random.Next(2, 4); string physicalImagePath = @"C:\MyImages\" + vehicle.DealerId + "\\" + vehicle.Vin; try { var dirNormal = new DirectoryInfo(physicalImagePath); if (!dirNormal.Exists) { dirNormal.Create(); } //var htmlToImageConverter = new HtmlToImage //{ // SerialNumber = ConfigurationManager.AppSettings["PDFSerialNumber"], // BrowserWidth = 570, // TransparentImage = false //}; //string snapshotfilePath = dirNormal + "\\" + vehicle.Vin + ".jpg"; //System.Drawing.Image imageObjectSnapshot = htmlToImageConverter.ConvertHtmlToImage( // ComputerAccountHelper.GenerateHtmlImageCodeSnapshotInfoLayout1(vehicle), null)[0]; //imageObjectSnapshot.Save(snapshotfilePath, ImageFormat.Jpeg); //imageModel.PhysicalImageUrl.Add(snapshotfilePath); for (int i = 0; i < carImage.Length; i++) { string singleImagePath = dirNormal + "\\" + (i + 1) + ".jpg"; ComputerAccountHelper.DownloadImage(request, carImage[i], singleImagePath); imageModel.PhysicalImageUrl.Add(singleImagePath); if (imageModel.PhysicalImageUrl.Count > number) { break; } } } catch (Exception ex) { } return(imageModel); }
public static ImageModel GenerateRunTimePhysicalImageForFullertonAutoSquare(WhitmanEntepriseMasterVehicleInfo vehicle, List <WhitmanEntepriseMasterVehicleInfo> squareRandom) { var imageModel = new ImageModel { PhysicalImageUrl = new List <string>() }; var random = new Random(); string[] carImage = vehicle.CarImageUrl.Split(new string[] { ",", "|" }, StringSplitOptions.RemoveEmptyEntries); var number = random.Next(4, 6); var count = 1; var physicalImagePath = @"C:\ImageWarehouse" + "\\" + vehicle.DealerId + "\\" + vehicle.Vin; try { var dirNormal = new DirectoryInfo(physicalImagePath); if (!dirNormal.Exists) { dirNormal.Create(); } var htmlToImageConverter = new HtmlToImage { SerialNumber = ConfigurationManager.AppSettings["PDFSerialNumber"], BrowserWidth = 570, HtmlLoadedTimeout = 15, TransparentImage = false }; //string square4FilePath = dirNormal + "\\" + vehicle.StockNumber + "-" + (count++); //if (squareRandom.Count >= 4) //{ // var imageObjectSquare = // htmlToImageConverter.ConvertHtmlToImage(ComputerAccountHelper.GenerateHtmlImageCodeSquare4Pictures(squareRandom), null)[0]; // imageObjectSquare.Save(square4FilePath, System.Drawing.Imaging.ImageFormat.Jpeg); //} foreach (string tmp in carImage) { string imageFileName = vehicle.StockNumber + "-" + count; var imageObject = htmlToImageConverter.ConvertHtmlToImage(ComputerAccountHelper.GenerateHtmlImageCodeOverlayForFullerton(vehicle, tmp), null)[0]; string filePath = dirNormal + "\\" + imageFileName + ".jpg"; imageObject.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg); imageModel.PhysicalImageUrl.Add(filePath); count++; break; //if (imageModel.PhysicalImageUrl.Count > number) // break; } foreach (var tmp in squareRandom) { if (!String.IsNullOrEmpty(tmp.CarImageUrl)) { string[] totalImage = tmp.CarImageUrl.Split(new[] { "|", "," }, StringSplitOptions.RemoveEmptyEntries); string imageFileName = vehicle.StockNumber + "-" + count; var imageObject = htmlToImageConverter.ConvertHtmlToImage(ComputerAccountHelper.GenerateHtmlImageCodeOverlayForFullerton(tmp, totalImage[0]), null)[0]; string filePath = dirNormal + "\\" + imageFileName + ".jpg"; imageObject.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg); imageModel.PhysicalImageUrl.Add(filePath); count++; } } //if (squareRandom.Count >= 4) // imageModel.PhysicalImageUrl.Add(square4FilePath); } catch (Exception) { } return(imageModel); }
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); }
public LoginWarningForm(WhitmanEntepriseMasterVehicleInfo vehicle) { InitializeComponent(); lblCheck.Text = "Login Warning"; this.vehicle = vehicle; }