//============================================================================= /// <summary> /// Export to the dwg file using PRDApp.exe, PRD_Temp.dwt template and LayoutDrawing.dll. /// </summary> public bool CreateDWG() { DrawingDocument currDoc = this.CurrentDocument; if (currDoc == null) { return(false); } // ENQ number is neccessary for any kind of export. // Text document should have name like ENQ number. string textFileName = currDoc.CustomerENQ; if (string.IsNullOrEmpty(textFileName)) { return(false); } string strAppFolder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string strDefaultFolder = FileUtils.BuildDefaultDirectory(currDoc.CustomerENQ); bool result = false; try { // Check that ENQ number is correct as a filename. if (textFileName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0) { return(false); } // STEP 1. // Copy PRDApp.exe. string PRDApp_FilePath = strAppFolder + "\\Resources\\PRDApp.exe"; if (File.Exists(PRDApp_FilePath)) { string NewPRDApp_FilePath = strDefaultFolder + "\\PRDApp.exe"; File.Copy(PRDApp_FilePath, NewPRDApp_FilePath, true); if (File.Exists(NewPRDApp_FilePath)) { // STEP 2. // Copy LayoutDrawing.dll try { string LayoutDrawing_FilePath = strAppFolder + "\\Resources\\LayoutDrawing.dll"; if (File.Exists(LayoutDrawing_FilePath)) { string NewLayoutDrawing_FilePath = strDefaultFolder + "\\LayoutDrawing.dll"; File.Copy(LayoutDrawing_FilePath, NewLayoutDrawing_FilePath, true); if (File.Exists(NewLayoutDrawing_FilePath)) { // STEP 3. // Copy PRD_Temp.dwt try { string PRD_Temp_FilePath = strAppFolder + "\\Resources\\PRD_Temp.dwt"; if (File.Exists(PRD_Temp_FilePath)) { string NewPRD_Temp_FilePath = strDefaultFolder + "\\PRD_Temp.dwt"; File.Copy(PRD_Temp_FilePath, NewPRD_Temp_FilePath, true); if (File.Exists(NewPRD_Temp_FilePath)) { // STEP 3. // Export txt file in the same folder. string textFilePath = strDefaultFolder + "\\" + textFileName + ".txt"; if (currDoc.ExportToTxt(textFilePath)) { // STEP 4. // Run exe file. try { using (Process exeProcess = Process.Start(NewPRDApp_FilePath)) { exeProcess.WaitForExit(); result = true; } } catch { } } try { File.Delete(textFilePath); } catch { } // Delete copied "PRD_Temp.dwt" try { File.Delete(NewPRD_Temp_FilePath); } catch { } } } } catch { } // Delete copied "LayoutDrawing.dll" try { File.Delete(NewLayoutDrawing_FilePath); } catch { } } } } catch { } // Delete copied PRDApp.exe"" try { File.Delete(NewPRDApp_FilePath); } catch { } } } } catch { } return(result); }
//============================================================================= /// <summary> /// Export to the excel file using PRDBOM_App.exe, BOM_Temp.xlsx template abd "Master BOM.xlsx". /// </summary> public bool CreateBOM() { DrawingDocument currDoc = this.CurrentDocument; if (currDoc == null) { return(false); } // ENQ number is neccessary for any kind of export. // Text document should have name like ENQ number. string textFileName = currDoc.CustomerENQ; if (string.IsNullOrEmpty(textFileName)) { return(false); } string strAppFolder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string strDefaultFolder = FileUtils.BuildDefaultDirectory(currDoc.CustomerENQ); bool result = false; try { // Check that ENQ number is correct as a filename. if (textFileName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0) { return(false); } // STEP 1. // Copy PRDBOM_App.exe. string PRDBOM_App_FilePath = strAppFolder + "\\Resources\\PRDBOM_App.exe"; if (File.Exists(PRDBOM_App_FilePath)) { string NewPRDBOM_App_FilePath = strDefaultFolder + "\\PRDBOM_App.exe"; File.Copy(PRDBOM_App_FilePath, NewPRDBOM_App_FilePath, true); if (File.Exists(NewPRDBOM_App_FilePath)) { // STEP 2. // Copy BOM_Temp.slsx. try { string BOM_Temp_FilePath = strAppFolder + "\\Resources\\BOM_Temp.xlsx"; if (File.Exists(BOM_Temp_FilePath)) { string NewBOM_Temp_FilePath = strDefaultFolder + "\\BOM_Temp.xlsx"; File.Copy(BOM_Temp_FilePath, NewBOM_Temp_FilePath, true); if (File.Exists(NewBOM_Temp_FilePath)) { // MasterBOM excel file is not required. // Skype message 06.01.2020 // // STEP 3. // Copy "Master BOM.xlsx". try { //string masterBOMFilePath = strAppFolder + "\\Resources\\Master BOM.xlsx"; //if (File.Exists(masterBOMFilePath)) { //string strNewMasterBOMFilePath = strDefaultFolder + "\\Master BOM.xlsx"; //File.Copy(masterBOMFilePath, strNewMasterBOMFilePath, true); //if (File.Exists(strNewMasterBOMFilePath)) { // STEP 4. // Export txt file in the same folder. string textFilePath = strDefaultFolder + "\\" + textFileName + ".txt"; if (currDoc.ExportToTxt(textFilePath)) { // STEP 5. // Run exe file. try { using (Process exeProcess = Process.Start(NewPRDBOM_App_FilePath)) { exeProcess.WaitForExit(); result = true; } } catch { } } try { File.Delete(textFilePath); } catch { } } // Delete copied "Master BOM.xlsx" //try //{ // File.Delete(strNewMasterBOMFilePath); //} //catch { } } } catch { } // Delete copied "BOM_Temp.xlsx" try { File.Delete(NewBOM_Temp_FilePath); } catch { } } } } catch { } // Delete copied "PRDBOM_App.exe" try { File.Delete(NewPRDBOM_App_FilePath); } catch { } } } } catch { } return(result); }