| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- using CallCenter.Utility;
- using CallCenterApi.Interface.Controllers.Base;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace CallCenterApi.Interface.Controllers.Wiki
- {
- [Authority]
- public class HotspotGlossaryController : BaseController
- {
- // GET: HotspotGlossary
- /// <summary>
- /// 上传附件
- /// </summary>
- /// <returns></returns>
- public ActionResult UploadFile()
- {
- HttpFileCollection files = RequestString.GetFiles();
- if (files.Count > 0)
- {
- List<Model.T_Sys_Accessories> acs = new List<Model.T_Sys_Accessories>();
- string path = "/Upload/Wiki/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
- for (int i = 0; i < files.Count; i++)
- {
- HttpPostedFile file = files[i];
- FileUp fu = new FileUp();
- string name = fu.Upload(file, path);
- Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
- model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
- model_T_Sys_Accessories.F_FileName = name;//附件名称
- model_T_Sys_Accessories.F_FileType = System.IO.Path.GetExtension(file.FileName);//附件类型
- model_T_Sys_Accessories.F_FileUrl = path + name;//附件地址
- model_T_Sys_Accessories.F_Size = file.ContentLength;
- model_T_Sys_Accessories.F_UserCode = User.F_UserCode;//上传人
- int id = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
- model_T_Sys_Accessories.F_FileId = id;
- acs.Add(model_T_Sys_Accessories);
- }
- return Success("成功", acs);
- }
- else
- {
- return Error("请选择要上传的文件");
- }
- }
- /// <summary>
- /// 列表
- /// </summary>
- /// <param name="page"></param>
- /// <param name="pagesize"></param>
- /// <param name="isdc"></param>
- /// <returns></returns>
- public ActionResult GetList(string keyvalue, string stime, string etime, int key = 0, int page = 1, int pagesize = 10, int isdc = 0)
- {
- DataTable dt = new DataTable();
- string sql = " and F_IsDelete=0 ";
- string sqldt = "";
- if (stime.Trim() != "" && stime != "undefined")
- {
- sql += " and F_FaBuShiJian >= '" + stime + " 00:00:00" + "' ";
- }
- if (etime.Trim() != "" && etime != "undefined")
- {
- sql += " and F_FaBuShiJian <= '" + etime + " 23:59:59" + "' ";
- }
- if (key > 0)
- {
- //sql += " and F_Key = " + key;
- sqldt = " INNER JOIN [GetValueId]('" + key + "') Value on a.F_Key = Value.F_ValueId";
- }
- if (!string.IsNullOrEmpty(keyvalue))
- {
- sql += " and (F_ZhengCeMingCi like '%" + keyvalue + "%' or F_QiTaShuoMing like '%" + keyvalue + "%' or F_BanLiLiuCheng like '%" + keyvalue + "%' or F_BeiZhu like '%" + keyvalue + "%')";
- }
- string cols = "a.*,dbo.GetDictionaryName(F_Key) as KeyName";
- if (isdc > 0)
- {
- var dtdc = DB.DbHelperSQL.Query(" select " + cols + " from T_Wiki_HotspotGlossary a with(nolock) " + sqldt + " where 1=1 " + sql).Tables[0];
- var msg = new NPOIHelper().ExportToExcel("办事指南", dtdc);
- if (msg == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- int recordCount = 0;
- dt = BLL.PagerBLL.GetListPager(
- "T_Wiki_HotspotGlossary a with(nolock) " + sqldt,
- "F_Id",
- cols,
- sql,
- "ORDER BY F_DianJiLiang,F_CreateTime DESC",
- pagesize,
- page,
- true,
- out recordCount);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 获取
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public ActionResult GetModel(int id = 0)
- {
- if (id != 0)
- {
- var model = new BLL.T_Wiki_HotspotGlossary().GetModel(id);
- if (model != null)
- {
- DB.DbHelperSQL.ExecuteSql(" update T_Wiki_HotspotGlossary set F_DianJiLiang=F_DianJiLiang+1 where F_Id=" + id);
- DataTable dtkey = new DataTable();
- if (model.F_Key > 0)
- {
- dtkey = DB.DbHelperSQL.Query(" select * from View_KeysSplit where id=" + model.F_Key).Tables[0];
- }
- DataTable dtfile = new DataTable();
- var configfj = new BLL.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
- if (!string.IsNullOrEmpty(model.F_File) && configfj != null)
- {
- dtfile = DB.DbHelperSQL.Query("select * from T_Sys_Accessories WITH(NOLOCK) where F_FileId in (" + model.F_File + ")").Tables[0];
- foreach (DataRow dr in dtfile.Rows)
- {
- dr["F_FileUrl"] = configfj.F_ParamValue + dr["F_FileUrl"].ToString();
- }
- }
- var obj = new { model, dtkey, dtfile };
- return Success("成功", obj);
- }
- return Error("参数错误");
- }
- else
- {
- return Error("参数错误");
- }
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult AddModel(int id = 0, int key = 0)
- {
- string fabudanwei = RequestString.GetFormString("fabudanwei");
- string faburen = RequestString.GetFormString("faburen");
- string hangye = RequestString.GetFormString("hangye");
- string diqu = RequestString.GetFormString("diqu");
- string shengxiaoshijian = RequestString.GetFormString("shengxiaoshijian");
- string shixiaoshijian = RequestString.GetFormString("shixiaoshijian");
- string fabushijian = RequestString.GetFormString("fabushijian");
- string fawenwenhao = RequestString.GetFormString("fawenwenhao");
- string fawendanwei = RequestString.GetFormString("fawendanwei");
- string biaoshibianma = RequestString.GetFormString("biaoshibianma");
- string jiedadanwei = RequestString.GetFormString("jiedadanwei");
- string zhengcemingci = RequestString.GetFormString("zhengcemingci");
- string file = RequestString.GetFormString("file");
- string redianwenti = RequestString.GetFormString("redianwenti");
- string wentijieda = RequestString.GetFormString("wentijieda");
- Model.T_Wiki_HotspotGlossary dModel = new Model.T_Wiki_HotspotGlossary();
- if (id == 0)
- {
- //var list = new BLL.T_Wiki_HotspotGlossary().GetList(" F_FaBuDanWei='" + fabudanwei + "' and F_IsDelete=0 ").Tables[0];
- //if (list.Rows.Count > 0)
- //{
- // return Error("已经存在");
- //}
- //else
- //{
- dModel.F_FaBuRen = faburen;
- dModel.F_FaBuDanWei = fabudanwei;
- dModel.F_HangYe = hangye;
- dModel.F_DiQu = diqu;
- try
- {
- dModel.F_ShengXiaoShiJian = DateTime.Parse(shengxiaoshijian);
- }
- catch { };
- try
- {
- dModel.F_ShiXiaoShiJian = DateTime.Parse(shixiaoshijian);
- }
- catch { };
- try
- {
- dModel.F_FaBuShiJian = DateTime.Parse(fabushijian);
- }
- catch { };
- dModel.F_Key = key;
- dModel.F_FaWenWenHao = fawenwenhao;
- dModel.F_FaWenDanWei = fawendanwei;
- dModel.F_BiaoShiBianMa = biaoshibianma;
- dModel.F_JieDaDanWei = jiedadanwei;
- dModel.F_ZhengCeMingCi = zhengcemingci;
- dModel.F_File = file;
- dModel.F_ReDianWenTi = redianwenti;
- dModel.F_WenTiJieDa = wentijieda;
- dModel.F_DianJiLiang = 0;
- dModel.F_IsDelete = 0;
- dModel.F_CreateUser = User.F_UserCode;
- dModel.F_CreateTime = DateTime.Now;
- int n = new BLL.T_Wiki_HotspotGlossary().Add(dModel);
- if (n > 0)
- return Success("添加成功", n);
- else
- return Error("添加失败");
- //}
- }
- else
- {
- dModel = new BLL.T_Wiki_HotspotGlossary().GetModel(id);
- if (dModel != null)
- {
- //var list = new BLL.T_Wiki_HotspotGlossary().GetList(" F_FaBuDanWei='" + fabudanwei + "' and F_IsDelete=0 and F_Id!='" + id + "' ").Tables[0];
- //if (list.Rows.Count > 0)
- //{
- // return Error("已经存在");
- //}
- //else
- //{
- dModel.F_FaBuRen = faburen;
- dModel.F_FaBuDanWei = fabudanwei;
- dModel.F_HangYe = hangye;
- dModel.F_DiQu = diqu;
- try
- {
- dModel.F_ShengXiaoShiJian = DateTime.Parse(shengxiaoshijian);
- }
- catch { };
- try
- {
- dModel.F_ShiXiaoShiJian = DateTime.Parse(shixiaoshijian);
- }
- catch { };
- try
- {
- dModel.F_FaBuShiJian = DateTime.Parse(fabushijian);
- }
- catch { };
- dModel.F_Key = key;
- dModel.F_FaWenWenHao = fawenwenhao;
- dModel.F_FaWenDanWei = fawendanwei;
- dModel.F_BiaoShiBianMa = biaoshibianma;
- dModel.F_JieDaDanWei = jiedadanwei;
- dModel.F_ZhengCeMingCi = zhengcemingci;
- dModel.F_File = file;
- dModel.F_ReDianWenTi = redianwenti;
- dModel.F_WenTiJieDa = wentijieda;
- if (new BLL.T_Wiki_HotspotGlossary().Update(dModel))
- return Success("修改成功");
- else
- return Error("修改失败");
- //}
- }
- else
- {
- return Error("修改失败");
- }
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- public ActionResult DelModel(string[] ids)
- {
- if (ids == null || ids.Length <= 0)
- {
- return Error("请选择要删除的选项");
- }
- var idStr = string.Join(",", ids);
- if (string.IsNullOrEmpty(idStr.Trim()))
- {
- return Error("请选择要删除的选项");
- }
- int n = DB.DbHelperSQL.ExecuteSql(" update T_Wiki_HotspotGlossary set F_IsDelete=1,F_DeleteUser='" + User.F_UserCode + "',F_DeleteTime=getdate() where F_Id in (" + idStr + ")");
- if (n > 0)
- {
- return Success("删除成功");
- }
- return Error("删除失败");
- }
- }
- }
|