private List <Photo> Photos(List <IFormFile> files) { DirectoryManagement dm = new DirectoryManagement(); List <Photo> photos = new List <Photo>(); foreach (var file in files) { if (file.Length > 0 && file != null) { var path = dm.GetFolderPath(); var fileName = FileNameManipulator.GenerateName(); var fullPath = Path.Combine(path, fileName); var fileType = Path.GetExtension(file.FileName); photos.Add(new Photo() { ImageType = fileType, PhotoDir = fullPath }); using (var str = new FileStream(fullPath + fileType, FileMode.Create)) { file.CopyTo(str); } } } return(photos); }
/// <summary> /// When the save button is clicked, saves the changes to the settings and closes the window. /// </summary> /// <param name="sender">Automatically generated by Visual Studio.</param> /// <param name="e">Automatically generated by Visual Studio.</param> private void SaveButton_Click(object sender, EventArgs e) { DirectoryManagement.AudioFolder = audioFolderTextBox.Text; DirectoryManagement.RecordingFolder = recordingFolderTextBox.Text; DirectoryManagement.ScoreboardReportFolder = reportFolderTextBox.Text; DirectoryManagement.HTKFolder = HTKFolderTextBox.Text; DirectoryManagement.WritePaths(); Close(); }
/// <summary> /// Fires when the form closes. /// If the user pressed the back button, the next form will be loaded. /// If the user closed the form in some other way, the app will temrinate. /// </summary> /// <param name="sender">Automatically generated by Visual Studio.</param> /// <param name="e">Automatically generated by Visual Studio.</param> private void AudioPlayer_FormClosing(object sender, FormClosingEventArgs e) { if (appClosing) { UserManagement.WriteSettings(); DirectoryManagement.WritePaths(); Application.Exit(); } }
/// <summary> /// Fires when the form closes. /// If the user pressed the back button, the next form will be loaded. /// If the user closed the form in some other way, the app will temrinate. /// </summary> /// <param name="sender">Automatically generated by Visual Studio.</param> /// <param name="e">Automatically generated by Visual Studio.</param> private void MPAiSoundMainMenu_FormClosing(object sender, FormClosingEventArgs e) { if (appClosing) { UserManagement.WriteSettings(); DirectoryManagement.WritePaths(); Application.Exit(); } }
/// <summary> /// When the save button is clicked, saves the changes to the settings and closes the window. /// </summary> /// <param name="sender">Automatically generated by Visual Studio.</param> /// <param name="e">Automatically generated by Visual Studio.</param> private void SaveButton_Click(object sender, EventArgs e) { DirectoryManagement.VideoFolder = videoFolderTextBox.Text; DirectoryManagement.ScoreboardReportFolder = reportFolderTextBox.Text; DirectoryManagement.FormantFolder = formantFolderTextBox.Text; DirectoryManagement.RecordingFolder = recordingFolderTextBox.Text; DirectoryManagement.WritePaths(); Close(); }
/// <summary> /// Fires when the form closes. /// If the user pressed the back button, the next form will be loaded. /// If the user closed the form in some other way, the app will temrinate. /// </summary> /// <param name="sender">Automatically generated by Visual Studio.</param> /// <param name="e">Automatically generated by Visual Studio.</param> private void SpeechRecognitionTest_FormClosing(object sender, FormClosingEventArgs e) { StopPlay(); // The audio player runs threads in the background. To prevent them running after the form closes, call stop on close. if (appClosing) { UserManagement.WriteSettings(); DirectoryManagement.WritePaths(); Application.Exit(); } }
/// <summary> /// Populate all configurations /// </summary> private static void PopulateConfigurations() { // make sure that necessary folders are created. DirectoryManagement.CreateFolders(); // Populate the App Config and Test Config ConfigurationManager.GetDefaultInstance(); // based on customer feedback, we will set default selection mode to Element // when AccessibilityInsights starts up. ConfigurationManager.GetDefaultInstance().AppConfig.IsUnderElementScope = true; // enable/disable telemetry Logger.IsTelemetryAllowed = ConfigurationManager.GetDefaultInstance().AppConfig.EnableTelemetry; }
/// <summary> /// Populate all configurations /// </summary> private static void PopulateConfigurations() { // make sure that necessary folders are created. DirectoryManagement.CreateFolders(); // Populate the App Config and Test Config ConfigurationManager.GetDefaultInstance(); // based on customer feedback, we will set default selection mode to Element // when AccessibilityInsights starts up. ConfigurationManager.GetDefaultInstance().AppConfig.IsUnderElementScope = true; // Configure the correct ReleaseChannel for autoupdate Container.SetAutoUpdateReleaseChannel(ConfigurationManager.GetDefaultInstance().AppConfig.ReleaseChannel.ToString()); // enable/disable telemetry if (ConfigurationManager.GetDefaultInstance().AppConfig.EnableTelemetry) { TelemetryController.EnableTelemetry(); } }
/// <summary> /// Saves any changes made when the form is closed. /// </summary> /// <param name="sender">Automatically generated by Visual Studio.</param> /// <param name="e">Automatically generated by Visual Studio.</param> private void LoginScreen_FormClosing(object sender, FormClosingEventArgs e) { if (!(PlotController.getCurrentPlotProcess() == null)) { //Kills any persistent Processes. try { //PlotController.getCurrentPlotProcess().Kill(); //PlotController.getCurrentPlotProcess().WaitForExit(); //PlotController.getCurrentPlotProcess().Dispose(); } catch (Exception exp) { Console.WriteLine(exp.StackTrace); } } foreach (var process in Process.GetProcessesByName("MPAiVowelRunner")) { if (process == null) { process.Kill(); process.WaitForExit(); process.Dispose(); } } foreach (var process in Process.GetProcessesByName("MPAiPlotRunner")) { if (process == null) { process.Kill(); process.WaitForExit(); process.Dispose(); } } UserManagement.WriteSettings(); DirectoryManagement.WritePaths(); }
/// <summary> /// Handles actions to take during the time when the splash screen is visible. /// </summary> /// <param name="sender">Automaitcally generated by Visual Studio.</param> /// <param name="e">Automaitcally generated by Visual Studio.</param> private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { // NOTE: Put any time-consuming tasks that only need to be done once on startup (such as file I/O) here. // They will be done while the splash screen is up. InitializeDB(); //Set the default folders to where the application is currently running. DirectoryManagement.Initialise(); // Kill any erroneous processes that may be running. int currentPID = Process.GetCurrentProcess().Id; foreach (Process p in Process.GetProcessesByName("MPAi")) { if (!(p.Id == currentPID)) { p.Kill(); p.WaitForExit(); p.Dispose(); } } }
/// <summary> /// Saves any changes made when the form is closed. /// </summary> /// <param name="sender">Automatically generated by Visual Studio.</param> /// <param name="e">Automatically generated by Visual Studio.</param> private void LoginScreen_FormClosing(object sender, FormClosingEventArgs e) { UserManagement.WriteSettings(); DirectoryManagement.WritePaths(); }
public async Task <Process> Update() { // Backup the data folder string dataPath = ServerPath.GetServersServerFiles(_serverData.ServerID, "data"); string tempPath = ServerPath.GetServers(_serverData.ServerID, "__temp"); bool needBackup = Directory.Exists(dataPath); if (needBackup) { if (Directory.Exists(tempPath)) { if (!await DirectoryManagement.DeleteAsync(tempPath, true)) { Error = "Fail to delete the temp folder"; return(null); } } if (!await Task.Run(() => { try { Microsoft.VisualBasic.FileIO.FileSystem.CopyDirectory(dataPath, tempPath); return(true); } catch (Exception e) { Error = e.Message; return(false); } })) { return(null); } } // Delete the serverfiles folder if (!await DirectoryManagement.DeleteAsync(ServerPath.GetServersServerFiles(_serverData.ServerID), true)) { Error = "Fail to delete the serverfiles"; return(null); } // Recreate the serverfiles folder Directory.CreateDirectory(ServerPath.GetServersServerFiles(_serverData.ServerID)); if (needBackup) { // Restore the data folder if (!await Task.Run(() => { try { Microsoft.VisualBasic.FileIO.FileSystem.CopyDirectory(tempPath, dataPath); return(true); } catch (Exception e) { Error = e.Message; return(false); } })) { return(null); } await DirectoryManagement.DeleteAsync(tempPath, true); } // Update the server by install again await Install(); // Return is valid if (IsInstallValid()) { return(null); } Error = "Update fail"; return(null); }