Ejemplo n.º 1
0
        public chatboxInfo GetInfo(int id)
        {
            chatboxInfo info = null;

            SqlParameter[] param =
            {
                new SqlParameter("@ID", id)
            };
            var r = DataHelper.ExecuteReader(Config.ConnectString, "usp_chatbox_GetById", param);

            if (r != null)
            {
                info = new chatboxInfo();
                while (r.Read())
                {
                    info.id         = Int32.Parse(r["ID"].ToString());
                    info.name       = r["name"].ToString();
                    info.comment    = r["comment"].ToString();
                    info.CreateDate = Convert.ToDateTime(r["CreateDate"]);
                }
                r.Close();
                r.Dispose();
            }
            return(info);
        }
Ejemplo n.º 2
0
        public List <chatboxInfo> GetAll(int top)
        {
            List <chatboxInfo> list = null;
            var t = 0;

            SqlParameter[] param =
            {
                new SqlParameter("@top", top)
            };
            SqlCommand comx;
            var        r = DataHelper.ExecuteReader(Config.ConnectString, "tuan_chatbox_selectop_desc", param);

            if (r != null)
            {
                list = new List <chatboxInfo>();
                while (r.Read())
                {
                    var info = new chatboxInfo();
                    info.name    = r["name"].ToString();
                    info.comment = r["comment"].ToString();
                    info.isAdmin = r.GetBoolean(r.GetOrdinal("isadmin"));
                    list.Add(info);
                }
                r.Close();
                r.Dispose();
            }
            return(list);
        }
Ejemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            var times    = 0;
            var username = context.Request.Form["username"];
            var comment  = Emotify(context.Request.Form["comment"]);
            var ip       = context.Request.ServerVariables["REMOTE_ADDR"];
            var cach     = context.Cache[cachcomment + ip];

            if (cach != null)
            {
                times = int.Parse(cach.ToString());
            }
            if (times >= 0 && times < 15)
            {
                //Insert
                var info = new chatboxInfo();
                info.isAdmin = false;
                info.active  = true;
                info.name    = username;
                info.comment = comment;
                ServiceFactory.GetInstanceChatbox().Add(info);
                //Recache
                //context.Cache.Add(cachcomment + ip.Replace(".", "_"), ++times, null, DateTime.Now.AddDays(1),Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
                context.Response.Write(1);
            }
            else
            {
                context.Response.Write(2);
            }
            context.Response.End();
        }
Ejemplo n.º 4
0
 public int Update(chatboxInfo info)
 {
     SqlParameter[] param =
     {
         new SqlParameter("@ID",      info.id)
         ,                            new SqlParameter("@name",info.name),
         new SqlParameter("@comment", info.comment),
     };
     return(DataHelper.ExecuteNonQuery(Config.ConnectString, "usp_chatbox_Update", param));
 }
Ejemplo n.º 5
0
 public int Add(chatboxInfo info)
 {
     SqlParameter[] param =
     {
         new SqlParameter("@name",       info.name),
         new SqlParameter("@comment",    info.comment),
         new SqlParameter("@CreateDate", info.CreateDate)
     };
     return(int.Parse(DataHelper.ExecuteScalar(Config.ConnectString, "usp_chatbox_Add", param).ToString()));
 }
        protected void BT_Save_Click(object sender, EventArgs e)
        {
            chatboxInfo info = new chatboxInfo();

            info.comment = TB_Comment.Text;
            info.name    = "Admin";
            info.isAdmin = true;
            info.active  = CB_Active.Checked;
            ServiceFactory.GetInstanceChatbox().Add(info);
            Response.Redirect("list-chatbox-other.aspx");
        }
Ejemplo n.º 7
0
        public List <chatboxInfo> GetList(int pageIndex, int pageSize, out int total)
        {
            List <chatboxInfo> list = null;
            var t = 0;

            SqlParameter[] param =
            {
                new SqlParameter("@pageIndex", pageIndex),
                new SqlParameter("@pageSize",  pageSize),
                new SqlParameter("@totalrow",  DbType.Int32)
                {
                    Direction = ParameterDirection.Output
                }
            };
            SqlCommand comx;
            var        r = DataHelper.ExecuteReader(Config.ConnectString, "usp_chatbox_GetList", param, out comx);

            if (r != null)
            {
                list = new List <chatboxInfo>();
                while (r.Read())
                {
                    var info = new chatboxInfo();
                    info.id         = Int32.Parse(r["ID"].ToString());
                    info.name       = r["name"].ToString();
                    info.comment    = r["comment"].ToString();
                    info.CreateDate = Convert.ToDateTime(r["CreateDate"]);


                    list.Add(info);
                }
                r.Close();
                r.Dispose();
                t = int.Parse(comx.Parameters[2].Value.ToString());
            }

            total = t;
            return(list);
        }