Example #1
0
        public bool AddGuestbook(GuestbookEntity guestbookEntity)
        {
            bool          flag           = false;
            StringBuilder sqlCommandText = new StringBuilder();

            sqlCommandText.Append(" @JournalID");
            sqlCommandText.Append(", @UserName");
            sqlCommandText.Append(", @Email");
            sqlCommandText.Append(", @Tel");
            sqlCommandText.Append(", @Title");
            sqlCommandText.Append(", @MessageContent");
            sqlCommandText.Append(", @IP");

            DbCommand cmd = db.GetSqlStringCommand(String.Format("INSERT INTO dbo.Guestbook ({0}) VALUES ({1})", sqlCommandText.ToString().Replace("@", ""), sqlCommandText.ToString()));

            db.AddInParameter(cmd, "@JournalID", DbType.Int64, guestbookEntity.JournalID);
            db.AddInParameter(cmd, "@UserName", DbType.AnsiString, guestbookEntity.UserName.TextFilter());
            db.AddInParameter(cmd, "@Email", DbType.AnsiString, guestbookEntity.Email.TextFilter());
            db.AddInParameter(cmd, "@Tel", DbType.AnsiString, guestbookEntity.Tel.TextFilter());
            db.AddInParameter(cmd, "@Title", DbType.AnsiString, guestbookEntity.Title.TextFilter());
            db.AddInParameter(cmd, "@MessageContent", DbType.AnsiString, guestbookEntity.MessageContent.TextFilter());
            db.AddInParameter(cmd, "@IP", DbType.AnsiString, guestbookEntity.IP);

            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch (SqlException sqlEx)
            {
                throw sqlEx;
            }
            return(flag);
        }
        public bool AddGuestbook(GuestbookEntity guestbookEntity)
        {
            bool flag = false;
            StringBuilder sqlCommandText = new StringBuilder();
            sqlCommandText.Append(" @JournalID");
            sqlCommandText.Append(", @UserName");
            sqlCommandText.Append(", @Email");
            sqlCommandText.Append(", @Tel");
            sqlCommandText.Append(", @Title");
            sqlCommandText.Append(", @MessageContent");
            sqlCommandText.Append(", @IP");

            DbCommand cmd = db.GetSqlStringCommand(String.Format("INSERT INTO dbo.Guestbook ({0}) VALUES ({1})",sqlCommandText.ToString().Replace("@", ""),sqlCommandText.ToString()));

            db.AddInParameter(cmd,"@JournalID",DbType.Int64,guestbookEntity.JournalID);
            db.AddInParameter(cmd, "@UserName", DbType.AnsiString, guestbookEntity.UserName.TextFilter());
            db.AddInParameter(cmd, "@Email", DbType.AnsiString, guestbookEntity.Email.TextFilter());
            db.AddInParameter(cmd, "@Tel", DbType.AnsiString, guestbookEntity.Tel.TextFilter());
            db.AddInParameter(cmd, "@Title", DbType.AnsiString, guestbookEntity.Title.TextFilter());
            db.AddInParameter(cmd,"@MessageContent",DbType.AnsiString,guestbookEntity.MessageContent.TextFilter());
            db.AddInParameter(cmd,"@IP",DbType.AnsiString,guestbookEntity.IP);

            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch(SqlException sqlEx)
            {
                throw sqlEx;
            }
            return flag;
        }
Example #3
0
        public List <GuestbookEntity> MakeGuestbookList(DataTable dt)
        {
            List <GuestbookEntity> list = new List <GuestbookEntity>();

            if (dt != null)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    GuestbookEntity guestbookEntity = MakeGuestbook(dt.Rows[i]);
                    list.Add(guestbookEntity);
                }
            }
            return(list);
        }
