public static IEnumerable<公告> 筛选公告(int skip, int limit, 公告.公告类别 公告类别, 公告.公告性质 公告性质, DateTime 起始日期, DateTime 结束日期, string 关键字 = null) { var q = new List<IMongoQuery>(); if (公告类别 != 公告.公告类别.未设置) q.Add(Query.EQ("公告信息.公告类别", 公告类别)); if (公告性质 != 公告.公告性质.未设置) q.Add(Query.EQ("公告信息.公告性质", 公告性质)); if (DateTime.MinValue != 起始日期 && DateTime.MinValue != 结束日期) q.Add(Query.And( Query.GTE("基本数据.修改时间", 起始日期), Query.LTE("基本数据.修改时间", 结束日期) )); if (string.IsNullOrWhiteSpace(关键字)) q.Add(Query.Matches("内容主体.标题", 关键字)); return Mongo.查询<公告>(skip, limit, Query.And(q.ToArray()), includeDisabled: false); }
public ActionResult Procure_AdSend(公告 model) { if (ModelState.IsValid) { var firstclass = Request.Form["hy"]; var secondclass = Request.Form["secondclass"]; var thirdclass = Request.Form["thirdclass"]; if (firstclass != "请选择行业" && secondclass != "不限") { model.公告信息.一级分类 = firstclass; model.公告信息.二级分类 = secondclass; if (thirdclass != "不限") { model.公告信息.三级分类 = thirdclass; } } var time = Request.Form["publishtime"]; if (!string.IsNullOrEmpty(time)) { try { model.内容主体.发布时间 = Convert.ToDateTime(time); } catch { model.内容主体.发布时间 = DateTime.Now; } } else { model.内容主体.发布时间 = DateTime.Now; } try { if (!string.IsNullOrEmpty(model.内容主体.附件[0])) { var str = model.内容主体.附件[0].Trim(); model.内容主体.附件 = new List<string>(str.Substring(0, str.Length - 1).Split('|')); } else { model.内容主体.附件 = null; } model.审核数据.审核状态 = 审核状态.审核通过; //model.公告信息.一级分类 = Request.Form["hy"]; model.公告信息.所属地域.省份 = Request.Form["deliverprovince"]; model.公告信息.所属地域.城市 = Request.Form["delivercity"]; model.公告信息.所属地域.区县 = Request.Form["deliverarea"]; try { 站内消息 Msg = new 站内消息(); Msg.基本数据.备注 = "此公告于 " + DateTime.Now + " 由 " + currentUser.单位信息.单位名称 + " 提交到 " + currentUser.管理单位.用户数据.单位信息.单位名称; 对话消息 Talk = new 对话消息(); Msg.收信人.用户ID = currentUser.管理单位.用户ID; Msg.发起者.用户ID = currentUser.Id; Talk.发言人.用户ID = currentUser.Id; Msg.消息类型 = 消息类型.公告传递; 站内消息管理.添加站内消息(Msg, Msg.发起者.用户ID, Msg.收信人.用户ID); Talk.消息主体.附件 = model.内容主体.附件; Talk.消息主体.内容 = "公告标题:" + model.内容主体.标题 + "<br />" + "发布时间:" + model.内容主体.发布时间 + "<br />" + "相关行业:" + model.公告信息.一级分类 + "<br />" + "所在地域:" + model.公告信息.所属地域.地域 + "<br />" + "项目名称:" + model.项目信息.项目名称 + "<br />" + "项目编号:" + model.项目信息.项目编号 + "<br />" + "公告类别:" + model.公告信息.公告类别 + "<br />" + "公告性质:" + model.公告信息.公告性质 + "<br />" + "公告版本:" + model.公告信息.公告版本 + "<br />" + "公告内容:" + model.内容主体.内容 + "<br />"; 对话消息管理.添加对话消息(Talk, Msg); } catch { return Content("<script>alert('输入有误!请检查数据格式');location.href='javascript:history.go(-1)';</script>"); } } catch { return Content("<script>alert('输入有误!请检查数据格式');location.href='javascript:history.go(-1)';</script>"); } } return View("Procure_AdSendList_S"); }
public ActionResult Procure_AdModify(公告 model) { //对未绑定字段赋值 var m = 公告管理.查找公告(model.Id); model.审核数据 = m.审核数据; model.审核数据2 = m.审核数据2; model.项目信息.项目标的物 = m.项目信息.项目标的物; model.项目信息.预算金额 = m.项目信息.预算金额; model.点击次数 = m.点击次数; model.内容基本信息 = m.内容基本信息; model.公告信息.是否撤回 = false; // model.基本数据.修改时间 = DateTime.Now; //var firstclass = Request.Form["hy"]; //var secondclass = Request.Form["secondclass"]; //var thirdclass = Request.Form["thirdclass"]; //if (firstclass != "请选择行业" && secondclass != "不限") //{ // model.公告信息.一级分类 = firstclass; // model.公告信息.二级分类 = secondclass; // if (thirdclass != "不限") // { // model.公告信息.三级分类 = thirdclass; // } //} //var time = Request.Form["publishtime"]; //if (!string.IsNullOrEmpty(time)) //{ // try // { // model.内容主体.发布时间 = Convert.ToDateTime(time); // } // catch // { // } //} try { //附件 string attachstr = Request.Form["attachpath"].ToString() + Request.Form["attachtext"]; if (!string.IsNullOrEmpty(attachstr)) { attachstr = attachstr.Trim(); model.内容主体.附件 = new List<string>(attachstr.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries)); } else { model.内容主体.附件 = null; } //扫描件 string sm = Request.Form["smPath"].ToString() + Request.Form["attachtext_s"]; if (!string.IsNullOrWhiteSpace(sm)) { sm = sm.Trim(); model.内容主体.图片 = new List<string>(sm.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries)); } else { model.内容主体.图片 = null; } if (!string.IsNullOrWhiteSpace(Request.Form["delPath"].ToString())) { string[] path = Request.Form["delPath"].ToString().Split('|'); for (int i = 0; i < path.Length - 1; i++) { if (System.IO.File.Exists(Server.MapPath(@path[i]))) { System.IO.File.Delete(Server.MapPath(@path[i])); } } } //model.公告信息.所属地域.省份 = Request.Form["deliverprovince"]; //model.公告信息.所属地域.城市 = Request.Form["delivercity"]; //model.公告信息.所属地域.区县 = Request.Form["deliverarea"]; //最高级单位进行修改,改变内容,并且把审核数据置为未审核,再审核一次才会显示再页面上 if (currentUser.管理单位.用户ID == 10) { //不是由西藏或成都采购站的下级单位发布的公告 model.审核数据.审核状态 = 审核状态.未审核; model.审核数据.未通过理由 = ""; } else { //修改自己的公告(昆明采购站、贵阳采购站、重庆采购站、成都采购站直接下级、西藏采购站直接下级) if (model.内容基本信息.所有者.用户ID == currentUser.Id && model.审核数据2.审核者.用户ID == -1 && model.审核数据.审核者.用户ID == 11) { //二级单位修改自己的公告 model.审核数据.审核状态 = 审核状态.未审核; model.审核数据.未通过理由 = ""; } else { //三级单位修改自己的公告,或者二级单位修改下级单位的公告 model.审核数据.审核状态 = 审核状态.未审核; model.审核数据2.审核状态 = 审核状态.未审核; model.审核数据2.未通过理由 = ""; model.审核数据.未通过理由 = ""; model.审核数据.审核者.用户ID = -1; } } model.内容主体.标题 = model.项目信息.项目名称 + "(" + model.项目信息.项目编号 + ")"; 公告管理.更新公告(model, false); deleteIndex("/Lucene.Net/IndexDic/GongGao", model.Id.ToString()); deleteIndex("/Lucene.Net/IndexDic/GongGao", "-1"); } catch { return Content("<script>alert('输入有误!请检查数据格式');location.href='javascript:history.go(-1)';</script>"); } //CreateIndex(model, "/Lucene.Net/IndexDic/GongGao"); var h = Request.QueryString["h"]; if (null != h && h == "s") { return View("Procure_AdSendList_S"); } else { return View("Procure_AdSendList_S"); } }
public ActionResult Procure_AdAdd(公告 model) { //var firstclass = Request.Form["hy"]; //var secondclass = Request.Form["secondclass"]; //var thirdclass = Request.Form["thirdclass"]; //if (firstclass != "请选择行业" && secondclass != "不限") //{ // model.公告信息.一级分类 = firstclass; // model.公告信息.二级分类 = secondclass; // if (thirdclass != "不限") // { // model.公告信息.三级分类 = thirdclass; // } //} //var time = Request.Form["publishtime"]; //var zb_contact = Request.Form["zb_contact"]; //var isybm = Request.Form["isybm"]; //if (!string.IsNullOrEmpty(time)) //{ // try // { // model.内容主体.发布时间 = Convert.ToDateTime(time); // } // catch // { // model.内容主体.发布时间 = DateTime.Now; // } //} //else //{ // model.内容主体.发布时间 = DateTime.Now; //} try { if (!string.IsNullOrWhiteSpace(Request.Form["attachtext"].ToString())) { var str = Request.Form["attachtext"].ToString(); model.内容主体.附件 = new List<string>(str.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries)); } else { model.内容主体.附件 = null; } if (!string.IsNullOrWhiteSpace(Request.Form["attachtext_s"].ToString())) { var str = Request.Form["attachtext_s"].ToString(); model.内容主体.图片 = new List<string>(str.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries)); } else { model.内容主体.图片 = null; } model.内容主体.发布时间 = DateTime.Now; //model.公告信息.一级分类 = Request.Form["hy"]; //model.公告信息.所属地域.省份 = Request.Form["deliverprovince"]; //model.公告信息.所属地域.城市 = Request.Form["delivercity"]; //model.公告信息.所属地域.区县 = Request.Form["deliverarea"]; //赋值公告所有者 model.内容基本信息.所有者.用户ID = currentUser.Id; #if INTRANET //如果是采购处或者更高级别的用户,直接审核通过进行发布,创建lucene(成都采购站,西藏采购站或者采购处及其助理员) if (currentUser.管理单位.用户ID == 10) { model.审核数据.审核状态 = 审核状态.审核通过; model.审核数据.审核时间 = DateTime.Now; model.审核数据.审核者.用户ID = currentUser.Id; //model.审核数据2.审核状态 = 审核状态.审核通过; //model.审核数据2.审核时间 = DateTime.Now; //model.审核数据2.审核者.用户ID = currentUser.Id; model.内容主体.标题 = model.项目信息.项目名称 + "(" + model.项目信息.项目编号 + ")"; model.内容主体.发布时间 = DateTime.Now; 公告管理.添加公告(model); GG_CreateIndex(model, "/Lucene.Net/IndexDic/GongGao"); } else { //站内消息 站内消息 Msg = new 站内消息(); 对话消息 Talk = new 对话消息(); Msg.重要程度 = 重要程度.特别重要; Msg.消息类型 = 消息类型.公告传递; Msg.发起者.用户ID = currentUser.Id; Talk.发言人.用户ID = currentUser.Id; Talk.消息主体.标题 = "待审核公告"; Talk.消息主体.内容 = "有一条待审核的公告未处理,<a style='color:red;text-decoration:underline;' href='/单位用户后台/Procure_AdSendList'>点击这里进行审核</a>"; var sendid = currentUser.Id; //二级单位的公告(昆明采购站,云南采购站,重庆采购站) if (currentUser.管理单位.用户ID == 11) { model.审核数据.审核状态 = 审核状态.未审核; model.审核数据.审核者.用户ID = 11; sendid = 11; } else { //低级单位提交的公告--根据省份提交到各采购站 var p = currentUser.所属地域.省份; switch (p) { case "重庆市": model.审核数据2.审核者.用户ID = 12; model.审核数据2.审核状态 = 审核状态.未审核; sendid = 12; break; case "云南省": model.审核数据2.审核者.用户ID = 13; model.审核数据2.审核状态 = 审核状态.未审核; sendid = 13; break; case "贵州省": model.审核数据2.审核者.用户ID = 14; model.审核数据2.审核状态 = 审核状态.未审核; sendid = 14; break; case "西藏自治区": model.审核数据2.审核者.用户ID = 15; model.审核数据2.审核状态 = 审核状态.未审核; sendid = 15; break; default: model.审核数据2.审核者.用户ID = 16; model.审核数据2.审核状态 = 审核状态.未审核; sendid = 16; break; } } model.内容主体.标题 = model.项目信息.项目名称 + "(" + model.项目信息.项目编号 + ")"; model.内容主体.发布时间 = DateTime.Now; 公告管理.添加公告(model); 站内消息管理.添加站内消息(Msg, currentUser.Id, sendid); 对话消息管理.添加对话消息(Talk, Msg); } #else model.审核数据.审核状态 = 审核状态.未审核; model.内容主体.标题 = model.项目信息.项目名称 + "(" + model.项目信息.项目编号 + ")"; model.内容主体.发布时间 = DateTime.Now; 公告管理.添加公告(model); #endif //if (!string.IsNullOrEmpty(zb_contact)) //{ // try // { // 招标采购项目 z = 招标采购项目管理.查找招标采购项目(int.Parse(zb_contact)); // if (model.公告信息.公告版本 == 公告.公告版本.变更 || model.公告信息.公告版本 == 公告.公告版本.更正 || model.公告信息.公告版本 == 公告.公告版本.补遗) // { // 公告链接 g = new 公告链接(); // g.公告ID = model.Id; // z.修正公告链接.Add(g); // } // switch (model.公告信息.公告性质) // { // case 公告.公告性质.技术公告: // z.技术公告链接.公告ID = model.Id; // break; // case 公告.公告性质.发标公告: // z.招标公告链接.公告ID = model.Id; // break; // case 公告.公告性质.中标公告: // z.中标公告链接.公告ID = model.Id; // break; // case 公告.公告性质.废标公告: // z.废标公告链接.公告ID = model.Id; // break; // case 公告.公告性质.流标公告: // z.流标公告链接.公告ID = model.Id; // break; // default: // break; // } // 招标采购项目管理.更新招标采购项目(z); // } // catch // { // } //} var isybm = Request.Form["isybm"]; if (isybm == "1") { if (model.公告信息.公告性质 == 公告.公告性质.采购公告 && model.公告信息.公告类别 == 公告.公告类别.公开招标) { 招标采购预报名 temp = new 招标采购预报名(); temp.所属公告链接.公告ID = model.Id; 招标采购预报名管理.添加招标采购预报名(temp); } } } catch { return Content("<script>alert('输入有误!请检查数据格式');location.href='javascript:history.go(-1)';</script>"); } return Content("<script>if(confirm('公告添加成功,点击确定继续添加,点击取消查看')){window.location='/单位用户后台/Procure_AdAdd';}else{window.location='/单位用户后台/Procure_AdSendList_S';}</script>"); }
//生成html文件 放入App_Uploads/公告下载/年月日时分秒 公告名称的一个文件夹 public string getHtmlString(公告 model, string time) { try { if (System.IO.File.Exists(Server.MapPath("/App_Uploads/download.html"))) { var sr = new StreamReader(Server.MapPath("/App_Uploads/download.html"), Encoding.UTF8); string input = sr.ReadToEnd(); sr.Close(); input = input.Replace("{0}", model.内容主体.标题) .Replace("{1}", model.公告来源.来源名称) .Replace("{2}", model.公告来源.来源链接) .Replace("{3}", model.内容主体.发布时间.ToString("yyyy-MM-dd")) .Replace("{4}", model.公告信息.一级分类) .Replace("{5}", model.公告信息.二级分类) .Replace("{6}", model.公告信息.三级分类) .Replace("{7}", model.公告信息.所属地域.省份) .Replace("{8}", model.公告信息.所属地域.城市) .Replace("{9}", model.公告信息.所属地域.区县) .Replace("{10}", model.项目信息.项目名称) .Replace("{11}", model.项目信息.项目编号) .Replace("{12}", model.公告信息.公告类别.ToString()) .Replace("{13}", model.公告信息.公告性质.ToString()) .Replace("{14}", model.公告信息.公告版本.ToString()) .Replace("{15}", model.内容主体.内容); var dir = Server.MapPath("/App_Uploads/公告下载/" + time + "/"); var file = dir + model.内容主体.标题 + ".html"; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } if (!System.IO.File.Exists(file)) { FileStream fs = System.IO.File.Create(file); fs.Close(); } var sw = new StreamWriter(file, false, Encoding.UTF8); sw.Write(input); sw.Close(); return file; } else { return ""; } } catch { return ""; } }
/// <summary> /// 创建公告索引 /// </summary> /// <param name="analyzer"></param> /// <param name="title"></param> /// <param name="content"></param> private void GG_AddIndex(IndexWriter writer, 公告 model) { try { Document doc = new Document(); doc.Add(new Field("NumId", model.Id.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));//存储且索引 Field f = new Field("Title", model.内容主体.标题, Field.Store.YES, Field.Index.ANALYZED); f.SetBoost(5F);//为标题增加权重 doc.Add(f);//存储且索引 doc.Add(new Field("Content", model.内容主体.内容, Field.Store.YES, Field.Index.ANALYZED));//存储且索引 doc.Add(new Field("AdClass", model.公告信息.公告类别.ToString(), Field.Store.YES, Field.Index.ANALYZED));//存储且索引 doc.Add(new Field("AdFeature", model.公告信息.公告性质.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));//存储且索引 doc.Add(new Field("AdPro", model.公告信息.所属地域.省份, Field.Store.YES, Field.Index.ANALYZED));//存储且索引 doc.Add(new Field("AdCity", model.公告信息.所属地域.城市, Field.Store.YES, Field.Index.ANALYZED));//存储且索引 doc.Add(new Field("AdArea", model.公告信息.所属地域.区县, Field.Store.YES, Field.Index.ANALYZED));//存储且索引 doc.Add(new Field("AdHy", model.公告信息.一级分类, Field.Store.YES, Field.Index.ANALYZED));//存储且索引 doc.Add(new Field("AddTime", model.内容主体.发布时间.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));//存储且索引 writer.AddDocument(doc); } catch { return; } }
/// <summary> /// 创建公告索引 /// </summary> private void GG_CreateIndex(公告 g, string indexdic) { string Indexdic_Server = IndexDic(indexdic); PanGu.Segment.Init(PanGuXmlPath); //创建索引目录 if (!Directory.Exists(Indexdic_Server)) { Directory.CreateDirectory(Indexdic_Server); } Lucene.Net.Store.Directory dir = new Lucene.Net.Store.SimpleFSDirectory(new DirectoryInfo(Indexdic_Server)); //IndexWriter第三个参数:true指重新创建索引,false指从当前索引追加....此处为追加索引所以为false try { IndexWriter writer = new IndexWriter(dir, PanGuAnalyzer, false, IndexWriter.MaxFieldLength.UNLIMITED); //IndexWriter writer = new IndexWriter(Indexdic_Server, PanGuAnalyzer, false, Lucene.Net.Index.IndexWriter.MaxFieldLength.LIMITED); GG_AddIndex(writer, g); writer.Optimize(); writer.Close(); } catch { IndexWriter writer = new IndexWriter(dir, PanGuAnalyzer, true, IndexWriter.MaxFieldLength.UNLIMITED); //IndexWriter writer = new IndexWriter(Indexdic_Server, PanGuAnalyzer, true, Lucene.Net.Index.IndexWriter.MaxFieldLength.LIMITED); GG_AddIndex(writer, g); writer.Optimize(); writer.Close(); } }
public static bool 更新公告(公告 content,bool s = true,bool f = true) { if(s){content.审核数据.审核状态 = 审核状态.未审核;} return Mongo.更新(content,f); }
public static bool 添加公告(公告 content) { return Mongo.添加(content); }
/// <summary> /// 设置关键字高亮 /// </summary> /// <param name="dicKeywords">关键字列表</param> /// <param name="model">返回的数据模型</param> /// <returns></returns> private 公告 SetHighlighter(Dictionary<string, string> dicKeywords, 公告 model) { SimpleHTMLFormatter simpleHTMLFormatter = new PanGu.HighLight.SimpleHTMLFormatter("<font color=\"red\">", "</font>"); Highlighter highlighter = new PanGu.HighLight.Highlighter(simpleHTMLFormatter, new Segment()); highlighter.FragmentSize = 50; string strTitle = string.Empty; dicKeywords.TryGetValue("title", out strTitle); if (!string.IsNullOrEmpty(strTitle)) { string title = highlighter.GetBestFragment(strTitle, model.内容主体.标题); if (!string.IsNullOrEmpty(title)) model.内容主体.标题 = title; } return model; }
public ActionResult Part_Zb_Detail(int? id) { var model = new 公告(); try { model = 公告管理.查找公告((int)id); } catch { } return PartialView("Gys_Part/Part_Zb_Detail", model); }