Ejemplo n.º 1
0
        private void BackgroundWorker1_DoWork(System.Object sender, System.ComponentModel.DoWorkEventArgs e) {
            //R            Dim d As New QueriesTableAdapter
            dynamic r = new Random();

            dynamic PIE2UID = 0;
            dynamic dataDate = new DateTime(2010, 1, 1);

            //NOTE: CODE HERE DOES NOT HANDLE e.g. 60 inputs per minute, only 525600 records

            /*
            for (x = 0; x <= dateTimeCount - 1; x++) {
                if (x % numberOfInputsPerMinute == 0) {
                    dataDate = dataDate.AddMinutes(1);
                }


                if (BackgroundWorker1.CancellationPending) {
                    break; // TODO: might not be correct. Was : Exit For
                }
                else {
                    if (PIE2UID % 30000 == 0) {
                        PIE2UID = 0;
                    }
                    PIE2UID = PIE2UID + 1;

                    dynamic value = Math.Round(r.NextDouble * 1000, 5);
                    //R     d.AddRecordVarchar(PIE2UID, value, dataDate)
                    //R   d.AddRecord(PIE2UID, value, dataDate)

                    if (x % 5000 == 0) {
                        BackgroundWorker1.ReportProgress(x / dateTimeCount * 100 * 0.9);
                    }
                }
            }*/

            BackgroundWorker1.ReportProgress(100);
        }
Ejemplo n.º 2
0
 private void Scanforset(string path)
 {
     string[] osufiles = Directory.GetFiles(path, "*.osu");
     if (osufiles.Length != 0)
     {
         foreach (var osufile in osufiles)
         {
             var tmp = new Beatmap(osufile, path);
             _allBeatmap.Add(tmp);
         }
         BackgroundWorker1.ReportProgress(0);
     }
     else
     {
         var tmpfolder = Directory.GetDirectories(path);
         _all += tmpfolder.Length;
         BackgroundWorker1.ReportProgress(0);
         foreach (string subfolder in tmpfolder)
         {
             Scanforset(subfolder);
         }
     }
     _ok++;
 }