Example #4
0
        public GuestbookEntity GetGuestbook(Int64 messageID)
        {
            GuestbookEntity guestbookEntity = null;
            StringBuilder   sqlCommandText  = new StringBuilder();

            sqlCommandText.Append("SELECT TOP 1  MessageID,JournalID,PMessageID,UserName,Email,Tel,Title,MessageContent,IP,AddDate FROM dbo.Guestbook WITH(NOLOCK)");
            sqlCommandText.Append(" WHERE  MessageID=@MessageID");

            DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString());

            db.AddInParameter(cmd, "@MessageID", DbType.Int64, messageID);

            using (IDataReader dr = db.ExecuteReader(cmd))
            {
                guestbookEntity = MakeGuestbook(dr);
            }
            return(guestbookEntity);
        }
Example #5
0
        public bool UpdateGuestbook(GuestbookEntity guestbookEntity)
        {
            bool          flag             = false;
            StringBuilder whereCommandText = new StringBuilder();

            whereCommandText.Append("  MessageID=@MessageID");
            StringBuilder sqlCommandText = new StringBuilder();

            sqlCommandText.Append(" JournalID=@JournalID");
            sqlCommandText.Append(", PMessageID=@PMessageID");
            sqlCommandText.Append(", UserName=@UserName");
            sqlCommandText.Append(", Email=@Email");
            sqlCommandText.Append(", Tel=@Tel");
            sqlCommandText.Append(", Title=@Title");
            sqlCommandText.Append(", MessageContent=@MessageContent");
            sqlCommandText.Append(", ReplyContent=@ReplyContent");
            sqlCommandText.Append(", IP=@IP");
            sqlCommandText.Append(", AddDate=@AddDate");

            DbCommand cmd = db.GetSqlStringCommand(String.Format("UPDATE dbo.Guestbook SET {0} WHERE  {1}", sqlCommandText.ToString(), whereCommandText.ToString()));

            db.AddInParameter(cmd, "@MessageID", DbType.Int64, guestbookEntity.MessageID);
            db.AddInParameter(cmd, "@JournalID", DbType.Int64, guestbookEntity.JournalID);
            db.AddInParameter(cmd, "@PMessageID", DbType.Int64, guestbookEntity.PMessageID);
            db.AddInParameter(cmd, "@UserName", DbType.AnsiString, guestbookEntity.UserName);
            db.AddInParameter(cmd, "@Email", DbType.AnsiString, guestbookEntity.Email);
            db.AddInParameter(cmd, "@Tel", DbType.AnsiString, guestbookEntity.Tel);
            db.AddInParameter(cmd, "@Title", DbType.AnsiString, guestbookEntity.Title);
            db.AddInParameter(cmd, "@MessageContent", DbType.AnsiString, guestbookEntity.MessageContent);
            db.AddInParameter(cmd, "@ReplyContent", DbType.AnsiString, guestbookEntity.ReplyContent);
            db.AddInParameter(cmd, "@IP", DbType.AnsiString, guestbookEntity.IP);
            db.AddInParameter(cmd, "@AddDate", DbType.DateTime, guestbookEntity.AddDate);

            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch (SqlException sqlEx)
            {
                throw sqlEx;
            }
            return(flag);
        }
Example #6
0
        public GuestbookEntity MakeGuestbook(DataRow dr)
        {
            GuestbookEntity guestbookEntity = null;

            if (dr != null)
            {
                guestbookEntity                = new GuestbookEntity();
                guestbookEntity.MessageID      = (Int64)dr["MessageID"];
                guestbookEntity.JournalID      = (Int64)dr["JournalID"];
                guestbookEntity.PMessageID     = (Int64)dr["PMessageID"];
                guestbookEntity.UserName       = (String)dr["UserName"];
                guestbookEntity.Email          = (String)dr["Email"];
                guestbookEntity.Tel            = (String)dr["Tel"];
                guestbookEntity.Title          = (String)dr["Title"];
                guestbookEntity.MessageContent = (String)dr["MessageContent"];
                guestbookEntity.IP             = (String)dr["IP"];
                guestbookEntity.AddDate        = (DateTime)dr["AddDate"];
            }
            return(guestbookEntity);
        }
