public void GenerateStateSummary(List <List <Slot> > outputTimetables, IStateElementFactory factory) { ClearGui(); var bg = CustomBackgroundWorker <List <List <Slot> >, StateTable> .RunAndShowLoadingScreen(StateTable.Parse, outputTimetables, "Calculating state table . . ."); var stateTable = bg.GetResult(); foreach (var cell in stateTable) { int paddedRowIndex = cell.RowIndex * _eachDayHaveHowManyRow + _paddingDueToTimeRow; int paddedColIndex = cell.ColumnIndex + _paddingDueToDayColumn; int colSpan = StateCell.ColumnSpanOfEachCell; switch (cell.State) { case CellState.DefinitelyOccupied: AddToGrid(factory.CreateDefinitelyOccupiedState(), paddedColIndex, paddedRowIndex, colSpan); break; case CellState.MaybeUnoccupied: AddToGrid(factory.CreateMaybeUnoccupiedState(cell), paddedColIndex, paddedRowIndex, colSpan); break; case CellState.DefinitelyUnoccupied: AddToGrid(factory.CreateDefinitelyUnoccupiedState(), paddedColIndex, paddedRowIndex, 1); break; } } }
private void publishResultsInternal() { if (m_publishResultsRunning) { Utilities.showErrorMessage("A Publish Results operation is already running. Wait for it to finish or Cancel it before starting another!"); return; } string resultsWebsite = websiteAddress_textBox.Text; if (string.IsNullOrWhiteSpace(resultsWebsite)) { MessageBox.Show("Please provide a results website to publish to."); return; } string siteName, pagePath; Utilities.getGoogleSiteComponents(resultsWebsite, out siteName, out pagePath); String username = "******"; String password = "******"; SitesAPI sa = new SitesAPI(siteName, username, password, true, false); CustomBackgroundWorker cbw = new CustomBackgroundWorker("Create Local Webpages", sa.uploadDirectoryInBackground, publishResultsCompleted, operationStatus, operationProgressBar, operationCancelButton, null); Tuple <string, string> values = new Tuple <string, string>(m_eventInformation.webpagesDirectory, pagePath); m_publishResultsRunning = true; cbw.run(values); }
private void publishResults() { if (m_publishResultsRunning) { Utilities.showErrorMessage("A Publish Results operation is already running. Wait for it to finish or Cancel it before starting another!"); return; } if (string.IsNullOrWhiteSpace(m_resultsPublishParameters.ResultsWebsite)) { MessageBox.Show("Please provide a results website to publish to."); return; } string siteName, pagePath; Utilities.getGoogleSiteComponents(m_resultsPublishParameters.ResultsWebsite, out siteName, out pagePath); String username = "******"; String password = "******"; m_sitesAPI = new SitesAPI(siteName, username, password, true, false); m_publishResultsCBW = new CustomBackgroundWorker("Publish Results", m_sitesAPI.uploadDirectoryInBackground, publishResultsCompleted, publishResultsStatus, publishResultsProgressBar, cancelPublishResultsButton, publishResultsStatusTextbox); oldFontSize = Utilities.fontSize; Utilities.fontSize = m_resultsPublishParameters.FontSize; Tuple <string, string> values = new Tuple <string, string>(Constants.getEventWebpagesFolder(m_eventName), pagePath); m_publishResultsRunning = true; m_publishResultsCBW.run(values); }
private void AddSlotButton_Click(object sender, RoutedEventArgs e) { var input = Clipboard.GetText(); if (_previousInputString.Any(s => s.Contains(input))) { DialogBox.Show("Erm...", "The content you copied is already added to the program just now."); return; } var previousCount = Global.InputSlotList.Count; var bg = CustomBackgroundWorker <string, List <Slot> > .RunAndShowLoadingScreen (new SlotParser().Parse, input, "Loading time slots . . ."); Global.InputSlotList.AddRange(bg.GetResult()); if (Global.InputSlotList.Count == previousCount) { DialogBox.Show("Please use GOOGLE CHROME", "Unable to load data, please make sure you copied the correct content from the course registration website using Google Chrome."); return; } NOAS_Label.Content = Global.InputSlotList.Count; _previousInputString.Add(input); UpdateListView(Global.InputSlotList); CountingBadge.Badge = Global.InputSlotList.Count; Global.MaxTime = FindMaxTime(Global.InputSlotList); GetStartDateAndEndDate(input); //new Window_GetConstructionStringOfSlots(Database.inputSlots).Show(); }
private void publishResultsToWordpress() { if (m_publishResultsRunning) { Utilities.showErrorMessage("A Publish Results operation is already running. Wait for it to finish or Cancel it before starting another!"); return; } string siteName = wordpressURLTextbox.Text; string pagePath = wordpressPathTextbox.Text; string username = usernameTextbox.Text; string password = passwordTextbox.Text; UploadWebpages uw = new UploadWebpages(siteName, username, password, true); uw.UseTourneyTemplate = useTourneyTemplateCheckbox.Checked; uw.ForceUpload = true; String fileName = selectedFolderTextbox.Text; if (Directory.Exists(fileName) || File.Exists(fileName)) { m_publishResultsCBW = new CustomBackgroundWorker("Publish Results", uw.uploadDirectoryInBackground, publishResultsCompleted, publishResultsStatus, publishResultsProgressBar, cancelPublishResultsButton, uploadStatusTextbox); Tuple <string, string> values = new Tuple <string, string>(selectedFolderTextbox.Text, pagePath); m_publishResultsRunning = true; m_publishResultsCBW.run(values); } else { MessageBox.Show(fileName + " is not a valid file or folder!"); } }
private void GetUserAvatarInBackgroundWorker(User sender) { CustomBackgroundWorker.QueueWorker( this.workerQueue, sender, (x, e) => { e.Result = GetUserAvatar(sender); }, (x, e) => { SetAvatar((Task <Stream>)e.Result, sender); }); }
private List <List <Slot> > RunPermutation(Slot[] input) { var filteredSlot = Filterer.Filter(input, _predicates); var bg = CustomBackgroundWorker <Slot[], List <List <Slot> > > . RunAndShowLoadingScreen(_permutator, filteredSlot, "Finding possible combination . . . "); return(bg.GetResult()); }
private void RegenerateOutput() { var package = new TimetablesAndPredicates(_outputTimetables, Predicates); var bg = CustomBackgroundWorker <TimetablesAndPredicates, List <List <Slot> > > . RunAndShowLoadingScreen(Filterer.Filter, package, "Filtering unsatisfactory timetables . . ."); var filteredTimetable = bg.GetResult(); TimeTableGui.RegenerateStateSummary(filteredTimetable, _factory); }
public void RegenerateStateSummary(List <List <Slot> > outputTimetables, IStateElementFactory factory) { var bg = CustomBackgroundWorker <List <List <Slot> >, StateTable> .RunAndShowLoadingScreen(StateTable.Parse, outputTimetables, "Recalculating . . ."); var stateTable = bg.GetResult(); foreach (var cell in stateTable) { int paddedRowIndex = cell.RowIndex * _eachDayHaveHowManyRow + _paddingDueToTimeRow; int paddedColIndex = cell.ColumnIndex + _paddingDueToDayColumn; int colSpan = StateCell.ColumnSpanOfEachCell; var element = Grid.Children .Cast <UIElement>() .First(e => Grid.GetRow(e) == paddedRowIndex && Grid.GetColumn(e) == paddedColIndex); if (element is ToggleButton) { if (((ToggleButton)element).IsChecked.Value) { continue; } } switch (cell.State) { case CellState.DefinitelyOccupied: if (element != null) { Grid.Children.Remove(element); } AddToGrid(factory.CreateDefinitelyOccupiedState(), paddedColIndex, paddedRowIndex, colSpan); break; case CellState.MaybeUnoccupied: if (element != null) { Grid.Children.Remove(element); } AddToGrid(factory.CreateMaybeUnoccupiedState(cell), paddedColIndex, paddedRowIndex, colSpan); break; case CellState.DefinitelyUnoccupied: if (element != null) { Grid.Children.Remove(element); } AddToGrid(factory.CreateDefinitelyUnoccupiedState(), paddedColIndex, paddedRowIndex, 1); break; } } }
private void createWebpages() { if (m_createWebpagesRunning) { Utilities.showErrorMessage("A Create Webpages operation is already running. Wait for it to finish or Cancel it before starting another!"); return; } m_databaseToWebpages = new PairsDatabaseToWebpages(m_eventInformation, m_databaseParameters); m_createWebpagesCBW = new CustomBackgroundWorker("Create Local Webpages", m_databaseToWebpages.createWebpagesInBackground, createWebpagesCompleted, createWebpagesStatus, createWebpagesProgressBar, createWebpagesCancelButton, null); m_createWebpagesRunning = true; m_createWebpagesCBW.run(); }
private void DownloadTourney_Load(object sender, EventArgs e) { this.Enabled = false; this.Opacity = 0.75; m_le = new LoadingEvents("Loading Online Tourney List"); m_le.StartPosition = FormStartPosition.CenterParent; m_da = new DocsAPI("*****@*****.**", "kibitzer"); CustomBackgroundWorker cbw = new CustomBackgroundWorker("List Online Tourneys", m_da.getListOfFoldersInBackground, tourneysImported, null, null, null, null); cbw.run(Path.Combine("Indian Bridge Scorer", "Tourneys")); m_le.ShowDialog(this); }
private void Browser_OnLoadCompleted(object sender, NavigationEventArgs e) { Browser.InvokeScript("execScript", "document.documentElement.style.overflow ='hidden'", "JavaScript"); RefreshButton.IsEnabled = true; string currentUrl = Browser.Source.ToString(); //if (currentUrl == LoginPageUrl) return; //if(currentUrl == LoginSuccessUrl) //if(currentUrl == LoginFailedUrl) Browser.Navigate(LoginPageUrl); if (currentUrl == LoginPageUrl || currentUrl == LoginFailedUrl || currentUrl == EndUrl) { _navigationCount = 0; return; } if (currentUrl.Contains(CourseTimetablePreviewUrl) == false) { _currentPage = 1; if (_browsingToCourseTimetablePreview == false) { if (_navigationCount < NavigationCountUpperLimit) { Browser.Navigate(CourseTimetablePreviewUrl); _navigationCount++; } else { Browser.Navigate(LoginPageUrl); Global.Snackbar.MessageQueue.Enqueue("No record found, please try again."); } } return; } Browser.Visibility = Visibility.Hidden; string plainText = GetPlainTextOfHtml(Browser); var bg = CustomBackgroundWorker <string, List <Slot> > .RunAndShowLoadingScreen( new SlotParser().Parse, plainText, "Loading slots . . ."); TryGetStartDateAndEndDate(plainText); Global.InputSlotList.AddRange(bg.GetResult()); if (CanGoToPage(_currentPage + 1)) { Browser.InvokeScript("changePage", _currentPage + 1); _currentPage++; } else { Browser.Navigate(EndUrl); NavigationService.Navigate( Page_CreateTimetable.GetInstance(Global.Settings.SearchByConsideringWeekNumber, Global.Settings.GeneralizeSlot)); } }
public static void InProcessLinkTracerSample() { // start a custom background worker CustomBackgroundWorker customBackgroundWorker = new CustomBackgroundWorker(); // we're using the incoming remote call tracer as an example for an active service call IIncomingRemoteCallTracer incomingRemoteCallTracer = SampleApplication.OneAgentSdk .TraceIncomingRemoteCall("RemoteMethod", "RemoteServiceName", "mrcp://endpoint/service"); incomingRemoteCallTracer.Start(); try { // create an in-process link on the originating thread IInProcessLink inProcessLink = SampleApplication.OneAgentSdk.CreateInProcessLink(); // delegate work to another thread, in this case we use a custom background worker implementation customBackgroundWorker.EnqueueWorkItem(() => { // use the in-process link to link the PurePath on the target thread to its origin IInProcessLinkTracer inProcessLinkTracer = SampleApplication.OneAgentSdk.TraceInProcessLink(inProcessLink); inProcessLinkTracer.Start(); DatabaseRequestTracerSamples.Sync_StartEnd(); // performs a database request traced using the IDatabaseRequestTracer inProcessLinkTracer.End(); }); // the same link can be re-used multiple times customBackgroundWorker.EnqueueWorkItem(() => { IInProcessLinkTracer inProcessLinkTracer = SampleApplication.OneAgentSdk.TraceInProcessLink(inProcessLink); inProcessLinkTracer.Trace(() => { DatabaseRequestTracerSamples.Sync_StartEnd(); }); }); customBackgroundWorker.EnqueueWorkItem(() => { IInProcessLinkTracer inProcessLinkTracer = SampleApplication.OneAgentSdk.TraceInProcessLink(inProcessLink); inProcessLinkTracer.Trace(DatabaseRequestTracerSamples.Sync_StartEnd); }); } catch (Exception e) { incomingRemoteCallTracer.Error(e); throw e; } finally { incomingRemoteCallTracer.End(); customBackgroundWorker.Shutdown(); } }
private void createLocalWebpages() { if (m_createWebpagesRunning) { Utilities.showErrorMessage("A Create Webpages operation is already running. Wait for it to finish or Cancel it before starting another!"); return; } m_databaseToWebpages = new PDDatabaseToWebpages(m_eventName, m_databaseFileName, Constants.getEventWebpagesFolder(m_eventName)); m_createWebpagesCBW = new CustomBackgroundWorker("Create Local Webpages", m_databaseToWebpages.createWebpagesInBackground, createWebpagesCompleted, createWebpagesStatus, createWebpagesProgressBar, cancelCreateWebpagesButton, createWebpagesStatusTextbox); oldFontSize = Utilities.fontSize; Utilities.fontSize = m_resultsPublishParameters.FontSize; m_createWebpagesRunning = true; m_createWebpagesCBW.run(); }
private void UploadTourney_Load(object sender, EventArgs e) { label1.Text = "Uploading " + Constants.CurrentTourneyName + " to Google Docs"; Dictionary <string, string> fileFilters = new Dictionary <string, string>(); fileFilters.Add(".ini", "text/plain"); fileFilters.Add(".mdb", "application/msaccess"); DocsAPI m_da = new DocsAPI("*****@*****.**", "kibitzer"); CustomBackgroundWorker m_cbw = new CustomBackgroundWorker("Upload to Google Docs", m_da.uploadDirectoryToGoogleDocsInBackground, uploadCompleted, operationStatus, operationProgressBar, operationCancelButton, null); Tuple <string, string, Dictionary <string, string> > values = new Tuple <string, string, Dictionary <string, string> >(Constants.getCurrentTourneyFolder(), Path.Combine("Indian Bridge Scorer", "Tourneys"), fileFilters); m_cbw.run(values); }
private void loadSummaryIntoDatabase() { if (m_loadSummaryRunning) { Utilities.showErrorMessage("A Load Summary operation is already running. Wait for it to finish or Cancel it before starting another!"); return; } std = new PairsSummaryToDatabase(m_eventInformation); CustomBackgroundWorker cbw = new CustomBackgroundWorker("Load Summary", std.loadSummaryIntoDatabaseInBackground, loadSummaryCompleted, operationStatus, operationProgressBar, operationCancelButton, null); m_loadSummaryRunning = true; cbw.run(); }
private void RegenerateOutput() { var package = new TimetablesAndPredicates(_outputTimetables, Predicates); var bg = CustomBackgroundWorker <TimetablesAndPredicates, List <List <Slot> > > . RunAndShowLoadingScreen(Filterer.Filter, package, "Filtering unsatisfactory timetables . . ."); var filteredTimetable = bg.GetResult(); int removedCount = _outputTimetables.Count - filteredTimetable.Count; int remainingCount = _outputTimetables.Count - removedCount; Label1.Content = $"Removed {removedCount} unsatisfactory timetables."; Label2.Content = $"{remainingCount} timetables remaining."; TimeTableGui.RegenerateStateSummary(filteredTimetable, _factory); }
private void Browser_OnLoadCompleted(object sender, NavigationEventArgs e) { Browser.InvokeScript("execScript", "document.documentElement.style.overflow ='hidden'", "JavaScript"); RefreshButton.IsEnabled = true; string currentUrl = Browser.Source.ToString(); //if (currentUrl == LoginPageUrl) return; //if(currentUrl == LoginSuccessUrl) //if(currentUrl == LoginFailedUrl) Browser.Navigate(LoginPageUrl); if (currentUrl == LoginPageUrl || currentUrl == LoginFailedUrl || currentUrl == EndUrl) { return; } if (currentUrl.Contains(CourseTimetablePreviewUrl) == false) { _currentPage = 1; if (_browsingToCourseTimetablePreview == false) { Browser.Navigate(CourseTimetablePreviewUrl); } return; } Browser.Visibility = Visibility.Hidden; string plainText = LoadPlainText(); var bg = CustomBackgroundWorker <string, List <Slot> > .RunAndShowLoadingScreen( new SlotParser().Parse, plainText, "Loading slots . . ."); TryGetStartDateAndEndDate(plainText); Global.InputSlotList.AddRange(bg.GetResult()); if (CanGoToPage(_currentPage + 1)) { Browser.InvokeScript("changePage", _currentPage + 1); _currentPage++; } else { Browser.Navigate(EndUrl); NavigationService.Navigate( Global.Factory .Generate_Page_CreateTimetable_with_GeneralizedSlots (Global.InputSlotList)); } }
private void publishResultsButton_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(m_resultsPublishParameters.ResultsWebsite)) { MessageBox.Show("Please provide a results website to publish to."); return; } string siteName, pagePath; Utilities.getGoogleSiteComponents(m_resultsPublishParameters.ResultsWebsite, out siteName, out pagePath); String username = "******"; String password = "******"; SitesAPI sa = new SitesAPI(siteName, username, password, true, false); CustomBackgroundWorker cbw = new CustomBackgroundWorker("Publish Results", sa.uploadDirectoryInBackground, null, publishResultsStatus, publishResultsProgressBar, cancelPublishResultsButton, null); double oldFontSize = Utilities.fontSize; Utilities.fontSize = m_resultsPublishParameters.FontSize; Tuple <string, string> values = new Tuple <string, string>(Constants.getEventWebpagesFolder(m_eventName), pagePath); cbw.run(values); Utilities.fontSize = oldFontSize; }
private void btnPublish_Click_1(object sender, EventArgs e) { var pagePath = getResultsPagePath(); statusStrip1.Visible = true; txtStatus.Clear(); txtStatus.Visible = lblStatus.Visible = true; var uw = new UploadWebpages(m_site, m_username, m_password, true, true) { ForceUpload = true }; var m_publishResultsCBW = new CustomBackgroundWorker("Publish Results", uw.uploadDirectoryInBackground, publishResultsCompleted, publishResultsStatus, publishResultsProgressBar, cancelPublishResultsButton, txtStatus); oldFontSize = Utilities.fontSize; Utilities.fontSize = 5; var values = new Tuple <string, string>(m_resultsFolderPath, pagePath); m_publishResultsCBW.run(values); }
private void downloadTourneyButton_Click(object sender, EventArgs e) { string directory = Path.Combine(Constants.getTourneysFolder(), tourneysListCombobox.Text); if (Directory.Exists(directory)) { if (MessageBox.Show("A directory already exists at " + directory + Environment.NewLine + "If you download online tourney it will overwrite existing contents.Do you want to overwrite?", "Directory Exists!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } } ChangeEnabled(false); statusStrip1.Enabled = true; operationCancelButton.Enabled = true; Dictionary <string, string> fileFilters = new Dictionary <string, string>(); fileFilters.Add(".ini", "text/plain"); fileFilters.Add(".mdb", "application/msaccess"); CustomBackgroundWorker m_cbw = new CustomBackgroundWorker("Download from Google Docs", m_da.DownloadGoogleDocsToDirectoryInBackground, downloadCompleted, operationStatus, operationProgressBar, operationCancelButton, null); Tuple <string, string, Dictionary <string, string> > values = new Tuple <string, string, Dictionary <string, string> >(Path.Combine("Indian Bridge Scorer", "Tourneys", tourneysListCombobox.Text), Constants.getTourneysFolder(), fileFilters); m_cbw.run(values); }
private void Browser_OnLoadCompleted(object sender, NavigationEventArgs e) { Browser.InvokeScript("execScript", "document.documentElement.style.overflow ='hidden'", "JavaScript"); RefreshButton.IsEnabled = true; string currentUrl = Browser.Source.ToString(); if (currentUrl.Contains(TestServerUrl)) { goto here; } if (currentUrl == LoginPageUrl || currentUrl == LoginFailedUrl) { _navigationCount = 0; return; } if (currentUrl.Contains(CourseTimetablePreviewUrl) == false) { _currentPage = 1; if (_browsingToCourseTimetablePreview == false) { if (_navigationCount < NavigationCountUpperLimit) { Browser.Navigate(CourseTimetablePreviewUrl); _navigationCount++; } else { Browser.Navigate(LoginPageUrl); Global.Snackbar.MessageQueue.Enqueue("No record found, please try again."); } } return; } here: string html = GetHtml(Browser); if (Global.Toggles.SaveLoadedHtmlToggle.IsToggledOn) { SaveToFile(html); } var bg = CustomBackgroundWorker <string, List <Slot> > .RunAndShowLoadingScreen( new HtmlSlotParser().Parse, html, "Loading slots . . ."); // TryGetStartDateAndEndDate(plainText); Global.InputSlotList.AddRange(bg.GetResult()); if (CanGoToPage(_currentPage + 1)) { Browser.InvokeScript("changePage", _currentPage + 1); _currentPage++; } else { if (Global.InputSlotList.Count == 0) { DialogBox.Show("No data available.", "", "OK"); if (DialogBox.Result == DialogBox.ResultEnum.RightButtonClicked) { LoadTestDataButton_OnClick(null, null); } return; } NavigationService.Navigate( Page_CreateTimetable.GetInstance(Global.Settings.SearchByConsideringWeekNumber, Global.Settings.GeneralizeSlot)); } }