Ejemplo n.º 3
0
        private void BackgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            if (Mode == "Complete library")
            {
                int i = 0;
                int j = 1;

                BeatmapEntry oldBeatmap = Odb.Beatmaps[0];
                BeatmapEntry beatmap    = Odb.Beatmaps[0];

                while (!Cancel && j < Odb.Beatmaps.Count)
                {
                    if (oldBeatmap.BeatmapSetId != beatmap.BeatmapSetId)
                    {
                        i++;
                        extractBeatmap(oldBeatmap);
                        BackgroundWorker1.ReportProgress(i);
                    }

                    oldBeatmap = beatmap;
                    beatmap    = Odb.Beatmaps[j];
                    j++;
                }

                if (!Cancel)
                {
                    i++;
                    extractBeatmap(oldBeatmap);
                    BackgroundWorker1.ReportProgress(i);
                    Result = true;
                }
                else
                {
                    Cancel = false;
                }
            }
            else
            {
                int i = 0;
                int j = 0;

                //Iterate though maps
                BeatmapEntry beatmap = Odb.Beatmaps[0];
                while (!Cancel && j < Odb.Beatmaps.Count && i < SelectedCollection.BeatmapHashes.Count)
                {
                    foreach (string hash in SelectedCollection.BeatmapHashes)
                    {
                        if (beatmap.BeatmapChecksum == hash)
                        {
                            i++;
                            extractBeatmap(beatmap);
                            BackgroundWorker1.ReportProgress(i);
                        }
                    }

                    beatmap = Odb.Beatmaps[j];
                    j++;
                }

                if (!Cancel)
                {
                    Result = true;
                }
                else
                {
                    Cancel = false;
                }
            }
        }
        private void BackgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            var driverService = FirefoxDriverService.CreateDefaultService();

            driverService.HideCommandPromptWindow = true;
            IWebDriver driver = new FirefoxDriver(driverService);

            //IWebDriver driver = new FirefoxDriver();
            driver.Manage().Window.Maximize();

            try
            {
                if ((ods != null) && (ods.Tables[0] != null) && ods.Tables[0].Rows.Count > 0)
                {
                    odtbl = ods.Tables[0];
                    int i        = 0;
                    int recCount = 0;
                    recCount = odtbl.Rows.Count;
                    addlog("######## Total PRs count: " + recCount);
                    string   strPRID   = "";
                    string   strStatus = "";
                    string   strPRLink = "";
                    string[] strPRArr  = null;
                    stopwatch.Start();
                    startTime = DateTime.Now;

                    foreach (DataRow dr in odtbl.Rows)
                    {
                        i        += 1;
                        strPRLink = dr["PR Link"].ToString();
                        if (!strPRLink.ToLower().Contains("pullrequest"))
                        {
                            strStatus    = "Invalid PRLink - It doesn't contains pullrequest in it.";
                            dr["Status"] = strStatus;
                            addlog(i + ") PR# Status: Invalid PRLink - It doesn't contains pullrequest in it.");
                            BackgroundWorker1.ReportProgress(i);
                            //UpdateSinglePRBuildStatusInExcel(strStatus, strPRLink);
                            System.Threading.Thread.Sleep(100);
                            continue;
                        }
                        strPRArr = System.Text.RegularExpressions.Regex.Split(strPRLink.ToLower(), "pullrequest/");
                        if (strPRArr.Length == 2)
                        {
                            strPRLink = strPRArr[0];
                            strPRID   = strPRArr[1];
                            strPRLink = strPRArr[0];
                            strPRID   = strPRArr[1];
                            ArrayList splChars = new ArrayList();
                            splChars.Add("!"); splChars.Add("@"); splChars.Add("$");
                            splChars.Add("&"); splChars.Add("("); splChars.Add(")");
                            splChars.Add("?"); splChars.Add("#"); splChars.Add("^");
                            splChars.Add("%"); splChars.Add("/"); splChars.Add("*");
                            foreach (string chr in splChars)
                            {
                                if (strPRID.Contains(chr))
                                {
                                    strPRID = strPRID.Substring(0, strPRID.IndexOf(chr));
                                }
                            }
                            // if (strPRID.Contains("?"))
                            //     strPRID = strPRID.Substring(0, strPRID.IndexOf("?"));
                            //else if(strPRID.Contains("#"))
                            //     strPRID = strPRID.Substring(0, strPRID.IndexOf("#"));
                            strPRLink = strPRLink + "pullrequest/" + strPRID + "?_a=overview";
                            strStatus = startProcess(driver, strPRLink);
                            if (strStatus == "remotewebdriver")
                            {
                                strStatus = "Browser closed unexpectedly, opening new browser.";
                                driver    = new FirefoxDriver(driverService);
                                stopwatch.Start();
                            }
                            dr["Status"] = strStatus;
                            addlog(i + ") PR#" + strPRID + "  Status: " + strStatus);

                            BackgroundWorker1.ReportProgress(i);
                            //UpdateSinglePRBuildStatusInExcel(strStatus, strPRLink);
                            System.Threading.Thread.Sleep(100);
                        }
                        else
                        {
                            strStatus    = "Invalid PRLink, split with pullrequest issue.";
                            dr["Status"] = strStatus;
                            addlog(i + ") PR# Status: Invalid PRLink, split with pullrequest issue.");
                            BackgroundWorker1.ReportProgress(i);
                            //UpdateSinglePRBuildStatusInExcel(strStatus, strPRLink);
                            System.Threading.Thread.Sleep(100);
                            continue;
                        }
                    }
                    UpdateAllPsRBuildStatusInExcel(ods);
                    //clsStaticMethods.WriteLog("Total Elapsed time: " + strTimeElapsed);
                }
                else
                {
                    MessageBox.Show("No records in Excel file.", strCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                clsStaticMethods.WriteLog("BackgroundWorker1_DoWork-->" + ex.Message);
                stopwatch.Stop();
            }
            finally
            {
                if (driver != null)
                {
                    driver.Quit();
                }
            }
        }