/// <summary> /// 插入数据 /// </summary> /// <param name="obj">对象</param> /// <returns>返回:该条数据的主键Id</returns> public int Insert(D_Tag obj) { if (obj == null) { throw new ArgumentNullException("obj"); } String stmtId = "D_Tag.Insert"; return(SqlMapper.Instance().QueryForObject <int>(stmtId, obj)); }
/// <summary> /// 更新数据 /// </summary> /// <param name="obj"></param> /// <returns>返回:ture 成功,false 失败</returns> public bool Update(D_Tag obj) { if (obj == null) { throw new ArgumentNullException("obj"); } String stmtId = "D_Tag.Update"; int result = SqlMapper.Instance().QueryForObject <int>(stmtId, obj); return(result > 0 ? true : false); }
/// <summary> /// 通过文章的标签字段来更新标签表,标签存在更新数量,不存在新增标签 /// </summary> /// <param name="tags"></param> public void UpdateFromDoc(string[] tags, int docId) { D_Rel_DocTagBLL drBll = new D_Rel_DocTagBLL(); //先删除该文档的关联关系 drBll.DeleteDoc(docId); foreach (string s in tags) { if (!string.IsNullOrEmpty(s.Trim())) { int tagId = 0; Hashtable p = new Hashtable(); p.Add("Tag", s); IList <D_Tag> list = GetList(p, null, 0, 1); if (list.Count > 0) { tagId = list[0].TagId; D_Tag oldTag = list[0]; oldTag.UseCount += 1; Update(oldTag); } else { D_Tag tag = new D_Tag() { Tag = s, UseCount = 1 }; tagId = Insert(tag); } //写入文档-标签关联表 D_Rel_DocTag dr = new D_Rel_DocTag() { DocId = docId, TagId = tagId }; drBll.Insert(dr); } } }
/// <summary> /// 更新数据 /// </summary> /// <param name="obj"></param> /// <returns>返回:ture 成功,false 失败</returns> public bool Update(D_Tag obj) { return(dal.Update(obj)); }
/// <summary> /// 插入数据 /// </summary> /// <param name="obj">对象</param> /// <returns>返回:该条数据的主键Id</returns> public int Insert(D_Tag obj) { return(dal.Insert(obj)); }
public void Default(int docId) { UserService us = Context.GetService <UserService>(); SystemService ss = Context.GetService <SystemService>(); DDocInfo doc = us.DocInfoBll.Get(docId); doc.Description = doc.Description.ReplaceEnterStr(); PropertyBag["doc"] = doc; if (!doc.IsAudit && !doc.IsTaskDoc) { if (!(Context.UrlReferrer.IndexOf("/admin/doc/index.do") > -1)) //如果从管理页面过来,不抛异常 { throw new Common.TmmException("该文档不存在"); } } try { //该用户其他文档 IList <DDocInfo> otherList = us.DocInfoBll.GetListByUser(doc.UserId, 0, 9, doc.DocId); PropertyBag["otherList"] = otherList; //文档分类 if (doc.CateId.HasValue) { S_Catalog c3 = ss.SCatalogBll.Get(doc.CateId.Value); S_Catalog c2 = null; S_Catalog c1 = null; if (c3 != null && c3.Pid.HasValue) { c2 = ss.SCatalogBll.Get(c3.Pid.Value); if (c2.Pid.HasValue) { c1 = ss.SCatalogBll.Get(c2.Pid.Value); } } StringBuilder sb = new StringBuilder(); if (c3 != null) { sb.Append(string.Format("<a href=\"/list-{1}-0-0-0-0-0.html\">{0}</a>", c3.CatalogName, c3.CatalogId)); if (c2 != null) { sb.Append(string.Format(" -- <a href=\"/list-{1}-0-0-0-0-0.html\">{0}</a>", c2.CatalogName, c2.CatalogId)); if (c1 != null) { sb.Append(string.Format(" -- <a href=\"/list-{1}-0-0-0-0-0.html\">{0}</a>", c1.CatalogName, c1.CatalogId)); } } } PropertyBag["catalog"] = sb.ToString(); } //标签 if (!string.IsNullOrEmpty(doc.Tags)) { string[] tags = doc.Tags.Split(' '); List <D_Tag> tagList = new List <D_Tag>(); tags.ToList().ForEach(s => { if (!string.IsNullOrEmpty(s.Trim())) { D_Tag dt = us.DTagBll.Get(s); if (dt != null) { tagList.Add(dt); } } }); PropertyBag["tagList"] = tagList; } //相关文档 IList <DDocInfo> recommandList = us.DocInfoBll.GetRelativeList(docId); if (recommandList == null) { PropertyBag["relativeDocs"] = us.DocInfoBll.GetRecommendList(0, 25); PropertyBag["recommend"] = true; } else { PropertyBag["relativeDocs"] = recommandList; } //浏览量 us.DocInfoBll.UpdateViewCount(docId); } catch (Exception ex) { Utils.Log4Net.Error(ex.Message + "\r\n" + ex.StackTrace); } }