private void butOK_Click(object sender, System.EventArgs e) { if (!Directory.Exists(textLocation.Text)) { MsgBox.Show(this, "Location does not exist."); return; } if (Directory.Exists(ODFileUtils.CombinePaths(textLocation.Text, textName.Text))) { MsgBox.Show(this, "Folder already exists."); return; } try { FileSystemAccessRule fsar = new FileSystemAccessRule("everyone", FileSystemRights.FullControl, AccessControlType.Allow); DirectorySecurity ds = new DirectorySecurity(); ds.AddAccessRule(fsar); string requestDir = textLocation.Text; string rootFolderName = textName.Text; string rootDir = ODFileUtils.CombinePaths(requestDir, rootFolderName); //Enable file sharing for the A to Z folder. if (Environment.OSVersion.Platform == PlatformID.Unix) { //Process.Start("net","usershare add OpenDentImages \""+rootDir+"\"");//for future use. } else //Windows { Process.Start("NET", "SHARE OpenDentImages=\"" + rootDir + "\""); } //All folder names to be created should be put in this list, so that each folder is created exactly //the same way. string[] aToZFolderNames = new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "EmailAttachments", "Forms", "Reports", "Sounds", }; //Create A to Z folders in root folder. for (int i = 0; i < aToZFolderNames.Length; i++) { string pathToCreate = ODFileUtils.CombinePaths(rootDir, aToZFolderNames[i]); if (!Directory.Exists(pathToCreate)) { // Mono does support Directory.CreateDirectory(string, DirectorySecurity) #if !LINUX Directory.CreateDirectory(pathToCreate, ds); #else Directory.CreateDirectory(pathToCreate); #endif } } //Save new image path into the DocPath and //set "use A to Z folders" check-box to checked. Prefs.UpdateString("DocPath", rootDir); Prefs.UpdateString("AtoZfolderNotRequired", "0"); Prefs.Refresh(); } catch (Exception ex) { Logger.openlog.LogMB("Failed to create A to Z folders: " + ex.ToString(), Logger.Severity.ERROR); } DialogResult = DialogResult.OK; }
///<summary>Called in two places. Once from RefreshLocalData, and also from FormBackups after a restore.</summary> public static bool CheckProgramVersion() { Version storedVersion = new Version(PrefB.GetString("ProgramVersion")); Version currentVersion = new Version(Application.ProductVersion); string database = ""; string command = ""; if (FormChooseDatabase.DBtype == DatabaseType.MySql) { command = "SELECT database()"; DataTable table = General.GetTable(command); database = PIn.PString(table.Rows[0][0].ToString()); } if (storedVersion < currentVersion) { UpdateString("ProgramVersion", currentVersion.ToString()); Prefs.Refresh(); } if (storedVersion > currentVersion) { if (File.Exists(PrefB.GetString("DocPath") + "Setup.exe")) { if (MessageBox.Show("You are attempting to run version " + currentVersion.ToString(3) + ",\r\n" + "But the database " + database + "\r\n" + "is already using version " + storedVersion.ToString(3) + ".\r\n" + "A newer version must have already been installed on at least one computer.\r\n" + "The setup program stored in your A to Z folder will now be launched.\r\n" + "Or, if you hit Cancel, then you will have the option to download again." , "", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { if (MessageBox.Show("Download again?", "", MessageBoxButtons.OKCancel) == DialogResult.OK) { FormUpdate FormU = new FormUpdate(); FormU.ShowDialog(); } Application.Exit(); return(false); } try { Process.Start(PrefB.GetString("DocPath") + "Setup.exe"); } catch { MessageBox.Show("Could not launch Setup.exe"); } } else if (MessageBox.Show("A newer version has been installed on at least one computer, but Setup.exe could not be found in " + PrefB.GetString("DocPath") + ". Download again?", "", MessageBoxButtons.OKCancel) == DialogResult.OK) { FormUpdate FormU = new FormUpdate(); FormU.ShowDialog(); } Application.Exit(); //always exits, whether launch of setup worked or no return(false); } return(true); }
private void checkUseSearch_Click(object sender, System.EventArgs e) { Prefs.UpdateBool("PatientSelectUsesSearchButton", checkUseSearch.Checked); Prefs.Refresh(); //simply not important enough to send an update to the other computers. FillSearchOption(); if (!checkUseSearch.Checked) { FillGrid(); } }
private void checkIncludeRet_Click(object sender, System.EventArgs e) { Prefs.UpdateBool("LettersIncludeReturnAddress", checkIncludeRet.Checked); localChanged = true; Prefs.Refresh(); }
///<summary>Called in two places. Once from RefreshLocalData, and also from FormBackups after a restore.</summary> public static bool CheckProgramVersion() { Version storedVersion = new Version(PrefB.GetString("ProgramVersion")); Version currentVersion = new Version(Application.ProductVersion); string database = ""; string command = ""; if (FormChooseDatabase.DBtype == DatabaseType.MySql) { command = "SELECT database()"; DataTable table = General.GetTable(command); database = PIn.PString(table.Rows[0][0].ToString()); } if (storedVersion < currentVersion) { UpdateString("ProgramVersion", currentVersion.ToString()); Prefs.Refresh(); } if (storedVersion > currentVersion) { if (PrefB.UsingAtoZfolder) { string setupBinPath = ODFileUtils.CombinePaths(FormPath.GetPreferredImagePath(), "Setup.exe"); if (File.Exists(setupBinPath)) { if (MessageBox.Show("You are attempting to run version " + currentVersion.ToString(3) + ",\r\n" + "But the database " + database + "\r\n" + "is already using version " + storedVersion.ToString(3) + ".\r\n" + "A newer version must have already been installed on at least one computer.\r\n" + "The setup program stored in your A to Z folder will now be launched.\r\n" + "Or, if you hit Cancel, then you will have the option to download again." , "", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { if (MessageBox.Show("Download again?", "", MessageBoxButtons.OKCancel) == DialogResult.OK) { FormUpdate FormU = new FormUpdate(); FormU.ShowDialog(); } Application.Exit(); return(false); } try { Process.Start(setupBinPath); } catch { MessageBox.Show("Could not launch Setup.exe"); } } else if (MessageBox.Show("A newer version has been installed on at least one computer," + "but Setup.exe could not be found in any of the following paths: " + FormPath.GetPreferredImagePath() + ". Download again?", "", MessageBoxButtons.OKCancel) == DialogResult.OK) { FormUpdate FormU = new FormUpdate(); FormU.ShowDialog(); } } else //Not using image path. //perform program update automatically. { string patchName = "Setup.exe"; string updateUri = PrefB.GetString("UpdateWebsitePath"); string registrationCode = PrefB.GetString("RegistrationNumber"); string updateInfoMajor = ""; string updateInfoMinor = ""; if (FormUpdate.ShouldDownloadUpdate(updateUri, registrationCode, out updateInfoMajor, out updateInfoMinor)) { if (MessageBox.Show(updateInfoMajor + Lan.g("Prefs", "Perform program update now?"), "", MessageBoxButtons.YesNo) == DialogResult.Yes) { string tempFile = ODFileUtils.CombinePaths(Path.GetTempPath(), patchName); //Resort to a more common temp file name. FormUpdate.DownloadInstallPatchFromURI(updateUri + registrationCode + "/" + patchName, //Source URI tempFile); //Local destination file. File.Delete(tempFile); //Cleanup install file. } } } Application.Exit(); //always exits, whether launch of setup worked or not return(false); } return(true); }