public bool AddSiteMessage(SiteMessageEntity siteMessageEntity) { bool flag = false; StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append(" @JournalID"); sqlCommandText.Append(", @CID"); sqlCommandText.Append(", @SendUser"); sqlCommandText.Append(", @ReciverID"); sqlCommandText.Append(", @Title"); sqlCommandText.Append(", @IsView"); sqlCommandText.Append(", @Content"); DbCommand cmd = db.GetSqlStringCommand(String.Format("INSERT INTO dbo.SiteMessage ({0},SendDate) VALUES ({1},getdate())", sqlCommandText.ToString().Replace("@", ""), sqlCommandText.ToString())); db.AddInParameter(cmd,"@JournalID",DbType.Int64,siteMessageEntity.JournalID); db.AddInParameter(cmd, "@CID", DbType.Int64, siteMessageEntity.CID); db.AddInParameter(cmd,"@SendUser",DbType.Int64,siteMessageEntity.SendUser); db.AddInParameter(cmd,"@ReciverID",DbType.Int64,siteMessageEntity.ReciverID); db.AddInParameter(cmd,"@Title",DbType.AnsiString,siteMessageEntity.Title); db.AddInParameter(cmd, "@IsView", DbType.Byte, siteMessageEntity.IsView); db.AddInParameter(cmd,"@Content",DbType.AnsiString,siteMessageEntity.Content); try { db.ExecuteNonQuery(cmd); flag = true; } catch(SqlException sqlEx) { throw sqlEx; } return flag; }
public ActionResult AuthorSendMessage(Int64 CID, Int32 Status, SiteMessageEntity model) { var user = GetAuthorInfo(CID, Status); if (user == null) return Json(new { result = EnumJsonResult.failure.ToString(), msg = "获取接收人失败,发送站内消息失败!" }); ISiteConfigFacadeService service = ServiceContainer.Instance.Container.Resolve<ISiteConfigFacadeService>(); model.JournalID = CurAuthor.JournalID; model.SendUser = CurAuthor.AuthorID; model.Content = Server.UrlDecode(model.Content); //通过稿件编号获取接收人、接受地址 model.ReciverID = user.AuthorID; ExecResult result = service.SaveSiteMessage(model); return Json(new { result = result.result, msg = result.msg }); }
private SiteMessageEntity GetModel(Int64 MessageID) { SiteMessageEntity model = null; if (MessageID > 0) { SiteMessageQuery query = new SiteMessageQuery(); query.JournalID = CurAuthor.JournalID; query.MessageID = MessageID; ISiteConfigFacadeService service = ServiceContainer.Instance.Container.Resolve<ISiteConfigFacadeService>(); model = service.GetSiteMessageModel(query); } if (model == null) model = new SiteMessageEntity(); return model; }
public ActionResult Save(SiteMessageEntity model) { ISiteConfigFacadeService service = ServiceContainer.Instance.Container.Resolve<ISiteConfigFacadeService>(); model.JournalID = CurAuthor.JournalID; model.Content = Server.UrlDecode(model.Content); ExecResult result = service.SaveSiteMessage(model); return Json(new { result = result.result, msg = result.msg }); }
/// <summary> /// 将实体数据存入存储媒介(持久化一个对象) /// </summary> /// <param name="siteMessage">SiteMessageEntity实体对象</param> /// <returns>true:存储成功 false:存储失败</returns> public bool AddSiteMessage(SiteMessageEntity siteMessage) { return SiteMessageBusProvider.AddSiteMessage(siteMessage); }
/// <summary> /// 更新存储媒介中的实体数据 /// </summary> /// <param name="siteMessage">SiteMessageEntity实体对象</param> /// <returns>true:更新成功 false:更新失败</returns> public bool UpdateSiteMessage(SiteMessageEntity siteMessage) { return SiteMessageBusProvider.UpdateSiteMessage(siteMessage); }
/// <summary> /// 保存 /// </summary> /// <param name="model"></param> /// <returns></returns> public ExecResult Save(SiteMessageEntity model) { ExecResult execResult = new ExecResult(); bool result = false; model.Title = model.Title.TextFilter(); model.Content = model.Content.HtmlFilter(); if (model.MessageID == 0) { result = AddSiteMessage(model); if (result) { execResult.result = EnumJsonResult.success.ToString(); execResult.msg = "发送站内消息成功!"; } else { execResult.result = EnumJsonResult.failure.ToString(); execResult.msg = "发送站内消息失败!"; } } else { result = UpdateSiteMessage(model); if (result) { execResult.result = EnumJsonResult.success.ToString(); execResult.msg = "编辑站内消息成功!"; } else { execResult.result = EnumJsonResult.failure.ToString(); execResult.msg = "编辑站内消息失败!"; } } return execResult; }
/// <summary> /// 从存储媒介删除实体数据 /// </summary> /// <param name="siteMessage">SiteMessageEntity实体对象</param> /// <returns>true:删除成功 false:删除失败</returns> public bool DeleteSiteMessage(SiteMessageEntity siteMessage) { return SiteMessageBusProvider.DeleteSiteMessage(siteMessage); }
public bool UpdateSiteMessage(SiteMessageEntity siteMessageEntity) { bool flag = false; StringBuilder whereCommandText = new StringBuilder(); whereCommandText.Append(" MessageID=@MessageID"); StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append(" Title=@Title"); sqlCommandText.Append(", Content=@Content"); DbCommand cmd = db.GetSqlStringCommand(String.Format("UPDATE dbo.SiteMessage SET {0} WHERE {1}",sqlCommandText.ToString(),whereCommandText.ToString())); db.AddInParameter(cmd,"@MessageID",DbType.Int64,siteMessageEntity.MessageID); db.AddInParameter(cmd,"@Title",DbType.AnsiString,siteMessageEntity.Title); db.AddInParameter(cmd,"@Content",DbType.AnsiString,siteMessageEntity.Content); try { db.ExecuteNonQuery(cmd); flag = true; } catch(SqlException sqlEx) { throw sqlEx; } return flag; }
public SiteMessageEntity MakeSiteMessage(DataRow dr) { SiteMessageEntity siteMessageEntity=null; if(dr!=null) { siteMessageEntity=new SiteMessageEntity(); siteMessageEntity.MessageID = (Int64)dr["MessageID"]; siteMessageEntity.JournalID = (Int64)dr["JournalID"]; siteMessageEntity.CID = (Int64)dr["CID"]; siteMessageEntity.IsView = (Byte)dr["IsView"]; siteMessageEntity.SendUser = (Int64)dr["SendUser"]; siteMessageEntity.ReciverID = (Int64)dr["ReciverID"]; siteMessageEntity.Title = (String)dr["Title"]; siteMessageEntity.Content = (String)dr["Content"]; siteMessageEntity.SendDate = (DateTime)dr["SendDate"]; } return siteMessageEntity; }
public List<SiteMessageEntity> MakeSiteMessageList(IDataReader dr) { List<SiteMessageEntity> list=new List<SiteMessageEntity>(); while(dr.Read()) { SiteMessageEntity siteMessageEntity=new SiteMessageEntity(); siteMessageEntity.MessageID = (Int64)dr["MessageID"]; siteMessageEntity.JournalID = (Int64)dr["JournalID"]; siteMessageEntity.CID = (Int64)dr["CID"]; siteMessageEntity.IsView = (Byte)dr["IsView"]; siteMessageEntity.SendUser = (Int64)dr["SendUser"]; siteMessageEntity.ReciverID = (Int64)dr["ReciverID"]; siteMessageEntity.Title = (String)dr["Title"]; siteMessageEntity.Content = (String)dr["Content"]; siteMessageEntity.SendDate = (DateTime)dr["SendDate"]; list.Add(siteMessageEntity); } dr.Close(); return list; }
public bool DeleteSiteMessage(SiteMessageEntity siteMessageEntity) { bool flag = false; StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append("DELETE FROM dbo.SiteMessage"); sqlCommandText.Append(" WHERE MessageID=@MessageID"); DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString()); db.AddInParameter(cmd,"@MessageID",DbType.Int64,siteMessageEntity.MessageID); try { db.ExecuteNonQuery(cmd); flag = true; } catch(SqlException sqlEx) { throw sqlEx; } return flag; }
public ExecResult Save(SiteMessageEntity model) { ISiteMessageService service = ServiceContainer.Instance.Container.Resolve<ISiteMessageService>(); return service.Save(model); }
/// <summary> /// 从存储媒介删除实体数据 /// </summary> /// <param name="siteMessage">SiteMessageEntity实体对象</param> /// <returns>true:删除成功 false:删除失败</returns> public bool DeleteSiteMessage(SiteMessageEntity siteMessage) { return SiteMessageDataAccess.Instance.DeleteSiteMessage(siteMessage); }
/// <summary> /// 将实体数据存入存储媒介(持久化一个对象) /// </summary> /// <param name="siteMessage">SiteMessageEntity实体对象</param> /// <returns>true:存储成功 false:存储失败</returns> public bool AddSiteMessage(SiteMessageEntity siteMessage) { return SiteMessageDataAccess.Instance.AddSiteMessage(siteMessage); }
/// <summary> /// 保存站内消息数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public ExecResult SaveSiteMessage(SiteMessageEntity model) { HttpClientHelper clientHelper = new HttpClientHelper(); ExecResult result = clientHelper.Post<ExecResult, SiteMessageEntity>(GetAPIUrl(APIConstant.SITEMESSAGE_SAVE), model); return result; }