public void SaveTest() { var firstApplicationName = "Adobe"; var serverName = "DESKTOP-1FTRA6H"; var serviceMonitoringRepository = new ServiceMonitoringRepository( new CSvServiceMonitoringReader(), new CSVServiceMonitoringWriter()); var serviceMonitoring = new ServiceMonitoring( serviceMonitoringRepository, "ApplicationsAndRespectiveServices.csv"); var firstApplicationServicesStatusModel = new ApplicationServicesStatusModel( serverName, firstApplicationName, "AdobeARMservice", "Running"); var secondApplicationServicesStatusModel = new ApplicationServicesStatusModel( serverName, firstApplicationName, "AdobeFlashPlayerUpdateSvc", "Stopped"); var applicationServicesStatusModels = new List <ApplicationServicesStatusModel>(); applicationServicesStatusModels.Add(firstApplicationServicesStatusModel); applicationServicesStatusModels.Add(secondApplicationServicesStatusModel); var path = @"D:\ServiceMonitoringStatus_2.csv"; serviceMonitoring.Save(applicationServicesStatusModels, path); }
public void SaveTest() { var firstApplicationName = "Adobe"; var serverName = "DESKTOP-1FTRA6H"; var firstApplicationServicesStatusModel = new ApplicationServicesStatusModel( serverName, firstApplicationName, "AdobeARMservice", "Running"); var secondApplicationServicesStatusModel = new ApplicationServicesStatusModel( serverName, firstApplicationName, "AdobeFlashPlayerUpdateSvc", "Stopped"); var secondApplicationName = "Amazon SSM Agent"; var dict2 = new Dictionary <string, string>(); var thirdApplicationServicesStatusModel = new ApplicationServicesStatusModel( serverName, secondApplicationName, "AmazonSSMAgent", "Running"); var thirdApplicationName = "Application Identity"; var fourthApplicationServicesStatusModel = new ApplicationServicesStatusModel( serverName, thirdApplicationName, "AppIDSvc", "Running"); var applicationServicesStatusModels = new List <ApplicationServicesStatusModel>(); applicationServicesStatusModels.Add(firstApplicationServicesStatusModel); applicationServicesStatusModels.Add(secondApplicationServicesStatusModel); applicationServicesStatusModels.Add(thirdApplicationServicesStatusModel); applicationServicesStatusModels.Add(fourthApplicationServicesStatusModel); var path = @"D:\ServiceMonitoringStatus.csv"; var csvWriter = new CSVServiceMonitoringWriter(); csvWriter.Save(applicationServicesStatusModels, path); }
public void CheckServicesStatus( string username, string passowrd, string authority, string savetoPath) { var listofApplicationServicesStatusModel = new List <ApplicationServicesStatusModel>(); foreach (var record in serviceMonitoring.AllRecords) { var firstRecord = serviceMonitoring.AllRecords[0]; var servername = firstRecord.Item1; var applicationName = firstRecord.Item2; var services = firstRecord.Item3; var mails = firstRecord.Item4; foreach (var service in services) { var status = this.serviceMonitoring.GetServiceStatus( username, passowrd, authority, servername, service); var applicationServicesStatusModel = new ApplicationServicesStatusModel( servername, applicationName, service, status); listofApplicationServicesStatusModel.Add(applicationServicesStatusModel); if (status.Equals("Stopped")) { var subject = $"{service} is stopped for application {applicationName} on server {servername}"; var body = "This is a notification mail to check service status"; mailService.SendMail(subject, body, mails, false); } } } this.serviceMonitoring.Save(listofApplicationServicesStatusModel, savetoPath); }
public void CheckServicesStatus( string username, string passowrd, string authority) { var listofApplicationServicesStatusModel = new List <ApplicationServicesStatusModel>(); foreach (var record in serviceMonitoring.AllRecords) { var firstRecord = serviceMonitoring.AllRecords[0]; var servername = firstRecord.Item1; var applicationName = firstRecord.Item2; var services = firstRecord.Item3; var mails = firstRecord.Item4; foreach (var service in services) { var status = this.serviceMonitoring.GetServiceStatus( username, passowrd, authority, servername, service); ApplicationServicesStatusModel applicationServicesStatusModel = new ApplicationServicesStatusModel( record.Item1, applicationName, service, status); listofApplicationServicesStatusModel.Add(applicationServicesStatusModel); var report = CreateReport(listofApplicationServicesStatusModel); var subject = $"Automated {shift} for Collabration FM"; mailService.SendMail(subject, report, firstRecord.Item4, true); } } }