Example #1
0
        static void Main(string[] args)
        {
            /*** MAIL SERVER CONFIG AND SETUP ***/
            string      mailHost   = "10.10.10.10";
            int         mailPort   = 25;
            string      mailDomain = @"@domain.com";
            MailHandler mailer     = new MailHandler(mailHost, mailPort, mailDomain);

            /*** SQL CONFIG AND SETUP ***/
            string     SQLserver   = "11.11.11.11";
            string     SQLdatabase = "Monitoring";
            string     SQLuser     = "******";
            string     SQLpass     = "******";
            SQLHandler SQL         = new SQLHandler(SQLserver, SQLdatabase, SQLuser, SQLpass);

            /*** PSTOOLS CONFIG AND SETUP ***/
            string         TVMuser = "******";
            string         TVMpass = "******";
            PSToolsHandler PSTools = new PSToolsHandler(TVMuser, TVMpass, mailer);

            //SQL query to get machine data
            string    queryMachine = "SELECT Site, Machine, DomainAddress FROM DeviceStatus WHERE EquipmentType = 2";
            DataTable SQLresult    = SQL.GetData(queryMachine);

            // Example case for main sequence with parallell processing
            Parallel.ForEach(SQLresult.AsEnumerable(), Machine => {
                //Retrieving variables from datatable
                string EquipmentIPAddress = Machine.Field <string>("DomainAddress");
                string SiteName           = Machine.Field <string>("Site");
                string MachineName        = Machine.Field <string>("Machine");

                if (NetworkHandler.pingTest(EquipmentIPAddress))
                {
                    PSTools.DeleteEODfilesAndReboot(DomainAddress);
                }
            });
            mailer.SendMail("toMail", "fromMail", "This is the subject", "This is the body");

            // For user input before closing
            Console.ReadLine();
        }
Example #2
0
 public PSToolsHandler(string username, string password, MailHandler mail)
 {
     this.pstoolsLogin = "******" + username + " -p " + password + " ";
     this.mail         = mail;
 }