Exemple #1
0
 public void AddBackend(IBackend backend, ISystemMetricsService systemMetrics, string name)
 {
     _log.InfoFormat("Adding backend {0} named '{1}'", backend.GetType().Name, name);
     _backends.Add(backend);
     _messageBroadcaster.LinkTo(backend);
     backend.Completion.LogAndContinueWith(name, () =>
     {
         if (_backends.All(q => !q.IsActive))
         {
             _shutdownComplete.Set();
         }
     });
     systemMetrics.LogCount("startup.backend." + name);
 }
Exemple #2
0
 public void AddBackend(IBackend backend, string name = "")
 {
     _log.InfoFormat("Adding backend {0} named '{1}'", backend.GetType().Name, name);
     _backends.Add(backend);
     SuperCheapIOC.Add(backend, name);
     _messageBroadcaster.LinkTo(backend);
     backend.Completion.LogAndContinueWith(_log, name, () =>
     {
         if (_backends.All(q => !q.IsActive))
         {
             _shutdownComplete.Set();
         }
     });
 }
Exemple #3
0
        /// <summary>
        /// Load all the available backends that Tasque can find.  First look in
        /// Tasque.exe and then for other DLLs in the same directory Tasque.ex
        /// resides.
        /// </summary>
        private void LoadAvailableBackends()
        {
            availableBackends = new Dictionary <string, IBackend> ();

            List <IBackend> backends = new List <IBackend> ();

            Assembly tasqueAssembly = Assembly.GetCallingAssembly();

            // Look for other backends in Tasque.exe
            backends.AddRange(GetBackendsFromAssembly(tasqueAssembly));

            // Look through the assemblies located in the same directory as
            // Tasque.exe.
            Logger.Debug("Tasque.exe location:  {0}", tasqueAssembly.Location);

            DirectoryInfo loadPathInfo =
                Directory.GetParent(tasqueAssembly.Location);

            Logger.Info("Searching for Backend DLLs in: {0}", loadPathInfo.FullName);

            foreach (FileInfo fileInfo in loadPathInfo.GetFiles("*.dll"))
            {
                Logger.Info("\tReading {0}", fileInfo.FullName);
                Assembly asm = null;
                try {
                    asm = Assembly.LoadFile(fileInfo.FullName);
                } catch (Exception e) {
                    Logger.Debug("Exception loading {0}: {1}",
                                 fileInfo.FullName,
                                 e.Message);
                    continue;
                }

                backends.AddRange(GetBackendsFromAssembly(asm));
            }

            foreach (IBackend backend in backends)
            {
                string typeId = backend.GetType().ToString();
                if (availableBackends.ContainsKey(typeId))
                {
                    continue;
                }

                Logger.Debug("Storing '{0}' = '{1}'", typeId, backend.Name);
                availableBackends [typeId] = backend;
            }
        }
Exemple #4
0
 public void AddBackend(IBackend backend, ISystemMetricsService systemMetrics, string name)
 {
     _log.InfoFormat("Adding backend {0} named '{1}'", backend.GetType().Name, name);
     _backends.Add(backend);
     _messageBroadcaster.LinkTo(backend);
     backend.Completion.LogAndContinueWith(_log, name, () =>
       {
           if (_backends.All(q => !q.IsActive))
           {
               _shutdownComplete.Set();
           }
       });
     systemMetrics.LogCount("startup.backend." + name);
 }
Exemple #5
0
        private void OnBackendComboBoxChanged(object sender, EventArgs args)
        {
            if (selectedBackend >= 0)
            {
                // TODO: Prompt the user and make sure they really want to change
                // which backend they are using.

                // Remove the existing backend's preference page
                if (backendPageId >= 0)
                {
                    notebook.RemovePage(backendPageId);
                    backendPageId = -1;
                    backendPage   = null;
                }

                // if yes (replace backend)
                if (backendComboMap.ContainsKey(selectedBackend))
                {
                    // Cleanup old backend
                    IBackend oldBackend = backendComboMap [selectedBackend];
                    Logger.Info("Cleaning up '{0}'...", oldBackend.Name);
                    try {
                        oldBackend.Cleanup();
                    } catch (Exception e) {
                        Logger.Warn("Exception cleaning up '{0}': {2}",
                                    oldBackend.Name,
                                    e.Message);
                    }

                    selectedBackend = -1;
                }
            }

            IBackend newBackend = null;

            if (backendComboMap.ContainsKey(backendComboBox.Active))
            {
                newBackend = backendComboMap [backendComboBox.Active];
            }

            // TODO: Set the new backend
            Application.Backend = newBackend;

            if (newBackend == null)
            {
                return;
            }

            selectedBackend = backendComboBox.Active;

            // Add a backend prefs page if one exists
            backendPage = newBackend.GetPreferencesWidget();
            if (backendPage != null)
            {
                backendPage.Show();
                Label l = new Label(GLib.Markup.EscapeText(newBackend.Name));
                l.UseMarkup    = false;
                l.UseUnderline = false;
                l.Show();
                backendPageId =
                    notebook.AppendPage(backendPage, l);

                // If the new backend is not configured, automatically switch
                // to the backend's preferences page
                if (!newBackend.Configured)
                {
                    notebook.Page = backendPageId;
                }
            }

            // Save the user preference
            Application.Preferences.Set(Preferences.CurrentBackend,
                                        newBackend.GetType().ToString());

            //categoriesToHide = BuildNewCategoryList ();
            //Application.Preferences.SetStringList (Preferences.HideInAllCategory,
            //									   categoriesToHide);
            RebuildCategoryTree();
        }