Ejemplo n.º 1
0
        /// <summary>
        /// Converts an instance of <see cref="Instance" /> to
        /// <see cref="InstanceDetail" />, so that the information can be used
        /// in constructing a list of whatever format.
        /// </summary>
        /// <param name="amazonEC2">
        /// An instance of <see cref="IAmazonEC2" />.
        /// </param>
        /// <param name="passwordEncryptionKey">
        /// The AWS password encryption key, used in decryption.
        /// </param>
        /// <param name="instance">
        /// An instance of <see cref="Instance" />.
        /// </param>
        /// <returns>
        /// An instance of <see cref="InstanceDetail" />.
        /// </returns>
        private InstanceDetail ConvertInstanceToInstanceDetail(
            IAmazonEC2 amazonEC2,
            string passwordEncryptionKey,
            Instance instance)
        {
            InstanceDetail toReturn = null;

            this.loggingProvider.Debug(
                $"Constructing {nameof(InstanceDetail)} instance from EC2 " +
                $"{nameof(Instance)}...");

            toReturn = new InstanceDetail()
            {
                IPAddress = IPAddress.Parse(instance.PrivateIpAddress)
            };

            // TODO: Investigate whether names are always stored in the tags?
            Tag nameTag = instance.Tags.Single(x => x.Key == "Name");

            toReturn.Name = nameTag.Value;

            string instancePassword = this.GetInstancePassword(
                amazonEC2,
                passwordEncryptionKey,
                instance.InstanceId);

            toReturn.Password = instancePassword;

            this.loggingProvider.Info(
                $"{nameof(InstanceDetail)} constructed: {toReturn}.");

            return(toReturn);
        }
