Пример #1
0
        public static void ResetAllPresets()
        {
            string commonAppData             = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Hen IT\\QuickMon 3");
            List <AgentPresetConfig> presets = AgentPresetConfig.ReadPresetsFromDirectory(commonAppData);

            SaveAllPresetsToFile(presets);
        }
Пример #2
0
        public static List <AgentPresetConfig> ReadPresetsFromFile(string filePath)
        {
            List <AgentPresetConfig> presets = new List <AgentPresetConfig>();

            try
            {
                if (System.IO.File.Exists(filePath))
                {
                    XmlDocument presetDoc = new XmlDocument();
                    presetDoc.Load(filePath);
                    XmlElement root = presetDoc.DocumentElement;
                    if (root.Name == "qmpresets")
                    {
                        foreach (XmlElement presetNode in root.SelectNodes("preset"))
                        {
                            try
                            {
                                AgentPresetConfig apc = new AgentPresetConfig();
                                apc.AgentClassName = presetNode.ReadXmlElementAttr("class", "");
                                apc.Description    = presetNode.ReadXmlElementAttr("description", "");
                                apc.Config         = presetNode.InnerXml; //all of it e.g. <config>...</config>
                                //to nmake sure only 'available' agents get loaded
                                if ((from r in RegistrationHelper.GetAllAvailableAgents()
                                     where r.ClassName.EndsWith(apc.AgentClassName)
                                     select r).Count() > 0)
                                {
                                    presets.Add(apc);
                                }
                            }
                            catch (Exception nodeEx)
                            {
                                System.Diagnostics.Trace.WriteLine("Error reading preset: " + nodeEx.ToString());
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.ToString());
            }
            return(presets);
        }
Пример #3
0
        static void Main(string[] args)
        {
            if (Properties.Settings.Default.NewVersion)
            {
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.NewVersion = false;
                Properties.Settings.Default.Save();
            }

            if (Properties.Settings.Default.RecentQMConfigFiles == null)
            {
                Properties.Settings.Default.RecentQMConfigFiles = new System.Collections.Specialized.StringCollection();
            }
            if (Properties.Settings.Default.KnownRemoteHosts == null)
            {
                Properties.Settings.Default.KnownRemoteHosts = new System.Collections.Specialized.StringCollection();
            }

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //Copy installed presets to user's application data directory
            try
            {
                if (!System.IO.File.Exists(MonitorPack.GetQuickMonUserDataTemplatesFile()))
                {
                    string commonAppData             = System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Hen IT\\QuickMon 3");
                    List <AgentPresetConfig> presets = AgentPresetConfig.ReadPresetsFromDirectory(commonAppData);
                    AgentPresetConfig.SaveAllPresetsToFile(presets);
                }
            }
            catch { }

            //if application is launched with qmconfig file set it as last Monitor pack
            if (args.Length > 0 && System.IO.File.Exists(args[0]) && (args[0].ToLower().EndsWith(".qmconfig") || args[0].ToLower().EndsWith(".qmp")))
            {
                Properties.Settings.Default.LastMonitorPack = args[0];
            }

            Application.Run(new MainForm());
        }