Example #7
0
        public List <GuestbookEntity> MakeGuestbookList(IDataReader dr)
        {
            List <GuestbookEntity> list = new List <GuestbookEntity>();

            while (dr.Read())
            {
                GuestbookEntity guestbookEntity = new GuestbookEntity();
                guestbookEntity.MessageID      = (Int64)dr["MessageID"];
                guestbookEntity.JournalID      = (Int64)dr["JournalID"];
                guestbookEntity.PMessageID     = (Int64)dr["PMessageID"];
                guestbookEntity.UserName       = (String)dr["UserName"];
                guestbookEntity.Email          = (String)dr["Email"];
                guestbookEntity.Tel            = (String)dr["Tel"];
                guestbookEntity.Title          = (String)dr["Title"];
                guestbookEntity.MessageContent = (String)dr["MessageContent"];
                guestbookEntity.IP             = (String)dr["IP"];
                guestbookEntity.AddDate        = (DateTime)dr["AddDate"];
                list.Add(guestbookEntity);
            }
            dr.Close();
            return(list);
        }
Example #8
0
        public GuestbookEntity MakeGuestbook(IDataReader dr)
        {
            GuestbookEntity guestbookEntity = null;

            if (dr.Read())
            {
                guestbookEntity                = new GuestbookEntity();
                guestbookEntity.MessageID      = (Int64)dr["MessageID"];
                guestbookEntity.JournalID      = (Int64)dr["JournalID"];
                guestbookEntity.PMessageID     = (Int64)dr["PMessageID"];
                guestbookEntity.UserName       = (String)dr["UserName"];
                guestbookEntity.Email          = (String)dr["Email"];
                guestbookEntity.Tel            = (String)dr["Tel"];
                guestbookEntity.Title          = (String)dr["Title"];
                guestbookEntity.MessageContent = (String)dr["MessageContent"];
                guestbookEntity.ReplyContent   = Convert.IsDBNull(dr["ReplyContent"]) ? null : (String)dr["ReplyContent"];
                guestbookEntity.IP             = (String)dr["IP"];
                guestbookEntity.AddDate        = (DateTime)dr["AddDate"];
            }
            dr.Close();
            return(guestbookEntity);
        }
Example #9
0
        public bool DeleteGuestbook(GuestbookEntity guestbookEntity)
        {
            bool          flag           = false;
            StringBuilder sqlCommandText = new StringBuilder();

            sqlCommandText.Append("DELETE FROM dbo.Guestbook");
            sqlCommandText.Append(" WHERE  MessageID=@MessageID");

            DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString());

            db.AddInParameter(cmd, "@MessageID", DbType.Int64, guestbookEntity.MessageID);

            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch (SqlException sqlEx)
            {
                throw sqlEx;
            }
            return(flag);
        }
Example #10
0
        public ActionResult AddMessage(GuestbookEntity guestBookEntit)
        {
            ExecResult execResult = new ExecResult();

            try
            {
                if (guestBookEntit != null)
                {
                    guestBookEntit.JournalID = JournalID;
                    guestBookEntit.IP        = WKT.Common.Utils.Utils.GetRealIP();
                    ISiteConfigFacadeService guestService = ServiceContainer.Instance.Container.Resolve <ISiteConfigFacadeService>();
                    execResult = guestService.SaveSiteGuestBook(guestBookEntit);
                }
            }
            catch (Exception ex)
            {
                execResult.result = EnumJsonResult.error.ToString();
                execResult.msg    = "在线留言出现异常:" + ex.Message;
                WKT.Log.LogProvider.Instance.Error("在线留言出现异常:" + ex.Message);
            }

            return(Content(JsonConvert.SerializeObject(execResult)));
        }
Example #11
0
        public ActionResult AddMessage(GuestbookEntity guestBookEntit)
        {
            ExecResult execResult = new ExecResult();

            try
            {
                if (guestBookEntit != null)
                {
                    guestBookEntit.JournalID = JournalID;
                    guestBookEntit.IP = WKT.Common.Utils.Utils.GetRealIP();
                    ISiteConfigFacadeService guestService = ServiceContainer.Instance.Container.Resolve<ISiteConfigFacadeService>();
                    execResult = guestService.SaveSiteGuestBook(guestBookEntit);
                }
            }
            catch (Exception ex)
            {
                execResult.result = EnumJsonResult.error.ToString();
                execResult.msg = "在线留言出现异常:" + ex.Message;
                WKT.Log.LogProvider.Instance.Error("在线留言出现异常:" + ex.Message);
            }

            return Content(JsonConvert.SerializeObject(execResult));
        }
