///<summary></summary> public void FormDocInfo_Load(object sender, System.EventArgs e) { //if (Docs.Cur.FileName.Equals(null)) listCategory.Items.Clear(); for (int i = 0; i < DefB.Short[(int)DefCat.ImageCats].Length; i++) { string folderName = DefB.Short[(int)DefCat.ImageCats][i].ItemName; listCategory.Items.Add(folderName); if (i == 0 || DefB.Short[(int)DefCat.ImageCats][i].DefNum == DocCur.DocCategory || folderName == initialSelection) { listCategory.SelectedIndex = i; } } listType.Items.Clear(); listType.Items.AddRange(Enum.GetNames(typeof(ImageType))); listType.SelectedIndex = (int)DocCur.ImgType; textToothNumbers.Text = Tooth.FormatRangeForDisplay(DocCur.ToothNumbers); textDate.Text = DocCur.DateCreated.ToString("d"); textDescript.Text = DocCur.Description; //When the A to Z folders are disabled, the image module is disabled and this //code will never get called. Thus, by the time this point in the code is reached, //there will be a valid image path. textFileName.Text = ODFileUtils.CombinePaths(new string[] { FormPath.GetPreferredImagePath(), PatCur.ImageFolder.Substring(0, 1).ToUpper(), PatCur.ImageFolder, DocCur.FileName }); if (File.Exists(textFileName.Text)) { FileInfo fileInfo = new FileInfo(textFileName.Text); textSize.Text = fileInfo.Length.ToString("n0"); } textToothNumbers.Text = Tooth.FormatRangeForDisplay(DocCur.ToothNumbers); //textNote.Text=DocCur.Note; }
private void butEditPaths_Click(object sender, System.EventArgs e) { FormPath FormP = new FormPath(); FormP.ShowDialog(); mergePath = PrefB.GetString("LetterMergePath"); textPath.Text = mergePath; }
/* * private void CheckClaimForm() { * butDownloadClaimform.Enabled=false; * textResultClaimform.Text=""; * if(textRegClaimform.Text.Length==0) { * return; * } * string remoteUri=textWebsitePath.Text+textRegClaimform.Text+"/"; * string fileName="Manifest.txt"; * WebClient myWebClient=new WebClient(); * string myStringWebResource=remoteUri+fileName; * string description; * try { * using(StreamReader sr=new StreamReader(myWebClient.OpenRead(myStringWebResource))) { * description=sr.ReadLine(); * BackgroundImg=sr.ReadLine(); * OldClaimFormID=sr.ReadLine(); * } * } * catch { * textResultClaimform.Text+=Lan.g(this,"Registration number not valid, or internet connection failed."); * return; * } * if(BackgroundImg==null) { * BackgroundImg=""; * } * if(OldClaimFormID==null) { * OldClaimFormID=""; * } * textResultClaimform.Text+=description; * butDownloadClaimform.Enabled=true; * }*/ private void butDownload_Click(object sender, System.EventArgs e) { string patchName = "Setup.exe"; string destDir = FormPath.GetPreferredImagePath(); if (destDir == null) //Not using A to Z folders? { destDir = Path.GetTempPath(); } DownloadInstallPatchFromURI(textWebsitePath.Text + textRegMain.Text + "/" + patchName, //Source URI ODFileUtils.CombinePaths(destDir, patchName)); //Local destination file. }
private void butAttach_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Multiselect = true; Patient PatCur = Patients.GetPat(MessageCur.PatNum); if (PatCur.ImageFolder != "") { if (PrefB.UsingAtoZfolder) { dlg.InitialDirectory = ODFileUtils.CombinePaths(new string[] { FormPath.GetPreferredImagePath(), PatCur.ImageFolder.Substring(0, 1).ToUpper(), PatCur.ImageFolder }); } else { //Use the OS default directory for this type of file viewer. dlg.InitialDirectory = ""; } } if (dlg.ShowDialog() != DialogResult.OK) { return; } Random rnd = new Random(); string newName; EmailAttach attach; string attachPath = GetAttachPath(); if (!Directory.Exists(attachPath)) { Directory.CreateDirectory(attachPath); } try{ for (int i = 0; i < dlg.FileNames.Length; i++) { //copy the file newName = DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.TimeOfDay.Ticks.ToString() + rnd.Next(1000).ToString(); File.Copy(dlg.FileNames[i], ODFileUtils.CombinePaths(attachPath, newName)); //create the attachment attach = new EmailAttach(); attach.DisplayedFileName = Path.GetFileName(dlg.FileNames[i]); attach.ActualFileName = newName; MessageCur.Attachments.Add(attach); } } catch (Exception ex) { MessageBox.Show(ex.Message); } FillAttachments(); }
private string GetAttachPath() { string attachPath; if (PrefB.UsingAtoZfolder) { attachPath = ODFileUtils.CombinePaths(FormPath.GetPreferredImagePath(), @"EmailAttachments"); } else { //For users which have the A to Z folders disabled, there is no defined image path, so we //have to use another path. Since we have chosen the temporary directory, this means that //email attachements for a particular email may or may not be viewable later (i.e. in case //someone cleaned out their temporary files to conserve disk space). attachPath = Path.GetTempPath(); } return(attachPath); }
private void butStationary_Click(object sender, EventArgs e) { if (PrefB.GetString("StationaryDocument") == "") { MsgBox.Show(this, "You must setup your stationary document and word processor path in Setup | Misc"); return; } Cursor = Cursors.AppStarting; PtLetter_ToClipboard(); try { this.Cursor = Cursors.AppStarting; string patFolder = ODFileUtils.CombinePaths( FormPath.GetPreferredImagePath(), PatCur.ImageFolder.Substring(0, 1), PatCur.ImageFolder); //string ProgName = @"C:\Program Files\OpenOffice.org 2.0\program\swriter.exe"; //string ProgName = PrefB.GetString("WordProcessorPath"); string TheFile = ODFileUtils.CombinePaths(patFolder, "Letter_" + DateTime.Now.ToFileTime() + ".doc"); try{ File.Copy( ODFileUtils.CombinePaths(FormPath.GetPreferredImagePath(), PrefB.GetString("StationaryDocument")), TheFile); DialogResult = DialogResult.OK; } catch { } try { Process.Start(TheFile); } catch { } this.Cursor = Cursors.Default; Commlog CommlogCur = new Commlog(); CommlogCur.CommDateTime = DateTime.Now; CommlogCur.CommType = Commlogs.GetTypeAuto(CommItemTypeAuto.MISC); CommlogCur.PatNum = PatCur.PatNum; CommlogCur.Note = Lan.g(this, "Letter sent: See Images for this date."); Commlogs.Insert(CommlogCur); } catch { Cursor = Cursors.Default; MsgBox.Show(this, "Cannot find stationary document. Or another problem exists."); } }
///<summary>Returns false if it can't complete a conversion, find datapath, or validate registration key.</summary> private bool PrefsStartup() { Cache.Refresh(InvalidType.Prefs); if(!PrefL.CheckMySqlVersion()){ return false; } if(DataConnection.DBtype==DatabaseType.MySql) { try { MiscData.SetSqlMode(); } catch { MessageBox.Show("Unable to set global sql mode. User probably does not have enough permission."); return false; } string updateComputerName=PrefC.GetStringSilent(PrefName.UpdateInProgressOnComputerName); if(updateComputerName != "" && Environment.MachineName != updateComputerName) { DialogResult result=MessageBox.Show("An update is in progress on "+updateComputerName+". Not allowed to start up until that update is complete.\r\n\r\nIf you are the person who started the update and you wish to override this message because an update is not in progress, click Retry.\r\n\r\nDo not click Retry unless you started the update.", "",MessageBoxButtons.RetryCancel); if(result==DialogResult.Retry) { Prefs.UpdateString(PrefName.UpdateInProgressOnComputerName,""); MsgBox.Show(this,"You will be allowed access when you restart."); } return false; } } //if RemotingRole.ClientWeb, version will have already been checked at login, so no danger here. //ClientWeb version can be older than this version, but that will be caught in a moment. if(!PrefL.ConvertDB()){ return false; } PrefL.MySqlVersion55Remind(); if(PrefC.UsingAtoZfolder) { string prefImagePath=ImageStore.GetPreferredAtoZpath(); if(prefImagePath==null || !Directory.Exists(prefImagePath)) {//AtoZ folder not found Cache.Refresh(InvalidType.Security); FormPath FormP=new FormPath(); FormP.IsStartingUp=true; FormP.ShowDialog(); if(FormP.DialogResult!=DialogResult.OK) { MsgBox.Show(this,"Invalid A to Z path. Closing program."); Application.Exit(); return false; } //bool usingAtoZ=FormPath.UsingImagePath(); //ContrImages2.Enabled=usingAtoZ; //menuItemClaimForms.Visible=usingAtoZ; //CheckCustomReports(); //this.RefreshCurrentModule(); Cache.Refresh(InvalidType.Prefs);//because listening thread not started yet. } } if(!PrefL.CheckProgramVersion()){ return false; } if(!FormRegistrationKey.ValidateKey(PrefC.GetString(PrefName.RegistrationKey))){ //true){ FormRegistrationKey FormR=new FormRegistrationKey(); FormR.ShowDialog(); if(FormR.DialogResult!=DialogResult.OK){ Application.Exit(); return false; } Cache.Refresh(InvalidType.Prefs); } Lans.RefreshCache();//automatically skips if current culture is en-US LanguageForeigns.Refresh(CultureInfo.CurrentCulture.Name,CultureInfo.CurrentCulture.TwoLetterISOLanguageName);//automatically skips if current culture is en-US //menuItemMergeDatabases.Visible=PrefC.GetBool(PrefName.RandomPrimaryKeys"); return true; }
private void menuItemDataPath_Click(object sender, System.EventArgs e) { //security is handled from within the form. FormPath FormP=new FormPath(); FormP.ShowDialog(); ContrImages2.Enabled=PrefC.UsingAtoZfolder; //menuItemClaimForms.Visible=PrefC.UsingAtoZfolder; CheckCustomReports(); this.RefreshCurrentModule(); SecurityLogs.MakeLogEntry(Permissions.Setup,0,"Data Path"); }
private void menuItemDataPath_Click(object sender, System.EventArgs e) { //security is handled from within the form. FormPath FormP=new FormPath(); FormP.ShowDialog(); CheckCustomReports(); this.RefreshCurrentModule(); SecurityLogs.MakeLogEntry(Permissions.Setup,0,"Data Path"); }
///<summary>Returns false if it can't complete a conversion, find datapath, or validate registration key.</summary> private bool PrefsStartup(bool isSilentUpdate){ try { Cache.Refresh(InvalidType.Prefs); } catch(Exception ex) { if(isSilentUpdate) { ExitCode=100;//Database could not be accessed for cache refresh Application.Exit(); return false; } MessageBox.Show(ex.Message); return false;//shuts program down. } if(!PrefL.CheckMySqlVersion(isSilentUpdate)){ return false; } if(DataConnection.DBtype==DatabaseType.MySql) { try { MiscData.SetSqlMode(); } catch { if(isSilentUpdate) { ExitCode=111;//Global SQL mode could not be set Application.Exit(); return false; } MessageBox.Show("Unable to set global sql mode. User probably does not have enough permission."); return false; } string updateComputerName=PrefC.GetStringSilent(PrefName.UpdateInProgressOnComputerName); if(updateComputerName != "" && Environment.MachineName != updateComputerName) { if(isSilentUpdate) { ExitCode=120;//Computer trying to access DB during update Application.Exit(); return false; } DialogResult result=MessageBox.Show("An update is in progress on "+updateComputerName+". Not allowed to start up until that update is complete.\r\n\r\nIf you are the person who started the update and you wish to override this message because an update is not in progress, click Retry.\r\n\r\nDo not click Retry unless you started the update.", "",MessageBoxButtons.RetryCancel); if(result==DialogResult.Retry) { Prefs.UpdateString(PrefName.UpdateInProgressOnComputerName,""); MsgBox.Show(this,"You will be allowed access when you restart."); } return false; } } //if RemotingRole.ClientWeb, version will have already been checked at login, so no danger here. //ClientWeb version can be older than this version, but that will be caught in a moment. if(isSilentUpdate) { if(!PrefL.ConvertDB(true,Application.ProductVersion)) {//refreshes Prefs if converted successfully. if(ExitCode==0) {//Unknown error occurred ExitCode=200;//Convert Database has failed during execution (Unknown Error) } Application.Exit(); return false; } } else { if(!PrefL.ConvertDB()) {//refreshes Prefs if converted successfully. return false; } } if(!isSilentUpdate) { PrefL.MySqlVersion55Remind(); } if(PrefC.AtoZfolderUsed) { string prefImagePath=ImageStore.GetPreferredAtoZpath(); if(prefImagePath==null || !Directory.Exists(prefImagePath)) {//AtoZ folder not found if(isSilentUpdate) { ExitCode=300;//AtoZ folder not found (Warning) Application.Exit(); return false; } Cache.Refresh(InvalidType.Security); FormPath FormP=new FormPath(); FormP.IsStartingUp=true; FormP.ShowDialog(); if(FormP.DialogResult!=DialogResult.OK) { MsgBox.Show(this,"Invalid A to Z path. Closing program."); Application.Exit(); return false; } Cache.Refresh(InvalidType.Prefs);//because listening thread not started yet. } } if(!PrefL.CheckProgramVersion(isSilentUpdate)){ return false; } if(!FormRegistrationKey.ValidateKey(PrefC.GetString(PrefName.RegistrationKey))){ if(isSilentUpdate) { ExitCode=311;//Registration Key could not be validated Application.Exit(); return false; } FormRegistrationKey FormR=new FormRegistrationKey(); FormR.ShowDialog(); if(FormR.DialogResult!=DialogResult.OK){ Application.Exit(); return false; } Cache.Refresh(InvalidType.Prefs); } //This must be done at startup in case the user does not perform any action to save something to temp file. //This will cause slowdown, but only for the first week. if(DateTime.Today<PrefC.GetDate(PrefName.TempFolderDateFirstCleaned).AddDays(7)) { PrefL.GetTempFolderPath();//We don't care about the return value. Just trying to trigger the one-time cleanup and create the temp/opendental directory. } Lans.RefreshCache();//automatically skips if current culture is en-US LanguageForeigns.Refresh(CultureInfo.CurrentCulture.Name,CultureInfo.CurrentCulture.TwoLetterISOLanguageName);//automatically skips if current culture is en-US //menuItemMergeDatabases.Visible=PrefC.GetBool(PrefName.RandomPrimaryKeys"); return true; }
private void butEditPaths_Click(object sender, System.EventArgs e) { FormPath FormP=new FormPath(); FormP.ShowDialog(); mergePath=PrefC.GetString(PrefName.LetterMergePath); textPath.Text=mergePath; }
///<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); }