public BaseApiController(IConfiguration config, IHostingEnvironment _hostingEnvironment) { Service = new SugarBase(); _config = config; hostingEnvironment = _hostingEnvironment; BasicConfig = BasicConfigHelper.getBasicConfig().Result; }
public IActionResult Index() { var number = Utils.GetOrderNumber(); ViewBag.SqlNumber = number; var ConnStr = _config.GetConnectionString("DefaultConnection"); string[] result = ConnStr.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Split('=')[1]).ToArray(); ViewBag.database = result[3]; ViewBag.paths = Utils.GetMapPath("/wwwroot/upload/backdb/") + result[3] + "_" + number + ".sql"; ViewBag.taskpath = Utils.GetMapPath("/wwwroot/upload/backdb/"); using (var db = SugarBase.GetIntance()) { var taskModel = db.Queryable <SysTask>().Where(m => m.Type == "database").First(); if (taskModel == null) { taskModel = new SysTask(); } ViewBag.Task = taskModel; } return(View()); }
static public List <Object> getYearHis(long userId, string year) { using (var db = SugarBase.GetIntance()) { return(new List <object>()); } }
public JsonResult ChangeSubmit(SysRole Model) { var jsonm = new ResultJson(); jsonm.data = Model; var model = new SysRole(); try { using (var db = SugarBase.GetIntance()) { if (!string.IsNullOrEmpty(Model.RoleID)) { model = db.Queryable <SysRole>().Where(m => m.RoleID == Model.RoleID).First(); } model.RoleName = Model.RoleName; model.Remarks = Model.Remarks; if (string.IsNullOrEmpty(Model.RoleID)) { db.Insertable(model).ExecuteCommand(); jsonm.status = 200; } else { db.Updateable(model).ExecuteCommand(); jsonm.status = 200; } db.Deleteable <SysRoleModule>().Where(m => m.RoleID == model.RoleID).ExecuteCommand(); if (Model.ModuleList != null) { List <SysRoleModule> rel_list = new List <SysRoleModule>(); foreach (var item in Model.ModuleList) { if (!string.IsNullOrEmpty(item.ID)) { var SysRoleMenuModel = new SysRoleModule(); SysRoleMenuModel.ModuleID = item.ID; SysRoleMenuModel.RoleID = model.RoleID; rel_list.Add(SysRoleMenuModel); } } if (rel_list.Count > 0) { db.Insertable(rel_list).ExecuteCommand(); } } } } catch (Exception ex) { LogProvider.Error("编辑角色", ex.StackTrace, ex.Message); jsonm.status = 500; jsonm.msg = "保存失败"; } return(Json(jsonm)); }
public JsonResult RecoverySubmit(string ids) { var jsonm = new ResultJson(); List <string> UserIDs = new List <string>(); try { if (!string.IsNullOrEmpty(ids)) { string[] ss = ids.Split(','); UserIDs.AddRange(ss); } jsonm.data = UserIDs; if (UserIDs.Count > 0) { using (var db = SugarBase.GetIntance()) { db.Updateable <UserInfo>().UpdateColumns(m => m.Status == true).Where(m => UserIDs.Contains(m.UserID)).ExecuteCommand(); } jsonm.status = 200; } else { jsonm.status = 500; jsonm.msg = "请选择用户"; } } catch (Exception ex) { jsonm.status = 500; jsonm.msg = "恢复失败"; LogProvider.Error("恢复用户", ex.StackTrace, ex.Message); } return(Json(jsonm)); }
static public User isUserExist(string username) { using (var db = SugarBase.GetIntance()) { return(db.Queryable <User>().Single(f => f.name == username)); } }
static public User isUserExist(long userId) { using (var db = SugarBase.GetIntance()) { return(db.Queryable <User>().Single(f => f.id == userId)); } }
static public Boolean modifyTask(long userId, String taskName, String property, String value) { using (var db = SugarBase.GetIntance()) { if (property == "description") { db.Updateable <Task>() .SetColumns(it => new Task() { description = value }) .Where(it => it.userId == userId && it.taskName == taskName).ExecuteCommand(); } else { db.Updateable <Task>() .SetColumns(it => new Task() { tomatoCompleted = Int32.Parse(value), status = 1 }) .Where(it => it.userId == userId && it.taskName == taskName).ExecuteCommand(); } return(true); } }
public JsonResult setStatus(string ID, bool Status) { var jsonm = new ResultJson(); try { using (var db = SugarBase.GetIntance()) { if (!string.IsNullOrEmpty(ID)) { var model = db.Queryable <SysRole>().Where(m => m.RoleID == ID).First(); if (model != null) { model.Status = Status; db.Updateable(model).ExecuteCommand(); } } else { jsonm.status = 500; jsonm.msg = "修改失败"; } } } catch (Exception ex) { LogProvider.Error("改变系统角色状态", ex.StackTrace, ex.Message); jsonm.status = 500; jsonm.msg = "修改失败"; } return(Json(jsonm)); }
/// <summary> /// 修改个人信息 /// </summary> /// <param name="Model"></param> /// <returns></returns> public JsonResult PersonalSubmit(SysUser Model) { var jsonm = new ResultJson(); jsonm.data = Model; var model = new SysUser(); try { using (var db = SugarBase.GetIntance()) { if (!string.IsNullOrEmpty(Model.SysUserID)) { model = db.Queryable <SysUser>().Where(m => m.SysUserID == Model.SysUserID).First(); } model.SysNickName = Model.SysNickName; db.Updateable(model).ExecuteCommand(); jsonm.status = 200; } } catch (Exception ex) { LogProvider.Error("系统用户编辑个人信息", ex.StackTrace, ex.Message); jsonm.status = 500; jsonm.msg = "保存失败"; } return(Json(jsonm)); }
public IActionResult Logout() { var jsonm = new ResultJson(); try { using (var db = SugarBase.GetIntance()) { //var userModel = getToken(); if (SysUserModel != null) { if (RedisHelper.KeyExists("system:SysToken:" + SysUserModel.UserID)) { HttpContextHelper.Current.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); RedisHelper.KeyDelete("system:SysToken:" + SysUserModel.UserID); CookieHelper.ClearCookie("systoken"); SetSysLog("【系统登出】" + SysUserModel.UserName, 1, 1); } } } } catch (Exception ex) { jsonm.status = 500; jsonm.msg = "登出失败"; LogProvider.Error("登出", ex.StackTrace, ex.Message); } return(Redirect("/SysAdmin/Account/Login")); }
public JsonResult GetList(int limit, int page, string Name, bool Status = true) { var lstRes = new List <UserInfo>(); int startIndex = (page == 1 || page == 0) ? 0 : limit * (page - 1); var total = 0; try { using (var db = SugarBase.GetIntance()) { var list = db.Queryable <UserInfo>() .Where(m => m.Status == Status); if (!string.IsNullOrEmpty(Name)) { list.Where(m => m.FullName.Contains(Name.Trim()) || m.Email.Contains(Name.Trim()) || m.Mobile.Contains(Name.Trim()) || m.UserAccount.Contains(Name.Trim())); } lstRes = list.OrderBy(m => m.CreateTime, OrderByType.Desc) .ToPageList(page, limit, ref total).ToList(); } } catch (Exception ex) { LogProvider.Error("获取用户列表", ex.StackTrace, ex.Message); } var rows = lstRes; return(Json(new { code = 0, count = total, data = rows })); }
/// <summary> /// 添加日志 /// </summary> /// <param name="Title">日志内容</param> /// <param name="LogType">日志类型,1:用户登录日志,2:内容操作日志,3:菜单操作日志,4:模板管理日志,5:数据备份日志,6:组件操作日志</param> /// <param name="LogGrade">日志级别,升序</param> public void SetSysLog(string Title, int LogType, int LogGrade) { try { var logModel = new SysLog() { UserName = SysUserModel.UserName, UserID = SysUserModel.UserID, Title = Title, IP = Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString(), LogType = LogType, LogGrade = LogGrade.ToString(), RequestUrl = FytRequest.GetRawUrl(), AddDate = DateTime.Now }; using (var db = SugarBase.GetIntance()) { db.Insertable(logModel).ExecuteCommandAsync(); } } catch (Exception) { throw; } }
static public User checkUserPwd(long userId, string password) { using (var db = SugarBase.GetIntance()) { return(db.Queryable <User>().Single(f => f.id == userId && f.password == password)); } }
public JsonResult GetList(string Name) { var lstRes = new List <SysModule>(); try { using (var db = SugarBase.GetIntance()) { if (!string.IsNullOrEmpty(Name)) { lstRes = db.Queryable <SysModule>() .Where(m => m.Name.Contains(Name.Trim())) .OrderBy(m => m.Type) .OrderBy(m => m.Sort, OrderByType.Desc) .OrderBy(m => m.CreateTime, OrderByType.Asc).ToList(); } else { lstRes = db.Queryable <SysModule>() .OrderBy(m => m.Type) .OrderBy(m => m.Sort, OrderByType.Desc) .OrderBy(m => m.CreateTime, OrderByType.Asc).ToList(); } } } catch (Exception ex) { LogProvider.Error("获取项目组列表", ex.StackTrace, ex.Message); } return(Json(new { code = 0, data = lstRes })); }
public static List <Feedback> getAllFeedback() { using (var db = SugarBase.GetIntance()) { return(db.Queryable <Feedback>().ToList()); } }
/// <summary> /// 个人信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public IActionResult Personal(string id) { var model = new SysUser(); var rel_list = new List <string>(); if (!string.IsNullOrEmpty(id)) { using (var db = SugarBase.GetIntance()) { model = db.Queryable <SysUser>().Where(m => m.SysUserID == id).First(); var rel_list1 = db.Queryable <SysUserRole>().Where(m => m.UserID == model.SysUserID).ToList(); if (rel_list1 != null) { foreach (var item in rel_list1) { rel_list.Add(item.RoleID); } } } } else { return(Redirect("/errir/404")); } return(View(model)); }
/// <summary> /// 添加/编辑页面 /// </summary> /// <param name="id"></param> /// <returns></returns> public IActionResult Change(string id) { var pid = FytRequest.GetQueryString("pid"); var model = new SysUser(); var rel_list = new List <string>(); using (var db = SugarBase.GetIntance()) { if (!string.IsNullOrEmpty(id)) { model = db.Queryable <SysUser>().Where(m => m.SysUserID == id).First(); var rel_list1 = db.Queryable <SysUserRole>().Where(m => m.UserID == model.SysUserID).ToList(); if (rel_list1 != null) { foreach (var item in rel_list1) { rel_list.Add(item.RoleID); } } } else { model.SysUserID = ""; } var role_list = db.Queryable <SysRole>().Where(m => m.Status).ToList(); ViewBag.RoleList = role_list; ViewBag.RelRoleList = rel_list; } return(View(model)); }
public static DateTime getEarlyTime(long Id) { // Query query= Query.query(Criteria.where("userId").is(Id)); using (var db = SugarBase.GetIntance()) { // get User tomatoLength User tomatoOwner = db.Queryable <User>().Single(f => f.id == Id); if (tomatoOwner == null) { throw new Exception("no user found"); } History history = new History(); while (history.startTime == DateTime.MinValue) { history = db.Queryable <History>(). Where(it => it.userId == Id). OrderBy(it => it.startTime, OrderByType.Asc).First(); if (history == null) { break; } if (history.startTime == null) { db.Deleteable <History>().Where(history).ExecuteCommand(); } } return(history.startTime); } }
public JsonResult GetList(int limit, int page, string Name, bool Status = true) { var lstRes = new List <SysRole>(); int startIndex = (page == 1 || page == 0) ? 0 : limit * (page - 1); var total = 0; try { using (var db = SugarBase.GetIntance()) { if (!string.IsNullOrEmpty(Name)) { lstRes = db.Queryable <SysRole>() .Where(m => m.RoleName.Contains(Name.Trim())) .OrderBy(m => m.CreateTime) .ToPageList(page, limit, ref total).ToList(); } else { lstRes = db.Queryable <SysRole>() .OrderBy(m => m.CreateTime) .ToPageList(page, limit, ref total).ToList(); } } } catch (Exception ex) { LogProvider.Error("获取系统角色列表", ex.StackTrace, ex.Message); } var rows = lstRes; return(Json(new { code = 0, count = total, data = rows })); }
/// <summary> /// 刷新菜单 /// </summary> public void setMenuCache() { using (var db = SugarBase.GetIntance()) { var menu_list_all = db.Queryable <SysModule>().Where(m => m.Status).ToList(); RedisHelper.StringSet("system:SysModule", MD5CryptHelper.Encrypt(JsonConvert.Serialize(menu_list_all))); } }
public IActionResult Index() { using (var db = SugarBase.GetIntance()) { var role_list = db.Queryable <SysRole>().Where(m => m.Status).ToList(); ViewBag.RoleList = role_list; } return(View()); }
public static List <Feedback> getFeedbackByID(long userid) { using (var db = SugarBase.GetIntance()) { return(db.Queryable <Feedback>().Where( it => it.userid == userid ).ToList()); } }
static public List <Task> getTask(long userId) { using (var db = SugarBase.GetIntance()) { return(db.Queryable <Task>().Where( it => it.userId == userId && it.status != -1 ).ToList()); } }
static public Boolean deleteTask(long userId, String taskName) { using (var db = SugarBase.GetIntance()) { db.Deleteable <Task>().Where(new Task() { userId = userId, taskName = taskName }).ExecuteCommand(); return(true); } }
public JsonResult ChangeSubmit(SysModule Model) { var jsonm = new ResultJson(); jsonm.data = Model; var model = new SysModule(); try { using (var db = SugarBase.GetIntance()) { if (!string.IsNullOrEmpty(Model.ID)) { model = db.Queryable <SysModule>().Where(m => m.ID == Model.ID).First(); } if (model == null) { model = new SysModule(); } model.Icon = Model.Icon; model.Href = Model.Href; model.Sort = Model.Sort; model.Type = Model.Type; model.Remarks = Model.Remarks; model.Business = Model.Business; model.ParentID = Model.ParentID; if (string.IsNullOrEmpty(Model.ID)) { SetSysLog("【添加菜单】" + Model.Name, 3, 1); model.Name = Model.Name; db.Insertable(model).ExecuteCommand(); jsonm.status = 200; } else { SetSysLog("【编辑菜单】" + model.Name + " --> " + Model.Name, 3, 1); model.Name = Model.Name; db.Updateable(model).ExecuteCommand(); jsonm.status = 200; } } } catch (Exception ex) { LogProvider.Error("编辑菜单", ex.StackTrace, ex.Message); jsonm.status = 500; jsonm.msg = "保存失败"; } return(Json(jsonm)); }
public JsonResult setStatus(string ID, string Name, bool Value) { var jsonm = new ResultJson(); try { using (var db = SugarBase.GetIntance()) { if (!string.IsNullOrEmpty(ID)) { var model = db.Queryable <SwGoods>().Where(m => m.ID == ID).First(); if (model != null) { if (Name == "IsHot") { model.IsHot = Value; } if (Name == "IsTop") { if (Value) { if (!model.IsTop) { var TopSortModel = db.Queryable <SwGoods>().Where(m => m.ID != model.ID).Select(m => new { TopSort = SqlFunc.AggregateMax(m.TopSort) }).First(); model.TopSort = TopSortModel.TopSort + 1; } } else { model.TopSort = 0; } model.IsTop = Value; } db.Updateable(model).ExecuteCommand(); } } else { jsonm.status = 500; jsonm.msg = "修改失败"; } } } catch (Exception ex) { LogProvider.Error("改变文章属性", ex.StackTrace, ex.Message); jsonm.status = 500; jsonm.msg = "修改失败"; } return(Json(jsonm)); }
public static bool handleFeedback(long id, String answer) { using (var db = SugarBase.GetIntance()) { db.Updateable <Feedback>() .SetColumns(it => new Feedback() { status = 1, answer = answer }) .Where(it => it.id == id).ExecuteCommand(); return(true); } }
public BaseController(IConfiguration config, IHostingEnvironment _hostingEnvironment) { Service = new SugarBase(); _config = config; //SugarBase.SetConnectionString(config); //RedisHelper.GetIntance(config); hostingEnvironment = _hostingEnvironment; //Utils.ServerPath = hostingEnvironment.ContentRootPath; SysUserModel = getToken(); BasicConfig = BasicConfigHelper.getBasicConfig().Result; //DataHelper.GetIntance(config); ModuleList = GetSysModule(); }
static public Boolean breakTask(long userId, String taskName, DateTime endTime) { using (var db = SugarBase.GetIntance()) { db.Updateable <Task>() .SetColumns(it => new Task() { status = -1, endTime = endTime }) .Where(it => it.userId == userId && it.taskName == taskName).ExecuteCommand(); return(true); } }