Example #12
0
 /// <summary>
 /// 更新存储媒介中的实体数据
 /// </summary>
 /// <param name="guestbook">GuestbookEntity实体对象</param>
 /// <returns>true:更新成功 false:更新失败</returns>
 public bool UpdateGuestbook(GuestbookEntity guestbook)
 {
     return(GuestbookBusProvider.UpdateGuestbook(guestbook));
 }
Example #13
0
 /// <summary>
 /// 将实体数据存入存储媒介(持久化一个对象)
 /// </summary>
 /// <param name="guestbook">GuestbookEntity实体对象</param>
 /// <returns>true:存储成功 false:存储失败</returns>
 public bool AddGuestbook(GuestbookEntity guestbook)
 {
     return GuestbookDataAccess.Instance.AddGuestbook(guestbook);
 }
Example #14
0
 /// <summary>
 /// 将实体数据存入存储媒介(持久化一个对象)
 /// </summary>
 /// <param name="guestbook">GuestbookEntity实体对象</param>
 /// <returns>true:存储成功 false:存储失败</returns>
 public bool AddGuestbook(GuestbookEntity guestbook)
 {
     return(GuestbookDataAccess.Instance.AddGuestbook(guestbook));
 }
 public ExecResult SaveGuestBook(GuestbookEntity model)
 {
     ExecResult exeResult = new ExecResult();
     try
     {
         IGuestbookService service = ServiceContainer.Instance.Container.Resolve<IGuestbookService>();
         bool flag = service.AddGuestbook(model);
         if (flag)
         {
             exeResult.result = EnumJsonResult.success.ToString();
         }
         else
         {
             exeResult.result = EnumJsonResult.failure.ToString();
         }
     }
     catch (Exception ex)
     {
         exeResult.result = EnumJsonResult.error.ToString();
         exeResult.msg = "保存留言出现异常:" + ex.Message;
     }
     return exeResult;
 }
        public bool UpdateGuestbook(GuestbookEntity guestbookEntity)
        {
            bool flag = false;
            StringBuilder whereCommandText = new StringBuilder();
            whereCommandText.Append("  MessageID=@MessageID");
            StringBuilder sqlCommandText = new StringBuilder();
            sqlCommandText.Append(" JournalID=@JournalID");
            sqlCommandText.Append(", PMessageID=@PMessageID");
            sqlCommandText.Append(", UserName=@UserName");
            sqlCommandText.Append(", Email=@Email");
            sqlCommandText.Append(", Tel=@Tel");
            sqlCommandText.Append(", Title=@Title");
            sqlCommandText.Append(", MessageContent=@MessageContent");
            sqlCommandText.Append(", IP=@IP");
            sqlCommandText.Append(", AddDate=@AddDate");

            DbCommand cmd = db.GetSqlStringCommand(String.Format("UPDATE dbo.Guestbook SET {0} WHERE  {1}",sqlCommandText.ToString(),whereCommandText.ToString()));

            db.AddInParameter(cmd,"@MessageID",DbType.Int64,guestbookEntity.MessageID);
            db.AddInParameter(cmd,"@JournalID",DbType.Int64,guestbookEntity.JournalID);
            db.AddInParameter(cmd,"@PMessageID",DbType.Int64,guestbookEntity.PMessageID);
            db.AddInParameter(cmd,"@UserName",DbType.AnsiString,guestbookEntity.UserName);
            db.AddInParameter(cmd,"@Email",DbType.AnsiString,guestbookEntity.Email);
            db.AddInParameter(cmd,"@Tel",DbType.AnsiString,guestbookEntity.Tel);
            db.AddInParameter(cmd,"@Title",DbType.AnsiString,guestbookEntity.Title);
            db.AddInParameter(cmd,"@MessageContent",DbType.AnsiString,guestbookEntity.MessageContent);
            db.AddInParameter(cmd,"@IP",DbType.AnsiString,guestbookEntity.IP);
            db.AddInParameter(cmd,"@AddDate",DbType.DateTime,guestbookEntity.AddDate);

            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch(SqlException sqlEx)
            {
                throw sqlEx;
            }
            return flag;
        }
 public List<GuestbookEntity> MakeGuestbookList(IDataReader dr)
 {
     List<GuestbookEntity> list=new List<GuestbookEntity>();
     while(dr.Read())
     {
      GuestbookEntity guestbookEntity=new GuestbookEntity();
     guestbookEntity.MessageID = (Int64)dr["MessageID"];
     guestbookEntity.JournalID = (Int64)dr["JournalID"];
     guestbookEntity.PMessageID = (Int64)dr["PMessageID"];
     guestbookEntity.UserName = (String)dr["UserName"];
     guestbookEntity.Email = (String)dr["Email"];
     guestbookEntity.Tel = (String)dr["Tel"];
     guestbookEntity.Title = (String)dr["Title"];
     guestbookEntity.MessageContent = (String)dr["MessageContent"];
     guestbookEntity.IP = (String)dr["IP"];
     guestbookEntity.AddDate = (DateTime)dr["AddDate"];
        list.Add(guestbookEntity);
     }
     dr.Close();
     return list;
 }
 public GuestbookEntity MakeGuestbook(DataRow dr)
 {
     GuestbookEntity guestbookEntity=null;
     if(dr!=null)
     {
          guestbookEntity=new GuestbookEntity();
          guestbookEntity.MessageID = (Int64)dr["MessageID"];
          guestbookEntity.JournalID = (Int64)dr["JournalID"];
          guestbookEntity.PMessageID = (Int64)dr["PMessageID"];
          guestbookEntity.UserName = (String)dr["UserName"];
          guestbookEntity.Email = (String)dr["Email"];
          guestbookEntity.Tel = (String)dr["Tel"];
          guestbookEntity.Title = (String)dr["Title"];
          guestbookEntity.MessageContent = (String)dr["MessageContent"];
          guestbookEntity.IP = (String)dr["IP"];
          guestbookEntity.AddDate = (DateTime)dr["AddDate"];
     }
     return guestbookEntity;
 }
        public bool DeleteGuestbook(GuestbookEntity guestbookEntity)
        {
            bool flag = false;
            StringBuilder sqlCommandText = new StringBuilder();
            sqlCommandText.Append("DELETE FROM dbo.Guestbook");
            sqlCommandText.Append(" WHERE  MessageID=@MessageID");

            DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString());

            db.AddInParameter(cmd,"@MessageID",DbType.Int64,guestbookEntity.MessageID);

            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch(SqlException sqlEx)
            {
                throw sqlEx;
            }
            return flag;
        }
