Esempio n. 1
0
        private void GetAllVideoAreas()
        {
            HttpContext context = HttpContext.Current;
            var         name = context.Request.Params["name"];
            int         type, status;

            int.TryParse(context.Request.Params["type"], out type);
            int.TryParse(context.Request.Params["state"], out status);
            VideoPollutionManager videoPollutionManager = new VideoPollutionManager();
            DataTable             dt = videoPollutionManager.GetAllVideoAreaList(name, type, status);

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dataRow in dt.Rows)
                {
                    if (dataRow["status"].ToString() == "0")
                    {
                        //dataRow["status2"] = "<img src='/widgets/assets/images/camera.png' />";
                        dataRow["status2"] = @"<div style=' width: 10px;
                        height: 10px;
                        background-color: #9DF94B;
                        border-radius: 50%;
                        -moz-border-radius: 50%;
                        -webkit-border-radius: 50%; '></div>";
                    }
                    else
                    {
                        dataRow["status2"] = @"<div style=' width: 10px;
                        height: 10px;
                        background-color: red;
                        border-radius: 50%;
                        -moz-border-radius: 50%;
                        -webkit-border-radius: 50%; '></div>";
                    }
                }
            }
            var jsonData = JsonConvert.SerializeObject(dt);

            context.Response.Write(jsonData.Replace("\r", "").Replace("\n", "").Replace("\r\n", "").Replace(Environment.NewLine, ""));
        }
Esempio n. 2
0
        private void GetAllVideoAreas()
        {
            HttpContext           context = HttpContext.Current;
            VideoPollutionManager videoPollutionManager = new VideoPollutionManager();
            DataTable             dt = videoPollutionManager.GetAllVideoAreaList();
            StringBuilder         sb = new StringBuilder("[");

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    sb.Append("{");
                    sb.Append($@"'name':'{dr["Name"]}',");
                    sb.Append($@"'longitude':'{dr["lon"]}',");
                    sb.Append($@"'latitude':'{dr["lat"]}'");
                    sb.Append("},");
                }
                sb = sb.Remove(sb.Length - 1, 1);
            }
            sb.Append("]");
            sb = sb.Replace("\n", "").Replace("\r\n", "");

            context.Response.Write(sb.ToString());
        }