private async void OnPlayScript() { ScriptPlaying = true; PlayScriptCommand.RaiseCanExecuteChanged(); //MessageBox.Show(String.Format("Playing {0}!", SelectedEventScriptFile.FileNameWithExtension)); EventParameterService eventParameterService = new EventParameterService(); ProgressBarSharedView progressBar = new ProgressBarSharedView("Downloading script from server..."); progressBar.Show(); //Backup current latest_test.js FileEndPointManager.WriteBackupFile(); string result = await eventParameterService.DownloadScriptFromServer(SelectedEvent.Id, SelectedEventScriptFile.ParentFolder); progressBar.Close(); if (result == string.Empty && _mainWindow != null) { await _mainWindow.Run(FileEndPointManager.DefaultPlayXMLFile); } else { MessageBox.Show(result, AppName, MessageBoxButton.OK, MessageBoxImage.Information); } //Restore latest_test.js FileEndPointManager.RestoreBackupFile(); ScriptPlaying = false; PlayScriptCommand.RaiseCanExecuteChanged(); }
public async void GetEventParameters(int eventId) { _progressBar = new ProgressBarSharedView("Loading Event Parameters..."); _progressBar.Show(); EventParameters = await _eventParameterService.GetEventParameters(eventId); _progressBar.Close(); }
//Get methods public async void GetEventTags() { _progressBar = new ProgressBarSharedView("Loading Events library..."); _progressBar.Show(); EventTags = await _eventTagService.GetEvents(); _progressBar.Close(); }
private async void OnUpload() { string headerFileName = Path.Combine(FileEndPointManager.Project2Folder, "header.json"); using (StreamWriter file = File.CreateText(headerFileName)) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, EventToAdd); } string recordJSDirectory = FileEndPointManager.DefaultPlayXMLFile; string recordXMLDirectory = FileEndPointManager.DefaultLatestXMLFile; if (!File.Exists(recordJSDirectory) || !File.Exists(recordXMLDirectory)) { //TODO: update this error message. MessageBox.Show("There are no record files to save. Please open an existing recording or make a new one.", AppName, MessageBoxButton.OK, MessageBoxImage.Error); } else { List <string> fullPathsOfFilesToCompress = new List <string> { recordJSDirectory, recordXMLDirectory, headerFileName }; string eventToUploadFileName = Path.Combine(FileEndPointManager.Project2Folder, EventToAdd.FileName + "." + RecordFileExtension); ZipArchiveHelper.ArchiveFiles(fullPathsOfFilesToCompress, eventToUploadFileName); EventTagService eventTagService = new EventTagService(); _progressBar = new ProgressBarSharedView("Uploading file. Please wait..."); _progressBar.Show(); var result = await eventTagService.CreateEvent(eventToUploadFileName); _progressBar.Close(); MessageBox.Show(result, AppName, MessageBoxButton.OK, MessageBoxImage.Information); File.Delete(eventToUploadFileName); } }