public void GetVatPrice() { var notifier = new ProgressCancelNotifier(); decimal vatRate = 20; decimal buyingPriceHt = 100; decimal sellingPriceHt = 200; decimal vatPriceOnRevenue = 40; decimal sellingPriceTTCOnRevenue = 240; decimal vatPriceOnProfit = 20; decimal sellingPriceTTCOnProfit = sellingPriceHt + vatPriceOnProfit; if (PriceHelper.GetVATPriceOnProfit(buyingPriceHt, sellingPriceHt, vatRate) != vatPriceOnProfit) { throw new Exception(); } if (PriceHelper.GetVATPriceOnRevenu(sellingPriceHt, vatRate) != vatPriceOnRevenue) { throw new Exception(); } Assert.AreEqual(vatPriceOnRevenue, PriceHelper.GetVATPriceOnRevenuWithSellingPriceTTC(sellingPriceTTCOnRevenue, vatRate)); if (PriceHelper.GetVATPriceOnProfitWithSellingPriceTTC(buyingPriceHt, sellingPriceTTCOnProfit, vatRate) != vatPriceOnProfit) { throw new Exception(); } }
/// <summary> /// Permettre d'effectuer plusieurs tentative lors d'action internet /// </summary> public InternetRetry(ProgressCancelNotifier iNotifier, int iWaitSecondBetweenCycles, int iNumberOfRetries, string iSiteUrl = null) : base(iNotifier) { _sleep = iWaitSecondBetweenCycles; _retries = iNumberOfRetries; _SiteUrl = iSiteUrl; }
public async Task SaveImage_GetImage_DeleteFile() { try { var notifier = new ProgressCancelNotifier(); string connectionString = ConfigurationManager.AppSettings["AzureStorageConnectionString"]; string containerName = Guid.NewGuid().ToString(); var blobContainer = new BlobContainer(notifier, false); await blobContainer.CreateContainerAsync(connectionString, containerName, BlobContainerPublicAccessEnum.Off); var theImage = Image.FromFile(ImagePath1); theImage = theImage.ScaleImage(500, 500); string fileName = "imagetest.jpeg"; string fileName2 = "imagetest2.jpeg"; string fakeName = "imagetest241.jpeg"; //save if (await blobContainer.SaveFileAsync(connectionString, containerName, theImage.ToStream(), fileName) == null) { throw new Exception(); } if (await blobContainer.SaveFileAsync(connectionString, containerName, theImage.ToStream(), fileName2) == null) { throw new Exception(); } //get var getImage = await blobContainer.GetFileAsync(connectionString, containerName, fileName); if (getImage == null) { throw new Exception(); } var getImage2 = await blobContainer.GetFileAsync(connectionString, containerName, fakeName); if (getImage2 != null) { throw new Exception(); } //delete if (!await blobContainer.DeleteFileAsync(connectionString, containerName, fileName)) { throw new Exception(); } if (!await blobContainer.DeleteFileAsync(connectionString, containerName, fileName2)) { throw new Exception(); } await blobContainer.DeleteContainerAsync(connectionString, containerName); } catch (Exception) { throw; } }
/// <summary> /// Création blob si risque de déconnection avec le blob /// </summary> public BlobContainer(ProgressCancelNotifier iNotifier, bool iWithSafeNetwork) : base(iNotifier) { WithSafeNetwork = iWithSafeNetwork; System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; }
public async Task SavePDF_GetImage_DeleteFile() { var notifier = new ProgressCancelNotifier(); string connectionString = ConfigurationManager.AppSettings["AzureStorageConnectionString"]; string containerName = Guid.NewGuid().ToString(); var blobContainer = new BlobContainer(notifier, false); await blobContainer.CreateContainerAsync(connectionString, containerName, BlobContainerPublicAccessEnum.Off); var theFile = File.ReadAllBytes(pdfPath); string fileName = "pdf1.pdf"; string fileName2 = "pdf2.pdf"; string fakeName = "pdf1001.pdf"; //save if (await blobContainer.SaveFileAsync(connectionString, containerName, theFile, fileName) == null) { throw new Exception(); } if (await blobContainer.SaveFileAsync(connectionString, containerName, theFile, fileName2) == null) { throw new Exception(); } //get var getImage = await blobContainer.GetFileAsync(connectionString, containerName, fileName); if (getImage == null) { throw new Exception(); } var getImage2 = await blobContainer.GetFileAsync(connectionString, containerName, fakeName); if (getImage2 != null) { throw new Exception(); } //delete if (!await blobContainer.DeleteFileAsync(connectionString, containerName, fileName)) { throw new Exception(); } if (!await blobContainer.DeleteFileAsync(connectionString, containerName, fileName2)) { throw new Exception(); } await blobContainer.DeleteContainerAsync(connectionString, containerName); }
public async Task Notifier() { var notifier = new ProgressCancelNotifier(); var worker = new Worker(notifier); var task1 = Task.Run(() => worker.Work1(), notifier.CancellationTokenSource.Token); await Task.Delay(1000); notifier.Cancel(); await task1; }
/// <param name="iNewIpFrequency">Temps en minutes</param> public WebQueryHideIP(ProgressCancelNotifier iProgressCancelNotifier, bool iWithSafeNetwork, bool iWithIpCheck = true, int iNewIpFrequency = 30) : base(iProgressCancelNotifier) { if (ProcessTools.IsProcessRunning("privoxy") == false) { throw new Exception("Pour effectuer des requetes via proxy, le logiciel 'Privoxy' doit être lancé."); } if (ProcessTools.IsProcessRunning("vidalia") == false) { throw new Exception("Pour effectuer des requetes via proxy, le logiciel 'Vidalia' doit être lancé."); } WebQueryType = WebQueryTypeEnum.WebQueryWithProxy; newIpFrequency = iNewIpFrequency; proxyAdress = PROXYADRESS; proxyPort = PROXYPORT; socksAdress = SOCKSADRESS; socksPort = SOCKSPORT; socksPassword = SOCKSPASSWORD; WithSafeNetwork = iWithSafeNetwork; //Chargement de la liste de user agent userAgentList.Add("Mozilla/5.0 (compatible; MSIE 9.0; AOL 9.7; AOLBuild 4343.19; Windows NT 6.1; WOW64; Trident/5.0; FunWebProducts)"); userAgentList.Add("Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0"); userAgentList.Add("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1944.0 Safari/537.36"); userAgentList.Add("Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25"); userAgentList.Add("Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14"); userAgentList.Add("Mozilla/5.0 (X11; U; Linux i686; fr-fr) AppleWebKit/525.1+ (KHTML, like Gecko, Safari/525.1+) midori/1.19"); //vérification de l'adresse proxy différente de l'adresse réel: if (iWithIpCheck) { string realIp = new WebQueryNoHideIP(Notifier, iWithSafeNetwork).GetMyIp(); string proxyIp = GetMyIp(); if (proxyIp != null && realIp != null && proxyIp != realIp) { using (var sublevel1 = new ProgressCancelNotifier.SubLevel(Notifier)) { Notifier.Report("Ip proxy : {0}, Ip box : {1} ".FormatString(proxyIp, realIp)); } } else { throw new Exception("Error lors de la vérification du proxy. Vérifier si le socks(vidalia) et le proxy(privoxy) sont bien démarrés."); } } }
public async Task GetHtmlSource() { try { var urlList = new List <string>(); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-bosch-12-volts-n32648"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-12-volts-beru-zs-106-avec-collier-n313569"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-12-volts-beru-zs-172-n315436"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-allumeur-bosch-avec-capsule-de-depression-qualite-d-origine-12-volts-n312584"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-bosch-12-volts-n32648"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-12-volts-beru-zs-106-avec-collier-n313569"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-12-volts-beru-zs-172-n315436"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-allumeur-bosch-avec-capsule-de-depression-qualite-d-origine-12-volts-n312584"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-bosch-12-volts-n32648"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-12-volts-beru-zs-106-avec-collier-n313569"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-12-volts-beru-zs-172-n315436"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-allumeur-bosch-avec-capsule-de-depression-qualite-d-origine-12-volts-n312584"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-bosch-12-volts-n32648"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-12-volts-beru-zs-106-avec-collier-n313569"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-12-volts-beru-zs-172-n315436"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-allumeur-bosch-avec-capsule-de-depression-qualite-d-origine-12-volts-n312584"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-bosch-12-volts-n32648"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-12-volts-beru-zs-106-avec-collier-n313569"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-12-volts-beru-zs-172-n315436"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-allumeur-bosch-avec-capsule-de-depression-qualite-d-origine-12-volts-n312584"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-bosch-12-volts-n32648"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-12-volts-beru-zs-106-avec-collier-n313569"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-12-volts-beru-zs-172-n315436"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-allumeur-bosch-avec-capsule-de-depression-qualite-d-origine-12-volts-n312584"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-bosch-12-volts-n32648"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-12-volts-beru-zs-106-avec-collier-n313569"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-bobine-d-allumage-12-volts-beru-zs-172-n315436"); urlList.Add("http://www.serial-kombi.com/fr-FR/combi-split-2/1950-7/1967-moteur-/-allumage-allumeur-bosch-avec-capsule-de-depression-qualite-d-origine-12-volts-n312584"); var notifier = new ProgressCancelNotifier(); var webQuery = new WebQuery2(notifier, false); var result = await webQuery.AllCarsInParallelNonBlockingAsync(); if (result.IsNullOrEmpty()) { throw new Exception(); } } catch (Exception) { throw; } }
public async Task CreateContainer() { var notifier = new ProgressCancelNotifier(); string connectionString = ConfigurationManager.AppSettings["AzureStorageConnectionString"]; string privateContainer = Guid.NewGuid().ToString(); string publicContainer = Guid.NewGuid().ToString(); var blobContainer = new BlobContainer(notifier, false); await blobContainer.CreateContainerAsync(connectionString, privateContainer, BlobContainerPublicAccessEnum.Off); var theImage = Image.FromFile(ImagePath1); Uri thePrivateUrl = await blobContainer.SaveFileAsync(connectionString, privateContainer, theImage.ToStream(), Guid.NewGuid().ToString() + ".jpg"); try { using (var webClient = new WebClient()) { Stream stream = webClient.OpenRead(thePrivateUrl); Image.FromStream(stream); throw new ArgumentException(); } } catch (ArgumentException) { throw; } catch (Exception) { } await blobContainer.CreateContainerAsync(connectionString, publicContainer, BlobContainerPublicAccessEnum.Blob); var theImage2 = Image.FromFile(ImagePath1); Uri thePublicUrl = await blobContainer.SaveFileAsync(connectionString, publicContainer, theImage.ToStream(), Guid.NewGuid().ToString() + ".jpg"); using (var webClient = new WebClient()) { Stream stream = webClient.OpenRead(thePublicUrl); var img = Image.FromStream(stream); if (img == null) { throw new Exception(); } } }
public WebQuery(ProgressCancelNotifier iNotifier, bool iKeepCookies, bool iSafeNetwork, bool iHideIp = false, bool iIpCheck = true, int iNewIpFrequencyMinutes = 0) : base(iNotifier) { CookieContainer = new CookieContainer(); System.Net.ServicePointManager.DefaultConnectionLimit = DEFAULTCONNECTIONLIMIT; ServicePointManager.CheckCertificateRevocationList = false; //ServicePointManager.MaxServicePointIdleTime = _MaxIdleTime; //ServicePointManager.Expect100Continue = false; _safeNetwork = iSafeNetwork; _hideIp = iHideIp; _newIpFrequencyMinutes = iNewIpFrequencyMinutes; _keepCookies = iKeepCookies; lock (_lastIpChangedDateTimeLocker) { if (_lastIpChangedDateTime == DateTime.MinValue) { _lastIpChangedDateTime = DateTime.Now; } } //Chargement de la liste de user agent _userAgentList = new List <string>(); //_userAgentList.Add("Mozilla/5.0 (compatible; MSIE 9.0; AOL 9.7; AOLBuild 4343.19; Windows NT 6.1; WOW64; Trident/5.0; FunWebProducts)"); //_userAgentList.Add("Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0"); _userAgentList.Add("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1944.0 Safari/537.36"); //_userAgentList.Add("Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25"); //_userAgentList.Add("Mozilla/5.0 (X11; U; Linux i686; fr-fr) AppleWebKit/525.1+ (KHTML, like Gecko, Safari/525.1+) midori/1.19"); if (iHideIp) { if (ProcessTools.IsProcessRunning("privoxy") == false) { throw new Exception("Pour effectuer des requetes via proxy, le processus 'Privoxy' doit être lancé."); } if (ProcessTools.IsProcessRunning("tor") == false) { throw new Exception("Pour effectuer des requetes via proxy, le processus 'TOR' doit être lancé."); } } }
public void Convert() { var notifier = new ProgressCancelNotifier(); decimal vatRate = 20; //TVA sur CA decimal amountTTC = 10; decimal amountHT = 8.33m; Assert.AreEqual(PriceHelper.ConvertVATRateOnRevenu(amountTTC, vatRate, 0), amountHT); Assert.AreEqual(PriceHelper.ConvertVATRateOnRevenu(amountHT, 0, vatRate), amountTTC); //TVA sur marge decimal sellingPriceTTC = 20; decimal sellingPriceHT = 18; decimal buyingPriceHT = 8; Assert.AreEqual(PriceHelper.ConvertVATRateOnProfit(sellingPriceTTC, buyingPriceHT, vatRate, 0), sellingPriceHT); Assert.AreEqual(PriceHelper.ConvertVATRateOnProfit(sellingPriceHT, buyingPriceHT, 0, vatRate), sellingPriceTTC); Assert.AreEqual(PriceHelper.ConvertVATRateOnProfit(sellingPriceTTC, buyingPriceHT, vatRate, vatRate), sellingPriceTTC); }
protected Repository(ProgressCancelNotifier iNotifier, bool iLazyLoading) : base(iNotifier) { SetEntityContext(iLazyLoading); }
/// <summary> /// Permet les conversions de devise via récupération du taux sur internet /// </summary> public PriceHelper(ProgressCancelNotifier iNotifier, bool iWithSafeNetwork) : base(iNotifier) { WithSafeNetwork = iWithSafeNetwork; }
public SleepWithStopCheck(ProgressCancelNotifier iNotifier) : base(iNotifier) { }
public WCFRetryHelper(ProgressCancelNotifier iNotifier, int iMaxRetry, int iWaitingTimeSecondOnNoNetwork) : base(iNotifier) { _maxRetry = iMaxRetry; _waitingTimeSecondOnNoNetwork = iWaitingTimeSecondOnNoNetwork; }
public Worker(ProgressCancelNotifier iNotifier) : base(iNotifier) { }