//Method to start a process and pass commandline to the process for tracking private bool NWCProcess() { //Check if the program is installed string NWCTaskRunner = @"\FiletoolsTaskRunner.exe"; string NWCTaskRunnerProgram = NWC_ProgramPath + NWCTaskRunner; //string NWCFileListText = @"C:\Temp\NWC_FileList.txt"; //Build the arguments including the double quotes string NWC_quote = "\""; string NWCFileListText = FolderLocation + "\\NWC_Automator.txt"; //This didn't needed the double quotes string NWC_list = NWC_quote + NWCFileListText + NWC_quote; string NWC_NWF = NWC_quote + FolderLocation + "\\NWC_Automator.nwf" + NWC_quote; string NWC_log = NWC_quote + FolderLocation + "\\NWC_Automator.Log" + NWC_quote; string NWC_lang = " /lang en-US"; //string NWC_arguments = @" /i ""C:\Temp\NWC_FileList.txt"" /of ""C:\Temp\conference.nwf"" /log ""C:\Temp\events.log"" /lang fr-fr"; string NWC_arguments = " /i " + NWC_list + " /of " + NWC_NWF + " /log " + NWC_log + NWC_lang; //Process the TaskRunner try { //Write the text file before passing it to the arguments if (FileHandlingForRevitFiles.WriteTXT(MyFileNames, NWCFileListText)) { if (File.Exists(NWCTaskRunnerProgram) == true) { process_NWC.StartInfo.UseShellExecute = false; process_NWC.StartInfo.RedirectStandardOutput = true; process_NWC.StartInfo.RedirectStandardError = true; process_NWC.StartInfo.FileName = NWCTaskRunnerProgram; process_NWC.StartInfo.Arguments = NWC_arguments; process_NWC.EnableRaisingEvents = true; process_NWC.Exited += new EventHandler(process_Exited); process_NWC.Start(); StreamReader reader = process_NWC.StandardOutput; //StreamReader errors = process_NWC.StandardError; //string output = reader.ReadToEnd(); //string error = errors.ReadToEnd(); //Console.WriteLine(output); //MessageBox.Show(error); Application.Current.MainWindow.WindowState = WindowState.Minimized; process_NWC.WaitForExit(); process_NWC.Close(); } else { MessageBox.Show("The program doesn't exist. Please verify if Navisworks Manage 2015 is installed."); } } } catch (Exception ex) { Console.WriteLine("An error occured \"{0}\" :" + "\n" + ex.Message, NWCTaskRunnerProgram); return(false); } return(true); }
//Actual Command that should run private void _NWC_ProgramPath() { string _tempPath = FileHandlingForRevitFiles.GetFolderPath(); if (_tempPath != "") { NWC_ProgramPath = _tempPath; } }
//Actual Command that should run private void _SaveXMLFileList() { if (MyFileNames.ListRowItem.Count != 0) { MyFileNames.NavisworksPath = NWC_ProgramPath; //string filepath = @"myFileList.xml"; FileHandlingForRevitFiles.SerializeToXML(MyFileNames); FolderLocation = FileHandlingForRevitFiles.MasterFolderLocation; } }
//void Selected(object sender, RoutedEventArgs e) // { // ListView cmd = (ListView)sender; // string selectedItem = (string)(((System.Data.DataRowView)(cmd.SelectedItem)).Row[0]); // } #region FileRowProcessing public static ObservableCollection <UnitFileRow> FileRowProcessing() { ObservableCollection <UnitFileRow> _fileList = new ObservableCollection <UnitFileRow>(); foreach (string fileName in FileHandlingForRevitFiles.GetAllRevitFilesForProcessing()) { bool isSelected = true; string name = fileName; //string rename = "<Give a new name>"; string rename = Path.GetFileNameWithoutExtension(fileName); DateTime dateRan = DateTime.Now; //string rename = name.Split(name) _fileList.Add(new UnitFileRow(isSelected, name, rename, dateRan)); } return(_fileList); }
//Actual Command that should run private void _LoadXMLFileList() { // MyFileNames = DataProcessing.FileRowProcessing(); MyFileNames = FileHandlingForRevitFiles.DeserializeFromXML(MyFileNames); FolderLocation = FileHandlingForRevitFiles.MasterFolderLocation; NWC_ProgramPath = MyFileNames.NavisworksPath; List <string> missingFiles = new List <string>(); //check if the loaded files exists in the location foreach (UnitFileRow element in MyFileNames.ListRowItem) { if (!File.Exists(element.UnitFileName)) { missingFiles.Add(element.UnitFileName); } } if (missingFiles.Count > 0) { MessageBox.Show("The following files doesn't exists! \n" + String.Join("\n", missingFiles) + "\nUse Cleanup button to remove such files from the list.", "Missing File", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
//Actual Command that should run private void _LocateFolder() { FolderLocation = FileHandlingForRevitFiles.GetFolderPath(); }