| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404 |
- 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;
- namespace YTSoft.BaseCallCenter.MVCWeb.Controllers
- {
- public class SystemManageController : BaseController
- {
- #region 部门管理
- BLL.T_Sys_Department deptBLL = new BLL.T_Sys_Department();
- /// <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)
- {
- 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)
- {
- 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)
- {
- return deptBLL.Update(deptModel);
- }
- else
- {
- return deptBLL.Add(deptModel) > 0;
- }
- }
- /// <summary>
- /// 删除部门
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Get)]
- public bool DeleteDeptData(int deptId)
- {
- 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;
- 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)
- {
- //数据结果集
- 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()));
- }
- return View(viewModel);
- }
- /// <summary>
- /// 保存编辑
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Post)]
- public bool SaveRoleEdit(T_Sys_RoleInfo roleInfoModel)
- {
- if (roleInfoModel.F_RoleId > 0)
- {
- return roleBLL.Update(roleInfoModel);
- }
- else
- {
- return roleBLL.Add(roleInfoModel) > 0;
- }
- }
- /// <summary>
- /// 删除数据
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Get)]
- public bool DeleteRoleData(string roleId)
- {
- 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
- {
- 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;
- if (roleBLL.AddRolesMenuList(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)
- {
- 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)
- {
- //数据结果集
- 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)
- {
- 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)
- {
- return dicTittleBLL.Update(WorkOrderTypeModel) > 0;
- }
- else
- {
- return dicTittleBLL.Add(WorkOrderTypeModel) > 0;
- }
- }
- /// <summary>
- /// 删除数据
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Get)]
- public bool DeleteBussiTypeData(int WorkOrderTypeId)
- {
- 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)
- {
- //数据结果集
- 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="editType">类型1、新增 2、修改</param>
- /// /// <returns></returns>
- public ActionResult DictionaryBaseEdit(string dicCode, int editType)
- {
- 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)
- {
- if (!string.IsNullOrEmpty(dicBaseModel.F_DictionaryFlagType))
- {
- return dicBaseBLL.Update(dicBaseModel);
- }
- else
- {
- return dicBaseBLL.Add(dicBaseModel);
- }
- }
- /// <summary>
- /// 删除字典项
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Get)]
- public bool DeleteBaseData(string baseCode)
- {
- return dicBaseBLL.Delete(baseCode);
- }
- /// <summary>
- /// 字典值编辑
- /// </summary>
- /// <param name="editType">类型1、新增 2、修改</param>
- /// /// <returns></returns>
- public ActionResult DictionaryValueEdit(int? valueId, string parentCode, int editType)
- {
- 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)
- {
- return dicValueBLL.Update(dicBaseModel);
- }
- else
- {
- return dicValueBLL.Add(dicBaseModel) > 0;
- }
- }
- /// <summary>
- /// 删除字典值
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Get)]
- public bool DeleteValueData(int id)
- {
- 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)
- {
- 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)
- {
- //数据结果集
- 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();
- //当前对象实体
- 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)
- {
- return menuBLL.Update(menuModel);
- }
- else
- {
- return menuBLL.Add(menuModel) > 0;
- }
- }
- /// <summary>
- /// 删除功能
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Get)]
- public bool DeleteMenuData(int menuId)
- {
- 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)
- {
- Model.T_Sys_UserAccount viewModel = new Model.T_Sys_UserAccount();
- //当前对象实体
- if (editType == 1)
- {
- viewModel.F_DeptId = int.Parse(deptId.ToString());
- }
- else
- {
- Model.T_Sys_UserAccount userModel = userBLL.GetModel(int.Parse(userId.ToString()));
- viewModel = 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)
- {
- 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;
- return userBLL.Update(oldUserModel);
- }
- else
- {
- userModel.F_HJType = 0;
- userModel.F_GroupId = 1;
- if (userModel.F_SeatFlag)
- {
- #region 调用接口插入用户信息
- try
- {
- StringBuilder returnStr = new StringBuilder();
- string wxAddUrl = "http://zzmetro-kf.sujie-china.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
- }
- return userBLL.Add(userModel) > 0;
- }
- }
- /// <summary>
- /// 删除用户
- /// </summary>
- /// <param name="workOrderBaseModel"></param>
- /// <returns></returns>
- [AcceptVerbs(HttpVerbs.Get)]
- public bool DeleteUserData(int userId)
- {
- 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)
- {
- //数据结果集
- 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()
- {
- Model.T_Sys_UserAccount model = new Model.T_Sys_UserAccount();
- if (F_UserID > 0)
- {
- model = userBLL.GetModel(F_UserID);
- }
- return View(model);
- }
- /// <summary>
- ///保存修改密码
- /// </summary>
- [AcceptVerbs(HttpVerbs.Post)]
- public string UpdateUserPwd(Model.T_Sys_UserAccount model)
- {
- 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))
- {
- 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);
- 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)
- {
- //数据结果集
- 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 ",
- sql,
- "ORDER BY F_NoticeId 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)
- {
- 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;
- viewModel.UseList = userBLL.GetModelList("F_DeptId=" + userModel.F_ReceiveInfo);
- }
- //获取部门列表
- viewModel.DepartmentList = deptBLL.GetModelList("F_ParentId=0");
- return View(viewModel);
- }
- /// <summary>
- /// 查看公告
- /// </summary>
- /// <param name="editType">类型1、新增 2、修改</param>
- /// /// <returns></returns>
- public ActionResult NoticeView(int? noticeId)
- {
- 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;
- result = noticeBLL.Update(oldnoticeinfoModel);
- }
- else
- {
- noticeid = 0;
- noticeinfoModel.F_DeviceId = noticeinfoModel.F_UserId;
- noticeinfoModel.F_State = 1;
- noticeinfoModel.F_CreateOn = DateTime.Now;
- readdate = noticeinfoModel.F_CreateOn;
- noticeid = noticeBLL.Add(noticeinfoModel);
- }
- //指定方式发送公告
- 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);
- //指定部门发公告
- 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
- }
- #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
- }
|