private bool InstallDotNetPackage() { bool ok = true; string processFilePath = System.IO.Path.Combine(AppHomeFolder.Trim(), "DOTNET", "dotNetFx40_Full_setup.exe"); if (File.Exists(processFilePath.Trim())) { try { // Use ProcessStartInfo class System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.CreateNoWindow = false; startInfo.UseShellExecute = false; startInfo.FileName = processFilePath; startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; //startInfo.Arguments = "-f j -o \"" + ex1 + "\" -z 1.0 -s y " + ex2; //using (System.Diagnostics.Process exeProcess = System.Diagnostics.Process.Start(startInfo)) using (System.Diagnostics.Process exeProcess = System.Diagnostics.Process.Start(processFilePath)) { exeProcess.WaitForExit(); } } catch (Exception ex) { ok = false; } } return(ok); }
public void InitEnvironmentTest() { List <AppHomeFolder.CreationResults> v_BootStrapResult = StandardFileBootstrapper.BootstrapWrapper(); bool v_IsCreatedOrCopied = true; foreach (AppHomeFolder.CreationResults i_Result in v_BootStrapResult) { v_IsCreatedOrCopied &= i_Result == AppHomeFolder.CreationResults.Exists || i_Result == AppHomeFolder.CreationResults.Copied; } Assert.IsTrue(v_IsCreatedOrCopied); m_Logger = LogManager.GetLogger("AppHomeFolderTests"); // First delete all files and dirs from earlier test run (if there are any). if (Directory.Exists(m_TestFilePath)) { Directory.Delete(m_TestFilePath, true); Console.WriteLine("DOES exist. " + m_TestFilePath); } else { Console.WriteLine("Does NOT exist."); } // First call creates the directory. AppHomeFolder.CreationResults v_Result = AppHomeFolder.TestAndCreateHomeFolder(m_TestFilePath); Assert.AreEqual(AppHomeFolder.CreationResults.Created, v_Result); // Second call reports existing directory. v_Result = AppHomeFolder.TestAndCreateHomeFolder(m_TestFilePath); Assert.AreEqual(AppHomeFolder.CreationResults.Exists, v_Result); m_Logger.Debug(VersionWrapper.NameExecuting); List <String> v_FilesToCopy = new List <string>() { "log4netConfig" }; // Copy the file to the empty folder. List <AppHomeFolder.CreationResults> v_ResultsFromResourceCopy = AppHomeFolder.CopyStaticResources(v_FilesToCopy, m_TestFilePath); Assert.AreEqual(new List <AppHomeFolder.CreationResults>() { AppHomeFolder.CreationResults.Copied }, v_ResultsFromResourceCopy); // Calling the same again will tell us that the file was already there. v_ResultsFromResourceCopy = AppHomeFolder.CopyStaticResources(v_FilesToCopy, m_TestFilePath); Assert.AreEqual(new List <AppHomeFolder.CreationResults>() { AppHomeFolder.CreationResults.Exists }, v_ResultsFromResourceCopy); // Files which don't exist will report an error. v_ResultsFromResourceCopy = AppHomeFolder.CopyStaticResources(new List <string>() { "invalidFileName.txt", "log4netConfig", "i3.txt" }, m_TestFilePath); Assert.AreEqual(new List <AppHomeFolder.CreationResults>() { AppHomeFolder.CreationResults.Error, AppHomeFolder.CreationResults.Exists, AppHomeFolder.CreationResults.Error }, v_ResultsFromResourceCopy); Directory.Delete(m_TestFilePath, true); }
private bool CopyPTSInstallationFiles() { bool ok = true; string sourceFolder = AppHomeFolder.Trim(); string destinationFolder = System.IO.Path.Combine(WindowsHomeFolder, "Rigaku", "PTS"); if (Directory.Exists(destinationFolder)) { // PTS files string[] filePaths = Directory.GetFiles(System.IO.Path.Combine(sourceFolder, "PTS")); foreach (string file in filePaths) { FileInfo info = new FileInfo(file); if (File.Exists(info.FullName)) { string fileName = Path.GetFileName(info.FullName); if (!string.IsNullOrEmpty(fileName)) { try { File.Copy(info.FullName, System.IO.Path.Combine(destinationFolder, fileName), true); } catch (Exception ex) { string strMsg = string.Format("{0}", ex.Message.ToString()); MessageBox.Show(strMsg, "Important Message"); return(false); } } } } // copy DLL filePaths = Directory.GetFiles(System.IO.Path.Combine(sourceFolder, "DLL")); foreach (string file in filePaths) { FileInfo info = new FileInfo(file); if (File.Exists(info.FullName)) { string fileName = Path.GetFileName(info.FullName); if (!string.IsNullOrEmpty(fileName)) { try { File.Copy(info.FullName, System.IO.Path.Combine(destinationFolder, fileName), true); } catch (Exception ex) { string strMsg = string.Format("{0}", ex.Message.ToString()); MessageBox.Show(strMsg, "Important Message"); return(false); } } } } // copy ICON filePaths = Directory.GetFiles(System.IO.Path.Combine(sourceFolder, "ICON")); foreach (string file in filePaths) { FileInfo info = new FileInfo(file); if (File.Exists(info.FullName)) { string fileName = Path.GetFileName(info.FullName); if (!string.IsNullOrEmpty(fileName)) { try { File.Copy(info.FullName, System.IO.Path.Combine(destinationFolder, fileName), true); } catch (Exception ex) { string strMsg = string.Format("{0}", ex.Message.ToString()); MessageBox.Show(strMsg, "Important Message"); return(false); } } } } // copy IMAGE filePaths = Directory.GetFiles(System.IO.Path.Combine(sourceFolder, "IMAGE")); foreach (string file in filePaths) { FileInfo info = new FileInfo(file); if (File.Exists(info.FullName)) { string fileName = Path.GetFileName(info.FullName); if (!string.IsNullOrEmpty(fileName)) { try { File.Copy(info.FullName, System.IO.Path.Combine(destinationFolder, fileName), true); } catch (Exception ex) { string strMsg = string.Format("{0}", ex.Message.ToString()); MessageBox.Show(strMsg, "Important Message"); return(false); } } } } // copy RUN trigger files filePaths = Directory.GetFiles(System.IO.Path.Combine(sourceFolder, "RUN", "shm", "comm")); string CopyToFolder = System.IO.Path.Combine(destinationFolder, "run", "shm", "comm"); foreach (string file in filePaths) { FileInfo info = new FileInfo(file); if (File.Exists(info.FullName)) { string fileName = Path.GetFileName(info.FullName); if (!string.IsNullOrEmpty(fileName)) { try { File.Copy(info.FullName, System.IO.Path.Combine(CopyToFolder, fileName), true); } catch (Exception ex) { string strMsg = string.Format("{0}", ex.Message.ToString()); MessageBox.Show(strMsg, "Important Message"); return(false); } } } } // copy RUN trigger files filePaths = Directory.GetFiles(System.IO.Path.Combine(sourceFolder, "RUN", "shm", "comm_archives")); CopyToFolder = System.IO.Path.Combine(destinationFolder, "run", "shm", "comm_archives"); foreach (string file in filePaths) { FileInfo info = new FileInfo(file); if (File.Exists(info.FullName)) { string fileName = Path.GetFileName(info.FullName); if (!string.IsNullOrEmpty(fileName)) { try { File.Copy(info.FullName, System.IO.Path.Combine(CopyToFolder, fileName), true); } catch (Exception ex) { string strMsg = string.Format("{0}", ex.Message.ToString()); MessageBox.Show(strMsg, "Important Message"); return(false); } } } } // create PTS desktop shurtcut appShortcutToDesktop("PTS"); } return(ok); }