| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710 |
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Web;
- using System.Web.Mvc;
- using YTSoft.BaseCallCenter.Model;
- using YTSoft.BaseCallCenter.MVCWeb.Commons;
- using YTSoft.BaseCallCenter.MVCWeb.Models;
- using YTSoft.Common;
- using YTSoft.DBUtility;
- namespace YTSoft.BaseCallCenter.MVCWeb.Controllers
- {
- public class SystemManageController : BaseController
- {
- #region 部门管理
- BLL.T_Sys_Department deptBLL = new BLL.T_Sys_Department();
- BLL.T_SYS_Time timeBLL = new BLL.T_SYS_Time();
- BLL.T_Sys_UserAccount userbll = new BLL.T_Sys_UserAccount();
-
- /// <summary>
- /// 部门列表
- /// </summary>
- /// <returns></returns>
- public ActionResult DepartmentList()
- {
- WorkOrderMyModel model = new WorkOrderMyModel();
- return View(model);
- }
- ///通过部门父级节点获取数据
- /// </summary>
- /// <param name="fid"></param>
- /// <returns></returns>
- public string GetDepartmentJsonModel(int parentId)
- {
- AddAction("t_sys_department", parentId.ToMyString(), "获取父级树结构", "");
- return Newtonsoft.Json.JsonConvert.SerializeObject(deptBLL.GetDepartmentJsonModel(parentId));
- }
- /// <summary>
- /// 部门编辑
- /// </summary>
- /// <param name="editType">类型1、新增 2、修改</param>
- /// /// <returns></returns>
- public ActionResult DepartmentEdit(int deptId, int editType)
- {
- AddAction("t_sys_department", deptId.ToMyString(), "打开部门编辑页面", "");
- Model.T_Sys_Department viewModel = new Model.T_Sys_Department();
- //当前对象实体
- if (editType == 1)
- {
- viewModel.F_ParentId = deptId;
- viewModel.F_Sort = 1;
- }
- else
- {
- Model.T_Sys_Department deptModel = deptBLL.GetModel(deptId);
- viewModel = deptModel;
- }
- return View(viewModel);
- }
- /// <summary>
- /// 保存编辑
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Post)]
- public bool SaveDeptData(T_Sys_Department deptModel)
- {
- if (deptModel.F_DeptId > 0)
- {
- AddAction("t_sys_department", deptModel.F_DeptId.ToMyString(), "更新部门", deptModel.F_DeptName);
- return deptBLL.Update(deptModel);
- }
- else
- {
- int id = deptBLL.Add(deptModel);
- AddAction("t_sys_department", id.ToMyString(), "添加部门", deptModel.F_DeptName);
- return id> 0;
- }
- }
- /// <summary>
- /// 删除部门
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Get)]
- public bool DeleteDeptData(int deptId)
- {
- AddAction("t_sys_department", deptId.ToMyString(), "删除部门");
- return deptBLL.Delete(deptId);
- }
- /// <summary>
- /// 获取部门数据
- /// </summary>
- /// <param name="page">当前页码</param>
- /// <param name="limit">每页数据量</param>
- /// <returns></returns>
- [ActionName("DeptDate")]
- [HttpGet]
- public string DeptDate(DateTime? NowDateTime, int page, int limit, int? parentId)
- {
- //数据结果集
- ResponseData dataModel = new ResponseData();
- string sql = "";
- if (parentId != null)
- {
- sql += " and F_ParentId=" + parentId;
- }
- DataTable dt = new DataTable();
- int recordCount = 0;
- Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
- dt = BLL.PagerBLL.GetListPager(
- "T_Sys_Department",
- "F_DeptId",
- "*",
- sql,
- "ORDER BY F_Sort asc ",
- limit,
- page,
- true,
- out recordCount);
- dataModel.code = 0;
- dataModel.count = recordCount;
- dataModel.data = dt;
- AddAction("t_sys_department", parentId.ToMyString(), "获取部门列表", "");
- return JsonConvert.SerializeObject(dataModel);
- }
- #endregion
- #region 角色管理
- BLL.T_Sys_RoleInfo roleBLL = new BLL.T_Sys_RoleInfo();
- public ActionResult RoleList()
- {
- WorkOrderMyModel model = new WorkOrderMyModel();
- return View(model);
- }
- /// <summary>
- /// 获取角色列表
- /// </summary>
- /// <param name="page">当前页码</param>
- /// <param name="limit">每页数据量</param>
- /// <returns></returns>
- [ActionName("RoleDate")]
- [HttpGet]
- public string RoleDate(DateTime? NowDateTime, int page, int limit)
- {
- AddAction("t_sys_roleinfo", "page", "查询角色列表",page.ToMyString()+"-"+ limit.ToMyString());
- //数据结果集
- ResponseData dataModel = new ResponseData();
- string sql = "";
- DataTable dt = new DataTable();
- int recordCount = 0;
- Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
- dt = BLL.PagerBLL.GetListPager(
- "T_Sys_RoleInfo",
- "F_RoleId",
- "*",
- sql,
- "ORDER BY F_RoleId",
- limit,
- page,
- true,
- out recordCount);
- dataModel.code = 0;
- dataModel.count = recordCount;
- dataModel.data = dt;
- return JsonConvert.SerializeObject(dataModel);
- }
- /// <summary>
- /// 编辑角色
- /// </summary>
- /// <returns></returns>
- public ActionResult RoleEdit(int? roleId)
- {
-
- Model.T_Sys_RoleInfo viewModel = new Model.T_Sys_RoleInfo();
- if (roleId != null && roleId > 0)
- {
- viewModel = roleBLL.GetModel(int.Parse(roleId.ToString()));
- AddAction("t_sys_roleinfo", roleId.ToMyString(), "打开角色编辑页", "角色名称:"+ viewModel.F_RoleName, "敏感信息");
- }
- return View(viewModel);
- }
- /// <summary>
- /// 保存编辑
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Post)]
- public bool SaveRoleEdit(T_Sys_RoleInfo roleInfoModel)
- {
- roleInfoModel.F_RoleCode = roleInfoModel.F_RoleCode.ToMyString();
- if (roleInfoModel.F_RoleId > 0)
- {
- AddAction("t_sys_roleinfo", roleInfoModel.F_RoleId.ToMyString(), "更新角色", roleInfoModel.F_RoleName);
- AddAction("t_sys_roleinfo", roleInfoModel.F_RoleId.ToMyString(), "更新角色", "数据:" + JsonConvert.SerializeObject(roleInfoModel), "敏感信息");
- return roleBLL.Update(roleInfoModel);
- }
- else
- {
- int id = roleBLL.Add(roleInfoModel);
- AddAction("t_sys_roleinfo", id.ToMyString(), "添加角色", roleInfoModel.F_RoleName);
- AddAction("t_sys_roleinfo", id.ToMyString(), "添加角色", "数据:" +JsonConvert.SerializeObject(roleInfoModel), "敏感信息");
- return id > 0;
- }
- }
- /// <summary>
- /// 删除数据
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Get)]
- public bool DeleteRoleData(string roleId)
- {
- AddAction("t_sys_roleinfo", roleId.ToMyString(), "删除角色");
- AddAction("t_sys_roleinfo", roleId.ToMyString(), "删除角色", "数据:" + roleId.ToMyString(), "敏感信息");
- return roleBLL.DeleteList(roleId);
- }
- #endregion
- #region 获取菜单树
- public class DicSeaarchModel
- {
- public string RootCode
- {
- get;
- set;
- }
- }
- /// <summary>
- /// 初始化字典结构
- /// </summary>
- /// <param name="rootCode"></param>
- /// <returns></returns>
- public ActionResult MenuTree(string rootCode)
- {
- DicSeaarchModel model = new DicSeaarchModel();
- model.RootCode = rootCode;
- return View(model);
- }
- /// <summary>
- /// 获取字典数据
- /// </summary>
- /// <param name="rootCode"></param>
- /// <returns></returns>
- public string GetMenuTreeData(int roleId)
- {
- try
- {
- AddAction("T_Sys_ModuleFunctions".ToLower(), roleId.ToMyString(), "获取角色字典", "角色id"+ roleId.ToMyString());
- return "[" + Newtonsoft.Json.JsonConvert.SerializeObject(roleBLL.GetMenuTree(roleId)).Replace("Checked", "checked") + "]";
- }
- catch (Exception ex)
- {
- return "";
- }
- }
- /// <summary>
- ///授权
- /// </summary>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Get)]
- public bool AcceptList(int roleId, string MenuIdStr)
- {
- bool accRersult = false;
- AddAction("T_Sys_ModuleFunctions", roleId.ToMyString(), "授权", "角色id" + roleId.ToMyString()+"功能菜单"+ MenuIdStr);
- if (roleBLL.AddRolesMenuList(roleId, MenuIdStr))
- {
- AddAction("T_Sys_ModuleFunctions", roleId.ToMyString(), "授权角色功能", string.Format("给角色{0}授权菜单功能{1}", roleId, MenuIdStr), "敏感信息");
- accRersult = true;
- }
- return accRersult;
- }
- #endregion
- #region 业务类型管理
- BLL.T_Wo_WorkOrderType dicTittleBLL = new BLL.T_Wo_WorkOrderType();
- public ActionResult BusinessTypeList()
- {
- WorkOrderMyModel model = new WorkOrderMyModel();
- return View(model);
- }
- ///通过dic编码获取dic值
- /// </summary>
- /// <param name="fid"></param>
- /// <returns></returns>
- public string GetDicTittleJson(int parentId)
- {
- AddAction("t_wo_workordertype".ToLower(), parentId.ToMyString(), "获取业务类型");
- return Newtonsoft.Json.JsonConvert.SerializeObject(dicTittleBLL.GetDicTittleJsonModel(parentId));
- }
- /// <summary>
- /// 获取业务类型数据
- /// </summary>
- /// <param name="page">当前页码</param>
- /// <param name="limit">每页数据量</param>
- /// <returns></returns>
- [ActionName("OrderTypeDate")]
- [HttpGet]
- public string OrderTypeDate(DateTime? NowDateTime, int page, int limit, int? parentId)
- {
- AddAction("t_wo_workordertype".ToLower(),"page", "获取业务类型列表", page.ToMyString() + "-" + limit.ToMyString());
- //数据结果集
- ResponseData dataModel = new ResponseData();
- string sql = "";
- if (parentId != null && parentId > 0)
- {
- sql += " and F_ParentId=" + parentId;
- }
- DataTable dt = new DataTable();
- int recordCount = 0;
- Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
- dt = BLL.PagerBLL.GetListPager(
- "T_Wo_WorkOrderType",
- "F_WorkOrderTypeId",
- "*",
- sql,
- "ORDER BY F_Sort asc ",
- limit,
- page,
- true,
- out recordCount);
- dataModel.code = 0;
- dataModel.count = recordCount;
- dataModel.data = dt;
- return JsonConvert.SerializeObject(dataModel);
- }
- /// <summary>
- /// 编辑业务类型
- /// </summary>
- /// <param name="F_WorkOrderTypeId">当前选中id</param>
- /// <param name="editType">类型1、新增 2、修改</param>
- /// <returns></returns>
- public ActionResult BussinessTypeEdit(int F_WorkOrderTypeId, int editType)
- {
- AddAction("t_wo_workordertype".ToLower(), F_WorkOrderTypeId.ToMyString(), "打开业务类型编辑页");
- Model.T_Wo_WorkOrderType viewModel = new Model.T_Wo_WorkOrderType();
- //当前对象实体
- Model.T_Wo_WorkOrderType orderTypeModel = dicTittleBLL.GetModel(F_WorkOrderTypeId);
- if (editType == 1)
- {
- viewModel.F_ParentId = orderTypeModel.F_WorkOrderTypeId;
- viewModel.F_ParentName = orderTypeModel.F_ParentName;
- viewModel.F_Sort = 1;
- }
- else
- {
- viewModel = orderTypeModel;
- }
- return View(viewModel);
- }
- /// <summary>
- /// 保存编辑
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Post)]
- public bool SaveBussiTypeData(T_Wo_WorkOrderType WorkOrderTypeModel)
- {
- ////当前用户信息
- //workOrderBaseModel.F_USERID = F_UserID;//id
- //workOrderBaseModel.F_LINKMAN = F_UserCode;//工号
- //workOrderBaseModel.F_REPAIRMANNAME = "12";//姓名
- if (WorkOrderTypeModel.F_WorkOrderTypeId > 0)
- {
- AddAction("t_wo_workordertype", WorkOrderTypeModel.F_WorkOrderTypeId.ToMyString(), "更新工单分类",WorkOrderTypeModel.F_Name);
- return dicTittleBLL.Update(WorkOrderTypeModel) > 0;
- }
- else
- {
- int id = dicTittleBLL.Add(WorkOrderTypeModel);
- AddAction("t_wo_workordertype", id.ToMyString(), "添加工单分类", WorkOrderTypeModel.F_Name);
- return id > 0;
- }
- }
- /// <summary>
- /// 删除数据
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Get)]
- public bool DeleteBussiTypeData(int WorkOrderTypeId)
- {
- AddAction("T_Sys_ModuleFunctions", WorkOrderTypeId.ToMyString(), "删除工单分类","", "敏感信息");
- AddAction("t_wo_workordertype", WorkOrderTypeId.ToMyString(), "删除工单分类");
- return dicTittleBLL.Delete(WorkOrderTypeId);
- }
- #endregion
- #region 字典管理
- BLL.T_Sys_DictionaryValue dicValueBLL = new BLL.T_Sys_DictionaryValue();
- BLL.T_Sys_DictionaryBase dicBaseBLL = new BLL.T_Sys_DictionaryBase();
- /// <summary>
- /// 字典列表
- /// </summary>
- /// <returns></returns>
- public ActionResult DictionaryList()
- {
- WorkOrderMyModel model = new WorkOrderMyModel();
- return View(model);
- }
- ///通过字典获取数据
- /// </summary>
- /// <param name="fid"></param>
- /// <returns></returns>
- public string GetDictionaryJsonModel(int parentId)
- {
- return Newtonsoft.Json.JsonConvert.SerializeObject(dicBaseBLL.GetDictionaryJsonModel());
- }
- /// <summary>
- /// 获取字典值数据
- /// </summary>
- /// <param name="page">当前页码</param>
- /// <param name="limit">每页数据量</param>
- /// <returns></returns>
- [ActionName("DictionaryDate")]
- [HttpGet]
- public string DictionaryDate(DateTime? NowDateTime, int page, int limit, string dictionaryFlag)
- {
- AddAction("t_sys_dictionarybase".ToLower(),"page", "获取字典列表", page+"-"+ limit);
- //数据结果集
- ResponseData dataModel = new ResponseData();
- string sql = "";
- if (!string.IsNullOrEmpty(dictionaryFlag) && dictionaryFlag != "0")
- {
- sql += " and F_DictionaryFlag='" + dictionaryFlag + "'";
- }
- DataTable dt = new DataTable();
- int recordCount = 0;
- Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
- if (string.IsNullOrEmpty(dictionaryFlag) || dictionaryFlag != "0")
- {
- dt = BLL.PagerBLL.GetListPager(
- "T_Sys_DictionaryValue",
- "F_DictionaryValueId",
- "*",
- sql,
- "ORDER BY F_Sort asc ",
- limit,
- page,
- true,
- out recordCount);
- }
- else
- {
- dt = BLL.PagerBLL.GetListPager(
- "T_Sys_DictionaryBase",
- "F_DictionaryName",
- "*,F_DictionaryName as F_Name",
- sql,
- "ORDER BY F_Sort asc ",
- limit,
- page,
- true,
- out recordCount);
- }
- dataModel.code = 0;
- dataModel.count = recordCount;
- dataModel.data = dt;
- return JsonConvert.SerializeObject(dataModel);
- }
- /// <summary>
- /// 获取字典值数据
- /// </summary>
- /// <param name="page">当前页码</param>
- /// <param name="limit">每页数据量</param>
- /// <returns></returns>
- [ActionName("DictionaryDateOut")]
- [HttpGet]
- public string DictionaryDateOut(DateTime? NowDateTime, int page, int limit, string dictionaryFlag)
- {
- AddAction("t_sys_dictionarybase".ToLower(), "page", "获取字典列表", page + "-" + limit);
- //数据结果集
- ResponseData dataModel = new ResponseData();
- string sql = "and (F_DictionaryFlag='ZDXX' OR F_DictionaryFlag='ZDXX2')";
- DataTable dt = new DataTable();
- int recordCount = 0;
- Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
- dt = BLL.PagerBLL.GetListPager(
- "T_Sys_DictionaryValue",
- "F_DictionaryValueId",
- "*",
- sql,
- "ORDER BY F_Sort asc ",
- limit,
- page,
- true,
- out recordCount);
- dataModel.code = 0;
- dataModel.count = recordCount;
- dataModel.data = dt;
- return JsonConvert.SerializeObject(dataModel);
- }
- /// <summary>
- /// 字典项编辑
- /// </summary>
- /// <param name="editType">类型1、新增 2、修改</param>
- /// /// <returns></returns>
- public ActionResult DictionaryBaseEdit(string dicCode, int editType)
- {
- AddAction("t_sys_dictionarybase".ToLower(), dicCode, "打开字典编辑页");
- Model.T_Sys_DictionaryBase viewModel = new Model.T_Sys_DictionaryBase();
- //当前对象实体
- if (editType == 1)
- {
- viewModel.F_Sort = 1;
- }
- else
- {
- Model.T_Sys_DictionaryBase dicBaseModel = dicBaseBLL.GetModel(dicCode);
- viewModel = dicBaseModel;
- }
- return View(viewModel);
- }
- /// <summary>
- /// 保存字典项编辑
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Post)]
- public bool SaveDictionaryBaseData(T_Sys_DictionaryBase dicBaseModel)
- {
- try
- {
- if (!string.IsNullOrEmpty(dicBaseModel.F_DictionaryFlagType))
- {
- AddAction("t_sys_dictionarybase", dicBaseModel.F_DictionaryFlagType, "更新字典项");
- return dicBaseBLL.Update(dicBaseModel);
- }
- else
- {
- AddAction("t_sys_dictionarybase", dicBaseModel.F_DictionaryFlagType, "添加字典项");
- return dicBaseBLL.Add(dicBaseModel);
- }
- }
- catch (Exception ex)
- {
- LogHelper.Default.WriteError("字典操作失败",ex);
- return false;
- }
- }
- /// <summary>
- /// 删除字典项
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Get)]
- public bool DeleteBaseData(string baseCode)
- {
- AddAction("t_sys_dictionarybase", baseCode,"删除字典项");
- return dicBaseBLL.Delete(baseCode);
- }
- /// <summary>
- /// 字典值编辑
- /// </summary>
- /// <param name="editType">类型1、新增 2、修改</param>
- /// /// <returns></returns>
- public ActionResult DictionaryValueEdit(int? valueId, string parentCode, int editType)
- {
- AddAction("t_sys_dictionarybase".ToLower(), valueId.ToMyString(), "打开字典值编辑页");
- Model.T_Sys_DictionaryValue viewModel = new Model.T_Sys_DictionaryValue();
- //当前对象实体
- if (editType == 1)
- {
- viewModel.F_Sort = 1;
- viewModel.F_DictionaryFlag = parentCode;
- }
- else
- {
- Model.T_Sys_DictionaryValue dicValueModel = dicValueBLL.GetModel(int.Parse(valueId.ToString()));
- viewModel = dicValueModel;
- }
- return View(viewModel);
- }
- /// <summary>
- /// 保存字典值
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Post)]
- public bool SaveDictionaryValueData(T_Sys_DictionaryValue dicBaseModel)
- {
- if (dicBaseModel.F_DictionaryValueId > 0)
- {
- AddAction("t_sys_dictionaryvalue", dicBaseModel.F_DictionaryValueId.ToMyString(), "更新字典值");
- return dicValueBLL.Update(dicBaseModel);
- }
- else
- {
-
- int id = dicValueBLL.Add(dicBaseModel);
- AddAction("t_sys_dictionaryvalue", id.ToMyString(), "添加字典值");
- return id > 0;
- }
- }
- /// <summary>
- /// 删除字典值
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Get)]
- public bool DeleteValueData(int id)
- {
- AddAction("t_sys_dictionaryvalue", id.ToMyString(), "删除字典值");
- return dicValueBLL.Delete(id);
- }
- #endregion
- #region 菜单管理
- BLL.T_Sys_ModuleFunctions menuBLL = new BLL.T_Sys_ModuleFunctions();
- /// <summary>
- /// 部门列表
- /// </summary>
- /// <returns></returns>
- public ActionResult MenuList()
- {
- WorkOrderMyModel model = new WorkOrderMyModel();
- return View(model);
- }
- ///通过部门父级节点获取数据
- /// </summary>
- /// <param name="fid"></param>
- /// <returns></returns>
- public string GetMenuJsonModel(int parentId)
- {
- AddAction("t_sys_modulefunctions", parentId.ToMyString(), "获取父级下菜单","父级id:"+ parentId);
- return Newtonsoft.Json.JsonConvert.SerializeObject(menuBLL.GetMenuJsonModel(parentId));
- }
- /// <summary>
- /// 获取部门数据
- /// </summary>
- /// <param name="page">当前页码</param>
- /// <param name="limit">每页数据量</param>
- /// <returns></returns>
- [ActionName("MenuDate")]
- [HttpGet]
- public string MenuDate(DateTime? NowDateTime, int page, int limit, int? parentId)
- {
- AddAction("t_sys_modulefunctions", "page", "获取菜单列表",page+"-"+limit);
- //数据结果集
- ResponseData dataModel = new ResponseData();
- string sql = "";
- if (parentId != null)
- {
- sql += " and F_ParentId=" + parentId;
- }
- DataTable dt = new DataTable();
- int recordCount = 0;
- Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
- dt = BLL.PagerBLL.GetListPager(
- "T_Sys_ModuleFunctions",
- "F_FunctionId",
- "* ,(CASE F_StateFlag WHEN 1 THEN '启用' WHEN 0 THEN '禁用' ELSE NULL END ) as F_StateFlagName",
- sql,
- "ORDER BY F_Sort asc ",
- limit,
- page,
- true,
- out recordCount);
- dataModel.code = 0;
- dataModel.count = recordCount;
- dataModel.data = dt;
- return JsonConvert.SerializeObject(dataModel);
- }
- /// <summary>
- /// 功能编辑
- /// </summary>
- /// <param name="editType">类型1、新增 2、修改</param>
- /// /// <returns></returns>
- public ActionResult MenuEdit(int menuId, int editType)
- {
- Model.T_Sys_ModuleFunctions viewModel = new Model.T_Sys_ModuleFunctions();
- AddAction("t_sys_modulefunctions", menuId.ToMyString(), "打开功能编辑页", "菜单编号"+ menuId);
- //当前对象实体
- if (editType == 1)
- {
- viewModel.F_ParentId = menuId;
- viewModel.F_Sort = 1;
- }
- else
- {
- Model.T_Sys_ModuleFunctions deptModel = menuBLL.GetModel(menuId);
- viewModel = deptModel;
- }
- return View(viewModel);
- }
- /// <summary>
- /// 保存编辑
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Post)]
- public bool SaveMenuData(T_Sys_ModuleFunctions menuModel)
- {
- if (menuModel.F_FunctionId > 0)
- {
- AddAction("t_sys_modulefunctions", menuModel.F_FunctionId.ToMyString(), "更新菜单", menuModel.F_Name);
- AddAction("t_sys_modulefunctions", menuModel.F_FunctionId.ToMyString(), "更新菜单", "数据:"+JsonConvert.SerializeObject(menuModel), "主要设置");
- return menuBLL.Update(menuModel);
- }
- else
- {
- int id = menuBLL.Add(menuModel);
- AddAction("t_sys_modulefunctions", id.ToMyString(), "添加菜单", menuModel.F_Name);
- AddAction("t_sys_modulefunctions", menuModel.F_FunctionId.ToMyString(), "添加菜单", "数据:" + JsonConvert.SerializeObject(menuModel), "主要设置");
- return id > 0;
- }
- }
- /// <summary>
- /// 删除功能
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Get)]
- public bool DeleteMenuData(int menuId)
- {
- Model.T_Sys_ModuleFunctions deptModel = menuBLL.GetModel(menuId);
- AddAction("t_sys_modulefunctions", deptModel.F_FunctionId.ToMyString(), "删除菜单", "数据:" + JsonConvert.SerializeObject(deptModel), "主要设置");
- AddAction("t_sys_modulefunctions", menuId.ToMyString(), "删除菜单");
- return menuBLL.Delete(menuId);
- }
- #endregion
- #region 用户管理
- BLL.T_Sys_UserAccount userBLL = new BLL.T_Sys_UserAccount();
- /// <summary>
- /// 部门列表
- /// </summary>
- /// <returns></returns>
- public ActionResult UserList()
- {
- WorkOrderMyModel model = new WorkOrderMyModel();
- return View(model);
- }
- /// <summary>
- /// 用户编辑
- /// </summary>
- /// <param name="editType">类型1、新增 2、修改</param>
- /// /// <returns></returns>
- public ActionResult UserEdit(int? userId, int? deptId, int editType)
- {
- AddAction("t_sys_useraccount", userId.ToMyString(), "打开用户编辑页", "用户编号/部门" + userId+"-"+ deptId);
- Model.T_Sys_UserAccount viewModel = new Model.T_Sys_UserAccount();
- //当前对象实体
- if (editType == 1)
- {
- viewModel.F_DeptId = int.Parse(deptId.ToString());
- AddAction("t_sys_useraccount", deptId.ToMyString(), "打开用户添加页", "", "敏感信息");
- }
- else
- {
- Model.T_Sys_UserAccount userModel = userBLL.GetModel(int.Parse(userId.ToString()));
- viewModel = userModel;
- AddAction("t_sys_useraccount", userId.ToMyString(), "打开用户编辑页", "数据:" + JsonConvert.SerializeObject(userModel), "敏感信息");
- }
- //获取部门列表
- viewModel.DepartmentList = deptBLL.GetModelList("F_ParentId=0");
- //获取角色列表
- viewModel.RoleInfoList = roleBLL.GetModelList("");
- return View(viewModel);
- }
- /// <summary>
- /// 保存编辑
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Post)]
- public bool SaveUserData(T_Sys_UserAccount userModel)
- {
- BLL.T_Sys_RoleInfo bll = new BLL.T_Sys_RoleInfo();
- BLL.T_Sys_UserAccount blluser = new BLL.T_Sys_UserAccount();
- if (userModel.F_UserId > 0)
- {
- Model.T_Sys_UserAccount oldusermodel = blluser.GetModel(userModel.F_UserId);
- Model.T_Sys_RoleInfo role2 = bll.GetModel(F_RoleID); //当前登录人的角色
- Model.T_Sys_RoleInfo role = bll.GetModel(oldusermodel.F_RoleId);//要修改账户的角色
- //要修改de账号 角色代码,登录人不是系统管理员,返回false
- if (role.F_RoleCode == "XTGLY" || role.F_RoleCode == "YWGLY")
- {
-
- if (role2.F_RoleCode != "XTGLY")
- {
- return false;
- }
- }
- Model.T_Sys_RoleInfo rolenew = bll.GetModel(userModel.F_RoleId);//要修改账户的改了之后的角色
- if (rolenew.F_RoleCode == "XTGLY" || rolenew.F_RoleCode == "YWGLY")
- {
- if (role2.F_RoleCode != "XTGLY")
- {
- return false;
- }
- }
- }
- userModel.F_WorkNumber = userModel.F_UserCode;
- if (userModel.F_UserId > 0)
- {
- T_Sys_UserAccount oldUserModel = userBLL.GetModel(userModel.F_UserId);
- oldUserModel.F_WorkNumber = userModel.F_WorkNumber;
- oldUserModel.F_UserName = userModel.F_UserName;
- oldUserModel.F_UserCode = userModel.F_UserCode;
- oldUserModel.F_DeptId = userModel.F_DeptId;
- oldUserModel.F_RoleId = userModel.F_RoleId;
- oldUserModel.F_SexFlag = userModel.F_SexFlag;
- oldUserModel.F_Telephone = userModel.F_Telephone;
- oldUserModel.F_SeatFlag = userModel.F_SeatFlag;
- oldUserModel.F_SeatRight = userModel.F_SeatRight;
- oldUserModel.F_Password = userModel.F_Password;
- oldUserModel.F_Remark = userModel.F_Remark;
- oldUserModel.F_ExtensionNumber = userModel.F_ExtensionNumber.ToMyString();
- AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "更新用户", userModel.F_UserName);
- AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "更新用户", "数据:" + JsonConvert.SerializeObject(oldUserModel), "敏感信息");
- return userBLL.Update(oldUserModel);
- }
- else
- {
- Model.T_Sys_RoleInfo role2 = bll.GetModel(F_RoleID); //当前登录人的角色
- Model.T_Sys_RoleInfo rolenew = bll.GetModel(userModel.F_RoleId);//要添加账户的的角色
- if (rolenew.F_RoleCode == "XTGLY" || rolenew.F_RoleCode == "YWGLY")
- {
- if (role2.F_RoleCode != "XTGLY")
- {
- return false;
- }
- }
- userModel.F_HJType = 0;
- userModel.F_GroupId = 1;
- if (userModel.F_SeatFlag)//&&false)
- {
- #region 调用接口插入用户信息
- try
- {
- AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "跨站插入用户数据", "rexian.zzmetro.com用户编号" + userModel.F_UserCode);
- AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "跨站插入用户数据", "数据:" + JsonConvert.SerializeObject(userModel), "敏感信息");
- StringBuilder returnStr = new StringBuilder();
- string wxAddUrl = "http://rexian.zzmetro.com/api/customer/insert";
- UserInfo model = new UserInfo();
- model.name = userModel.F_UserCode;
- object userInfo = JObject.Parse(JsonConvert.SerializeObject(model));
- string addWxResult = HttpHelper.HttpPost(wxAddUrl, userInfo);
- ResponseResult ResultModel = JsonConvert.DeserializeObject<ResponseResult>(addWxResult);
- userModel.F_PId = ResultModel.data;
- }
- catch (Exception ex)
- {
- }
- #endregion
- }
-
- int userid = userBLL.Add(userModel);
- AddAction("t_sys_useraccount", userid.ToMyString(), "新增用户", userModel.F_UserName);
- AddAction("t_sys_useraccount", userModel.F_UserId.ToMyString(), "新增用户", "数据:" + JsonConvert.SerializeObject(userModel), "敏感信息");
- return userid > 0;
- }
- }
- /// <summary>
- /// 删除用户
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Get)]
- public bool DeleteUserData(int userId)
- {
- T_Sys_UserAccount oldUserModel = userBLL.GetModel(userId);
- if (F_RoleID != 17 &&(oldUserModel.F_RoleId==17 || oldUserModel.F_RoleId == 57))
- {
- return false;
- }
- AddAction("t_sys_useraccount", userId.ToMyString(), "删除用户");
- AddAction("t_sys_useraccount", userId.ToMyString(), "删除用户", "数据:" + JsonConvert.SerializeObject(oldUserModel), "敏感信息");
-
- return userBLL.Delete(userId);
- }
- /// <summary>
- /// 获取用户数据
- /// </summary>
- /// <param name="page">当前页码</param>
- /// <param name="limit">每页数据量</param>
- /// <returns></returns>
- [ActionName("UserDate")]
- [HttpGet]
- public string UserDate(DateTime? NowDateTime, int page, int limit, int? deptId)
- {
- AddAction("t_sys_useraccount", "page", "获取用户列表", "部门编号" + deptId.ToMyString());
- //数据结果集
- ResponseData dataModel = new ResponseData();
- string sql = "";
- if (deptId != null && deptId > 0)
- {
- sql += " and F_DeptId=" + deptId;
- }
- DataTable dt = new DataTable();
- int recordCount = 0;
- Model.PageData<Model.T_Wo_WorkOrderBase> pageModel = new Model.PageData<Model.T_Wo_WorkOrderBase>();
- dt = BLL.PagerBLL.GetListPager(
- "T_Sys_UserAccount",
- "F_UserId",
- "*"
- + ",(select top 1 t.F_DeptName from T_Sys_Department t where t.F_DeptId=T_Sys_UserAccount.F_DeptId) as F_DeptName "
- + ",(select top 1 t.F_RoleName from T_Sys_RoleInfo t where t.F_RoleId=T_Sys_UserAccount.F_RoleId) as F_RoleName "
- + ",(CASE F_SeatFlag WHEN 1 THEN '使用' WHEN 0 THEN '不使用' ELSE NULL END ) as F_SeatFlagName"
- + ",(CASE F_SeatRight WHEN 1 THEN '班长坐席' WHEN 0 THEN '普通坐席' ELSE NULL END ) as F_SeatRightName"
- ,
- sql,
- "ORDER BY F_UserCode asc ",
- limit,
- page,
- true,
- out recordCount);
- dataModel.code = 0;
- dataModel.count = recordCount;
- dataModel.data = dt;
- return JsonConvert.SerializeObject(dataModel);
- }
- #endregion
- #region 修改密码
- /// <summary>
- ///用户修改个人密码
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public ActionResult UserPwdEdit()
- {
- AddAction("t_sys_useraccount", F_UserID.ToMyString(), "打开修改密码页");
- Model.T_Sys_UserAccount model = new Model.T_Sys_UserAccount();
- if (F_UserID > 0)
- {
- model = userBLL.GetModel(F_UserID);
- }
- return View(model);
- }
- /// </summary>
- [AcceptVerbs(HttpVerbs.Post)]
- public ActionResult CheckPwd(string pwd)
- {
- checkpwd.Chkrslt chkrslt = checkpwd.PasswordStrength(pwd);
- return Json(new
- {
- code = chkrslt.RSL ? 0 : 1,
- msg = chkrslt.MSG
- });
- }
- /// <summary>
- ///保存修改密码
- /// </summary>
- [AcceptVerbs(HttpVerbs.Post)]
- public string UpdateUserPwd(Model.T_Sys_UserAccount model)
- {
- //checkpwd.Chkrslt chkrslt = checkpwd.PasswordStrength(model.password);
- //if(!chkrslt.RSL)
- //{
- // return chkrslt.MSG;
- //}
- string AddRersult = "false";
- if (model.F_UserId > 0)
- {
- Model.T_Sys_UserAccount newModel = userBLL.GetModel(model.F_UserId);
- if (newModel != null && newModel.F_Password == model.oldPwd)
- {
- newModel.F_Password = model.password;
- if (userBLL.Update(newModel))
- {
- AddAction("t_sys_useraccount", model.F_UserId.ToMyString(), "修改密码");
- AddAction("t_sys_useraccount", model.F_UserId.ToMyString(), "修改密码", "数据:" + JsonConvert.SerializeObject(newModel), "敏感信息");
- AddRersult = "True";
- }
- }
- else
- {
- AddRersult = "旧密码不正确!";
- }
- }
- return AddRersult;
- }
- #endregion
- #region 基本信息
- /// <summary>
- /// 用户编辑
- /// </summary>
- /// <param name="editType">类型1、新增 2、修改</param>
- /// /// <returns></returns>
- public ActionResult UserView()
- {
- Model.T_Sys_UserAccount userModel = userBLL.GetModel(F_UserID);
- AddAction("t_sys_useraccount", F_UserID.ToMyString(), "打开用户编辑页", "用户:"+userModel.F_UserName);
- if (string.IsNullOrEmpty(userModel.F_HomePhone))
- {
- userModel.F_HomePhone = "/Content/images/face.jpg";
- }
- else
- {
- if (!System.IO.File.Exists(Server.MapPath(userModel.F_HomePhone)))
- {
- userModel.F_HomePhone = "/Content/images/face.jpg";
- }
- }
- return View(userModel);
- }
- #endregion
- #region 图片上传
- /// <summary>
- /// 图片上传
- /// </summary>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Post)]
- public ActionResult UploadFile()
- {
- try
- {
- if (Request.Files.Count > 0)
- {
- string uppath = string.Empty;
- string savepath = string.Empty;
- HttpPostedFileBase imgFile = Request.Files[0];
- if (imgFile != null)
- {
- //创建图片新的名称
- string nameImg = DateTime.Now.ToString("yyyyMMddHHmmssfff");
- //获得上传图片的路径
- string strPath = imgFile.FileName;
- //获得上传图片的类型(后缀名)
- string type = strPath.Substring(strPath.LastIndexOf(".") + 1).ToLower();
- //拼写数据库保存的相对路径字符串
- savepath = "/Content/HeadImg/images/";
- //拼写上传图片的路径
- uppath = Server.MapPath("~/Content/HeadImg/images/");
- if (!Directory.Exists(Path.GetDirectoryName(uppath)))
- {
- Directory.CreateDirectory(Path.GetDirectoryName(uppath));
- }
- uppath += nameImg + "." + type;
- savepath += nameImg + "." + type;
- //上传图片
- imgFile.SaveAs(uppath); //原图片路径
- }
- Model.T_Sys_UserAccount userModel = userBLL.GetModel(F_UserID);
- userModel.F_HomePhone = savepath;
- if (userBLL.Update(userModel))
- {
- return Json(new
- {
- code = 0,
- src = savepath,
- msg = "上传成功"
- });
- }
- else
- {
- return Json(new
- {
- code = 1,
- src = "",
- msg = "上传出错 请检查图片名称或图片内容"
- });
- }
- }
- else
- {
- return Json(new
- {
- code = 1,
- src = "",
- msg = "上传出错 请检查图片名称或图片内容"
- });
- }
- }
- catch (Exception ex)
- {
- return Json(new
- {
- code = 1,
- src = "",
- msg = "上传出错: " + ex.Message
- });
- }
- }
- #endregion
- #region 公告管理
- /// <summary>
- /// 公告管理
- /// </summary>
- /// <returns></returns>
- public ActionResult noticeManage()
- {
- Model.T_Msg_NoticeInfo noticeModel = new Model.T_Msg_NoticeInfo();
- return View(noticeModel);
- }
- public ActionResult test()
- {
- Model.T_Msg_NoticeInfo noticeModel = new Model.T_Msg_NoticeInfo();
- return View(noticeModel);
- }
- /// <summary>
- /// 获取公告数据
- /// </summary>
- /// <param name="page">当前页码</param>
- /// <param name="limit">每页数据量</param>
- /// <returns></returns>
- [ActionName("NoticeListDate")]
- [HttpGet]
- public string NoticeListDate(DateTime? NowDateTime, int page, int limit, int? parentId)
- {
- AddAction("t_msg_noticeinfo", parentId.ToMyString(), "获取公告列表", page+"-"+ limit);
- //数据结果集
- ResponseData dataModel = new ResponseData();
- string sql = "";
- if (parentId != null)
- {
- sql += " and F_ParentId=" + parentId;
- }
- DataTable dt = new DataTable();
- int recordCount = 0;
- Model.PageData<Model.T_Msg_NoticeInfo> pageModel = new Model.PageData<Model.T_Msg_NoticeInfo>();
- dt = BLL.PagerBLL.GetListPager(
- "T_Msg_NoticeInfo",
- "F_NoticeId",
- "*,CONVERT(varchar,F_CreateOn, 120 ) as F_CreateOnNew,isnull( CONVERT(varchar,F_ModifyDate, 120 ) ,CONVERT(varchar,F_CreateOn, 120 ) )as F_ModifyDateNew ",
- sql,
- "ORDER BY isnull( CONVERT(varchar,F_ModifyDate, 120 ) ,CONVERT(varchar,F_CreateOn, 120 ) ) desc ",
- limit,
- page,
- true,
- out recordCount);
- dataModel.code = 0;
- dataModel.count = recordCount;
- dataModel.data = dt;
- return JsonConvert.SerializeObject(dataModel);
- }
-
- BLL.T_Msg_NoticeInfo noticeBLL = new BLL.T_Msg_NoticeInfo();
- BLL.T_Msg_NoticeUsers noticeuserBLL = new BLL.T_Msg_NoticeUsers();
- BLL.T_Sys_UserAccount usersBLL = new BLL.T_Sys_UserAccount();
- /// <summary>
- /// 编辑公告
- /// </summary>
- /// <param name="editType">类型1、新增 2、修改</param>
- /// /// <returns></returns>
- public ActionResult NoticeEdit(int? noticeId, int editType)
- {
- AddAction("t_msg_noticeinfo", noticeId.ToMyString(), "打开公告编辑页");
- Model.T_Msg_NoticeInfo viewModel = new Model.T_Msg_NoticeInfo();
- //当前对象实体
- if (editType == 1)
- {
- viewModel.F_NoticeId = int.Parse(noticeId.ToString());
- //viewModel.UseList = userBLL.GetModelList("");
- }
- else
- {
- Model.T_Msg_NoticeInfo userModel = noticeBLL.GetModel(int.Parse(noticeId.ToString()));
- viewModel = userModel;
- if (!string.IsNullOrEmpty(userModel.F_ReceiveInfo))
- {
- int deviceid = userModel.F_DeviceId == null ? 0 : (int)userModel.F_DeviceId;
- viewModel.UseList = userBLL.GetModelList("F_UserId=" + deviceid);
- viewModel.DepartmentList = deptBLL.GetModelList("F_DeptId=" + userModel.F_ReceiveInfo);
- }
- }
- //获取部门列表
-
- return View(viewModel);
- }
- /// <summary>
- /// 查看公告
- /// </summary>
- /// <param name="editType">类型1、新增 2、修改</param>
- /// /// <returns></returns>
- public ActionResult NoticeView(int? noticeId)
- {
- AddAction("t_msg_noticeinfo", noticeId.ToMyString(), "查看公告详情");
- Model.T_Msg_NoticeInfo viewModel = new Model.T_Msg_NoticeInfo();
- viewModel.F_NoticeId = int.Parse(noticeId.ToString());
- viewModel.UseList = userBLL.GetModelList("");
-
- Model.T_Msg_NoticeInfo userModel = noticeBLL.GetModel(int.Parse(noticeId.ToString()));
- viewModel = userModel;
- viewModel.UseList = userBLL.GetModelList("F_DeptId=" + userModel.F_ReceiveInfo);
-
- //获取部门列表
- viewModel.DepartmentList = deptBLL.GetModelList("F_ParentId=0");
- return View(viewModel);
- }
- /// <summary>
- /// 保存编辑公告
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Post)]
- public bool SaveNoticeData(T_Msg_NoticeInfo noticeinfoModel)
- {
- bool result = false;
- DataTable dt = new DataTable();
- DataTable dtuser = new DataTable();
- int noticeid = 0;
- Model.T_Msg_NoticeUsers noticeuserModel = new Model.T_Msg_NoticeUsers();
- DateTime? readdate =null;
- try
- {
- //获取当前用户
- noticeinfoModel.F_CreateBy = F_UserID;
- noticeinfoModel.F_CreateName = HttpUtility.UrlDecode(F_UserName);
- if (noticeinfoModel.F_NoticeId > 0)
- {
- noticeid = noticeinfoModel.F_NoticeId;
- Model.T_Msg_NoticeInfo oldnoticeinfoModel = noticeBLL.GetModel(int.Parse(noticeid.ToString())); ;
-
- dt = new YTSoft.BaseCallCenter.BLL.T_Msg_NoticeInfo().GetList("1=1 and F_NoticeId= " + noticeid).Tables[0];
- if (dt.Rows.Count > 0)
- {
- dtuser = new YTSoft.BaseCallCenter.BLL.T_Sys_UserAccount().GetList("1=1 and F_DeptId= " + Convert.ToInt32(dt.Rows[0]["F_ReceiveInfo"].ToString())).Tables[0];
- foreach (DataRow dr in dtuser.Rows)
- {
- noticeuserModel.F_UserId = Convert.ToInt32(dr["F_UserId"].ToString());
- result = noticeuserBLL.Delete(noticeid, noticeuserModel.F_UserId);
- }
- }
- readdate =Convert.ToDateTime( oldnoticeinfoModel.F_CreateOn);
- oldnoticeinfoModel.F_Code = noticeinfoModel.F_Code;
- oldnoticeinfoModel.F_Title = noticeinfoModel.F_Title;
- oldnoticeinfoModel.F_Resume = noticeinfoModel.F_Resume;
- oldnoticeinfoModel.F_Content = noticeinfoModel.F_Content;
- oldnoticeinfoModel.F_ReceiveInfo = noticeinfoModel.F_ReceiveInfo;
- oldnoticeinfoModel.F_DeviceId = noticeinfoModel.F_DeviceId;
- oldnoticeinfoModel.F_State = 1;
- oldnoticeinfoModel.F_ModifyDate = DateTime.Now;
- oldnoticeinfoModel.F_ModifyBy = F_UserID;
- result = noticeBLL.Update(oldnoticeinfoModel);
- AddAction("t_msg_noticeinfo", oldnoticeinfoModel.F_NoticeId.ToMyString(), "修改公告");
- }
- else
- {
- noticeid = 0;
- noticeinfoModel.F_DeviceId = noticeinfoModel.F_UserId;
- noticeinfoModel.F_State = 1;
- noticeinfoModel.F_CreateOn = DateTime.Now;
- noticeinfoModel.F_ModifyDate = DateTime.Now;
- readdate = noticeinfoModel.F_CreateOn;
-
- noticeid = noticeBLL.Add(noticeinfoModel);
- if (noticeid > 0)
- {
- result = true;
- }
- ////添加公告的时候把公告user表添加数据
- //List<T_Sys_UserAccount> userlist= userbll.GetModelList("");
- //foreach (T_Sys_UserAccount item in userlist)
- //{
- // Model.usernotice usernoticemodel = new usernotice();
- // usernoticemodel.F_noticeid = noticeid;
- // usernoticemodel.F_userid = item.F_UserId;
- // usernoticemodel.F_state = 0;
- // usernoticebll.Add(usernoticemodel);
- //}
-
- AddAction("t_msg_noticeinfo", noticeid.ToMyString(), "添加公告");
- }
- //指定方式发送公告
- if (noticeinfoModel.F_DeviceId > 0)
- {//指定人员发公告
- noticeuserModel.F_NoticeId = noticeid;
- noticeuserModel.F_UserId = Convert.ToInt32(noticeinfoModel.F_UserId);
- noticeuserModel.F_UserName = noticeinfoModel.F_UserName;
- //if (readdate.ToString() != "")
- //{ noticeuserModel.F_ReadDate = readdate; }
- //else
- //{
- // noticeuserModel.F_ReadDate = noticeinfoModel.F_CreateOn;
- //}
- noticeuserModel.F_State = 0;
- noticeuserModel.F_Type = 0;
- result = noticeuserBLL.Add(noticeuserModel);
- }
- else
- {//指定部门发公告
- dt = new YTSoft.BaseCallCenter.BLL.T_Sys_UserAccount().GetList("1=1 and F_DeptId= " + noticeinfoModel.F_ReceiveInfo).Tables[0];
- if (dt.Rows.Count > 0)
- {
- noticeuserModel.F_NoticeId = noticeid;
- //if (readdate.ToString()!="")
- //{ noticeuserModel.F_ReadDate = readdate; }
- //else {
- //noticeuserModel.F_ReadDate = noticeinfoModel.F_CreateOn;
- //}
- foreach (DataRow dr in dt.Rows)
- {
- noticeuserModel.F_UserId = Convert.ToInt32(dr["F_UserId"].ToString());
- noticeuserModel.F_UserName = dr["F_UserName"].ToString();
- noticeuserModel.F_State = 0;
- noticeuserModel.F_Type = 0;
- result = noticeuserBLL.Add(noticeuserModel);
- }
- }
- }
- }
- catch (Exception) { }
- finally
- {
- dt.Clear();
- dt.Dispose();
- }
- return result;
- }
- /// <summary>
- /// 删除公告
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Get)]
- public bool DeleteNoticeData(int noticeId)
- {
- bool res = false;
- DataTable dt = new DataTable();
- DataTable dtuser = new DataTable();
- Model.T_Msg_NoticeUsers noticeuserModel = new Model.T_Msg_NoticeUsers();
- try
- {
- dt = noticeBLL.GetList("1=1 and F_NoticeId= " + noticeId).Tables[0];
- if (dt.Rows.Count > 0)
- {
- res = noticeBLL.Delete(noticeId);
- AddAction("t_msg_noticeinfo", noticeId.ToMyString(), "删除公告");
- //指定部门发公告
- dtuser = new YTSoft.BaseCallCenter.BLL.T_Sys_UserAccount().GetList("1=1 and F_DeptId= " + Convert.ToInt32( dt.Rows[0]["F_ReceiveInfo"].ToString()) ).Tables[0];
- foreach (DataRow dr in dtuser.Rows)
- {
- noticeuserModel.F_UserId = Convert.ToInt32(dr["F_UserId"].ToString());
- noticeuserBLL.Delete(noticeId, noticeuserModel.F_UserId);
- }
- }
- }
- catch (Exception) { }
- finally {
- dt.Clear();
- dt.Dispose();
- dtuser.Clear();
- dtuser.Dispose();
- }
- return res;
- }
- /// <summary>
- /// 未接根据recordid更新回访信息
- /// </summary>
- /// <param name="SetCallRecordHfInfo"></param>
- /// <returns></returns>
- [ActionName("SetNoticeState")]
- [HttpGet]
- public string SetNoticeState(string id, string timeno)
- {
- string res = "";
- try
- {
- Model.T_Msg_NoticeInfo model = new Model.T_Msg_NoticeInfo();
- model.F_State =1;
- model.F_NoticeId = Convert.ToInt32(id);
- bool bl = new BLL.T_Msg_NoticeInfo().UpdateNoticeState(model);
- if (bl)
- {
- res = "success";
- }
- }
- catch
- { }
- return res;
- }
- [ActionName("CookieData")]
- [HttpGet]
- public string CookieData() {
- return F_UserID.ToString();
- }
- #endregion
- /// <summary>
- /// 工作时间管理
- /// </summary>
- /// <returns></returns>
- public ActionResult workTimeManage()
- {
- Model.T_SYS_Time timeModel = new Model.T_SYS_Time();
- return View(timeModel);
- }
- /// <summary>
- /// 获取工作时间数据
- /// </summary>
- /// <param name="page">当前页码</param>
- /// <param name="limit">每页数据量</param>
- /// <returns></returns>
- [ActionName("workTimeListData")]
- [HttpGet]
- public string workTimeListData()
- {
-
- //数据结果集
- ResponseData dataModel = new ResponseData();
- string sql = " select top 1 * from T_SYS_Time";
- DataTable dt= DbHelperSQL.Query(sql).Tables[0];
-
- dataModel.code = 0;
- dataModel.count = 1;
- dataModel.data = dt;
- return JsonConvert.SerializeObject(dataModel);
- }
- public ActionResult workTimeEdit(int workTimeId )
- {
-
- Model.T_SYS_Time viewModel = new Model.T_SYS_Time();
-
-
-
- // Model.T_SYS_Time userModel = timeBLL.GetModel(workTimeId);
-
-
- //获取部门列表
- return View(viewModel);
- }
-
- [AcceptVerbs(HttpVerbs.Post)]
- public bool SaveWorkTimeData(T_SYS_Time systimeModel)
- {
- bool result = false;
- DataTable dt = new DataTable();
- DataTable dtuser = new DataTable();
-
- Model.T_Msg_NoticeUsers noticeuserModel = new Model.T_Msg_NoticeUsers();
- try
- {
-
- Model.T_SYS_Time oldsystimeModel = timeBLL.GetModel();
- oldsystimeModel.F_WorkEndTimes = systimeModel.F_WorkEndTimes;
- oldsystimeModel.F_WorkStartTimes = systimeModel.F_WorkStartTimes;
- result = timeBLL.Update(oldsystimeModel);
- AddAction("t_sys_time", "1", "修改工作时间", "", F_UserCode + "在" + DateTime.Now.ToString() + "修改工作时间");
- }
- catch (Exception) { }
- finally
- {
- dt.Clear();
- dt.Dispose();
- }
- return result;
- }
- [ActionName("noticeData")]
- [HttpGet]
- public string noticeListData()
- {
- int id = F_UserID;
- //数据结果集
- ResponseData dataModel = new ResponseData();
- string sql = " select top 1 * from T_SYS_Time";
- DataTable dt = DbHelperSQL.Query(sql).Tables[0];
- dataModel.code = 0;
- dataModel.count = 1;
- dataModel.data = dt;
- return JsonConvert.SerializeObject(dataModel);
- }
- }
- #region 接口基本信息
- /// <summary>
- /// 用户信息
- /// </summary>
- public class UserInfo
- {
- public int id
- {
- get;
- set;
- }
- public string name
- {
- get;
- set;
- }
- }
- /// <summary>
- /// 返回结果信息
- /// </summary>
- public class ResponseResult
- {
- public int code
- {
- get;
- set;
- }
- public int data
- {
- get;
- set;
- }
- }
- /// <summary>
- /// 返回结果信息
- /// </summary>
- public class WXResponseResult
- {
- public int customer
- {
- get;
- set;
- }
- public int service
- {
- get;
- set;
- }
- public int total
- {
- get;
- set;
- }
- }
- #endregion
- }
|