/// <summary> /// The method that aquires, filters and sends the indicator values. /// </summary> public void UpdateValues(WorkstationInfo node, IPlugin plugin, string indicator, ClusterConnection connection, Platform platform) { try { if (node.IsAvailable && node.CurrentOS == platform.ToString()) { // Aquire data var values = GetValues(node, plugin, indicator, connection); if (values != null && values.Count > 0 && values.First().Item2 != null) { // Filter values var filteredValues = FilterValues(node, plugin, indicator, values); // Send values if (filteredValues != null && filteredValues.Count > 0) { var valuesToSend = (from p in filteredValues select new Tuple <string, Object, MISD.Core.DataType, DateTime>(indicator, p.Item2, p.Item3, DateTime.Now)).ToList(); WorkstationManager.Instance.UploadIndicatorValues(node.ID, plugin.GetName(), valuesToSend); } } } } catch (Exception e) { MISD.Core.Logger.Instance.WriteEntry("ClusterJobScheduler_UpdateValues: Problem with node " + node.Name + " and plugin " + plugin.GetName() + " and indicator " + indicator + ": " + e.ToString(), LogType.Exception); } }
public WorkstationInfo GetWorkstationInfo() { WorkstationInfo workstationInfo = new WorkstationInfo(); try { workstationInfo.AppVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); workstationInfo.Id = WorkstationId; workstationInfo.MachineName = Environment.MachineName; workstationInfo.Domain = Environment.UserDomainName; try { RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows NT\\CurrentVersion"); workstationInfo.OsName = (string)registryKey.GetValue("ProductName"); workstationInfo.OsVersion = (string)registryKey.GetValue("ReleaseId"); workstationInfo.OsBuild = $"{registryKey.GetValue("CurrentBuild")}.{registryKey.GetValue("UBR")}"; } catch (Exception ex) { WriteLine(ex); Debug.Assert(false, "An exception occured while querrying workstation operating system"); } workstationInfo.Users = WorkstationHelper.GetAllUserNames(); } catch (Exception ex) { WriteLine(ex); Debug.Assert(false); } return(workstationInfo); }
public static IEnumerable <string> NetWorkstationUserEnumNames(string computer) { var users = new List <string>(); var domain = WorkstationInfo.FromComputer(null).LanGroup; foreach (var item in NetApiHelper.NetWkstaUserEnum(computer)) { if (item.username.EndsWith("$")) { continue; } string name; if (domain != item.logon_domain) { name = String.Format(CultureInfo.CurrentCulture, @"{0}\{1}", item.logon_domain.ToUpper(CultureInfo.CurrentCulture), item.username); } else { name = item.username; } if (!users.Contains(name)) { users.Add(name); } } users.Sort(); return(users); }
/// <summary> /// Initializes a timerjob for an indicator. /// </summary> /// <param name="monitoredSystem">The monitored system.</param> /// <param name="plugin">The plugin.</param> /// <param name="indicator">The indicator.</param> /// <param name="interval">The update interval.</param> public GlobalTimerJob(WorkstationInfo monitoredSystem, IPlugin plugin, string indicator, TimeSpan interval) { this.ID = monitoredSystem.ID + "." + plugin.GetName() + "." + indicator; this.system = monitoredSystem; this.plugin = plugin; this.indicator = indicator; this.Interval = interval; }
public void AddJob(int interval, WorkstationInfo node, IPlugin plugin, string indicator) { if (interval >= 1 && node != null && plugin != null && indicator != "") { int offset = new Random().Next(1, 30); jobs.Add(new Tuple <int, WorkstationInfo, IPlugin, string, int>(interval, node, plugin, indicator, offset)); } }
public void AddJob(int interval, WorkstationInfo node, IPlugin plugin, string indicator, ClusterConnection connection, Platform platform) { if (interval >= 1 && node != null && plugin != null && indicator != "" && connection != null) { int offset = new Random().Next(1, 30); jobs.Add(new Tuple <int, WorkstationInfo, IPlugin, string, ClusterConnection, Platform, int>(interval, node, plugin, indicator, connection, platform, offset)); } }
public override LoginResponse Login(WorkstationInfo awsInfo) { try { Profile profile; XmlSerializer mySerializer = new XmlSerializer(typeof(Profile)); string profileFile = Path.Combine(m_ProfilesFolder, awsInfo.userInfo.UserName + ".xml"); if (!File.Exists(profileFile)) { File.Copy(Path.Combine(m_ProfilesFolder, "default.xml"), profileFile); } using (FileStream fileStream = new FileStream(profileFile, FileMode.Open)) { profile = (Profile)mySerializer.Deserialize(fileStream); } if (Boolean.Parse(ConfigurationManager.AppSettings["TrainingModeEnabled"])) { SystemConfiguration sysConfig = new SystemConfiguration(String.Empty, 2); Database db = new Database(); sysConfig.ContainerDBConnectString = db.GetConnectionStringByDBName(ConfigurationManager.AppSettings["ContainerDBName"]); sysConfig.ContainerRefreshPeriodSeconds = int.Parse(ConfigurationManager.AppSettings["ContainerRefreshPeriodSeconds"]); return(new LoginResponse(L3.Cargo.Communications.Interfaces.AuthenticationLevel.Operator, sysConfig, profile)); } else if (Boolean.Parse(ConfigurationManager.AppSettings["LoginRequired"])) { L3.Cargo.Communications.Interfaces.AuthenticationLevel authenticationLevel = L3.Cargo.Communications.Interfaces.AuthenticationLevel.None; authenticationLevel = (L3.Cargo.Communications.Interfaces.AuthenticationLevel)m_HostComm.Login(awsInfo.userInfo.UserName, awsInfo.userInfo.Password); SystemConfiguration sysConfig = new SystemConfiguration(String.Empty, m_HostComm.GetMaxManifestPerCase()); return(new LoginResponse(authenticationLevel, sysConfig, profile)); } else { SystemConfiguration sysConfig = new SystemConfiguration(String.Empty, 0); return(new LoginResponse(L3.Cargo.Communications.Interfaces.AuthenticationLevel.None, sysConfig, null)); } } catch (CargoException cex) { throw new FaultException(new FaultReason(cex.error_msg)); } catch (Exception ex) { throw new FaultException(new FaultReason(ex.Message)); } }
private AuthenticationLevel LoginToIndividualSource(string sourceAlias, string username, string password) { AuthenticationLevel ret = AuthenticationLevel.None; try { string wsId = m_SysConfig.GetDefaultConfig().WorkstationAlias; UserInfo userInfo = new UserInfo(username, password); WorkstationInfo wsInfo = new WorkstationInfo(wsId, userInfo); LoginResponse loginResponse = m_DataSourceAccess.Login(sourceAlias, wsInfo); ret = loginResponse.UserAuthenticationLevel; if (!ret.Equals(AuthenticationLevel.None)) { SysConfiguration sysConfig = new SysConfiguration(); sysConfig.ID = sourceAlias; sysConfig.ContainerDBConnectionString = loginResponse.systemConfiguration.ContainerDBConnectString; sysConfig.ContainerRefreshPeriodmsecs = loginResponse.systemConfiguration.ContainerRefreshPeriodSeconds * 1000; if (m_SysConfig.Contains(sourceAlias)) { m_SysConfig.Delete(sourceAlias); } m_SysConfig.Add(sysConfig); if (m_SysConfig.UserProfileManager.Profile == null) { ProfileObject profile = ProfileTranslator.Translate(loginResponse.UserProfile, 4); profile.SourceAlias = sourceAlias; profile.UserName = wsInfo.userInfo.UserName; profile.Password = wsInfo.userInfo.Password; m_SysConfig.UserProfileManager.Profile = profile; m_SysConfig.UserProfileManager.Profile.ProfileUpdatedEvent += new ProfileUpdated(ProfileUpdated); } DataSet caselist = null; m_DataSourceAccess.GetCaseList(sourceAlias, out caselist); if (caselist != null) { CaseListDataSet caseListDataSet = (CaseListDataSet)caselist; caseListDataSet.CaseListTable.CaseListTableRowChanged += new CaseListDataSet.CaseListTableRowChangeEventHandler(CaseListTable_CaseListTableRowChanged); } } } catch (Exception ex) { throw ex; } return(ret); }
public void TestAsyncFill() { Utils.InitPlugins(); var strategy = new ComputerFiller(); var result = new Collection <PanelItemBase>(); string domain = WorkstationInfo.FromComputer(null).LanGroup; strategy.AsyncFill(new DomainPanelItem(null, domain), result); Assert.Greater(result.Count, 0); }
public LoginResponse Login(string sourceAlias, WorkstationInfo workstationInfo) { CaseSource <WSCommEndpoint> WSCommSource = FindSource <WSCommEndpoint>(sourceAlias); CaseSource <CaseRequestManagerEndpoint> ArchiveCaseSource = FindSource <CaseRequestManagerEndpoint>(sourceAlias); if (default(CaseSource <WSCommEndpoint>) != WSCommSource) { workstationInfo.WorkstationId = m_WorkstationId; try { return(WSCommSource.EndPoint.Login(workstationInfo)); } catch (FaultException ex) { throw; } catch (Exception) { WSCommSource.EndPoint.Abort(); if (m_SysConfigMgrAccess.Contains(WSCommSource.Alias)) { m_SysConfigMgrAccess.Delete(WSCommSource.Alias); } m_WSCommSources.RemoveSource(WSCommSource); throw; } } else if (default(CaseSource <CaseRequestManagerEndpoint>) != ArchiveCaseSource) { workstationInfo.WorkstationId = m_WorkstationId; try { return(ArchiveCaseSource.EndPoint.Login(workstationInfo)); } catch (FaultException ex) { throw; } catch (Exception) { ArchiveCaseSource.EndPoint.Abort(); if (m_SysConfigMgrAccess.Contains(ArchiveCaseSource.Alias)) { m_SysConfigMgrAccess.Delete(ArchiveCaseSource.Alias); } m_ACSSources.RemoveSource(ArchiveCaseSource); throw; } } throw new Exception(ErrorMessages.SOURCE_NOT_AVAILABLE); }
/// <summary> /// Acquires all available information of each cluster-node. /// </summary> /// <returns>List of WorkstationInfos conataining the node-information.</returns> public override List <WorkstationInfo> GetNodes() { List <Core.WorkstationInfo> nodes = new List <WorkstationInfo>(); string utilityAddress = url.Substring(7, url.Length - 7); utilityAddress = utilityAddress.Split(':')[0]; utilityAddress = utilityAddress.Split('.')[0]; HpcPipelineObject pipelineObject = this.getPipeline(); Dictionary <string, string> nodeInformation = HpcUtility.getSubnetInformation(utilityAddress, this); this.freePipeline(pipelineObject); Dictionary <string, NodeState> hpcNodesAvailability = new Dictionary <string, NodeState>(); foreach (ISchedulerNode node in ((IScheduler)this.CopyConnection().GetConnection()).GetNodeList(null, null)) { hpcNodesAvailability.Add(node.Name, node.State); } foreach (KeyValuePair <String, String> entry in nodeInformation) { if (hpcNodesAvailability.ContainsKey(entry.Key)) { WorkstationInfo workstationInfo = new WorkstationInfo(); workstationInfo.CurrentOS = (MISD.Core.Platform.HPC).ToString(); workstationInfo.Name = entry.Key; workstationInfo.FQDN = entry.Key + ".visus.uni-stuttgart.de"; workstationInfo.MacAddress = entry.Value; NodeState availability; hpcNodesAvailability.TryGetValue(entry.Key, out availability); if (availability.ToString().Equals("Online")) { workstationInfo.IsAvailable = true; } else { workstationInfo.IsAvailable = false; } workstationInfo.State = MISD.Core.MappingState.OK; nodes.Add(workstationInfo); } } return(nodes); }
public void TestNetServerEnumComps() { string domain = WorkstationInfo.FromComputer(null).LanGroup; IEnumerable <SERVER_INFO_101> list = NetApiHelper.NetServerEnum(domain, SV_101_TYPES.SV_TYPE_DOMAIN_ENUM); int count = 0; foreach (SERVER_INFO_101 item in list) { count++; } Assert.Greater(count, 0); }
public override List <WorkstationInfo> GetNodes() { if (this.ConnectionObject == null) { Logger.Instance.WriteEntry("BrightClusterConnection_CopyConnection(): Connection was null and cannot be copied", LogType.Warning); throw new Exception("BrightClusterConnection_GetNodes: You didn't call INIT before accessing the Cluster connection."); } List <Core.WorkstationInfo> nodes = new List <WorkstationInfo>(); string devices = ((BrightClusterShell)this.ConnectionObject).RunCommands(new List <string> { "device list" }); string devicesHealth = ((BrightClusterShell)this.ConnectionObject).RunCommands(new List <string> { "device status" }); string[] devicelist = devices.ToString().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); string[] devicesHealthList = devicesHealth.ToString().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); foreach (string current in devicelist) { if (current.Contains("PhysicalNode") || current.Contains("MasterNode")) { // columns: type, name, mac, desc, ip, unknown, unknown, unknown string[] details = current.ToString().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); WorkstationInfo currentNode = new WorkstationInfo(); currentNode.CurrentOS = MISD.Core.Platform.Bright.ToString(); currentNode.Name = details.ElementAt(1); currentNode.FQDN = BuildFQDN(currentNode.Name); currentNode.IsAvailable = false; foreach (string currentLine in devicesHealthList) { if (currentLine.Contains(details.ElementAt(1)) && currentLine.Contains("[ UP ]")) { currentNode.IsAvailable = true; } } currentNode.MacAddress = details.ElementAt(2); currentNode.State = MISD.Core.MappingState.OK; nodes.Add(currentNode); } } return(nodes); }
public void TestAsyncFill() { Utils.InitPlugins(); var strategy = new ShareFiller(); string domain = WorkstationInfo.FromComputer(null).LanGroup; var computer = new ComputerPanelItem(new DomainPanelItem(new DomainRoot(), domain), SystemInformation.ComputerName); ShareFiller.ShowHiddenShares = true; var result = new Collection <PanelItemBase>(); strategy.AsyncFill(computer, result); Assert.Greater(result.Count, 0); Assert.IsInstanceOf <SharePanelItem>(result[0]); ShareFiller.ShowHiddenShares = false; strategy.AsyncFill(computer, result); }
/// <summary> /// Method to aquire data with the plugin. /// </summary> /// <returns>A list containing IndicatorName | IndicatorValue | IndicatorValueDataType.</returns> private List <Tuple <string, object, DataType> > GetValues(WorkstationInfo node, IPlugin plugin, string indicator) { var temp = plugin.AcquireData(new List <String> { indicator }, node.FQDN); if (temp == null) { temp = new List <Tuple <string, object, DataType> >(); } // value itself is null if (temp != null && temp.Count > 0 && temp.First() != null && temp.First().Item2 == null) { temp = new List <Tuple <string, object, DataType> >(); } return(temp); }
public override LoginResponse Login(WorkstationInfo wsInfo) { try { AuthenticationLevel authLvl = AuthenticationLevel.None; authLvl = (AuthenticationLevel)m_CargoHostEndPoint.Login(wsInfo.userInfo.UserName, wsInfo.userInfo.Password); Profile profile; try { XmlSerializer mySerializer = new XmlSerializer(typeof(Profile)); string profileFile = m_ProfilesFolder + "\\" + wsInfo.userInfo.UserName + ".xml"; if (!File.Exists(profileFile)) { File.Copy(m_ProfilesFolder + "\\default.xml", profileFile); } using (FileStream fileStream = new FileStream(profileFile, FileMode.Open)) { profile = (Profile)mySerializer.Deserialize(fileStream); } } catch (Exception ex) { throw new Exception(ErrorMessages.NO_USER_PROFILE, ex.InnerException); } SystemConfiguration sysConfig = new SystemConfiguration(m_Alias, m_CargoHostEndPoint.GetMaxManifestPerCase()); Database db = new Database(); sysConfig.ContainerDBConnectString = db.GetConnectionStringByDBName(ConfigurationManager.AppSettings["ContainerDBName"]); sysConfig.ContainerRefreshPeriodSeconds = int.Parse(ConfigurationManager.AppSettings["ContainerRefreshPeriodSeconds"]); return(new LoginResponse(authLvl, sysConfig, profile)); } catch (Exception ex) { throw new FaultException(new FaultReason(ex.Message)); } }
public void RemoveJob(WorkstationInfo node, IPlugin plugin, string indicator) { List <Tuple <int, WorkstationInfo, IPlugin, string, ClusterConnection, Platform, int> > toBeRemoved = new List <Tuple <int, WorkstationInfo, IPlugin, string, ClusterConnection, Platform, int> >(); foreach (var job in jobs) { if (job.Item2.ID.Equals(node.ID) && job.Item3.Equals(plugin) && job.Item4.Equals(indicator)) { toBeRemoved.Add(job); } } foreach (var job in toBeRemoved) { jobs.Remove(job); } toBeRemoved.Clear(); }
/// <summary> /// Method to filter the values. /// </summary> /// <param name="unfilteredValues">The list of all values.</param> /// <returns>A list containing IndicatorName | IndicatorValue | IndicatorValueDataType.</returns> private List <Tuple <string, object, MISD.Core.DataType> > FilterValues(WorkstationInfo node, IPlugin plugin, string indicator, List <Tuple <string, object, MISD.Core.DataType> > unfilteredValues) { List <Tuple <string, object, MISD.Core.DataType> > result; var filteredValues = (from p in unfilteredValues where FilterManager.Instance.GetFilterValue(node.ID, plugin.GetName(), indicator, p.Item1) select p); if (filteredValues == null) { result = new List <Tuple <string, object, MISD.Core.DataType> >(); } else { result = filteredValues.ToList(); } return(result); }
/// <summary> /// Retuns all observer of an monitored system /// </summary> /// <param name="userID">ID of the users email adress</param> /// <returns>List of MAC adress </returns> public List <WorkstationInfo> GetObserver(int userID) { List <WorkstationInfo> result = new List <WorkstationInfo>(); try { using (var dataContext = DataContextFactory.CreateReadOnlyDataContext()) { var msIDs = (from q in dataContext.EmailObserver where q.EmailID == userID select q.MonitoredSystem.ID).ToList(); foreach (var ms in msIDs) { //update mapping state ValueManager.Instance.UpdateMonitoredSystemMappingState(ms); var monitoredSystem = PrecompiledQueries.GetMonitoredSystemByID(dataContext, ms); //create result var workstationinfo = new WorkstationInfo() { Name = monitoredSystem.Name, ID = monitoredSystem.ID, FQDN = monitoredSystem.FQDN, OuID = monitoredSystem.OrganizationalUnitID, IsAvailable = monitoredSystem.IsAvailable, CurrentOS = ((MISD.Core.Platform)monitoredSystem.OperatingSystem).ToString(), MacAddress = monitoredSystem.MacAddress, State = monitoredSystem.Status.HasValue ? (MappingState)monitoredSystem.Status : MappingState.OK }; result.Add(workstationinfo); } } return(result); } catch (Exception e) { Logger.Instance.WriteEntry("Mailer_GetObserver: Can't create result: " + e.StackTrace, LogType.Exception); return(null); } }
public void RemoveAllJobsForNode(WorkstationInfo node) { List <Tuple <int, WorkstationInfo, IPlugin, string, ClusterConnection, Platform, int> > toBeRemoved = new List <Tuple <int, WorkstationInfo, IPlugin, string, ClusterConnection, Platform, int> >(); foreach (var job in jobs) { if (job.Item2.ID.Equals(node.ID)) { toBeRemoved.Add(job); } } foreach (var job in toBeRemoved) { jobs.Remove(job); } toBeRemoved.Clear(); }
private void Tab1Login_Click(object sender, RoutedEventArgs e) { WorkstationInfo awsInfo = new WorkstationInfo(m_AWSId); awsInfo.userInfo.UserName = Tab1UsernameTextBox.Text; awsInfo.userInfo.Password = Tab1PasswordTextBox.Text; try { LoginResponse response = m_AWSCommEndPoint1.Login(awsInfo); Tab1LogListBox.Items.Add("Result: Success | AuthLevel: " + response.UserAuthenticationLevel.ToString()); } catch (Exception ex) { Tab1LogListBox.Items.Add("Result: Failed | ErrorMessage: " + ex.Message + " | AuthLevel: None"); } }
/// <summary> /// Method to aquire data with the plugin. /// </summary> /// <returns>A list containing IndicatorName | IndicatorValue | IndicatorValueDataType.</returns> private List <Tuple <string, object, DataType> > GetValues(WorkstationInfo node, IPlugin plugin, string indicator, ClusterConnection connection) { string name = node.FQDN.Split('.').FirstOrDefault(); if (name != null) { var temp = plugin.AcquireData(new List <String> { indicator }, name, connection); if (temp == null) { temp = new List <Tuple <string, object, DataType> >(); } return(temp); } return(null); }
/// <summary> /// Initializes a timerjob for an indicator. /// </summary> /// <param name="nodeID">The ID of the node.</param> /// <param name="connection">The connection to the cluster.</param> /// <param name="plugin">The plugin.</param> /// <param name="indicator">The indicator.</param> /// <param name="interval">The update interval.</param> public ClusterTimerJob(WorkstationInfo node, ClusterConnection connection, IPlugin plugin, string indicator, TimeSpan interval) { this.ID = node.ID + "." + plugin.GetName() + "." + indicator; this.Interval = interval; this.node = node; this.plugin = plugin; this.indicator = indicator; this.clusterConnection = connection; if (clusterConnection.GetType() == typeof(BrightClusterConnection)) { this.platform = Platform.Bright; } else if (clusterConnection.GetType() == typeof(HpcClusterConnection)) { this.platform = Platform.HPC; } else { Logger.Instance.WriteEntry("ClusterTimerJob: Trying to create timerjobs for unsupported platform.", LogType.Exception); throw new ArgumentOutOfRangeException(); } }
public void ExceptionGetMachineNetBiosDomain() { WorkstationInfo.FromComputer("~!@#$%^&"); }
public List <WorkstationInfo> GetWorkstationInfo(List <Tuple <int, TimeSpan> > workstationsWithReset) { List <WorkstationInfo> returns = new List <WorkstationInfo>(); using (var dataContext = DataContextFactory.CreateDataContext()) { dataContext.Log = Console.Out; try { foreach (Tuple <int, TimeSpan> current in workstationsWithReset) { //update mapping state UpdateMappingState(current.Item1); var monitoredSystem = PrecompiledQueries.GetMonitoredSystemByID(dataContext, current.Item1); WorkstationInfo workstationInfo; if (monitoredSystem.LastUpdate != null) { //create result workstationInfo = new WorkstationInfo() { Name = monitoredSystem.Name, ID = monitoredSystem.ID, FQDN = monitoredSystem.FQDN, OuID = monitoredSystem.OrganizationalUnitID, IsAvailable = monitoredSystem.IsAvailable, CurrentOS = ((MISD.Core.Platform)monitoredSystem.OperatingSystem).ToString(), MacAddress = monitoredSystem.MacAddress, State = monitoredSystem.Status.HasValue ? (MappingState)monitoredSystem.Status : MappingState.OK, LastUpdate = new DateTime((long)monitoredSystem.LastUpdate) }; } else { //create result workstationInfo = new WorkstationInfo() { Name = monitoredSystem.Name, ID = monitoredSystem.ID, FQDN = monitoredSystem.FQDN, OuID = monitoredSystem.OrganizationalUnitID, IsAvailable = monitoredSystem.IsAvailable, CurrentOS = ((MISD.Core.Platform)monitoredSystem.OperatingSystem).ToString(), MacAddress = monitoredSystem.MacAddress, State = monitoredSystem.Status.HasValue ? (MappingState)monitoredSystem.Status : MappingState.OK, LastUpdate = null }; } returns.Add(workstationInfo); } return(returns); } catch (Exception e) { //logging exception var messageEx = new StringBuilder(); messageEx.Append("Can't create List of WorkstationInfos" + ". " + e.ToString()); MISD.Core.Logger.Instance.WriteEntry(messageEx.ToString(), LogType.Exception); return(null); } } }
public LoginResponse Login(String sourceAlias, WorkstationInfo awsInfo) { return(m_CaseSourceManager.Login(sourceAlias, awsInfo)); }
/// <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); } } }
/// <summary> /// Starts with curent users's workgroup/domain as root. /// </summary> /// <returns></returns> public PanelItemBase CreateDefaultRoot() { var domain = WorkstationInfo.FromComputer(null).LanGroup; return(new DomainPanelItem(new DomainRoot(), domain)); }
public void TestGetMachineNetBiosDomain() { string value = WorkstationInfo.FromComputer(null).LanGroup; Assert.NotNull(value); }
public LoginResponse Login(WorkstationInfo awsInfo) { return(base.Channel.Login(awsInfo)); }