private static void RunDatabaseMaintenace(object state)
 {
     ScheduledTaskFactory.log.Info((object)"Database maintenance task is starting.");
     try
     {
         Process.Start(Path.Combine(OrionConfiguration.get_InstallPath(), "Database-Maint.exe"), "-Archive");
         ScheduledTaskFactory.log.Info((object)"Database maintenace task started.");
         SettingsDAL.Set("SWNetPerfMon-Settings-Last Archive", DateTime.UtcNow.ToOADate());
     }
     catch (Exception ex)
     {
         ScheduledTaskFactory.log.Error((object)"Error while executing Database-Maint.exe.", ex);
     }
 }
        private void Process(IEnumerable <string> files)
        {
            IEnumerable <PluginsFactory <T> .AssemblyVersionInfo> assemblyVersionInfos = files.Select <string, PluginsFactory <T> .AssemblyVersionInfo>(new Func <string, PluginsFactory <T> .AssemblyVersionInfo>(PluginsFactory <T> .AssemblyVersionInfo.Create)).OrderByDescending <PluginsFactory <T> .AssemblyVersionInfo, PluginsFactory <T> .AssemblyVersionInfo>((Func <PluginsFactory <T> .AssemblyVersionInfo, PluginsFactory <T> .AssemblyVersionInfo>)(name => name)).Distinct <PluginsFactory <T> .AssemblyVersionInfo>();
            string basePath = Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory);
            Dictionary <string, FileInfo> dictionary = new DirectoryXmlFilePluginsProvider(OrionConfiguration.get_InstallPath()).ReadAreas().Where <PluginsArea>((Func <PluginsArea, bool>)(n => n.get_Name().Equals("BackgroundInventory"))).SelectMany <PluginsArea, Plugin>((Func <PluginsArea, IEnumerable <Plugin> >)(area => (IEnumerable <Plugin>)area.get_Plugins())).Select <Plugin, FileInfo>((Func <Plugin, FileInfo>)(plugin => new FileInfo(Path.Combine(basePath, plugin.get_AssemblyPath())))).Where <FileInfo>((Func <FileInfo, bool>)(info => info.Exists)).ToDictionary <FileInfo, string>((Func <FileInfo, string>)(info => info.Name), (IEqualityComparer <string>)StringComparer.OrdinalIgnoreCase);
            List <PluginsFactory <T> .AssemblyVersionInfo> assemblyVersionInfoList = new List <PluginsFactory <T> .AssemblyVersionInfo>();

            foreach (PluginsFactory <T> .AssemblyVersionInfo assemblyVersionInfo1 in assemblyVersionInfos)
            {
                PluginsFactory <T> .AssemblyVersionInfo assemblyVersionInfo2 = assemblyVersionInfo1;
                try
                {
                    FileInfo fileInfo;
                    if (dictionary.TryGetValue(assemblyVersionInfo2.FileInfo.Name, out fileInfo))
                    {
                        assemblyVersionInfo2 = new PluginsFactory <T> .AssemblyVersionInfo(fileInfo);
                    }
                    assemblyVersionInfoList.Add(assemblyVersionInfo2);
                }
                catch (Exception ex)
                {
                    PluginsFactory <T> .log.ErrorFormat("Failed to process {0} @ '{1}'. {2}", (object)assemblyVersionInfo2.AssemblyName, (object)assemblyVersionInfo2.FileInfo, (object)ex);
                }
            }
            ResolveEventHandler resolveEventHandler = new ResolveEventHandler(PluginsFactory <T> .CurrentDomain_ReflectionOnlyAssemblyResolve);

            AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += resolveEventHandler;
            try
            {
                foreach (PluginsFactory <T> .AssemblyVersionInfo assemblyVersionInfo in assemblyVersionInfoList)
                {
                    try
                    {
                        this.ProcessAssembly(assemblyVersionInfo.FileInfo.FullName);
                    }
                    catch (Exception ex)
                    {
                        PluginsFactory <T> .log.WarnFormat("Failed to initialize {0} @ '{1}'. {2}", (object)assemblyVersionInfo.AssemblyName, (object)assemblyVersionInfo.FileInfo, (object)ex);
                    }
                }
            }
            finally
            {
                AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve -= resolveEventHandler;
            }
        }
 public PluginsFactory()
     : this(OrionConfiguration.get_InstallPath(), "*.Pollers.dll", "*.Collector.dll", "*.Plugin.dll")
 {
 }