public static void UpdateStats(ScriptStat stat)
 {
     if (!_stats.ContainsKey(stat.Script))
     {
         _stats.Add(stat.Script, stat);
     }
     else
     {
         _stats[stat.Script] = stat;
     }
 }
 public static void UpdateStats(ScriptStat stat)
 {
     if (!_stats.ContainsKey(stat.Script))
     {
         _stats.Add(stat.Script, stat);
     }
     else
     {
         _stats[stat.Script] = stat;
     }
 }
        public static ScriptStat InitScriptStat(ScriptConfigElement e)
        {
            ScriptStat ss;

            if (_stats.ContainsKey(e.PathToScript))
            {
                ss = _stats[e.PathToScript];
            }
            else
            {
                ss = new ScriptStat();
                ss.Script = e.PathToScript;
                ss.Type = e.Type;
            }

            return ss;
        }
        public static ScriptStat InitScriptStat(ScriptConfigElement e)
        {
            ScriptStat ss;

            if (_stats.ContainsKey(e.PathToScript))
            {
                ss = _stats[e.PathToScript];
            }
            else
            {
                ss        = new ScriptStat();
                ss.Script = e.PathToScript;
                ss.Type   = e.Type;
            }

            return(ss);
        }
        public void ProcessScripts()
        {
            PSRunnerSection psRunnerSection =
                ConfigurationManager.GetSection("PSRunner") as PSRunnerSection;

            if (psRunnerSection == null)
            {
                throw new ApplicationException("Failed to load PSRunnerSection.");
            }
            else
            {
                for (int i = 0; i < psRunnerSection.Scripts.Count; i++)
                {
                    var scriptElement = psRunnerSection.Scripts[i];
                    if (File.Exists(scriptElement.PathToScript))
                    {
                        ScriptStat ss = StatService.InitScriptStat(psRunnerSection.Scripts[i]);

                        switch (ss.Type)
                        {
                        case "LOOP":
                            ExecuteScript(scriptElement);
                            break;

                        case "COUNT":
                            if (ss.Count < scriptElement.Count)
                            {
                                ExecuteScript(scriptElement);
                            }
                            break;

                        case "SCHEDULED":
                            throw new NotImplementedException();
                            break;
                        }

                        ss.Count   = ss.Count + 1;
                        ss.LastRan = DateTime.Now;
                        StatService.UpdateStats(ss);
                    }
                }
            }
        }