private void DoDBCleanup(int logRetentionDays)
        {
            using (SQLiteConnection cn = new SQLiteConnection(SamayEngine.GetDBConnectionString()))
            {
                try
                {
                    cn.Open();
                    SQLiteCommand dCommand = new SQLiteCommand(@"DELETE FROM LOGS where TimeStamp < @LogRetentionDays", cn);

                    SQLiteParameter param = new SQLiteParameter("@LogRetentionDays", DateTime.Now.AddDays(logRetentionDays * -1).Date);
                    dCommand.Parameters.Add(param);

                    int count = dCommand.ExecuteNonQuery();

                    using (SQLiteCommand command = cn.CreateCommand())
                    {
                        command.CommandText = "vacuum;";
                        command.ExecuteNonQuery();
                    }

                    if (count > 0)
                    {
                        LogInfo("Logs Older than " + logRetentionDays + " Days Purged");
                    }
                }
                catch (Exception ex)
                {
                    LogError(ex.ToString());
                }
                finally
                {
                    cn.Close();
                }
            }
        }
Beispiel #2
0
        public void RunEngine()
        {
#if !DEBUG
            // System.Threading.Thread.Sleep(15000); //to attach when running inside service
#endif

            RunEngine(null, Config.GetSamayConfig(SamayEngine.GetDBConnectionString()));
        }
 public bool AddJob(string job, string comment)
 {
     return(Config.AddJob(job, comment, SamayEngine.GetDBConnectionString()));
 }
 public bool SaveSamayConfig(string config, string comment)
 {
     return(Config.SaveSamayConfig(JsonConvert.DeserializeObject <Engine>(config), comment, SamayEngine.GetDBConnectionString()));
 }
 public bool RemoveJob(string jobName, string comment)
 {
     return(Config.RemoveJob(jobName, comment, SamayEngine.GetDBConnectionString()));
 }
 public string GetSamayConfig()
 {
     return(JsonConvert.SerializeObject(Config.GetSamayConfig(SamayEngine.GetDBConnectionString()), Newtonsoft.Json.Formatting.Indented));
 }