/// <summary> /// Loops over databases and performs welfare checks on sites /// </summary> private void MonitorSites() { string[] databases = LocalData.GetAllDatabases(); // Loop over all databases for (int i = 0; i < databases.Length; ++i) { SiteWelfareData welfare = new SiteWelfareData(databases[i]); welfare.Run(); System.Threading.Thread.Sleep(100); } }
/// <summary> /// /// </summary> private void MonitorLoops() { string[] databases = LocalData.GetAllDatabases(); // Loop over all databases for (int i = 0; i < databases.Length; ++i) { SiteLoop loop = new SiteLoop(databases[i]); loop.Run(); System.Threading.Thread.Sleep(100); } }
/// <summary> /// Runs through the databases a single time and emails all outstanding tasks /// </summary> public void MonitorTasks() { // Get a list of all databases (schemas) to search through string[] databases = LocalData.GetAllDatabases(); // Loop over them for (int i = 0; i < databases.Length; ++i) { // Search for any pending tasks in each database data = new Data(databases[i]); // Get all pending tasks int[] tasks = data.GetPendingScheduledTasks(); // Loop over all tasks foreach (int taskId in tasks) { // Process the task this.ProcessTask(data, taskId); System.Threading.Thread.Sleep(1000); } } }
/// <summary> /// This is the main method of this class, it monitors the incoming emails from /// EXPORTEMAIL. The Uploader software on client machines will email export files. /// </summary> private void MonitorPop3() { string dbName = null; string[] databases = LocalData.GetAllDatabases(); bool match; try { MailMessage[] messages = GetEmails(); foreach (MailMessage message in messages) { // Start match as false match = false; // Check if subject contains database string string[] subjectArray = message.Subject.Split(' '); foreach (string str in subjectArray) { foreach (string db in databases) { if (db.ToLower() == str.ToLower()) { match = true; dbName = db; } } } // Get the message itself if (match) { MailMessage msg = GetMessage(message.Uid); // Get attachments int attachmentCount = msg.Attachments.Count; foreach (Attachment attachment in msg.Attachments) { string saveDir = ImportPath + dbName + @"\"; string savePath = saveDir + attachment.Filename; // Create directory if it does not exist DirectoryInfo dir = new DirectoryInfo(saveDir); if (!dir.Exists) { dir.Create(); } attachment.Save(savePath); } // Delete message DeleteMessage(msg.Uid); } } } catch (Exception ex) { Log.Error("Email Monitoring Error: " + ex.Message); } }