// LogLevel DefaultLogLevel = new LogLevel(); public VSServices() { VSFramework.VSAdaptor vsobject = new VSFramework.VSAdaptor(); DataSet DsSettings = new DataSet(); string Svalue = ""; string strSQL; string LogFilepath = ""; try { strSQL = "Select svalue from Settings Where sname=\'Log Files Path\'"; vsobject.FillDatasetAny("VitalSigns", "None", strSQL, ref DsSettings, "Settings"); LogFilepath = DsSettings.Tables["Settings"].Rows[0]["svalue"].ToString(); } catch (Exception ex) { Svalue = "0"; } try { strSQL = "Select svalue from Settings Where sname='Log Level'"; vsobject.FillDatasetAny("VitalSigns", "None", strSQL, ref DsSettings, "Settings"); string level = DsSettings.Tables["Settings"].Rows[0]["svalue"].ToString(); DefaultLogLevel = (LogLevel)Enum.Parse(typeof(LogLevel), level, true); } catch (Exception ex) { DefaultLogLevel = LogLevel.Normal; } logPath = LogFilepath; }
protected void WriteAuditEntries() { VSFramework.VSAdaptor vsobject = new VSFramework.VSAdaptor(); DataSet DsSettings = new DataSet(); string Svalue = ""; Int32 threadsleep = 0; string strSQL; // Dim LogFilepath As String = "" try { strSQL = "Select svalue from Settings Where sname=\'ThreadSleep\'"; vsobject.FillDatasetAny("VitalSigns", "None", strSQL, ref DsSettings, "Settings"); threadsleep = Convert.ToInt32(DsSettings.Tables["Settings"].Rows[0]["svalue"].ToString()); } catch (Exception ex) { Svalue = "0"; } while (true) { WriteLogToFiles(ref fileNameDicnry); Thread.Sleep((threadsleep * 1000)); } }
public static void CheckForInsufficentLicenses(Object objServers, string ServerType, string ServerTypeForTypeAndName) { MonitoredItems.MonitoredDevicesCollection servers = objServers as MonitoredItems.MonitoredDevicesCollection; VSFramework.VSAdaptor adapter = new VSFramework.VSAdaptor(); try { if (servers.Count > 0) { string nodeName = null; if (System.Configuration.ConfigurationManager.AppSettings["VSNodeName"] != null) { nodeName = System.Configuration.ConfigurationManager.AppSettings["VSNodeName"].ToString(); } for (int i = 0; i < servers.Count; i++) { MonitoredItems.MonitoredDevice server = servers.get_Item(i); if (server.CurrentNode != nodeName) { string status = ""; string details = ""; if (server.CurrentNode == VSNext.Mongo.Entities.Enums.NodeStatus.InsufficientLicenses.ToDescription()) { status = "Insufficient Licenses"; details = "There are not enough licenses to scan this server."; } else if (server.CurrentNode == VSNext.Mongo.Entities.Enums.NodeStatus.MasterServiceStopped.ToDescription()) { status = "Master Service is stopped"; details = "Master Service stopped running. Could not assign the server to a Node."; } else if (server.CurrentNode == VSNext.Mongo.Entities.Enums.NodeStatus.Unassigned.ToDescription()) { status = "Unassigned"; details = "Current server could not be assigned to a node."; } else if (server.CurrentNode == VSNext.Mongo.Entities.Enums.NodeStatus.Disabled.ToDescription()) { //do nothing } else { status = "Unassigned"; details = "Current server was not assigned a node."; } if (status != "") { VSNext.Mongo.Repository.Repository <VSNext.Mongo.Entities.Status> repository = new VSNext.Mongo.Repository.Repository <VSNext.Mongo.Entities.Status>(connectionString); FilterDefinition <VSNext.Mongo.Entities.Status> filterDef = repository.Filter.Where(p => p.DeviceType.Equals(server.ServerType) && p.DeviceName.Equals(server.Name) && p.DeviceId.Equals(server.ServerObjectID)); UpdateDefinition <VSNext.Mongo.Entities.Status> updateDef = repository.Updater .Set(p => p.CurrentStatus, status) .Set(p => p.Details, details) .Set(p => p.LastUpdated, DateTime.Now) .Set(p => p.Description, details) .Set(p => p.NextScan, DateTime.Now.AddDays(1)) .Set(p => p.StatusCode, "Maintenance") .Set(p => p.TypeAndName, server.Name + "-" + server.ServerType); repository.Upsert(filterDef, updateDef); } LogUtilities.LogUtils.WriteDeviceHistoryEntry("All", "InsufficentLicensesCheck", DateTime.Now.ToString() + " " + server.Name + " is being removed from the collection due to " + status + "..." + details + ". Server Current Node is " + server.CurrentNode, LogUtils.LogLevel.Verbose); servers.Delete(server.Name); } else { LogUtilities.LogUtils.WriteDeviceHistoryEntry("All", "InsufficentLicensesCheck", DateTime.Now.ToString() + " " + server.Name + " is being NOT removed from the collection.", LogUtils.LogLevel.Verbose); } } //10/3/2016 NS commented out per discussion with Wes - the insufficient licenses system message is being queued //using the QueueSysMessage function elsewhere. The SysMessageForLicenses is outdated and will be removed from the Alertdll //AlertLibrary.Alertdll myAlert = new AlertLibrary.Alertdll(); //myAlert.SysMessageForLicenses(); } } catch (Exception ex) { } }
public static void ReadXmlFile(string NodeName) { try { VSFramework.VSAdaptor myAdapter = new VSFramework.VSAdaptor(); VSFramework.XMLOperation myConnectionString = new VSFramework.XMLOperation(); DataSet DsSettings = new DataSet(); string FilePath = ""; string strSQL = ""; string VSWebPath = ""; string LogFilesPath = ""; try { strSQL = "Select svalue from Settings Where sname='VSWebPath'"; myAdapter.FillDatasetAny("VitalSigns", "None", strSQL, ref DsSettings, "Settings"); VSWebPath = DsSettings.Tables["Settings"].Rows[0]["svalue"].ToString(); } catch (Exception ex) { VSWebPath = "0"; } try { strSQL = "Select svalue from Settings Where sname='Log Files Path'"; myAdapter.FillDatasetAny("VitalSigns", "None", strSQL, ref DsSettings, "Settings1"); LogFilesPath = DsSettings.Tables["Settings1"].Rows[0]["svalue"].ToString(); LogFilesPath = LogFilesPath.ToUpper().Substring(0, LogFilesPath.ToUpper().IndexOf("LOG_FILES")); } catch (Exception ex) { LogFilesPath = "0"; } LogUtils.WriteHistoryEntry(DateTime.Now.ToString() + ",VSWebPath: " + VSWebPath + ",LogFilesPath: " + LogFilesPath, "AssemblyVersionError.txt", LogUtils.LogLevel.Verbose); DataTable newt = new DataTable(); newt.ReadXml(LogFilesPath + "Assemblies.xml"); newt.Columns.Add("BuildDate"); LogUtils.WriteHistoryEntry(DateTime.Now.ToString() + ",xml rows: " + newt.Rows.Count, "AssemblyVersionError.txt", LogUtils.LogLevel.Verbose); List <VSNext.Mongo.Entities.AssemblyInfo> listAssemblyInfo = new List <VSNext.Mongo.Entities.AssemblyInfo>(); for (int i = 0; i <= newt.Rows.Count - 1; i++) { DataTable dt = new DataTable(); try { try { if ((newt.Rows[i]["FileArea"].ToString() == "VSWebUI")) { FilePath = VSWebPath; } else if ((newt.Rows[i]["FileArea"].ToString() == "Services")) { FilePath = LogFilesPath; } } catch { FilePath = ""; } LogUtils.WriteHistoryEntry(DateTime.Now.ToString() + ",Filepath: " + FilePath, "AssemblyVersionError.txt", LogUtils.LogLevel.Verbose); string ver = AssemblyName.GetAssemblyName((FilePath + newt.Rows[i]["AssemblyName"].ToString())).Version.Major.ToString() + "." + AssemblyName.GetAssemblyName((FilePath + newt.Rows[i]["AssemblyName"].ToString())).Version.Minor.ToString() + "." + AssemblyName.GetAssemblyName((FilePath + newt.Rows[i]["AssemblyName"].ToString())).Version.Build.ToString(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo((FilePath + newt.Rows[i]["AssemblyName"].ToString())); string fversion = fvi.ProductMajorPart.ToString() + "." + fvi.ProductMinorPart.ToString() + "." + fvi.ProductBuildPart; DateTime builddt = System.IO.File.GetLastWriteTime(FilePath + newt.Rows[i]["AssemblyName"]); try { listAssemblyInfo.Add(new VSNext.Mongo.Entities.AssemblyInfo() { AssemblyName = newt.Rows[i]["AssemblyName"].ToString(), AssemblyVersion = ver.ToString(), ProductVersion = fversion, BuildDate = builddt, FileArea = newt.Rows[i]["FileArea"].ToString() }); } catch (Exception ex) { LogUtils.WriteHistoryEntry(DateTime.Now.ToString() + " Error adding new AssemblyInfo to list error:" + ex.Message, "AssemblyVersionError.txt", LogUtils.LogLevel.Verbose); } } catch (Exception ex) { LogUtils.WriteHistoryEntry(DateTime.Now.ToString() + " error: " + ex.Message, "AssemblyVersionError.txt" + ", error:" + ex.Message, LogUtils.LogLevel.Verbose); } } try { VSNext.Mongo.Repository.Repository <VSNext.Mongo.Entities.Nodes> repository = new VSNext.Mongo.Repository.Repository <VSNext.Mongo.Entities.Nodes>(connectionString); FilterDefinition <VSNext.Mongo.Entities.Nodes> filterDef = repository.Filter.Eq(x => x.Name, NodeName); UpdateDefinition <VSNext.Mongo.Entities.Nodes> updateDef = repository.Updater.Set(x => x.AssemblyInfo, listAssemblyInfo); repository.Update(filterDef, updateDef); } catch (Exception ex) { LogUtils.WriteHistoryEntry(DateTime.Now.ToString() + " error when updating node collection. Error: " + ex.Message, "AssemblyVersionError.txt" + ", error:" + ex.Message, LogUtils.LogLevel.Verbose); } } catch (Exception ex) { throw ex; } }