コード例 #1
0
 private void DisplayProcessedFile(ZipArchivingEventArgs e)
 {
     Application.DoEvents();
     if (e.ProcessingStage == ZipProcessingStages.ADDING_FOLDER)
     {
         txtBoxCurrentAction.Text = "Creating Folder => " + e.FileName;
         AddLogItems("Adding Folder", e.FileName);
         lblFoldersCreated.Text = String.Format("{0}% > {1}",
                                                ConverterUtils.GetPercentageFloored(e.FolderProcessedCount, zipFileStatisticsModel.EstimatedFoldersCount),
                                                zipFileStatisticsModel.EstimatedFoldersCount);
     }
     else if (e.ProcessingStage == ZipProcessingStages.ADDING_FILE || e.ProcessingStage == ZipProcessingStages.ADDING_FILE_FAILED)
     {
         String addingStatus = (e.ProcessingStage == ZipProcessingStages.ADDING_FILE) ? "" : "Failed";
         txtBoxCurrentAction.Text = String.Format("Adding File {0} => {1}", addingStatus, e.ZipFileToCreateFullPath);
         AddLogItems(String.Format("Adding File {0}", addingStatus), e.ZipFileToCreateFullPath);
         lblFilesAdded.Text = String.Format("{0}% > {1}",
                                            ConverterUtils.GetPercentageFloored(e.FilesProcessedCount, zipFileStatisticsModel.EstimatedFilesCount),
                                            zipFileStatisticsModel.EstimatedFilesCount);
         lblArchivedSize.Text = ConverterUtils.HumanReadableFileSize(e.ArchiveSize, 2);
     }
     else if (e.ProcessingStage == ZipProcessingStages.GENERATE_SERIALIZED_TREE_NODE_BASE_FILTER_RULE)
     {
         txtBoxCurrentAction.Text = String.Format("Constructing dynamic filter folder => {0}", e.ZipFileToCreateFullPath);
     }
     else if (e.ProcessingStage == ZipProcessingStages.POST_PROCESSING)
     {
         txtBoxCurrentAction.Text = "Writing the Zip file into the target folder...";
     }
 }
