Beispiel #1
0
        public static List <DisplayUserJson> allUsersList(string URL)
        {
            try
            {
                List <DisplayUserJson> usersList = new List <DisplayUserJson>();


                string m_URL = URL + "/scripts/displayData.php";

                string param = "ABEX=" + LoneUtil.sha256(LoneUtil.SECRET_KEY);

                WebClient server = new WebClient();
                server.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
                string HtmlResult = server.UploadString(m_URL, param);

                usersList = JsonConvert.DeserializeObject <List <DisplayUserJson> >(HtmlResult);


                return(usersList);
            }
            catch (WebException e)
            {
                MessageBox.Show("ERROR: " + e);
                return(null);
            }
        }
Beispiel #2
0
        private void store(string URL)
        {
            foreach (LiveUserJson xx in liveUsersList)
            {
                xx.LiveUser = null;
            }

            try
            {
                string m_URL = URL + "/scripts/liveData.php";

                string param = "ABEX=" + LoneUtil.sha256(LoneUtil.SECRET_KEY);

                WebClient server = new WebClient();
                server.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
                string htmlResult = server.UploadString(m_URL, param);

                liveUsersList = JsonConvert.DeserializeObject <List <LiveUserJson> >(htmlResult);
                //Console.WriteLine(htmlResult);
            }
            catch (WebException e)
            {
                System.Windows.Forms.MessageBox.Show("ERROR: " + e);
            }
        }
Beispiel #3
0
        /*
         * public static User CheckUser(string URL, string username) {
         *  try
         *  {
         *      User _user = new User();
         *
         *      string m_URL = URL + "/scripts/delPrepare.php";
         *      string param = "username="******"&ABEX=" + LoneUtil.sha256(LoneUtil.SECRET_KEY);
         *
         *      WebClient server = new WebClient();
         *      server.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
         *      string HtmlResult = server.UploadString(m_URL, param);
         *
         *      _user = JsonConvert.DeserializeObject<User>(HtmlResult);
         *
         *      return _user;
         *  }
         *  catch (WebException e)
         *  {
         *      MessageBox.Show("Cannot check the user: "******"/scripts/sosDone.php";
                string param = "username="******"&ABEX=" + LoneUtil.sha256(LoneUtil.SECRET_KEY);

                WebClient server = new WebClient();
                server.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
                string HtmlResult = server.UploadString(m_URL, param);
            }
            catch (WebException e)
            {
                MessageBox.Show("ERROR: " + e);
            }
        }
Beispiel #4
0
        public Connection(string URL, string username, string password)
        {
            try
            {
                string p = LoneUtil.sha256(password);

                string m_URL = URL + "/scripts/login.php";
                string param = "username="******"&password="******"&ABEX=" + LoneUtil.sha256(LoneUtil.SECRET_KEY);

                WebClient server = new WebClient();
                server.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
                string HtmlResult = server.UploadString(m_URL, param);

                user = new User();

                user = JsonConvert.DeserializeObject <User>(HtmlResult);
            }
            catch (WebException e)
            {
                MessageBox.Show("Cannot log-in: " + e);
            }
        }
Beispiel #5
0
        private void store(string URL, string fromDate)
        {
            foreach (ReportUserJson xx in reportUsersList)
            {
                xx.ReportUser = null;
            }

            try
            {
                string m_URL = URL + "/scripts/reportUser.php";
                string param = "fromDate=" + fromDate + "&ABEX=" + LoneUtil.sha256(LoneUtil.SECRET_KEY);

                WebClient server = new WebClient();
                server.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
                string htmlResult = server.UploadString(m_URL, param);
                //string htmlResult = server.DownloadString(m_URL);

                reportUsersList = JsonConvert.DeserializeObject <List <ReportUserJson> >(htmlResult);
            }
            catch (WebException e)
            {
                System.Windows.Forms.MessageBox.Show("ERROR: " + e);
            }
        }
Beispiel #6
0
        private void live()
        {
            reset();
            //load the list to the data grid
            try
            {
                foreach (LiveUser user in newList)
                {
                    if (user != null)
                    {
                        string[] checkin = new string[8] {
                            user.Checkin1, user.Checkin2,
                            user.Checkin3, user.Checkin4, user.Checkin5,
                            user.Checkin6, user.Checkin7, user.Checkin8
                        };

                        string fullName = user.Firstname + " " + user.Lastname;

                        dataGrid.Rows.Add(fullName, user.Risklevel, user.StartTime, user.EndTime,
                                          checkin[0], checkin[1], checkin[2], checkin[3],
                                          checkin[4], checkin[5], checkin[6], checkin[7]);

                        //if sos is = 1 make notifications
                        if (user.NeedSOS == 1)
                        {
                            if (adminEmail != null)
                            {
                                //send an email to the admin as long as his email provided
                                notifyEmail(adminName, adminLname, adminEmail, user, "S.O.S.");
                            }

                            //push sos notification to the gui
                            sos(user);
                        }


                        //if not any checkin is between 1 to 3 makes that an escalation
                        for (int x = 0; x < 8; x++)
                        {
                            int userEsc = 0;
                            LoneUtil.getInt(checkin[x], ref userEsc);

                            int num = x + 1;

                            for (int i = 1; i < 4; i++)
                            {
                                if (userEsc == i)
                                {
                                    if (adminEmail != null)
                                    {//send admin email as long as its provided
                                        notifyEmail(adminName, adminLname, adminEmail, user, "ESCALATION LEVEL " + i.ToString());
                                    }
                                    //push gui notification
                                    notification(user, "checkin" + num.ToString(), i);
                                }
                            }
                        }
                        //ended
                    }
                }
            }
            catch (InvalidOperationException e)
            {
                Console.WriteLine(e);
            }
        }
Beispiel #7
0
        //alter escalation
        public static void notified(string URL, string username, string checkin, string esc)
        {
            try
            {
                string m_URL = URL + "/scripts/escDone.php";
                string param = "username="******"&checkin=" + checkin + "&esc=" + esc + "&ABEX=" + LoneUtil.sha256(LoneUtil.SECRET_KEY);

                WebClient server = new WebClient();
                server.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
                string HtmlResult = server.UploadString(m_URL, param);
            }
            catch (WebException e)
            {
                MessageBox.Show("ERROR: " + e);
            }


            //Console.WriteLine(HtmlResult);
        }