public ActionResult Save(SiteResourceEntity model) { ISiteConfigFacadeService service = ServiceContainer.Instance.Container.Resolve<ISiteConfigFacadeService>(); model.JournalID = CurAuthor.JournalID; if (model.ResourceID == 0) model.InUserID = CurAuthor.AuthorID; else model.EditUserID = CurAuthor.AuthorID; ExecResult result = service.SaveSiteResource(model); return Json(new { result = result.result, msg = result.msg }); }
/// <summary> /// 新增资源 /// </summary> /// <param name="SiteResourceEntity"></param> /// <returns></returns> public bool AddSiteResource(SiteResourceEntity model) { bool flag = false; StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append(" @JournalID"); sqlCommandText.Append(", @ChannelID"); sqlCommandText.Append(", @Name"); sqlCommandText.Append(", @FileIntro"); sqlCommandText.Append(", @FilePath"); sqlCommandText.Append(", @FileEx"); sqlCommandText.Append(", @FileSize"); sqlCommandText.Append(", @DownloadCount"); sqlCommandText.Append(", @InUserID"); DbCommand cmd = db.GetSqlStringCommand(String.Format("INSERT INTO dbo.SiteResource ({0},AddDate) VALUES ({1},getdate())", sqlCommandText.ToString().Replace("@", ""), sqlCommandText.ToString())); db.AddInParameter(cmd, "@JournalID", DbType.Int64, model.JournalID); db.AddInParameter(cmd, "@ChannelID", DbType.Int64, model.ChannelID); db.AddInParameter(cmd, "@Name", DbType.AnsiString, model.Name); db.AddInParameter(cmd, "@FileIntro", DbType.AnsiString, model.FileIntro); db.AddInParameter(cmd, "@FilePath", DbType.AnsiString, model.FilePath); db.AddInParameter(cmd, "@FileEx", DbType.AnsiString, model.FileEx); db.AddInParameter(cmd, "@FileSize", DbType.Decimal, model.FileSize); db.AddInParameter(cmd, "@DownloadCount", DbType.Int32, model.DownloadCount); db.AddInParameter(cmd, "@InUserID", DbType.Int64, model.InUserID); try { db.ExecuteNonQuery(cmd); flag = true; } catch (SqlException sqlEx) { throw sqlEx; } return flag; }
/// <summary> /// 累加下载次数 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AccumulationDownloadCount(SiteResourceEntity model) { string strSql = string.Format("UPDATE dbo.SiteResource set DownloadCount=DownloadCount+1 WHERE ResourceID={0}", model.ResourceID); DbCommand cmd = db.GetSqlStringCommand(strSql); return db.ExecuteNonQuery(cmd) > 0; }
/// <summary> /// 组装数据 /// </summary> /// <param name="dr"></param> /// <returns></returns> private SiteResourceEntity MakeSiteResourceModel(IDataReader dr) { SiteResourceEntity model = new SiteResourceEntity(); model.ResourceID = (Int64)dr["ResourceID"]; model.JournalID = (Int64)dr["JournalID"]; model.ChannelID = (Int64)dr["ChannelID"]; model.Name = (String)dr["Name"]; model.FileIntro = (String)dr["FileIntro"]; model.FilePath = (String)dr["FilePath"]; model.FileEx = (String)dr["FileEx"]; model.FileSize = (Decimal)dr["FileSize"]; model.DownloadCount = (Int32)dr["DownloadCount"]; model.InUserID = (Int64)dr["InUserID"]; model.EditUserID = (Int64)dr["EditUserID"]; model.EditDate = (DateTime)dr["EditDate"]; model.AddDate = (DateTime)dr["AddDate"]; return model; }
/// <summary> /// 编辑资源 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdateSiteResource(SiteResourceEntity model) { bool flag = false; StringBuilder whereCommandText = new StringBuilder(); whereCommandText.Append(" ResourceID=@ResourceID"); StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append(" Name=@Name"); sqlCommandText.Append(", FileIntro=@FileIntro"); sqlCommandText.Append(", FilePath=@FilePath"); sqlCommandText.Append(", FileEx=@FileEx"); sqlCommandText.Append(", FileSize=@FileSize"); sqlCommandText.Append(", EditUserID=@EditUserID"); sqlCommandText.Append(", EditDate=getdate()"); DbCommand cmd = db.GetSqlStringCommand(String.Format("UPDATE dbo.SiteResource SET {0} WHERE {1}", sqlCommandText.ToString(), whereCommandText.ToString())); db.AddInParameter(cmd, "@ResourceID", DbType.Int64, model.ResourceID); db.AddInParameter(cmd, "@Name", DbType.AnsiString, model.Name); db.AddInParameter(cmd, "@FileIntro", DbType.AnsiString, model.FileIntro); db.AddInParameter(cmd, "@FilePath", DbType.AnsiString, model.FilePath); db.AddInParameter(cmd, "@FileEx", DbType.AnsiString, model.FileEx); db.AddInParameter(cmd, "@FileSize", DbType.Decimal, model.FileSize); db.AddInParameter(cmd, "@EditUserID", DbType.Int64, model.EditUserID); try { db.ExecuteNonQuery(cmd); flag = true; } catch (SqlException sqlEx) { throw sqlEx; } return flag; }
public bool DownloadCount(SiteResourceEntity model) { ISiteResourceService service = ServiceContainer.Instance.Container.Resolve<ISiteResourceService>(); bool result = service.AccumulationDownloadCount(model); return result; }
public ExecResult Save(SiteResourceEntity model) { ISiteResourceService service = ServiceContainer.Instance.Container.Resolve<ISiteResourceService>(); return service.Save(model); }
/// <summary> /// 新增资源 /// </summary> /// <param name="SiteResourceEntity"></param> /// <returns></returns> public bool AddSiteResource(SiteResourceEntity model) { return SiteResourceDataAccess.Instance.AddSiteResource(model); }
/// <summary> /// 保存资源文件数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public ExecResult SaveSiteResource(SiteResourceEntity model) { HttpClientHelper clientHelper = new HttpClientHelper(); ExecResult result = clientHelper.Post<ExecResult, SiteResourceEntity>(GetAPIUrl(APIConstant.SITERESOURCE_SAVE), model); return result; }
/// <summary> /// 累加资源文件下载次数 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AccumSiteResourceDownLoadCount(SiteResourceEntity model) { HttpClientHelper clientHelper = new HttpClientHelper(); bool result = clientHelper.Post<bool, SiteResourceEntity>(GetAPIUrl(APIConstant.SITERESOURCE_DOWNLOADCOUNT), model); return result; }
/// <summary> /// 新增资源 /// </summary> /// <param name="SiteResourceEntity"></param> /// <returns></returns> public bool AddSiteResource(SiteResourceEntity model) { return SiteResourceBusProvider.AddSiteResource(model); }
/// <summary> /// 累加下载次数 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AccumulationDownloadCount(SiteResourceEntity model) { return SiteResourceBusProvider.AccumulationDownloadCount(model); }
/// <summary> /// 编辑资源 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdateSiteResource(SiteResourceEntity model) { return SiteResourceBusProvider.UpdateSiteResource(model); }
/// <summary> /// 保存资源 /// </summary> /// <param name="model"></param> /// <returns></returns> public ExecResult Save(SiteResourceEntity model) { ExecResult execResult = new ExecResult(); bool result = false; model.Name = model.Name.TextFilter(); model.FileIntro = model.FileIntro.TextFilter(); if (model.ResourceID == 0) { result = AddSiteResource(model); if (result) { execResult.result = EnumJsonResult.success.ToString(); execResult.msg = "新增资源文件成功!"; } else { execResult.result = EnumJsonResult.failure.ToString(); execResult.msg = "新增资源文件失败!"; } } else { result = UpdateSiteResource(model); if (result) { execResult.result = EnumJsonResult.success.ToString(); execResult.msg = "修改资源文件成功!"; } else { execResult.result = EnumJsonResult.failure.ToString(); execResult.msg = "修改资源文件失败!"; } } return execResult; }
/// <summary> /// 编辑资源 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdateSiteResource(SiteResourceEntity model) { return SiteResourceDataAccess.Instance.UpdateSiteResource(model); }
/// <summary> /// 显示指定的频道页面 /// </summary> /// <param name="ChannelID"></param> /// <param name="NewsID"></param> /// <returns></returns> public ActionResult resource() { long ItemID = TypeParse.ToLong(Request.QueryString["id"]); SiteResourceEntity contentEntity = new SiteResourceEntity(); if (ItemID > 0) { ISiteConfigFacadeService service = ServiceContainer.Instance.Container.Resolve<ISiteConfigFacadeService>(); SiteResourceQuery resourceQuery = new SiteResourceQuery(); resourceQuery.JournalID = JournalID; resourceQuery.ResourceID = ItemID; contentEntity = service.GetSiteResourceModel(resourceQuery); } ViewBag.Title = Utils.ClearHtml(contentEntity.Name); return View(contentEntity); }
private SiteResourceEntity GetModel(Int64 ResourceID) { SiteResourceEntity model = null; if (ResourceID > 0) { SiteResourceQuery query = new SiteResourceQuery(); query.JournalID = CurAuthor.JournalID; query.ResourceID = ResourceID; ISiteConfigFacadeService service = ServiceContainer.Instance.Container.Resolve<ISiteConfigFacadeService>(); model = service.GetSiteResourceModel(query); } if (model == null) model = new SiteResourceEntity(); return model; }
/// <summary> /// 累加下载次数 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AccumulationDownloadCount(SiteResourceEntity model) { return SiteResourceDataAccess.Instance.AccumulationDownloadCount(model); }