Example #1
0
        private void Import_Json_OnClick(object sender, RoutedEventArgs e)
        {
            var browser = new OpenFileDialog
            {
                Multiselect = false,
                Filter      = "json files (*.json)|*.json|All files (*.*)|*.*"
            };

            // show browser
            browser.ShowDialog();

            var fileName = browser.FileName;

            try {
                //Load CSV into Mainwindow
                if (AccProjectConfig.LoadBim360Projectsfromjson(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!";
                }
            }
            catch (Exception ex)
            {
                statusbar.Text = "Fail to Load: " + ex.Message;
            }
        }