Example #20
0
 /// <summary>
 /// 更新存储媒介中的实体数据
 /// </summary>
 /// <param name="guestbook">GuestbookEntity实体对象</param>
 /// <returns>true:更新成功 false:更新失败</returns>
 public bool UpdateGuestbook(GuestbookEntity guestbook)
 {
     return GuestbookDataAccess.Instance.UpdateGuestbook(guestbook);
 }
Example #21
0
 /// <summary>
 /// 从存储媒介删除实体数据
 /// </summary>
 /// <param name="guestbook">GuestbookEntity实体对象</param>
 /// <returns>true:删除成功 false:删除失败</returns>
 public bool DeleteGuestbook(GuestbookEntity guestbook)
 {
     return(GuestbookDataAccess.Instance.DeleteGuestbook(guestbook));
 }
Example #22
0
 /// <summary>
 /// 更新存储媒介中的实体数据
 /// </summary>
 /// <param name="guestbook">GuestbookEntity实体对象</param>
 /// <returns>true:更新成功 false:更新失败</returns>
 public bool UpdateGuestbook(GuestbookEntity guestbook)
 {
     return(GuestbookDataAccess.Instance.UpdateGuestbook(guestbook));
 }
Example #23
0
 /// <summary>
 /// 从存储媒介删除实体数据
 /// </summary>
 /// <param name="guestbook">GuestbookEntity实体对象</param>
 /// <returns>true:删除成功 false:删除失败</returns>
 public bool DeleteGuestbook(GuestbookEntity guestbook)
 {
     return GuestbookBusProvider.DeleteGuestbook(guestbook);
 }
