public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            MonitoredSystem ms          = null;
            string          plugin_name = null;

            foreach (var o in values)
            {
                if ((o as MonitoredSystem) != null)
                {
                    ms = o as MonitoredSystem;
                }
                if ((o as string) != null)
                {
                    plugin_name = o as string;
                }
                //if ((o as int?) != null)
                //{
                //    Console.WriteLine("Sequence was " + o);
                //}
            }
            if (plugin_name == null || ms == null)
            {
                return(false);
            }
            MonitoredSystemState state = LayoutManager.Instance.GetMSState(ms.ID);

            return(state.ShownPlugins.Contains(plugin_name));
        }
Exemple #2
0
        /// <summary>
        /// Registers a new node in the database.
        /// </summary>
        /// <param name="node">The node to be registered.</param>
        /// <param name="OUName">The name of the OU for the node.</param>
        private void RegisterNode(WorkstationInfo node, string OUName)
        {
            using (var dataContext = DataContextFactory.CreateDataContext())
            {
                Database.MonitoredSystem monitoredSystem = null;
                try
                {
                    try
                    {
                        monitoredSystem = PrecompiledQueries.GetMonitoredSystemByID(dataContext, PrecompiledQueries.GetMonitoredSystemIDByMAC(dataContext, node.MacAddress));
                    }
                    catch (Exception)
                    {
                        monitoredSystem = null;
                    }

                    // monitored system is not yet known in the db
                    if (monitoredSystem == null)
                    {
                        monitoredSystem = new MonitoredSystem();
                        monitoredSystem.OrganizationalUnitID = this.OUID;
                        monitoredSystem.Name            = node.Name;
                        monitoredSystem.FQDN            = node.FQDN;
                        monitoredSystem.IsAvailable     = node.IsAvailable;
                        monitoredSystem.IsIgnored       = false;
                        monitoredSystem.OperatingSystem = (byte)PlatformHelper.ParsePlatform(node.CurrentOS);
                        monitoredSystem.MacAddress      = node.MacAddress;

                        dataContext.MonitoredSystem.InsertOnSubmit(monitoredSystem);
                        dataContext.SubmitChanges();

                        //logging info
                        var messageOK = new StringBuilder();
                        messageOK.Append("ClusterManager_RegisterNode: ");
                        messageOK.Append("Cluster node " + monitoredSystem.Name + " ");
                        messageOK.Append("(" + monitoredSystem.OperatingSystem.ToString() + ") ");
                        messageOK.Append("is now added to the system.");
                        MISD.Core.Logger.Instance.WriteEntry(messageOK.ToString(), LogType.Info);
                    }
                    else
                    {
                        if (node.IsAvailable)
                        {
                            monitoredSystem.IsAvailable          = node.IsAvailable;
                            monitoredSystem.Name                 = node.Name;
                            monitoredSystem.FQDN                 = node.FQDN;
                            monitoredSystem.OperatingSystem      = (byte)PlatformHelper.ParsePlatform(node.CurrentOS);
                            monitoredSystem.OrganizationalUnitID = this.OUID;
                        }
                        else
                        {
                            // no changes necessary as the node might be booted under a different cluster
                        }
                        dataContext.SubmitChanges();
                    }
                    node.ID = monitoredSystem.ID;
                }
                catch (Exception e)
                {
                    //logging exception
                    string workstationLogName;
                    string osLogName;
                    if (monitoredSystem != null)
                    {
                        workstationLogName = monitoredSystem.Name;
                        osLogName          = monitoredSystem.OperatingSystem.ToString();
                    }
                    else
                    {
                        workstationLogName = "[unkown]";
                        osLogName          = "system unkown";
                    }

                    var messageEx2 = new StringBuilder();
                    messageEx2.Append("ClusterManager_RegisterNode: ");
                    messageEx2.Append("Cluster node" + workstationLogName + " ");
                    messageEx2.Append("(" + osLogName + ") ");
                    messageEx2.Append("sign in has failed. " + e.ToString());
                    MISD.Core.Logger.Instance.WriteEntry(messageEx2.ToString(), LogType.Exception);
                }
            }
        }