public ActionResult ChangeStatusSOS(int?id)
 {
     if (id != null)
     {
         var data = SOSService.UpdateStatusSOSbyID((int)id, -1);
         return(Json(data, JsonRequestBehavior.AllowGet));
     }
     return(Json("Không thành công !", JsonRequestBehavior.AllowGet));
 }
Esempio n. 2
0
        public ActionResult GetSOSByID()
        {
            var user = (Users)Session["User"];

            if (user == null)
            {
                return(RedirectToAction("Login", "Home", new { area = "" }));
            }
            var data = SOSService.GetSOSByUserID(user.UserID);

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        // GET: SOS
        public ActionResult Index()
        {
            var user = (Users)Session["User"];

            if (user == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            List <SOSDTO> data = SOSService.GetSOSByUserID(user.UserID);

            return(View("BaoCaoCanhBaoSOS", data));
        }
        public ActionResult GetListSOS()
        {
            var user = (Users)Session["User"];

            if (user.RoleID == 1)
            {
                var data = SOSService.GetSOSPending();
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
            if (user.RoleID == 2)
            {
                var data = SOSService.GetSOSPendingByUserID(user.UserID);
                return(Json(data, JsonRequestBehavior.AllowGet));
            }

            return(Json("Không thành công !", JsonRequestBehavior.AllowGet));
        }
Esempio n. 5
0
        public void Execute(IJobExecutionContext context)
        {
            Console.WriteLine("Hello, JOb executed");
            var lstSOS = SOSService.GetSOSPending();

            if (lstSOS != null)
            {
                foreach (var item in lstSOS)
                {
                    try
                    {
                        var client  = new RestClient("http://192.168.1.1");
                        var request = new RestRequest("api/item/", Method.POST);
                        request.RequestFormat = DataFormat.Json;
                        request.AddBody(new
                        {
                            MRFF  = "3",
                            ID    = item.DeviceID,
                            Space = "1",
                            item.Latitude,
                            ExpSN = item.DirectionSN,
                            item.Longitude,
                            ExpEW = item.DirectionEW,
                            Date  = item.DateRequest.ToString("dd/MM/yyyy"),
                            Time  = item.DateRequest.ToString("HH:mm:ss"),
                            item.GMT
                        });
                        request.Timeout = 30 * 1000;
                        var rs = client.Execute(request);
                        if (rs.StatusCode == HttpStatusCode.OK)
                        {
                            item.Status = 1;
                            SOSService.UpdateStatusSOSbyID(item);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
Esempio n. 6
0
        public async void Execute(IJobExecutionContext context)
        {
            Console.WriteLine("Hello, JOb executed");
            var lstSOS = SOSService.GetSOSPending();

            if (lstSOS != null)
            {
                foreach (var i in lstSOS)
                {
                    HttpClient client = new HttpClient();
                    var        value  = new Dictionary <string, string>
                    {
                        { "MREF", "SOS" },
                        { "ID", i.DeviceImei },
                        { "Space", " " },
                        { "Latitude", i.Latitude.ToString() },
                        { "ExpSN", i.DirectionSN },
                        { "Longitude", i.Longitude.ToString() },
                        { "ExpEW", i.DirectionEW },
                        { "Date", i.DateRequest.ToString("dd/MM/yyyy") },
                        { "Time", i.DateRequest.ToString("HH:mm:ss") },
                        { "GMT", i.GMT },
                    };
                    var content = new FormUrlEncodedContent(value);
                    //var emptyContent = new StringContent("{}", Encoding.UTF8, "application/json");
                    var res = await client.PostAsync(ConnectData.URLSOS, content);

                    //var res = await client.PostAsync("http://192.168.1.14:11413", emptyContent);
                    var responseString = await res.Content.ReadAsStringAsync();

                    if (res.StatusCode == HttpStatusCode.OK)
                    {
                        SOSService.UpdateStatusSOSbyID((int)i.SOSID, 2);
                    }

                    //var value = await Task.Run(() => JsonConvert.SerializeObject(i));
                    //var content = new StringContent(value, Encoding.UTF8, "application/json");
                    //using (HttpClient client = new HttpClient())
                    //{
                    //    var res = await client.PostAsync(ConnectData.URLSOS, content);
                    //    var responseString = await res.Content.ReadAsStringAsync();
                    //    if (res.StatusCode == HttpStatusCode.OK)
                    //    {
                    //        SOSService.UpdateStatusSOSbyID((int)i.SOSID, 2);
                    //    }

                    //}
                }
            }
            //    foreach (var item in lstSOS)
            //{
            //    try
            //    {
            //        var client = new RestClient(ConnectData.URLSOS);
            //        var request = new RestRequest(ConnectData.SOSResource, Method.POST);
            //        request.RequestFormat = DataFormat.Json;
            //        request.AddJsonBody(new
            //        {
            //            MREF = "SOS",
            //            ID = item.DeviceImei,
            //            Space = " ",
            //            Latitude = item.Latitude,
            //            ExpSN = item.DirectionSN,
            //            Longitude = item.Longitude,
            //            ExpEW = item.DirectionEW,
            //            date = item.DateRequest.ToString("dd/MM/yyyy"),
            //            time = item.DateRequest.ToString("HH:mm:ss"),
            //            GMT = item.GMT
            //        });
            //        request.Timeout = 30 * 1000;
            //        var rs = client.Execute(request);
            //        if (rs.StatusCode == HttpStatusCode.OK)
            //        {
            //            item.Status = 2;
            //
            //        }
            //    }
        }