Ejemplo n.º 2
0
 public void Update(InstanceDetail obj)
 {
     using (InsightEntities db = new InsightEntities())
     {
         db.InstanceDetails.Attach(obj);
         db.Entry(obj).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 public InstanceDetail Insert(InstanceDetail obj)
 {
     using (InsightEntities db = new InsightEntities())
     {
         db.InstanceDetails.Add(obj);
         db.SaveChanges();
         return(obj);
     }
 }
Ejemplo n.º 4
0
 public void Delete(InstanceDetail obj)
 {
     using (InsightEntities db = new InsightEntities())
     {
         db.InstanceDetails.Attach(obj);
         db.InstanceDetails.Remove(obj);
         db.SaveChanges();
     }
 }
        public List <InstanceDetail> GetVMProperties()
        {
            List <InstanceDetail> instancedetails = new List <InstanceDetail>();
            var profileList = SqlHelper.GetAzureAccounts();

            foreach (var profile in profileList)
            {
                var credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal(profile.ClientId, profile.ClientSecretKey, profile.TenantId, AzureEnvironment.AzureGlobalCloud);
                try
                {
                    var azure     = Azure.Authenticate(credentials).WithSubscription(profile.SubscriptionId);
                    var resources = azure.ResourceGroups.List();
                    foreach (var virtualMachine in azure.VirtualMachines.List())
                    {
                        var name                  = virtualMachine.Name;
                        AzureCloudService p       = new AzureCloudService();
                        InstanceDetail    details = new InstanceDetail();
                        details.accountId     = profile.accountId;
                        details.ResourceGroup = virtualMachine.ResourceGroupName;
                        var ipaddress = p.GetIpAddress(virtualMachine.ResourceGroupName, name, azure.SubscriptionId, credentials);
                        details.OSType      = virtualMachine.StorageProfile.OsDisk.OsType.Value.ToString(); ////OS Type
                        details.ProfileName = "Not Applicable";                                             ////VM Name
                        Console.WriteLine("ResourceGroup: " + virtualMachine.ResourceGroupName);
                        details.InstanceId  = virtualMachine.VMId;
                        details.DiskSize    = virtualMachine.Size.Value;
                        details.Region      = virtualMachine.Region.ToString();
                        details.MachineName = virtualMachine.ComputerName;
                        string   status = virtualMachine.PowerState.Value;
                        string[] s      = status.Split('/');
                        details.Status = s[1];
                        string   type = virtualMachine.Type;
                        string[] ss   = type.Split('/');
                        details.Type          = ss[1];
                        details.InstanceState = "Available";
                        details.InstanceType  = virtualMachine.Size.Value;
                        details.IpAddress     = ipaddress;
                        if (details.IpAddress == null)
                        {
                            details.IpAddress = "Not Assigned";
                        }

                        instancedetails.Add(details);
                    }
                }
                catch (Exception e)
                {
                    this.log.Error(e);
                    return(null);
                }
            }

            return(instancedetails);
        }
 public static void Delete(InstanceDetail obj)
 {
     repository.Delete(obj);
 }
 public static void Update(InstanceDetail obj)
 {
     repository.Update(obj);
 }
 public static InstanceDetail Insert(InstanceDetail obj)
 {
     return(repository.Insert(obj));
 }
        public List <InstanceDetail> GetVMProperties()
        {
            List <AWSProfile> profile;

            profile = SqlHelper.GetAWSAccounts();
            List <InstanceDetail> profilelist = new List <InstanceDetail>();

            //foreach (var profile_ in profile)
            //{
            //    Amazon.Util.ProfileManager.RegisterProfile(profile_.ProfileName, profile_.Accesskey, profile_.Secretkey);
            //}

            try
            {
                foreach (var profile_ in profile)
                {
                    var regions = Amazon.RegionEndpoint.EnumerableAllRegions;
                    //Amazon.Runtime.AWSCredentials credentials = new Amazon.Runtime.StoredProfileAWSCredentials(profile_.ProfileName);
                    foreach (var r in regions)
                    {
                        string region_;
                        if (r.SystemName != "us-gov-west-1" && r.SystemName != "cn-north-1")
                        {
                            region_ = r.SystemName;
                            var region = RegionEndpoint.GetBySystemName(region_);

                            AmazonEC2Client           ec2            = new AmazonEC2Client(profile_.Accesskey, profile_.Secretkey, region);
                            DescribeInstancesRequest  request        = new DescribeInstancesRequest();
                            DescribeInstancesResponse response       = ec2.DescribeInstances(request);
                            DescribeVolumesRequest    volumeRequest  = new DescribeVolumesRequest();
                            DescribeVolumesResponse   volumeResponse = ec2.DescribeVolumes(volumeRequest);
                            int size = 0;
                            foreach (var volume in volumeResponse.Volumes)
                            {
                                size += volume.Size;
                            }
                            List <Reservation> result = response.Reservations;
                            foreach (var item in result)
                            {
                                List <Instance> results = item.Instances;
                                foreach (var instance in results)
                                {
                                    InstanceDetail p = new InstanceDetail();
                                    p.InstanceId = instance.InstanceId.ToString();
                                    DescribeInstanceStatusRequest req = new DescribeInstanceStatusRequest();
                                    req.InstanceIds.Add(p.InstanceId);
                                    DescribeInstanceStatusResponse resp = ec2.DescribeInstanceStatus(req);
                                    var statuses = resp.InstanceStatuses;
                                    foreach (var status in statuses)
                                    {
                                        p.InstanceState = status.Status.Status;
                                    }

                                    if (p.InstanceState == null)
                                    {
                                        p.InstanceState = "Not Available";
                                    }

                                    p.Region   = r.SystemName;
                                    p.DiskSize = (size / result.Count).ToString() + " GB"; //
                                    if (instance.PublicIpAddress != null)
                                    {
                                        p.IpAddress = instance.PublicIpAddress;
                                    }
                                    else
                                    {
                                        p.IpAddress = "Not Assigned";
                                    }

                                    p.ProfileName   = profile_.ProfileName;
                                    p.InstanceType  = instance.InstanceType;
                                    p.Status        = instance.State.Name.Value;
                                    p.ResourceGroup = "Not Applicable";
                                    if (instance.IamInstanceProfile != null)
                                    {
                                        p.MachineName = instance.IamInstanceProfile.Arn;
                                    }
                                    else
                                    {
                                        p.MachineName = "Not Assigned";
                                    }
                                    p.accountId = profile_.accountId;
                                    var type = instance.InstanceType;
                                    p.Type = "virtualMachines";
                                    var b = instance.Tags.Count;
                                    if (b != 0)
                                    {
                                        p.MachineName = instance.Tags[0].Value;
                                    }
                                    if (instance.Platform != null)
                                    {
                                        p.OSType = instance.Platform;
                                    }
                                    else
                                    {
                                        p.OSType = "Amazon Linux";
                                    }

                                    profilelist.Add(p);
                                }
                            }
                        }
                    }
                }

                return(profilelist);
            }
            catch (Exception e)
            {
                this.log.Error(e);
                return(null);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Writes the contents of an array of <see cref="InstanceDetail" />
        /// instances to a text file (specified by
        /// <paramref name="outputFile" />).
        /// </summary>
        /// <param name="instanceDetails">
        /// An array of <see cref="InstanceDetail" /> instances.
        /// </param>
        /// <param name="outputFile">
        /// An instance of <see cref="FileInfo" /> describing the location of
        /// the output file.
        /// </param>
        private void InstanceDetailToTextFile(
            InstanceDetail[] instanceDetails,
            FileInfo outputFile)
        {
            this.loggingProvider.Debug(
                $"Composing output file containing {instanceDetails.Length} " +
                $"{nameof(InstanceDetail)} instances before writing to " +
                $"\"{outputFile.FullName}\"...");

            // Then, save it to the output file. Just text file for now.
            // TODO: Terminals favourite export.
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine(
                $"Connection details for {instanceDetails.Length} " +
                $"instance(s) in total.");
            stringBuilder.AppendLine();

            int padding = instanceDetails
                          .Length  // We want to take the length...
                          .ToString()
                          .Length; // ... and get the length of the length as a string..

            InstanceDetail instanceDetail = null;

            for (int i = 0; i < instanceDetails.Length; i++)
            {
                instanceDetail = instanceDetails[i];

                this.loggingProvider.Debug(
                    $"Composing detail for \"{instanceDetail}\"...");

                stringBuilder.AppendLine(
                    $"{(i + 1).ToString(new string('0', padding))}.\t" +
                    $"{nameof(instanceDetail.Name)}: " +
                    $"{instanceDetail.Name}");
                stringBuilder.AppendLine(
                    $"\t" +
                    $"{nameof(instanceDetail.IPAddress)}: " +
                    $"{instanceDetail.IPAddress}");

                if (!string.IsNullOrEmpty(instanceDetail.Password))
                {
                    stringBuilder.AppendLine(
                        $"\t" +
                        $"{nameof(instanceDetail.Password)}: " +
                        $"{instanceDetail.Password}");
                }

                stringBuilder.AppendLine();

                this.loggingProvider.Info(
                    $"Finished composing detail for \"{instanceDetail}\".");
            }

            this.loggingProvider.Debug(
                $"Composing of output file content complete. Writing to " +
                $"output file location (\"{outputFile.FullName}\")...");

            this.fileSystemProvider.WriteStringToFileInfo(
                outputFile,
                stringBuilder.ToString());

            this.loggingProvider.Info(
                $"Write to \"{outputFile.FullName}\" complete.");
        }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            var RunDate = DateTime.Now;

            RunDate = RunDate.AddTicks(-(RunDate.Ticks % 10000000));;

            var Instances = InstanceServices.GetAllActive();
            var Jobs      = JobServices.GetById(1);

            Jobs.RunDate  = RunDate;
            Jobs.RunCount = Jobs.RunCount + 1;
            JobServices.Update(Jobs);
            //JobLogServices.logging = true;

            var LogBook = new JobLog {
                JobId = Jobs.Id, RunDate = RunDate, RunCount = (Int32)Jobs.RunCount
            };

            LogBook.Type = "INF"; LogBook.Message = "***** START OF LOG FILE *****";
            JobLogServices.Insert(LogBook);
            //Console.WriteLine("***** START OF LOG FILE *****");

            if (Jobs.Enabled == true)
            {
                LogBook.Type = "INF"; LogBook.Message = ("JOB: " + Jobs.Name + " IS ENABLED"); LogBook.RunDate = DateTime.Now;
                JobLogServices.Insert(LogBook);
                #region SchedulerSettings
                // construct a scheduler factory
                //ISchedulerFactory schedulerFactory = new StdSchedulerFactory();

                //get a scheduler
                // _scheduler = schedulerFactory.GetScheduler();


                //// add scheduler listener
                ////_scheduler.ListenerManager.AddSchedulerListener(new SchedulerListener());

                //// add global job listener
                ////_scheduler.ListenerManager.AddJobListener(new JobListener(), GroupMatcher<JobKey>.AnyGroup());

                //// add global trigger listener
                ////_scheduler.ListenerManager.AddTriggerListener(new TriggerListener(), GroupMatcher<TriggerKey>.AnyGroup());

                //_scheduler.Start();
                // Console.WriteLine("Starting Scheduler");
                #endregion

                #region CallQuartzJob

                /*foreach (string value in servers)
                 * {
                 * //  if (_utility.VerifyRemoteMachineStatus(value) == true)
                 *  //{
                 *
                 *      // foreach (string value in servers)
                 *      //{
                 *
                 *      Jobs.getServerName srvName = new Jobs.getServerName(); //This Constructor needs to be parameterless
                 *      AddSimpleJob(srvName, value);
                 *
                 *      Jobs.getCpuData cpuData = new Jobs.getCpuData();
                 *      AddSimpleJob(cpuData, value);
                 *
                 *  //}
                 *  //else
                 *  //{
                 *    //  Console.WriteLine("Server: " + value + " is offline");
                 *  //}
                 *
                 * }*/
                #endregion
                LogBook.Type = "INF"; LogBook.Message = ("INITIATING SQL CONNECTIVITY TEST"); LogBook.RunDate = DateTime.Now;
                JobLogServices.Insert(LogBook);
                //Console.WriteLine("INFORMATIVE: INITIATING SQL CONNECTIVITY TEST");
                foreach (var i in Instances)
                {
                    var objLogic = new BusinessLayer.BusinessLayer();
                    objLogic.SetConnString(i.Name);

                    if (objLogic.IsServerConnected(objLogic.objDataLayer.ConnString) == true)
                    {
                        //Console.WriteLine("INFORMATIVE: SQL INSTANCE :" + i.Name + " IS UP");
                        LogBook.Type = "INF"; LogBook.Message = ("SQL INSTANCE :" + i.Name + " IS UP"); LogBook.RunDate = DateTime.Now;
                        JobLogServices.Insert(LogBook);
                        var helper_ServerProperty = new ServerProperty();
                        var helper_SysConfig      = new SysConfig();
                        var helper_SysOsInfo      = new SysOsInfo();
                        var helper_PowerPlan      = new PowerPlan();

                        var InstanceDetail_obj = new InstanceDetail();

                        Console.WriteLine("INFORMATIVE: Getting Information from Instance: " + i.Name);

                        helper_ServerProperty = objLogic.GetServerProperties();
                        if (helper_ServerProperty.Success == true)
                        {
                            LogBook.Type = "INF"; LogBook.Message = ("<SUCCESS> GET SERVER PROPERTIES"); LogBook.RunDate = DateTime.Now;
                            JobLogServices.Insert(LogBook);
                            helper_SysConfig = objLogic.GetSysConfiguration();
                            if (helper_SysConfig.Success == true)
                            {
                                LogBook.Type = "INF"; LogBook.Message = ("<SUCCESS> GET SYSTEM CONFIG"); LogBook.RunDate = DateTime.Now;
                                JobLogServices.Insert(LogBook);
                                helper_SysOsInfo = objLogic.GetSysOsInformation();
                                if (helper_SysOsInfo.Success == true)
                                {
                                    LogBook.Type = "INF"; LogBook.Message = ("<SUCCESS> GET SYSTEM OS INFORMATION"); LogBook.RunDate = DateTime.Now;
                                    JobLogServices.Insert(LogBook);
                                    helper_PowerPlan = objLogic.GetPowerPlan();
                                    if (helper_PowerPlan.Success == true)
                                    {
                                        LogBook.Type = "INF"; LogBook.Message = ("<SUCCESS> GET POWER PLAN"); LogBook.RunDate = DateTime.Now;
                                        JobLogServices.Insert(LogBook);
                                        InstanceDetail_obj.Edition     = helper_ServerProperty.Edition;
                                        InstanceDetail_obj.Version     = helper_ServerProperty.ProductVersion;
                                        InstanceDetail_obj.ServicePack = helper_ServerProperty.ProductLevel;
                                        InstanceDetail_obj.AuthMode    = helper_ServerProperty.AuthMode;
                                        InstanceDetail_obj.InstallDate = helper_ServerProperty.SQLInstallDate;
                                        InstanceDetail_obj.TcpPort     = helper_ServerProperty.LocalTcpPort;

                                        InstanceDetail_obj.MaxServerMemory_MB = helper_SysConfig.MaxServerMemory;
                                        InstanceDetail_obj.MinServerMemory_MB = helper_SysConfig.MinServerMemory;
                                        InstanceDetail_obj.BackupCompression  = helper_SysConfig.BackupCompression;
                                        InstanceDetail_obj.MaxDOP             = helper_SysConfig.MaxDop;
                                        InstanceDetail_obj.Xp_Cmdshell        = helper_SysConfig.Xp_Cmdshell;

                                        InstanceDetail_obj.CPU_Count       = helper_SysOsInfo.CpuCount;
                                        InstanceDetail_obj.ServerMemory_MB = helper_SysOsInfo.ServerMemory;
                                        InstanceDetail_obj.LastStartDate   = helper_SysOsInfo.SQLStartTime;
                                        InstanceDetail_obj.MachineType     = helper_SysOsInfo.MachineType;
                                        InstanceDetail_obj.PowerPlan       = helper_PowerPlan.powerPlan;

                                        InstanceDetail_obj.InstanceId = i.Id;
                                        InstanceDetail_obj.RunCount   = (Int32)Jobs.RunCount;
                                        InstanceDetail_obj.RunDate    = (DateTime)Jobs.RunDate;

                                        try
                                        {
                                            InstanceDetailServices.Insert(InstanceDetail_obj);
                                        }
                                        catch (Exception ex)
                                        {
                                            //Console.WriteLine("ERROR: FAILED TO INSERT OBJECT INTO InstanceDetailed TABLE");
                                            LogBook.Type = "ERR"; LogBook.Message = ("<FAILED> COULD NOT INSERT OBJECT INTO InstanceDetailed TABLE - INSTANCE: " + i.Name + " TABLE - EXCEPTION: " + ex.Message); LogBook.RunDate = DateTime.Now;
                                            JobLogServices.Insert(LogBook);
                                        }
                                    }
                                    else
                                    {
                                        LogBook.Type = "ERR"; LogBook.Message = ("<FAIL> GET POWER PLAN - INSTANCE: " + i.Name); LogBook.RunDate = DateTime.Now;
                                        JobLogServices.Insert(LogBook);
                                    }
                                }
                                else
                                {
                                    LogBook.Type = "ERR"; LogBook.Message = ("<FAIL> GET SYSTEM OS INFORMATION - INSTANCE: " + i.Name); LogBook.RunDate = DateTime.Now;
                                    JobLogServices.Insert(LogBook);
                                }
                            }
                            else
                            {
                                LogBook.Type = "ERR"; LogBook.Message = ("<FAIL> GET SYSTEM CONFIG - INSTANCE: " + i.Name); LogBook.RunDate = DateTime.Now;
                                JobLogServices.Insert(LogBook);
                            }
                        }
                        else
                        {
                            LogBook.Type = "ERR"; LogBook.Message = ("<FAIL> GET SERVER PROPERTIES - INSTANCE: " + i.Name); LogBook.RunDate = DateTime.Now;
                            JobLogServices.Insert(LogBook);
                        }
                        //var databaselist = new List<DataLayer.HelperClasses.DatabaseOption>();
                        //databaselist =
                        try
                        {
                            foreach (DatabaseOption DO in objLogic.GetDatabaseOptions())
                            {
                                DO.InstanceId = i.Id;
                                DO.RunDate    = (DateTime)Jobs.RunDate;
                                DO.RunCount   = (Int32)Jobs.RunCount;

                                DatabaseOptionServices.Insert(DO);
                            }
                            LogBook.Type = "INF"; LogBook.Message = ("<SUCCESS> GET DATABASE OPTIONS"); LogBook.RunDate = DateTime.Now;
                            JobLogServices.Insert(LogBook);
                        }
                        catch (Exception ex)
                        {
                            //Console.WriteLine("Exception: " + ex.Message);
                            LogBook.Type = "ERR"; LogBook.Message = ("<FAIL> COULD NOT RETRIEVE OR INSERT DATA INTO DatabaseOptions TABLE - INSTANCE: " + i.Name + " - EXCEPTION: " + ex.Message); LogBook.RunDate = DateTime.Now;
                            JobLogServices.Insert(LogBook);
                        }
                        try
                        {
                            foreach (Backup B in objLogic.GetBackups())
                            {
                                B.RunDate    = (DateTime)Jobs.RunDate;
                                B.RunCount   = (Int32)Jobs.RunCount;
                                B.InstanceId = i.Id;
                                BackupServices.Insert(B);
                            }
                            LogBook.Type = "INF"; LogBook.Message = ("<SUCCESS> GET BACKUPS"); LogBook.RunDate = DateTime.Now;
                            JobLogServices.Insert(LogBook);
                        }
                        catch (Exception ex)
                        {
                            //Console.WriteLine("Exception: " + ex.Message);
                            LogBook.Type = "ERR"; LogBook.Message = ("<FAIL> COULD NOT RETRIEVE OR INSERT DATA INTO Backups TABLE - INSTANCE: " + i.Name + " - EXCEPTION: " + ex.Message); LogBook.RunDate = DateTime.Now;
                            JobLogServices.Insert(LogBook);
                        }
                        try
                        {
                            foreach (Drive D in objLogic.GetDrives())
                            {
                                D.RunDate    = (DateTime)Jobs.RunDate;
                                D.RunCount   = (Int32)Jobs.RunCount;
                                D.InstanceId = i.Id;
                                DriveServices.Insert(D);
                            }
                            LogBook.Type = "INF"; LogBook.Message = ("<SUCCESS> GET DRIVE INFORMATION"); LogBook.RunDate = DateTime.Now;
                            JobLogServices.Insert(LogBook);
                        }
                        catch (Exception ex)
                        {
                            //Console.WriteLine("Exception: " + ex.Message);
                            LogBook.Type = "ERR"; LogBook.Message = ("<FAIL> COULD NOT RETRIEVE OR INSERT DATA INTO Drives TABLE - INSTANCE: " + i.Name + " - EXCEPTION: " + ex.Message); LogBook.RunDate = DateTime.Now;
                            JobLogServices.Insert(LogBook);
                        }
                        try
                        {
                            foreach (DatabaseFile DBF in objLogic.GetDatabaseFiles())
                            {
                                DBF.RunDate    = (DateTime)Jobs.RunDate;
                                DBF.RunCount   = (Int32)Jobs.RunCount;
                                DBF.InstanceId = i.Id;
                                DatabaseFileServices.Insert(DBF);
                            }
                            LogBook.Type = "INF"; LogBook.Message = ("<SUCCESS> GET DATABASE FILE INFORMATION"); LogBook.RunDate = DateTime.Now;
                            JobLogServices.Insert(LogBook);
                        }
                        catch (Exception ex)
                        {
                            //Console.WriteLine("Exception: " + ex.Message);
                            LogBook.Type = "ERR"; LogBook.Message = ("<FAIL> COULD NOT RETRIEVE OR INSERT DATA INTO DatabaseFiles TABLE - INSTANCE: " + i.Name + " - EXCEPTION: " + ex.Message); LogBook.RunDate = DateTime.Now;
                            JobLogServices.Insert(LogBook);
                        }
                        try
                        {
                            foreach (DatabaseSize DBS in objLogic.GetDatabaseSize())
                            {
                                DBS.RunDate    = (DateTime)Jobs.RunDate;
                                DBS.RunCount   = (Int32)Jobs.RunCount;
                                DBS.InstanceId = i.Id;
                                DatabaseSizeServices.Insert(DBS);
                            }
                            LogBook.Type = "INF"; LogBook.Message = ("<SUCCESS> GET DATABASE SIZE INFORMATION"); LogBook.RunDate = DateTime.Now;
                            JobLogServices.Insert(LogBook);
                        }
                        catch (Exception ex)
                        {
                            //Console.WriteLine("Exception: " + ex.Message);
                            LogBook.Type = "ERR"; LogBook.Message = ("<FAIL> COULD NOT RETRIEVE OR INSERT DATA INTO DatabaseSize TABLE - INSTANCE: " + i.Name + " - EXCEPTION: " + ex.Message); LogBook.RunDate = DateTime.Now;
                            JobLogServices.Insert(LogBook);
                        }
                        try
                        {
                            foreach (UserMembership UM in objLogic.GetUserMembership())
                            {
                                UM.RunDate    = (DateTime)Jobs.RunDate;
                                UM.RunCount   = (Int32)Jobs.RunCount;
                                UM.InstanceId = i.Id;
                                UserMembershipServices.Insert(UM);
                            }
                            LogBook.Type = "INF"; LogBook.Message = ("<SUCCESS> GET USER MEMBERSHIP INFORMATION"); LogBook.RunDate = DateTime.Now;
                            JobLogServices.Insert(LogBook);
                        }
                        catch (Exception ex)
                        {
                            //Console.WriteLine("Exception: " + ex.Message);
                            LogBook.Type = "ERR"; LogBook.Message = ("<FAIL> COULD NOT RETRIEVE OR INSERT DATA INTO UserMembership TABLE - INSTANCE: " + i.Name + " - EXCEPTION: " + ex.Message); LogBook.RunDate = DateTime.Now;
                            JobLogServices.Insert(LogBook);
                        }
                        try
                        {
                            foreach (LoginMembership LM in objLogic.GetLoginMembership())
                            {
                                LM.RunDate    = (DateTime)Jobs.RunDate;
                                LM.RunCount   = (Int32)Jobs.RunCount;
                                LM.InstanceId = i.Id;
                                LoginMembershipServices.Insert(LM);
                            }
                            LogBook.Type = "INF"; LogBook.Message = ("<SUCCESS> GET LOGIN MEMBERSHIP INFORMATION"); LogBook.RunDate = DateTime.Now;
                            JobLogServices.Insert(LogBook);
                        }
                        catch (Exception ex)
                        {
                            //Console.WriteLine("Exception: " + ex.Message);
                            LogBook.Type = "ERR"; LogBook.Message = ("<FAIL> COULD NOT RETRIEVE OR INSERT DATA INTO LoginMembership TABLE - INSTANCE: " + i.Name + " - EXCEPTION: " + ex.Message); LogBook.RunDate = DateTime.Now;
                            JobLogServices.Insert(LogBook);
                        }
                        try
                        {
                            foreach (LogSize LS in objLogic.GetLogSize())
                            {
                                LS.RunDate    = (DateTime)Jobs.RunDate;
                                LS.RunCount   = (Int32)Jobs.RunCount;
                                LS.InstanceId = i.Id;
                                LogSizeServices.Insert(LS);
                            }
                            LogBook.Type = "INF"; LogBook.Message = ("<SUCCESS> GET LOG SIZE INFORMATION"); LogBook.RunDate = DateTime.Now;
                            JobLogServices.Insert(LogBook);
                        }
                        catch (Exception ex)
                        {
                            //Console.WriteLine("Exception: " + ex.Message);
                            LogBook.Type = "ERR"; LogBook.Message = ("<FAIL> COULD NOT RETRIEVE OR INSERT DATA INTO LogSize TABLE - INSTANCE: " + i.Name + " - EXCEPTION: " + ex.Message); LogBook.RunDate = DateTime.Now;
                            JobLogServices.Insert(LogBook);
                        }
                    }
                    else
                    {
                        //Console.WriteLine("WARNING: COULD NOT CONNECT TO SQL INSTANCE: " + i.Name);
                        LogBook.Type = "WRN"; LogBook.Message = ("COULD NOT CONNECT TO SQL INSTANCE: " + i.Name); LogBook.RunDate = DateTime.Now;
                        JobLogServices.Insert(LogBook);
                    }
                }

                //JobServices.Update(Jobs);
            }
            else
            {
                LogBook.Type = "INF"; LogBook.Message = ("JOB: " + Jobs.Name + " IS DISABLED");
                JobLogServices.Insert(LogBook);
            }
            //_scheduler.Shutdown();

            Console.WriteLine("***** END OF LOG FILE *****");
            LogBook.Type = "INF"; LogBook.Message = "***** END OF LOG FILE *****";
            JobLogServices.Insert(LogBook);
            //Console.ReadLine();
        }