Пример #1
0
        public bool makeCheck(string address)
        {
            //BondClockDataSetTableAdapters.WebStatusTableAdapter tableadapter = new BondClockDataSetTableAdapters.WebStatusTableAdapter();
            Slackwrapper slackwrapper = new Slackwrapper();

            using (var client = new HttpClient(new HttpClientHandler {
                AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
            }))
            {
                client.BaseAddress = new Uri(address);
                HttpResponseMessage response = client.GetAsync("").Result;
                response.EnsureSuccessStatusCode();
                string statuscode = response.StatusCode.ToString();
                string result     = response.Content.ReadAsStringAsync().Result;

                if (statuscode == "OK")
                {
                    //tableadapter.Insert(address,DateTime.Now,"OK");

                    if (result.Contains("Maintenance"))
                    {
                        slackwrapper.sendslack(address + " is in Maintenance Mode " + Environment.NewLine);
                        //tableadapter.Insert(address, DateTime.Now, "Maintenance Mode");
                    }
                }
                else
                {
                    //tableadapter.Insert(address, DateTime.Now, "Not returning ok. Not in Maintenance");
                    slackwrapper.sendslack(address + " is not returning a 200 ok. " + Environment.NewLine);
                }
            }
            return(true);
        }
Пример #2
0
        protected override void OnStop()
        {
            Slackwrapper slackwrapper = new Slackwrapper();

            slackwrapper.sendslack("Service Stop " + DateTime.Now);
            host.Stop();
        }
Пример #3
0
        protected override void OnStart(string[] args)
        {
            Slackwrapper slackwrapper = new Slackwrapper();

            slackwrapper.sendslack("Session Start " + DateTime.Now);

            host.Start();

            System.Timers.Timer timer = new System.Timers.Timer();
            timer.Interval = 180000;
            timer.Elapsed += new System.Timers.ElapsedEventHandler(this.OnTimer);
            timer.Start();
        }
Пример #4
0
        protected override void OnSessionChange(SessionChangeDescription changeDescription)
        {
            TimeSpan     morningstartTime = new TimeSpan(7, 0, 0);
            TimeSpan     morningendTime   = new TimeSpan(9, 0, 0);
            TimeSpan     eveningstartTime = new TimeSpan(16, 0, 0);
            TimeSpan     eveningendTime   = new TimeSpan(18, 0, 0);
            Slackwrapper slackwrapper     = new Slackwrapper();

            switch (changeDescription.Reason)
            {
            case SessionChangeReason.SessionLogon:
                slackwrapper.sendslack("Session Logon " + DateTime.Now + " for user " + Environment.UserName);
                if (DateTime.Now.TimeOfDay >= morningstartTime && DateTime.Now.TimeOfDay <= morningendTime)
                {
                    slackwrapper.sendslack("Did you clock in?");
                }
                break;

            case SessionChangeReason.SessionLogoff:
                slackwrapper.sendslack("Session Logoff " + DateTime.Now + " for user " + Environment.UserName);
                if (DateTime.Now.TimeOfDay >= eveningstartTime && DateTime.Now.TimeOfDay <= eveningendTime)
                {
                    slackwrapper.sendslack("Did you clock out?");
                }
                break;

            case SessionChangeReason.SessionLock:
                slackwrapper.sendslack("Session Locked " + DateTime.Now + " for user " + Environment.UserName);
                if (DateTime.Now.TimeOfDay >= eveningstartTime && DateTime.Now.TimeOfDay <= eveningendTime)
                {
                    slackwrapper.sendslack("Did you clock out?");
                }
                break;

            case SessionChangeReason.SessionUnlock:
                slackwrapper.sendslack("Session Unlocked " + DateTime.Now + " for user " + Environment.UserName);
                if (DateTime.Now.TimeOfDay >= morningstartTime && DateTime.Now.TimeOfDay <= morningendTime)
                {
                    slackwrapper.sendslack("Did you clock in?");
                }
                break;
            }

            base.OnSessionChange(changeDescription);
        }