private void Import_OnClick(object sender, RoutedEventArgs e) { //Folderbrowser var dialog = new CommonOpenFileDialog(); dialog.IsFolderPicker = false; dialog.Multiselect = false; //if use canceled the selection if (Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Cancel == dialog.ShowDialog()) { statusbar.Text = "canceled"; return; } //Load CSV into Mainwindow if (AccProjectConfig.LoadBim360Projects(dialog.FileName)) { statusbar.Text = "Import successful!"; using (FileStream fs = File.OpenWrite(path_last)) { using (var sr = new StreamWriter(fs)) { //Delete the content of the file sr.Write(string.Empty); sr.WriteLine(dialog.FileName); } } } else { statusbar.Text = "Import failed! Unknown CSV Config or File not found!"; } }
/// <summary> /// provides a user dialog to load a csv file /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Import_OnClick(object sender, RoutedEventArgs e) { var browser = new OpenFileDialog { Multiselect = false, Filter = "csv files (*.csv)|*.csv|All files (*.*)|*.*" }; // show browser browser.ShowDialog(); var fileName = browser.FileName; //Load CSV into Mainwindow if (AccProjectConfig.LoadBim360Projects(fileName)) { statusbar.Text = "Import successful!"; using (FileStream fs = File.OpenWrite(path_last)) { using (var sr = new StreamWriter(fs)) { //Delete the content of the file sr.Write(string.Empty); sr.WriteLine(fileName); } } } else { statusbar.Text = "Import failed! Unknown CSV Config or File not found!"; } }
//UserManagement private void MainWindow_OnInitialized(object?sender, EventArgs e) { string csvpath = null; //create history if (!File.Exists(path_last)) { //Create Directory and File for the Config Directory.CreateDirectory(path_last.Remove(path_last.LastIndexOf("\\"))); var tmp = File.Create(path_last); tmp.Close(); } else { using (FileStream fs = File.OpenRead(path_last)) { using (var sr = new StreamReader(fs)) { //Delete the content of the file csvpath = sr.ReadLine(); } } try { AccProjectConfig.LoadBim360Projects(csvpath); } catch (Exception) { } } var ConfigFilePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Bim360Interface\Config\config.txt";; //Get Last Config from Login Data if (File.Exists(ConfigFilePath)) { using (FileStream fs = File.OpenRead(ConfigFilePath)) { using (StreamReader reader = new StreamReader(fs)) { ClientId = reader.ReadLine(); ClientSecret = reader.ReadLine(); BimId = reader.ReadLine(); AdminMail = reader.ReadLine(); } } } }