Пример #1
0
 protected override void OnStop()
 {
     lg("Service Stop requested");
     for (int i = 0; i < alModules.Count; i++)
     {
         try
         {
             AbstractFOGService genericModule = (AbstractFOGService)alModules[i];
             genericModule.mStop();
         }
         catch
         {
         }
     }
 }
Пример #2
0
        /*
         * Checks if we should run the setup wizard.
         */
        private void startAllSubProcesses()
        {
            if (loadIniFile())
            {
                lg("FOG Service Engine Version: " + VERSION);
                lg("Starting all sub processes");
                if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory))
                {
                    String[] files = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory);
                    for (int i = 0; i < files.Length; i++)
                    {
                        if (files[i].EndsWith(".dll"))
                        {
                            try
                            {
                                byte[]   buffer = File.ReadAllBytes(files[i]);
                                Assembly assemb = Assembly.Load(buffer);
                                if (assemb != null)
                                {
                                    Type[] type = assemb.GetTypes();
                                    for (int z = 0; z < type.Length; z++)
                                    {
                                        if (type[z] != null)
                                        {
                                            try
                                            {
                                                Object   module    = Activator.CreateInstance(type[z]);
                                                Assembly abstractA = Assembly.LoadFrom(AppDomain.CurrentDomain.BaseDirectory + @"AbstractFOGService.dll");
                                                Type     t         = abstractA.GetTypes()[0];

                                                if (module.GetType().IsSubclassOf(t))
                                                {
                                                    alModules.Add(module);
                                                }
                                            }
                                            catch
                                            {
                                            }
                                        }
                                    }
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                    lg(alModules.Count + " modules loaded");

                    if (alModules.Count > 0)
                    {
                        for (int i = 0; i < alModules.Count; i++)
                        {
                            try
                            {
                                AbstractFOGService genericModule = (AbstractFOGService)alModules[i];
                                genericModule.setINIReader(ini);
                                lg(" * Starting " + genericModule.GetType().FullName);
                                Thread tmp = new Thread(genericModule.mStart);
                                tmp.Priority     = ThreadPriority.AboveNormal;
                                tmp.IsBackground = true;
                                tmp.Start();
                                alThreads.Add(tmp);
                            }
                            catch (Exception ex)
                            {
                                lg(ex.Message);
                                lg(ex.StackTrace);
                                lg(ex.InnerException.ToString());
                                lg(ex.ToString());
                            }
                        }
                    }
                }
                else
                {
                    lg("Module directory not found");
                }
            }
            else
            {
                lg("Unable to load settings");
            }
        }