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();
                }
            }
        }
示例#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()));
        }
示例#3
0
        protected override void OnStart(string[] args)
        {
            eventLog.WriteEntry("Samay Engine Service Started");

            base.OnStart(args);

            Technisient.SamayEngine     samayEngine = new SamayEngine();
            System.Threading.Tasks.Task t           = System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                samayEngine.RunEngine();
            }, TaskCreationOptions.LongRunning);
        }
 public bool AddJob(string job, string comment)
 {
     return(Config.AddJob(job, comment, SamayEngine.GetDBConnectionString()));
 }
 public void SafeStopEngine(string requester)
 {
     SamayLogger.LogInfo("Engine Stop initiated by " + requester, "Engine Stop", null, "Engine Stop");
     SamayEngine.SafeStopEngine();
 }
 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 void ReloadConfig(string requester)
 {
     SamayLogger.LogInfo("Engine Config Reload initiated by " + requester, "Engine Stop", null, "Engine Stop");
     SamayEngine.ReloadConfig();
 }
 public string GetSamayConfig()
 {
     return(JsonConvert.SerializeObject(Config.GetSamayConfig(SamayEngine.GetDBConnectionString()), Newtonsoft.Json.Formatting.Indented));
 }
 public DateTime GetEngineStartTime()
 {
     return(SamayEngine.EngineStartTime());
 }
示例#11
0
        static void Main(string[] args)
        {
            SamayEngine myEngine = new SamayEngine();

            myEngine.RunEngine();
        }