Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        private void Save_As_Click(object sender, RoutedEventArgs e)
        {
            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
                };

                using (var diag = new System.Windows.Forms.SaveFileDialog())
                {
                    diag.SupportMultiDottedExtensions = true;
                    diag.FileOk      += CheckIfFileHasCorrectExtension;
                    diag.Filter       = FileDialogFilter;
                    diag.DefaultExt   = RecordFileExtension;
                    diag.AddExtension = true;

                    var result = diag.ShowDialog();

                    if (result == System.Windows.Forms.DialogResult.OK)
                    {
                        string destinationPathAndFileName = diag.FileName;
                        ZipArchiveHelper.ArchiveFiles(fullPathsOfFilesToCompress, destinationPathAndFileName);

                        OpenedFile = Path.GetFileName(diag.FileName);
                        UpdateStatus(false);
                    }
                }
            }
        }