Exemplo n.º 1
0
        public static async Task<DisplayData> RefreshAsync(int displayId)
        {
            DisplayData data = new DisplayData()
            {
                DisplayId = 0,
                IdleInterval = 0,
                Hash = 0,
                RecycleTime = null
            };
            
            using (SqlCommand cmd = new SqlCommand("sp_GetDisplayData"))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@displayId", displayId);

                await cmd.ExecuteReaderExtAsync((reader) =>
                {
                    data.DisplayId = reader.IntOrZero("DisplayId");
                    data.IdleInterval = reader.IntOrZero("IdleInterval");
                    data.Hash = reader.IntOrZero("Hash");

                    if (reader["RecycleTime"] != DBNull.Value)
                    {
                        data.RecycleTime = (TimeSpan)reader["RecycleTime"];
                    }

                    return false;
                });
            }
            
            return data;
        }
Exemplo n.º 2
0
        public static DisplayData Refresh(int displayId)
        {
            DisplayData data = new DisplayData()
            {
                DisplayId    = 0,
                IdleInterval = 0,
                Hash         = 0,
                RecycleTime  = null
            };

            using (SqlCommand cmd = new SqlCommand("sp_GetDisplayData"))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@displayId", displayId);
                using (DataSet ds = DataAccess.RunSql(cmd))
                {
                    if (ds.Tables.Count > 0)
                    {
                        DataRow r = ds.Tables[0].Rows[0];
                        data.DisplayId    = r.IntOrZero("DisplayId");
                        data.IdleInterval = r.IntOrZero("IdleInterval");
                        data.Hash         = r.IntOrZero("Hash");

                        if (r["RecycleTime"] != DBNull.Value)
                        {
                            data.RecycleTime = (TimeSpan)r["RecycleTime"];
                        }
                    }
                }
            }

            return(data);
        }
Exemplo n.º 3
0
        public static DisplayData Refresh(int displayId)
        {
            DisplayData data = new DisplayData()
            {
                DisplayId = 0,
                IdleInterval = 0,
                Hash = 0,
                RecycleTime = null
            };
            
            using (SqlCommand cmd = new SqlCommand("sp_GetDisplayData"))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@displayId", displayId);
                using (DataSet ds = DataAccess.RunSql(cmd))
                {
                    if (ds.Tables.Count > 0)
                    {
                        DataRow r = ds.Tables[0].Rows[0];
                        data.DisplayId = r.IntOrZero("DisplayId");
                        data.IdleInterval = r.IntOrZero("IdleInterval");
                        data.Hash = r.IntOrZero("Hash");

                        if (r["RecycleTime"] != DBNull.Value)
                        {
                            data.RecycleTime = (TimeSpan)r["RecycleTime"];
                        }
                    }
                }
            }
            
            return data;
        }
Exemplo n.º 4
0
        public static async Task <DisplayData> RefreshAsync(int displayId)
        {
            DisplayData data = new DisplayData()
            {
                DisplayId    = 0,
                IdleInterval = 0,
                Hash         = 0,
                RecycleTime  = null
            };

            using (SqlCommand cmd = new SqlCommand("sp_GetDisplayData"))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@displayId", displayId);

                await cmd.ExecuteReaderExtAsync((reader) =>
                {
                    data.DisplayId    = reader.IntOrZero("DisplayId");
                    data.IdleInterval = reader.IntOrZero("IdleInterval");
                    data.Hash         = reader.IntOrZero("Hash");

                    if (reader["RecycleTime"] != DBNull.Value)
                    {
                        data.RecycleTime = (TimeSpan)reader["RecycleTime"];
                    }

                    return(false);
                });
            }

            return(data);
        }
        public override async Task ProcessRequestAsync(HttpContext context)
        {
            HttpRequest  request  = context.Request;
            HttpResponse response = context.Response;

            int displayId = request.IntOrZero("display");
            int trace     = request.IntOrZero("trace");

            string json = "";

            try
            {
                DisplayData data = await DisplayData.RefreshAsync(displayId);

                JavaScriptSerializer oSerializer = new JavaScriptSerializer();
                json = oSerializer.Serialize(data);
            }

            catch (Exception ex)
            {
                JavaScriptSerializer s = new JavaScriptSerializer();
                if (trace == 0)
                {
                    json = s.Serialize(new
                    {
                        Error = ex.Message,
                        Data  = new
                        {
                            DisplayId = displayId,
                        },
                    });
                }
                else
                {
                    json = s.Serialize(new
                    {
                        Error = ex.Message,
                        Stack = ex.StackTrace,
                        Data  = new
                        {
                            DisplayId = displayId,
                        },
                    });
                }
            }

            response.Clear();
            response.Cache.SetCacheability(HttpCacheability.NoCache);
            response.Cache.SetSlidingExpiration(true);
            response.Cache.SetNoStore();
            response.ContentType = "application/json";
            response.Write(json);
            response.Flush();
        }
Exemplo n.º 6
0
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest  Request  = context.Request;
            HttpResponse Response = context.Response;

            int displayId = DataAccess.IntOrZero(Request.QueryString["display"]);

            string json = "";

            try
            {
                DisplayData          data        = DisplayData.Refresh(displayId);
                JavaScriptSerializer oSerializer = new JavaScriptSerializer();
                json = oSerializer.Serialize(data);
            }

            catch (Exception ex)
            {
                JavaScriptSerializer s = new JavaScriptSerializer();
                json = s.Serialize(new
                {
                    Error = ex.Message,
                    Data  = new
                    {
                        DisplayId = displayId,
                    },
                });
            }

            Response.Clear();
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetSlidingExpiration(true);
            Response.Cache.SetNoStore();
            Response.ContentType = "application/json";
            Response.Write(json);
            Response.Flush();
        }