Example #24
0
 /// <summary>
 /// 将实体数据存入存储媒介(持久化一个对象)
 /// </summary>
 /// <param name="guestbook">GuestbookEntity实体对象</param>
 /// <returns>true:存储成功 false:存储失败</returns>
 public bool AddGuestbook(GuestbookEntity guestbook)
 {
     return GuestbookBusProvider.AddGuestbook(guestbook);
 }
Example #25
0
 /// <summary>
 /// 更新存储媒介中的实体数据
 /// </summary>
 /// <param name="guestbook">GuestbookEntity实体对象</param>
 /// <returns>true:更新成功 false:更新失败</returns>
 public bool UpdateGuestbook(GuestbookEntity guestbook)
 {
     return GuestbookBusProvider.UpdateGuestbook(guestbook);
 }
Example #26
0
 /// <summary>
 /// 从存储媒介删除实体数据
 /// </summary>
 /// <param name="guestbook">GuestbookEntity实体对象</param>
 /// <returns>true:删除成功 false:删除失败</returns>
 public bool DeleteGuestbook(GuestbookEntity guestbook)
 {
     return GuestbookDataAccess.Instance.DeleteGuestbook(guestbook);
 }
Example #27
0
 /// <summary>
 /// 从存储媒介删除实体数据
 /// </summary>
 /// <param name="guestbook">GuestbookEntity实体对象</param>
 /// <returns>true:删除成功 false:删除失败</returns>
 public bool DeleteGuestbook(GuestbookEntity guestbook)
 {
     return(GuestbookBusProvider.DeleteGuestbook(guestbook));
 }
 public GuestbookEntity MakeGuestbook(IDataReader dr)
 {
     GuestbookEntity guestbookEntity = null;
     if(dr.Read())
     {
      guestbookEntity=new GuestbookEntity();
      guestbookEntity.MessageID = (Int64)dr["MessageID"];
      guestbookEntity.JournalID = (Int64)dr["JournalID"];
      guestbookEntity.PMessageID = (Int64)dr["PMessageID"];
      guestbookEntity.UserName = (String)dr["UserName"];
      guestbookEntity.Email = (String)dr["Email"];
      guestbookEntity.Tel = (String)dr["Tel"];
      guestbookEntity.Title = (String)dr["Title"];
      guestbookEntity.MessageContent = (String)dr["MessageContent"];
      guestbookEntity.ReplyContent = Convert.IsDBNull(dr["ReplyContent"]) ? null : (String)dr["ReplyContent"];
      guestbookEntity.IP = (String)dr["IP"];
      guestbookEntity.AddDate = (DateTime)dr["AddDate"];
     }
     dr.Close();
     return guestbookEntity;
 }
Example #29
0
 /// <summary>
 /// 将实体数据存入存储媒介(持久化一个对象)
 /// </summary>
 /// <param name="guestbook">GuestbookEntity实体对象</param>
 /// <returns>true:存储成功 false:存储失败</returns>
 public bool AddGuestbook(GuestbookEntity guestbook)
 {
     return(GuestbookBusProvider.AddGuestbook(guestbook));
 }
 /// <summary>
 /// 保存留言
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public ExecResult SaveSiteGuestBook(GuestbookEntity model)
 {
     HttpClientHelper clientHelper = new HttpClientHelper();
     ExecResult result = clientHelper.Post<ExecResult, GuestbookEntity>(GetAPIUrl(APIConstant.SITE_GUESTBOOKE_SAVE), model);
     return result;
 }