コード例 #2
0
        private void SaveLotteryBetsChanges()
        {
            //get all rows with modification
            List <LotteryWinningBetSetup> modifiedWinBetsArr = new List <LotteryWinningBetSetup>();

            foreach (OLVListItem item in objectListViewWinningBets.Items)
            {
                if (IsListViewItemModified(item))
                {
                    LotteryWinningBetSetup winbet = (LotteryWinningBetSetup)item.RowObject;
                    winbet.ClaimStatus = item.Checked;
                    modifiedWinBetsArr.Add(winbet);
                }
            }
            if (modifiedWinBetsArr.Count <= 0)
            {
                return;
            }

            try
            {
                DialogResult dr = MessageBox.Show(ResourcesUtils.GetMessage("mod_clm_stat_msg_8"),
                                                  ResourcesUtils.GetMessage("mod_clm_stat_msg_9"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                if (dr == DialogResult.OK)
                {
                    toolStripProgBar.Value   = 0;
                    toolStripProgBar.Visible = true;
                    Application.DoEvents();
                    int ctr = 0;
                    int totalCheckedObjects = modifiedWinBetsArr.Count;
                    foreach (LotteryWinningBet lotWinBet in modifiedWinBetsArr)
                    {
                        toolStripStatusLbl.Text = String.Format(ResourcesUtils.GetMessage("mod_clm_stat_msg_10"), String.Join("-", lotWinBet.GetAllNumberSequence()));
                        toolStripProgBar.Value  = ConverterUtils.GetPercentageFloored(++ctr, totalCheckedObjects);
                        this.lotteryDataServices.UpdateClaimStatus(lotWinBet);
                        hasClaimsStatusChange = true;
                        Application.DoEvents();
                    }
                    FillUpBetList();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ResourcesUtils.GetMessage("mod_clm_stat_msg_11"));
                FillUpBetList();
            }
            finally
            {
                toolStripStatusLbl.Text  = "";
                toolStripProgBar.Value   = 0;
                toolStripProgBar.Visible = false;
            }
        }
コード例 #3
0
        private void SaveLotteryBetsChanges()
        {
            //get all rows with modification
            List <LotteryBet> modifiedBetsArr = new List <LotteryBet>();

            foreach (OLVListItem item in objectListViewBets.Items)
            {
                if (IsListViewItemModified(item))
                {
                    modifiedBetsArr.Add((LotteryBet)item.RowObject);
                }
            }
            if (modifiedBetsArr.Count <= 0)
            {
                return;
            }

            try
            {
                DialogResult dr = MessageBox.Show(ResourcesUtils.GetMessage("modfy_bets_msg_11"),
                                                  ResourcesUtils.GetMessage("modfy_bets_msg_12"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                if (dr == DialogResult.OK)
                {
                    toolStripProgBar.Value   = 0;
                    toolStripProgBar.Visible = true;
                    Application.DoEvents();
                    int ctr = 0;
                    int totalCheckedObjects = modifiedBetsArr.Count;
                    foreach (LotteryBet lotBet in modifiedBetsArr)
                    {
                        toolStripStatusLbl.Text = String.Format(ResourcesUtils.GetMessage("modfy_bets_msg_13"), lotBet.GetSimpleContentDetails());
                        toolStripProgBar.Value  = ConverterUtils.GetPercentageFloored(++ctr, totalCheckedObjects);
                        this.lotteryDataServices.SaveLotteryBetChange(lotBet);
                        hasDataUpdates = true;
                        Application.DoEvents();
                    }
                    FillUpBetList();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ResourcesUtils.GetMessage("modfy_bets_msg_14"));
                FillUpBetList();
            }
            finally
            {
                toolStripStatusLbl.Text  = "";
                toolStripProgBar.Value   = 0;
                toolStripProgBar.Visible = false;
            }
        }
コード例 #4
0
        private void objListVwBet_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.objListVwBet.SelectedObjects.Count <= 0)
            {
                return;
            }
            LotteryBet      lotteryBet = (LotteryBet)objListVwBet.SelectedObjects[0];
            TextMatchFilter filter     = new TextMatchFilter(this.objListVwDrawResult);

            List <String> regex = new List <string>();

            foreach (int n in lotteryBet.GetAllNumberSequenceSorted())
            {
                regex.Add("^" + n.ToString() + "$");
            }
            filter.RegexStrings = regex;

            HighlightTextRenderer highlightTextRenderer = new HighlightTextRenderer(filter);

            highlightTextRenderer.CornerRoundness      = 1;
            highlightTextRenderer.FramePen             = new Pen(Color.Empty);
            highlightTextRenderer.FillBrush            = new SolidBrush(Color.LightBlue);
            highlightTextRenderer.CellPadding          = new Rectangle(0, 0, 0, 0);
            highlightTextRenderer.Bounds               = new Rectangle(2, 2, 2, 2);
            this.objListVwDrawResult.ModelFilter       = filter;
            this.objListVwDrawResult.DefaultRenderer   = highlightTextRenderer;
            this.objListVwDrawResult.SelectedForeColor = Color.Black;

            int itemProcessCtr = 0;

            toolStripProgBarRefresh.Value   = 0;
            toolStripProgBarRefresh.Visible = true;
            toolStripStatusLbl.Visible      = true;
            this.objListVwDrawResult.BeginUpdate();
            foreach (OLVListItem item in this.objListVwDrawResult.Items)
            {
                toolStripProgBarRefresh.Value = ConverterUtils.GetPercentageFloored(++itemProcessCtr, this.objListVwDrawResult.Items.Count);
                this.objListVwDrawResult.RefreshObject(item.RowObject);
                if (itemProcessCtr % 50 == 0)
                {
                    Application.DoEvents();
                }
            }

            this.objListVwDrawResult.EndUpdate();
            this.objListVwDrawResult.Sort();
            toolStripProgBarRefresh.Value   = 0;
            toolStripProgBarRefresh.Visible = false;
            toolStripStatusLbl.Visible      = false;
        }
コード例 #5
0
        private void DeleteLotteryBets()
        {
            if (objectListViewBets.CheckedObjects.Count <= 0)
            {
                return;
            }
            DialogResult dr = DialogResult.Cancel;

            try
            {
                dr = MessageBox.Show(ResourcesUtils.GetMessage("modfy_bets_msg_7"),
                                     ResourcesUtils.GetMessage("modfy_bets_msg_8"), MessageBoxButtons.OKCancel,
                                     MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
                if (dr == DialogResult.OK)
                {
                    toolStripProgBar.Value   = 0;
                    toolStripProgBar.Visible = true;
                    Application.DoEvents();
                    int ctr = 0;
                    int totalCheckedObjects = objectListViewBets.CheckedObjects.Count;
                    foreach (LotteryBet lotBet in objectListViewBets.CheckedObjects)
                    {
                        toolStripStatusLbl.Text = String.Format(ResourcesUtils.GetMessage("modfy_bets_msg_9"), lotBet.GetSimpleContentDetails());
                        toolStripProgBar.Value  = ConverterUtils.GetPercentageFloored(++ctr, totalCheckedObjects);
                        this.lotteryDataServices.DeleteLotteryBet(lotBet);
                        Application.DoEvents();
                    }
                    if (totalCheckedObjects > 0)
                    {
                        hasDataUpdates = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ResourcesUtils.GetMessage("modfy_bets_msg_10"));
            }
            finally
            {
                toolStripStatusLbl.Text  = "";
                toolStripProgBar.Value   = 0;
                toolStripProgBar.Visible = false;
                if (dr == DialogResult.OK)
                {
                    FillUpBetList();
                }
            }
        }
コード例 #6
0
        internal async void ScrapeWebsite(LotteryDetails lotteryDetails, Dictionary <string, string> parameters)
        {
            try
            {
                RaiseEvent(LottoWebScrapingStages.CONNECTING);
                IHtmlDocument documentForSession = await GetWebsiteDOMAsync(GenerateParameters(lotteryDetails));

                RaiseEvent(LottoWebScrapingStages.SESSION_CREATION);
                Dictionary <string, string> sessionParam = GetSessionBasedParameters(lotteryDetails, documentForSession);
                RaiseEvent(LottoWebScrapingStages.SEARCHING_DATA);
                IHtmlDocument document = await GetWebsiteDOMAsync(sessionParam);

                RaiseEvent(LottoWebScrapingStages.SCRAPING);
                List <LotteryDrawResult> lotteryDrawResultArr = GetScrapeResults(lotteryDetails, document);

                int countCtr = 1;
                LotteryDrawResultDao lotteryDao = LotteryDrawResultDaoImpl.GetInstance();
                foreach (LotteryDrawResult scrapeResult in lotteryDrawResultArr.ToList())
                {
                    LotteryDrawResult result = lotteryDao.GetLotteryDrawResultByDrawDate(lotteryDetails.GameMode, scrapeResult.GetDrawDate());
                    if (result == null && !scrapeResult.IsDrawResulSequenceEmpty())
                    {
                        newRecordsCount++;
                        lotteryDao.InsertDrawDate(scrapeResult);
                    }
                    RaiseEvent(LottoWebScrapingStages.INSERT, ConverterUtils.GetPercentageFloored(countCtr++, lotteryDrawResultArr.Count), scrapeResult.GetExtractedDrawnResultDetails());
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                RaiseEvent(LottoWebScrapingStages.ERROR, 0, ex.Message);
            }
            finally
            {
                RaiseEvent(LottoWebScrapingStages.FINISH);
            }
        }
コード例 #7
0
        private void CopyOutputToOtherTargetFolders(ZipArchivingEventArgs e)
        {
            TargetOutputLocationModel targetOutputLoc    = zipModel.TargetOutputLocationModel;
            List <string>             targetLocationsArr = targetOutputLoc.GetTargetLocations();

            if (targetLocationsArr.Count <= 0)
            {
                progressBarStatus.Value = progressBarStatus.Maximum;
                return;
            }

            FileInfo zipOutputFile                         = new FileInfo(zipArchiving.NewArchiveName);
            String   zipOutputFileName                     = zipOutputFile.Name;
            String   zipOutputFullFilePathName             = zipOutputFile.FullName;
            long     totalFileOutputSize                   = zipOutputFile.Length * targetLocationsArr.Count;
            long     totalTransferredByte                  = 0;
            long     totalTransferredByteUpdateProgress    = 10485760; //10 * 1024 * 1024, every 10MB
            long     totalTransferredByteUpdateProgressCtr = 0;

            progressBarStatus.Value = 0;

            foreach (String targetOutputFolder in targetLocationsArr)
            {
                String outputFileFullPath = targetOutputFolder + @"\" + zipOutputFileName;
                if (isStopProcessing)
                {
                    break;
                }
                try
                {
                    if (!IsDirectoryValidAndAccessible(targetOutputFolder))
                    {
                        AddLogItems("Copy file failed", String.Format(@"Failed to place the file [{1}] in [{0}] due to folder is not accessible" +
                                                                      @" or no read and write permission", targetOutputFolder, zipOutputFile.Name));
                        continue;
                    }

                    int bufferSize = 8 * 1024;
                    using (FileStream sourceStream = new FileStream(zipOutputFullFilePathName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
                    {
                        using (FileStream fileStream = new FileStream(outputFileFullPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
                        {
                            fileStream.SetLength(sourceStream.Length);
                            int    bytesRead = -1;
                            byte[] bytes     = new byte[bufferSize];

                            if (isStopProcessing)
                            {
                                break;
                            }
                            while ((bytesRead = sourceStream.Read(bytes, 0, bufferSize)) > 0)
                            {
                                fileStream.Write(bytes, 0, bytesRead);
                                totalTransferredByte += bytesRead;

                                //update progress bar not that much, e.g. every 10MB
                                if ((totalTransferredByte - totalTransferredByteUpdateProgressCtr) >= totalTransferredByteUpdateProgress)
                                {
                                    totalTransferredByteUpdateProgressCtr = totalTransferredByte;
                                    Application.DoEvents();
                                    progressBarStatus.Value = ConverterUtils.GetPercentageFloored(totalTransferredByte, totalFileOutputSize);
                                }
                            }
                            fileStream.Flush();
                            txtBoxCurrentAction.Text = "Copying output Zip Archive to => " + targetOutputFolder;
                            AddLogItems("Copy file success", outputFileFullPath);
                        }
                    }
                    progressBarStatus.Value = ConverterUtils.GetPercentageFloored(totalTransferredByte, totalFileOutputSize);
                }
                catch (Exception ex)
                {
                    AddLogItems("Copy file failed", String.Format(@"Failed: {0}\{1}. / Error message: {2}", targetOutputFolder, zipOutputFile.Name, ex.Message));
                }
            }
            //In case some locations are not valid anymore
            progressBarStatus.Value = progressBarStatus.Maximum;
            if (isStopProcessing)
            {
                txtBoxCurrentAction.Text = "Copying has been halted...";
                AddLogItems("Copy Output File", "Copying has been halted...");
                progressBarStatus.Value = progressBarStatus.Maximum;
            }
        }