Пример #1
0
 public ApplicationHandler(ApplicationHandlerModel model)
 {
     HandledProcessName = model.ProcessName;
     RunTime = model.RunTime;
     switch (model.ApplicationStatus)
     {
         case "Green":
             HandlerStatus = AppHandlerStatus.Green;
             break;
         case "Yellow":
             HandlerStatus = AppHandlerStatus.Yellow;
             break;
         case "Red":
             HandlerStatus = AppHandlerStatus.Red;
             break;
         case "Allowed":
             HandlerStatus = AppHandlerStatus.Allowed;
             break;
         case "Ignored":
             HandlerStatus = AppHandlerStatus.Ignored;
             break;
         default:
             HandlerStatus = AppHandlerStatus.Working;
             break;
     }
     CycleDuration = 60 * 1; //1 minute by default
 }
Пример #2
0
 public IEnumerable<ApplicationHandlerModel> LoadHandlers()
 {
     _dbconnection.Open();
     var sql = "SELECT * FROM handlers";
     var command = new SQLiteCommand(sql, _dbconnection);
     var reader = command.ExecuteReader();
     var handlers = new List<ApplicationHandlerModel>();
     while (reader.Read())
     {
         var procname = (string)reader["process_name"];
         var appstatus = (string)reader["appstatus"];
         var totalSeconds = (long)reader["total_seconds"];
         var model = new ApplicationHandlerModel(procname, appstatus, totalSeconds);
         handlers.Add(model);
     }
     _dbconnection.Close();
     return handlers;
 }