///<summary>Write the given text to the given file. ///If using a WEB compiled version of Open Dental, pass through to the odcloud client for File IO.</summary> public static void WriteAllText(string filePath, string text) { if (ODBuild.IsWeb()) { ODCloudClient.LaunchFileWithODCloudClient(extraFilePath: filePath, extraFileData: text); } else { File.WriteAllText(filePath, text); } }
///<summary>Writes the text to the user's clipboard.</summary> public static void SetClipboard(string text) { if (ODBuild.IsWeb()) { ODCloudClient.SendDataToBrowser(text, (int)ODCloudClient.BrowserAction.SetClipboard); } else { Clipboard.SetText(text); } }
///<summary>Write the given text to the given file, then start a new process with the given path. ///If using a WEB compiled version of Open Dental, pass through to the odcloud client for File IO and to start the process locally.</summary> public static Process WriteAllTextThenStart(string filePath, string fileText, string processPath, string commandLineArgs) { if (ODBuild.IsWeb()) { ODCloudClient.LaunchFileWithODCloudClient(processPath, commandLineArgs, filePath, fileText); return(null); } else { File.WriteAllText(filePath, fileText); return(Process.Start(processPath, commandLineArgs)); } }
///<summary>Write the given text to the given file, then start a new process with the given path. ///If using a WEB compiled version of Open Dental, pass through to the odcloud client for File IO and to start the process locally.</summary> public static Process WriteAllTextThenStart(string filePath, string fileText, Encoding encoding, string processPath, string commandLineArgs) { if (ODBuild.IsWeb()) { //Purposefully omit encoding. This can be an enhancement if needed. ODCloudClient.LaunchFileWithODCloudClient(processPath, commandLineArgs, filePath, fileText); return(null); } else { File.WriteAllText(filePath, fileText, encoding); return(Process.Start(processPath, commandLineArgs)); } }
///<summary>Start a new process with the given path and arguments. ///If using a WEB compiled version of Open Dental, pass through to the odcloud client to start the process locally.</summary> ///<param name="doWaitForODCloudClientResponse">If true, will wait for ODCloudClient and throw any exceptions from it.</param> ///<param name="createDirIfNeeded">If included, will create the directory if it doesn't exist.</param> public static Process ProcessStart(string path, string commandLineArgs = "", bool doWaitForODCloudClientResponse = false, string createDirIfNeeded = "") { if (ODBuild.IsWeb()) { ODCloudClient.LaunchFileWithODCloudClient(path, commandLineArgs, doWaitForResponse: doWaitForODCloudClientResponse, createDirIfNeeded: createDirIfNeeded); return(null); } if (!string.IsNullOrEmpty(createDirIfNeeded) && !Directory.Exists(createDirIfNeeded)) { Directory.CreateDirectory(createDirIfNeeded); } return(Process.Start(path, commandLineArgs)); }
///<summary>Write the given filebytes and launches a file.</summary> ///<param name="filePath">The location to write the bytes to.</param> ///<param name="fileBytes">The bytes to write to the file.</param> ///<param name="processPath">The path of the file to launch.</param> ///<param name="commandLineArgs">Command line arguments to pass to processPath.</param> public static Process WriteAllBytesThenStart(string filePath, byte[] fileBytes, string processPath, string commandLineArgs) { if (ODBuild.IsWeb()) { string byteString = Convert.ToBase64String(fileBytes); ODCloudClient.LaunchFileWithODCloudClient(processPath, commandLineArgs, filePath, byteString, "binary"); return(null); } else { File.WriteAllBytes(filePath, fileBytes); if (!string.IsNullOrEmpty(processPath)) { return(Process.Start(processPath, commandLineArgs)); } return(Process.Start(filePath, commandLineArgs)); } }