/// <summary> /// Add additional language /// </summary> public override void SetAdditionalLanguage() { DentneDModel dentnedModel = new DentneDModel(); dentnedModel.LanguageHelper.LoadFromFile(Program.uighfApplication.LanguageFilename); LanguageHelper.AddAdditionalLanguage(dentnedModel.LanguageHelper.Get()); }
public DentneDHelpersTest() { Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); _dentnedModel = new DentneDModel(); tmpdir = ConfigurationManager.AppSettings["tmpdir"]; }
/// <summary> /// Load handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FormMain_Load(object sender, EventArgs e) { //perform the first connection try { DentneDModel dentnedModel = new DentneDModel(); dentnedModel.Doctors.Find(-1); } catch { MessageBox.Show("Database connection error. This application will be closed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } //clean temporary folder if (Convert.ToBoolean(ConfigurationManager.AppSettings["cleanTmpdirAtStartup"])) { string[] messages = new string[] { }; string[] errors = new string[] { }; try { CleanDir.CleanTmpdir(ConfigurationManager.AppSettings["tmpdir"], false, -4, ref messages, ref errors); } catch { } } //set startup size try { Match sizeOnStartup = Regex.Match(ConfigurationManager.AppSettings["sizeOnStartup"], @"^(?<w>\d*)x(?<h>\d*)(?<m>M*)$"); if (sizeOnStartup.Success) { int width = Convert.ToInt16(sizeOnStartup.Groups[1].Value); int height = Convert.ToInt16(sizeOnStartup.Groups[2].Value); if (width > Screen.PrimaryScreen.WorkingArea.Width) { width = Screen.PrimaryScreen.WorkingArea.Width - 5; } if (height > Screen.PrimaryScreen.WorkingArea.Height) { height = Screen.PrimaryScreen.WorkingArea.Height - 5; } this.Size = new Size(width, height); this.CenterToScreen(); if (!String.IsNullOrEmpty(sizeOnStartup.Groups[3].Value)) { this.WindowState = FormWindowState.Maximized; } } } catch { } //set AdvancedDataGridView translations AdvancedDataGridView.SetTranslations(AdvancedDataGridView.LoadTranslationsFromFile(Program.uighfApplication.LanguageFilename)); AdvancedDataGridViewSearchToolBar.SetTranslations(AdvancedDataGridViewSearchToolBar.LoadTranslationsFromFile(Program.uighfApplication.LanguageFilename)); }
/// <summary> /// Constructor /// </summary> public FormPatientsAttachmentsTypes() { InitializeComponent(); (new TabOrderManager(this)).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst); Initialize(Program.uighfApplication); _dentnedModel = new DentneDModel(); _dentnedModel.LanguageHelper.LoadFromFile(Program.uighfApplication.LanguageFilename); }
/// <summary> /// Add additional language /// </summary> public override void SetAdditionalLanguage() { //set models languages DentneDModel dentnedModel = new DentneDModel(); dentnedModel.LanguageHelper.LoadFromFile(Program.uighfApplication.LanguageFilename); LanguageHelper.AddAdditionalLanguage(dentnedModel.LanguageHelper.Get()); //set AdvancedDataGridView languages LanguageHelper.AddAdditionalLanguage(AdvancedDataGridView.LoadTranslationsFromFile(Program.uighfApplication.LanguageFilename)); LanguageHelper.AddAdditionalLanguage(AdvancedDataGridViewSearchToolBar.LoadTranslationsFromFile(Program.uighfApplication.LanguageFilename)); }
/// <summary> /// Delete sub folders without patients attached /// </summary> /// <param name="folder"></param> /// <param name="doSecureDelete"></param> /// <param name="messages"></param> /// <param name="errors"></param> public static void CleanPatientDir(string folder, bool doSecureDelete, ref string[] messages, ref string[] errors) { messages = new string[] { }; errors = new string[] { }; DentneDModel dentnedModel = new DentneDModel(); DirectoryInfo directoryInfo = new DirectoryInfo(folder); DirectoryInfo[] subDirectoriesInfo = directoryInfo.GetDirectories(); //clean files foreach (FileInfo file in directoryInfo.GetFiles()) { FileHelper.DeleteFile(file.FullName, doSecureDelete); } //clean folder foreach (DirectoryInfo subDirectoryInfo in subDirectoriesInfo) { int patients_id = -1; try { patients_id = Convert.ToInt32(subDirectoryInfo.Name); } catch { } bool deleteFolder = false; if (patients_id != -1) { //check if folder patient exists if (dentnedModel.Patients.Find(patients_id) == null) { deleteFolder = true; } } else { deleteFolder = true; } if (deleteFolder) { FileHelper.DeleteFolder(subDirectoryInfo.FullName, doSecureDelete); if (!Directory.Exists(subDirectoryInfo.FullName)) { messages = messages.Concat(new string[] { String.Format("Folder \"{0}\" does not have any patient attached, it was deleted successfully.", subDirectoryInfo.FullName) }).ToArray(); } else { errors = errors.Concat(new string[] { String.Format("Error: Can not delete folder \"{0}\".", subDirectoryInfo.FullName) }).ToArray(); } } } }
/// <summary> /// Constructor /// </summary> public FormComputedLines() { InitializeComponent(); (new TabOrderManager(this)).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst); Initialize(Program.uighfApplication); _dentnedModel = new DentneDModel(); _dentnedModel.LanguageHelper.LoadFromFile(Program.uighfApplication.LanguageFilename); _boxLoader = new BoxLoader(_dentnedModel); }
public PopulateTestDatabase() { _dentnedModel = new DentneDModel(); using (var context = (DbContext)Activator.CreateInstance(_dentnedModel.ContextType, _dentnedModel.ContextParameters)) { _connectionString = context.Database.Connection.ConnectionString.ToString(); } _patientsDatadir = ConfigurationManager.AppSettings["patientsDatadir"]; _patientsAttachmentsdir = ConfigurationManager.AppSettings["patientsAttachmentsdir"]; _patientsNum = Convert.ToInt16(ConfigurationManager.AppSettings["patientsNum"]); }
/// <summary> /// Constructor /// </summary> public FormReportsrun() { InitializeComponent(); (new TabOrderManager(this)).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst); Initialize(Program.uighfApplication); _dentnedModel = new DentneDModel(); _dentnedModel.LanguageHelper.LoadFromFile(Program.uighfApplication.LanguageFilename); _boxLoader = new BoxLoader(_dentnedModel); //get the connection string using (var context = (DbContext)Activator.CreateInstance(_dentnedModel.ContextType, _dentnedModel.ContextParameters)) { _sqlConnection.ConnectionString = context.Database.Connection.ConnectionString; } }
/// <summary> /// main service worker /// </summary> public ServiceWorker() { //set current working directory and load logger files Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)); if (File.Exists("Config.log4net")) { log4net.Config.XmlConfigurator.Configure(new FileInfo("Config.log4net")); } else { throw new Exception("Can not load log4net configuration file."); } log = log4net.LogManager.GetLogger("MainLogger"); //start message log.Info("Service is starting..."); //load main configuration file ExeConfigurationFileMap configMap = new ExeConfigurationFileMap(); #if DEBUG if (File.Exists("DentneD.exe.config")) { configMap.ExeConfigFilename = "DentneD.exe.config"; } else { if (File.Exists("..\\..\\..\\DentneD\\bin\\Debug\\DentneD.exe.config")) { configMap.ExeConfigFilename = "..\\..\\..\\DentneD\\bin\\Debug\\DentneD.exe.config"; } else { throw new Exception("Can not load configuration file."); } } #else if (File.Exists("DentneD.exe.config")) { configMap.ExeConfigFilename = "DentneD.exe.config"; } else { throw new Exception("Can not load configuration file."); } #endif Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None); //set if run at startup enabled #if DEBUG runactions = true; #endif //load folder preferences tmpdir = config.AppSettings.Settings["tmpdir"].Value; patientsDatadir = config.AppSettings.Settings["patientsDatadir"].Value; patientsAttachmentsdir = config.AppSettings.Settings["patientsAttachmentsdir"].Value; doSecureDelete = Convert.ToBoolean(config.AppSettings.Settings["doSecureDelete"].Value); //load mailer preferences mailerSMTPhost = config.AppSettings.Settings["mailerSMTPhost"].Value; mailerSMTPport = Convert.ToInt16(config.AppSettings.Settings["mailerSMTPport"].Value); mailerSMTPfrom = config.AppSettings.Settings["mailerSMTPfrom"].Value; mailerSMTPusername = config.AppSettings.Settings["mailerSMTPusername"].Value; mailerSMTPpassword = config.AppSettings.Settings["mailerSMTPpassword"].Value; mailerSMTPenablessl = Convert.ToBoolean(config.AppSettings.Settings["mailerSMTPenablessl"].Value); //set mailer _mailer = new Mailer(mailerSMTPhost, mailerSMTPport, mailerSMTPfrom, mailerSMTPusername, mailerSMTPpassword, mailerSMTPenablessl); //load language if (!String.IsNullOrEmpty(languageFolder + "\\" + LanguageFilenamePrefix + config.AppSettings.Settings["language"].Value + ".json")) { try { string jsontext = null; #if DEBUG if (File.Exists(languageFolder + "\\" + LanguageFilenamePrefix + config.AppSettings.Settings["language"].Value + ".json")) { jsontext = File.ReadAllText(languageFolder + "\\" + LanguageFilenamePrefix + config.AppSettings.Settings["language"].Value + ".json"); } else { if (File.Exists("..\\..\\..\\DentneD\\bin\\Debug\\" + languageFolder + "\\" + LanguageFilenamePrefix + config.AppSettings.Settings["language"].Value + ".json")) { jsontext = File.ReadAllText("..\\..\\..\\DentneD\\bin\\Debug\\" + languageFolder + "\\" + LanguageFilenamePrefix + config.AppSettings.Settings["language"].Value + ".json"); } } #else if (File.Exists(languageFolder + "\\" + LanguageFilenamePrefix + config.AppSettings.Settings["language"].Value + ".json")) { jsontext = File.ReadAllText(languageFolder + "\\" + LanguageFilenamePrefix + config.AppSettings.Settings["language"].Value + ".json"); } #endif language = new JavaScriptSerializer().Deserialize <DentneDSerLanguage>(jsontext); } catch { } } //load data model _dentnedModel = new DentneDModel(); _dentnedModel.LanguageHelper.LoadFromFile(languageFolder + "\\" + language + ".json"); //load services runner paramenters SendAppointmentsReminderLoad(); PurgeAppointmentsLoad(); CleanTmpdirLoad(); CleanDataDirLoad(); }
public DentneDModelTest() { Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory); _dentnedModel = new DentneDModel(); }
public BoxLoader(DentneDModel dentnedModel) { this._dentnedModel = dentnedModel; }
/// <summary> /// Delete sub folders without patients attachment attached /// </summary> /// <param name="folder"></param> /// <param name="doSecureDelete"></param> /// <param name="messages"></param> /// <param name="errors"></param> public static void CleanPatientAttachmentsDir(string folder, bool doSecureDelete, ref string[] messages, ref string[] errors) { messages = new string[] { }; errors = new string[] { }; DentneDModel dentnedModel = new DentneDModel(); DirectoryInfo directoryInfo = new DirectoryInfo(folder); DirectoryInfo[] subDirectoriesInfo = directoryInfo.GetDirectories(); //clean files foreach (FileInfo file in directoryInfo.GetFiles()) { FileHelper.DeleteFile(file.FullName, doSecureDelete); } //clean folder foreach (DirectoryInfo subDirectoryInfo in subDirectoriesInfo) { int patients_id = -1; try { patients_id = Convert.ToInt32(subDirectoryInfo.Name); } catch { } bool deleteFolder = false; if (patients_id != -1) { //check if folder patient exists if (dentnedModel.Patients.Find(patients_id) == null) { deleteFolder = true; } } else { deleteFolder = true; } if (deleteFolder) { FileHelper.DeleteFolder(subDirectoryInfo.FullName, doSecureDelete); if (!Directory.Exists(subDirectoryInfo.FullName)) { messages = messages.Concat(new string[] { String.Format("Folder \"{0}\" does not have any patient attached, it was deleted successfully.", subDirectoryInfo.FullName) }).ToArray(); } else { errors = errors.Concat(new string[] { String.Format("Error: Can not delete folder \"{0}\".", subDirectoryInfo.FullName) }).ToArray(); } } else { //check attachments DirectoryInfo sdirectoryInfo = new DirectoryInfo(subDirectoryInfo.FullName); DirectoryInfo[] subsDirectoriesInfo = sdirectoryInfo.GetDirectories(); foreach (DirectoryInfo subsDirectoryInfo in subsDirectoriesInfo) { FileHelper.DeleteFolder(subsDirectoryInfo.FullName, doSecureDelete); if (!Directory.Exists(subsDirectoryInfo.FullName)) { messages = messages.Concat(new string[] { String.Format("Folder \"{0}\" does not have any attachment binded, it was deleted successfully.", subsDirectoryInfo.FullName) }).ToArray(); } else { errors = errors.Concat(new string[] { String.Format("Error: Can not delete folder \"{0}\".", subsDirectoryInfo.FullName) }).ToArray(); } } //clean attachments if needed foreach (FileInfo file in sdirectoryInfo.GetFiles()) { if (!dentnedModel.PatientsAttachments.Any(r => r.patients_id == patients_id && r.patientsattachments_filename == file.Name)) { FileHelper.DeleteFile(file.FullName, doSecureDelete); if (!File.Exists(file.FullName)) { messages = messages.Concat(new string[] { String.Format("File \"{0}\" does not belong to any patient attachment, it was deleted successfully.", file.FullName) }).ToArray(); } else { errors = errors.Concat(new string[] { String.Format("Error: Can not delete file \"{0}\".", file.FullName) }).ToArray(); } } } //check if folder is empty if (subDirectoryInfo.GetDirectories().Count() == 0 && subDirectoryInfo.GetFiles().Count() == 0) { FileHelper.DeleteFolder(subDirectoryInfo.FullName, doSecureDelete); if (!Directory.Exists(subDirectoryInfo.FullName)) { messages = messages.Concat(new string[] { String.Format("Folder \"{0}\" is empty, it was deleted successfully.", subDirectoryInfo.FullName) }).ToArray(); } else { errors = errors.Concat(new string[] { String.Format("Error: Can not delete empty folder \"{0}\".", subDirectoryInfo.FullName) }).ToArray(); } } } } }