| | |
| | | using Newtonsoft.Json.Linq; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Net; |
| | | using System.Net.Http; |
| | |
| | | return TJson.toJson(mes); |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | #region[用户清单查询] |
| | |
| | | //objs = Serializer.Deserialize<List<RoleUserSubmit>>(json); |
| | | mes= BasicSettingBLL.SaveUserAssoctRole(usercode, json); |
| | | return TJson.toJson(mes); |
| | | } |
| | | #endregion |
| | | |
| | | #region[用户清单导入] |
| | | public HttpResponseMessage ImportUserExcel(HttpPostedFileBase files) |
| | | { |
| | | string savePath; |
| | | if (files == null || files.ContentLength <= 0) |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "上传文件内容不能为空!"; |
| | | } |
| | | else |
| | | { |
| | | var username = HttpContext.Current.Request.Cookies["admin"].Value.ToString(); //登录用户名 |
| | | string filename = Path.GetFileName(files.FileName); |
| | | int filesize = files.ContentLength;//获取上传文件的大小单位为字节byte |
| | | string fileEx = System.IO.Path.GetExtension(filename);//获取上传文件的扩展名 |
| | | int Maxsize = 4000 * 1024;//定义上传文件的最大空间大小为4M |
| | | string FileType = ".xls,.xlsx";//定义上传文件的类型字符串 |
| | | |
| | | if (!FileType.Contains(fileEx)) |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "文件类型不对,只能导入xls和xlsx格式的文件!"; |
| | | } |
| | | else |
| | | { |
| | | if (filesize >= Maxsize) |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "上传文件超过4M,不能上传!"; |
| | | } |
| | | else |
| | | { |
| | | string path = System.Web.HttpContext.Current.Server.MapPath("/File/excel/"); |
| | | |
| | | if (Directory.Exists(path) == false)//如果不存在就创建file文件夹 |
| | | { |
| | | Directory.CreateDirectory(path); //添加文件夹 |
| | | } |
| | | savePath = Path.Combine(path, filename); |
| | | if (Directory.Exists(savePath) == true) //如果存在重名文件就提示 |
| | | { |
| | | mes.code = "300"; |
| | | mes.Message = "已存在同名文件"; |
| | | } |
| | | else |
| | | { |
| | | files.SaveAs(savePath); //将选择的文件保存到指定文件夹下 |
| | | string FilesName = System.Web.HttpContext.Current.Server.MapPath("/File/excel/" + filename); |
| | | mes = BasicSettingBLL.ImportUserExcel(username,FilesName); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return TJson.toJson(mes); |
| | | |
| | | } |
| | | #endregion |
| | | |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region[角色清单关联功能查询] |
| | | /// <summary> |
| | | /// 用户清单关联功能查询 |
| | | /// </summary> |
| | | /// <param name="rolecode">角色编码</param> |
| | | /// <param name="type">操作端分类编码</param> |
| | | /// <returns></returns> |
| | | [Route(template: "RoleAssociationRight")] |
| | | [HttpGet] |
| | | public HttpResponseMessage RoleAssociationRight(string rolecode,string type) |
| | | { |
| | | mes = BasicSettingBLL.RoleAssociationRight(rolecode,type); |
| | | return TJson.toJson(mes); |
| | | } |
| | | #endregion |
| | | |
| | | #region[角色清单关联功能保存] |
| | | /// <summary> |
| | | /// 角色清单关联功能保存 |
| | | /// </summary> |
| | | /// <param name="rolecode">角色编码</param> |
| | | /// <param name="usercode">登录用户编码</param> |
| | | /// <param name="json">提交数据对象</param> |
| | | /// <returns></returns> |
| | | [Route(template: "SaveUserAssoctRight")] |
| | | [HttpPost] |
| | | public HttpResponseMessage SaveUserAssoctRight(string rolecode,string usercode, List<TreeDM> json) |
| | | { |
| | | mes = BasicSettingBLL.SaveUserAssoctRight(rolecode, usercode, json); |
| | | return TJson.toJson(mes); |
| | | } |
| | | #endregion |
| | | |
| | | } |
| | | } |