/// <summary> /// 根据科目、版本返回资源类型名称 /// </summary> /// <param name="Subject"></param> /// <param name="Edition"></param> public static List <string> BackTypeName(int Subject, int Edition) { List <string> _list = new List <string>(); using (var db = new box_omsEntities()) { var _query = db.Database.SqlQuery <dataInfo>(string.Format(@"SELECT TypeName FROM box_resource_statist WHERE Subject={0} AND Edition={1} AND TypeName IS NOT NULL GROUP BY TypeName", Subject, Edition)).ToList(); if (_query.Count != 0) { _query.ForEach(_ => { _list.Add(_.TypeName); }); } int _count = _list.Count; if (_count != 13) { for (int i = 0; i < 13 - _count; i++) { _list.Add(""); } } } return(_list); }
public ActionResult Index(VM_SyUser_Index m) { if (m.Grid == null) { m.Grid = new OMS.Common.Model.PList <VM_SyUser_Index_Grid>(); m.Grid.Pager = new OMS.Common.Model.Pager(); } using (var db = new box_omsEntities()) { var query = db.sys_user.OrderBy(o => o.UserId).AsQueryable(); if (m.State != null) { query = query.Where(w => w.State == m.State); } if (!string.IsNullOrWhiteSpace(m.Key)) { query = query.Where(w => w.Account.Contains(m.Key) || w.Name.Contains(m.Key)); } m.Grid.Pager = new OMS.Common.Model.Pager(m.Grid.Pager.PageIndex, m.Grid.Pager.PageSize, query.Count()); m.Grid.Data = query.Skip((m.Grid.Pager.PageIndex - 1) * m.Grid.Pager.PageSize).Take(m.Grid.Pager.PageSize).Select(s => new VM_SyUser_Index_Grid { Id = s.UserId, Account = s.Account, Name = s.Name, State = s.State }).ToList(); } return(View(m)); }
public static List <VM_Page> Get(int id, int userid) { List <VM_Page> _list = new List <VM_Page>(); //首先找到该用户是否选择了角色 using (var db = new box_omsEntities()) { var _listRole = db.sys_user_and_role.Where(_ => _.UserId == userid).Select(w => w.RoleId); if (_listRole.Count() == 0) { return(GetHome()); } var _listAuth = db.sys_role_and_auth.Where(_ => _listRole.Contains(_.RoleId)).ToList(); if (_listAuth.Count == 0) { return(GetHome()); } //foreach (var item in _listAuth) //{ // _list = Get().Where(w => item.LeftId == w.NavLeftId && w.NavTopId == id).OrderBy(_ => _.NavLeftId).ToList(); // if (_list.Count > 0) // break; //} var _list_result = from t in Get() from r in _listAuth where t.NavLeftId == r.LeftId select t; var _li = _list_result.Where(w => w.NavTopId == id).OrderBy(_ => _.NavLeftId).ToList(); _li.Insert(0, GetHome().FirstOrDefault()); return(_li); } }
public ActionResult Edit(VM_RpEnte_Form m) { if (ModelState.IsValid) { using (var db = new box_omsEntities()) { rp_enterprise dbm = db.rp_enterprise.Find(m.Id); if (m.Name.ToUpper() != dbm.EntName.ToUpper() && db.rp_enterprise.Where(w => w.EntName == m.Name).Count() > 0) { ModelState.AddModelError("Name", "企业名称已存在"); } else { dbm.EntName = m.Name; dbm.Remark = m.Remark; db.SaveChanges(); return(Json(new { success = true })); } } } return(View(m)); }
public static List <VM_NavLeft> Get(string controller, string action, int userid) { int _topid = 0; //VM_NavLeft _m = d.Where(w => w.Url == "/" + controller + "/" + action).FirstOrDefault(); //if (_m != null) // _topid = _m.NavTopId; var _mpage = Pages.Get().Where(_ => _.Controller == controller && _.Action == action).FirstOrDefault(); if (_mpage != null) { _topid = Convert.ToInt32(_mpage.NavTopId); } if (_topid == 0) { return(new List <VM_NavLeft>()); } //首先找到该用户是否选择了角色 using (var db = new box_omsEntities()) { var _listRole = db.sys_user_and_role.Where(_ => _.UserId == userid).Select(w => w.RoleId); if (_listRole.Count() == 0) { return(new List <VM_NavLeft>()); } var _listAuth = db.sys_role_and_auth.Where(_ => _listRole.Contains(_.RoleId)).ToList(); if (_listAuth.Count == 0) { return(new List <VM_NavLeft>()); } return(d.Where(w => _listAuth.Select(_ => _.LeftId).Contains(w.Id) && w.NavTopId == _topid).OrderBy(o => o.Sort).ToList()); } }
/// <summary> /// 绑定盒子与教材、版本的关系 /// </summary> /// <param name="val"></param> /// <param name="db"></param> /// <param name="BoxId"></param> /// <param name="Subject"></param> private static void Bind(string val, box_omsEntities db, int BoxId, int Subject) { if (!string.IsNullOrWhiteSpace(val)) { string[] _ids = val.Split(','); for (int i = 0; i < _ids.Length; i++) { if (string.IsNullOrEmpty(_ids[i])) { continue; } if (string.IsNullOrWhiteSpace(BoxOms.Dict.Edition.GetVal(Convert.ToInt32(_ids[i])))) { continue; } db.box_subject_edition.Add(new box_subject_edition() { Id = Guid.NewGuid().ToString(), BoxId = BoxId, Subject = Subject, Edition = Convert.ToInt32(_ids[i]) }); } } }
/// <summary> /// 得到所有的角色 /// </summary> /// <returns></returns> public static List <sys_role> GetAllRole() { using (var db = new box_omsEntities()) { return(db.sys_role.OrderBy(o => o.RoleId).ToList()); } }
public ActionResult Login(VM_SyPassport_Login m) { if (ModelState.IsValid) { using (var db = new box_omsEntities()) { var dbm = db.sys_user.Where(w => w.Account == m.Account).FirstOrDefault(); if (dbm == null) { ModelState.AddModelError("Account", "你输入的帐号不存在!"); } else if (dbm.Password.Trim() != OMS.Common.Function.MD5Encrypt(m.Password.Trim())) { ModelState.AddModelError("Account", "密码错误!"); } else if (dbm.State == 1) { ModelState.AddModelError("Account", "帐号已停用!"); } else { VM_SyPassport_UserInfo info = new VM_SyPassport_UserInfo(); info.Id = dbm.UserId; info.Name = dbm.Name; System.Web.HttpContext.Current.Session["UserInfo"] = info; return(RedirectToAction("Index", "BoxHome")); } } } return(View(m)); }
public ActionResult ChangePassword(VM_SyPassport_ChangePassword m) { if (ModelState.IsValid) { using (var db = new box_omsEntities()) { if (m.NewPwd != m.NewPwd2) { ModelState.AddModelError("NewPwd2", "两次密码不一样!"); return(View(m)); } VM_SyPassport_UserInfo info = (VM_SyPassport_UserInfo)Session["UserInfo"]; sys_user _user = db.sys_user.Find(info.Id); if (_user.Password.Trim() != OMS.Common.Function.MD5Encrypt(m.OldPwd.Trim())) { ModelState.AddModelError("OldPwd", "原始密码不正确!"); return(View(m)); } _user.Password = OMS.Common.Function.MD5Encrypt(m.NewPwd.Trim()); db.SaveChanges(); } return(Json(new { success = true })); } return(View(m)); }
/// <summary> /// 根据网卡MAC地址获取该商品是否需要更新 /// </summary> /// <param name="id">MAC地址</param> /// <returns>返回:True-需要更新,False-不需要更新</returns> public JsonData Get(string id) { using (var db = new box_omsEntities()) { //1.判断当前盒子是否有权限更新 var good = db.box_good.Where(w => w.Mac == id).FirstOrDefault(); if (good == null || good.IsCanUpdate == false) { return(new JsonData { flag = JsonDataFlag.Succeed, data = false, msg = "无自动更新权限" }); } //2.判断当前盒子是否在更新中或者版本更新失败 if (db.box_update_sys_log.Where(w => w.BoxId == good.BoxId && w.State != 2).Count() > 0) { return(new JsonData { flag = JsonDataFlag.Succeed, data = false, msg = string.Format("【{0}】版正在更新中,或者已经更新失败", good.SysVersion) }); } //3.判断当前已发布的版本更新包中是否有更新版本。 if (db.box_update_sys.OrderBy(o => o.VNumber).Where(w => w.VNumber > good.SysVersion && w.IsPublish == true).Count() <= 0) { return(new JsonData { flag = JsonDataFlag.Succeed, data = false, msg = "目前没有需要更新的版本" }); } return(new JsonData { flag = JsonDataFlag.Succeed, data = true }); } }
public ActionResult Add(VM_RpEnte_Form m) { if (ModelState.IsValid) { using (var db = new box_omsEntities()) { if (db.rp_enterprise.Where(w => w.EntName == m.Name).Count() > 0) { ModelState.AddModelError("Name", "企业名称已存在"); } else { rp_enterprise dbm = new rp_enterprise { EntName = m.Name, Remark = m.Remark }; db.rp_enterprise.Add(dbm); db.SaveChanges(); return(Json(new { success = true })); } } } return(View(m)); }
public ActionResult Index(VM_RpEnte_Index m) { if (m.Grid == null) { m.Grid = new OMS.Common.Model.PList <VM_RpEnte_Index_Grid>(); m.Grid.Pager = new OMS.Common.Model.Pager(); } using (var db = new box_omsEntities()) { var query = db.rp_enterprise.OrderBy(o => o.EntId).AsQueryable(); if (!string.IsNullOrWhiteSpace(m.Key)) { query = query.Where(w => w.EntName.Contains(m.Key)); } m.Grid.Pager = new OMS.Common.Model.Pager(m.Grid.Pager.PageIndex, m.Grid.Pager.PageSize, query.Count()); m.Grid.Data = query.Skip((m.Grid.Pager.PageIndex - 1) * m.Grid.Pager.PageSize).Take(m.Grid.Pager.PageSize).Select(s => new VM_RpEnte_Index_Grid { Id = s.EntId, Name = s.EntName, ActiveNum = s.rp_cdkey.Count(), AlreadyActiveNum = s.rp_cdkey.Where(_ => _.ActiveTime != null).Count(), Remark = s.Remark }).ToList(); } return(View(m)); }
public ActionResult Index(VM_BoxUpdateSys_Index m) { if (m.Grid == null) { m.Grid = new OMS.Common.Model.PList <VM_BoxUpdateSys_Index_Grid>(); m.Grid.Pager = new OMS.Common.Model.Pager(); } using (var db = new box_omsEntities()) { var query = db.box_update_sys.OrderBy(o => o.Id).AsQueryable(); m.Grid.Pager = new OMS.Common.Model.Pager(m.Grid.Pager.PageIndex, m.Grid.Pager.PageSize, query.Count()); m.Grid.Data = query.Skip((m.Grid.Pager.PageIndex - 1) * m.Grid.Pager.PageSize).Take(m.Grid.Pager.PageSize).Select(s => new VM_BoxUpdateSys_Index_Grid { Id = s.Id, VNumber = s.VNumber, Name = s.PackUrl, Principal = s.Principal, Cause = s.Cause, UpdateCount = s.box_update_sys_log.Count, IsPublish = s.IsPublish }).ToList(); } return(View(m)); }
public ActionResult Look(string id) { VM_RpCode_Index_Grid _m = new VM_RpCode_Index_Grid(); using (var db = new box_omsEntities()) { var dbm = db.rp_cdkey.Where(_ => _.Id == id).FirstOrDefault(); _m.Id = dbm.Id; _m.EnteName = dbm.rp_enterprise.EntName; _m.EntId = dbm.EntId; _m.UseSchool = dbm.UseSchool; _m.Validity = dbm.Validity; _m.ActiveTime = dbm.ActiveTime; _m.Remark = dbm.Remark; _m.ActiveCode = dbm.ActiveCode; _m.AuthUserCount = dbm.AuthUserCount; _m.ActiveMac = dbm.ActiveMac; _m.ActiveIp = dbm.ActiveIp; _m.ActiveDisk = dbm.ActiveDisk; ViewBag.Chinese = BoxOms.Web.BLL.Rp_Code.BackEditionName(_m.Id, 1); ViewBag.Math = BoxOms.Web.BLL.Rp_Code.BackEditionName(_m.Id, 2); ViewBag.English = BoxOms.Web.BLL.Rp_Code.BackEditionName(_m.Id, 3); } return(View(_m)); }
// GET: SyRole public ActionResult Index() { using (var db = new box_omsEntities()) { var query = db.sys_role.OrderBy(o => o.RoleId).ToList(); ViewData["list"] = query; } return(View()); }
/// <summary> /// 根据区域返回该区域所有的学校 /// </summary> /// <param name="UseDist"></param> /// <returns></returns> public static List <rp_cdkey> BackSchoolName(int UseDist) { List <rp_cdkey> _list = new List <rp_cdkey>(); using (var db = new box_omsEntities()) { _list = db.rp_cdkey.Where(_ => _.UseDist == UseDist).ToList(); } return(_list); }
/// <summary> /// 返回数据 /// </summary> /// <param name="list"></param> /// <returns></returns> public static List <rp_resource_statist> BackList(string key, int resourcetype) { List <rp_resource_statist> _lrs = new List <rp_resource_statist>(); using (var db = new box_omsEntities()) { _lrs = db.rp_resource_statist.Where(_ => _.Cd_key == key && _.ResourceType == resourcetype).ToList(); } return(_lrs); }
/// <summary> /// 根据城市ID获取区 /// </summary> /// <param name="cid">城市ID</param> /// <returns></returns> public JsonResult GetAreas(int?cid) { using (var db = new box_omsEntities()) { List <SelectListItem> items = db.oms_district.Where(w => w.ParentID == cid && w.Deleted == 0).Select(s => new SelectListItem { Text = s.CodeName, Value = s.ID.ToString() }).ToList(); return(Json(items, JsonRequestBehavior.AllowGet)); } }
// GET: BoxRunStat #region 列表页 public ActionResult Index(VM_BoxRunStat_Index m) { if (m.Grid == null) { m.Grid = new OMS.Common.Model.PList <VM_BoxRunStat_Index_Grid>(); m.Grid.Pager = new OMS.Common.Model.Pager(); } using (var db = new box_omsEntities()) { var query = db.box_good.OrderByDescending(o => o.BoxId).AsQueryable(); if (!string.IsNullOrWhiteSpace(m.key)) { if (System.Text.RegularExpressions.Regex.IsMatch(m.key, @"^[0-9]+$")) { int _id = Convert.ToInt32(m.key); query = query.Where(w => w.BoxId == _id); } else { query = query.Where(w => w.SchoolName.Contains(m.key) || w.UseUserName.Contains(m.key)); } } if (!string.IsNullOrWhiteSpace(m.State)) { int _state = Convert.ToInt32(m.State); query = query.Where(w => w.State == _state); } m.Grid.Pager = new OMS.Common.Model.Pager(m.Grid.Pager.PageIndex, m.Grid.Pager.PageSize, query.Count()); m.Grid.Data = query.Skip((m.Grid.Pager.PageIndex - 1) * m.Grid.Pager.PageSize).Take(m.Grid.Pager.PageSize).Select(s => new VM_BoxRunStat_Index_Grid { BoxId = s.BoxId, SchoolName = s.SchoolName, FirstRunTime = s.FirstRunTime, UseUserName = s.UseUserName, State = s.State }).ToList(); if (m.Grid.Data.Count > 0) { foreach (var item in m.Grid.Data) { item.Prov = BoxOms.Web.BLL.BoxGoodBLL.BackPrName(item.BoxId); item.Chinese = BoxOms.Web.BLL.BoxGoodBLL.BackEditionName(item.BoxId, 1); item.Math = BoxOms.Web.BLL.BoxGoodBLL.BackEditionName(item.BoxId, 2); item.English = BoxOms.Web.BLL.BoxGoodBLL.BackEditionName(item.BoxId, 3); } } } return(View(m)); }
public JsonResult Delete(int id) { using (var db = new box_omsEntities()) { db.box_update_sys.Remove(db.box_update_sys.Find(id)); db.SaveChanges(); } return(Json(new OMS.Common.Model.JsonData { flag = OMS.Common.Model.JsonDataFlag.Succeed })); }
/// <summary> /// 根据id得到区域名称 /// </summary> /// <param name="pid"></param> /// <returns></returns> public static string GetName(int pid) { using (var db = new box_omsEntities()) { var _m = db.oms_district.Where(_ => _.ID == pid && _.Deleted == 0).FirstOrDefault(); if (_m != null) { return(_m.CodeName); } return(""); } }
public JsonResult ResetPwd(int id) { using (var db = new box_omsEntities()) { sys_user dbm = db.sys_user.Find(id); dbm.Password = OMS.Common.Function.MD5Encrypt("123456"); db.SaveChanges(); } return(Json(new OMS.Common.Model.JsonData { flag = OMS.Common.Model.JsonDataFlag.Succeed })); }
public ActionResult Detail(int id) { using (var db = new box_omsEntities()) { var query = db.box_update_sys_log.Where(w => w.UpdateId == id); return(View(query.Select(s => new VM_BoxUpdateSys_Detail { UTime = s.StartTime, Mac = "" }).ToList())); } }
public JsonResult Delete(string id) { using (var db = new box_omsEntities()) { db.rp_cdkey_and_edition.RemoveRange(db.rp_cdkey_and_edition.Where(_ => _.CdKey == id)); db.rp_cdkey.Remove(db.rp_cdkey.Where(_ => _.Id == id).FirstOrDefault()); db.SaveChanges(); } return(Json(new OMS.Common.Model.JsonData { flag = OMS.Common.Model.JsonDataFlag.Succeed })); }
public JsonResult PublishCancel(int id) { using (var db = new box_omsEntities()) { box_update_sys dbm = db.box_update_sys.Find(id); dbm.IsPublish = false; db.SaveChanges(); } return(Json(new OMS.Common.Model.JsonData { flag = OMS.Common.Model.JsonDataFlag.Succeed })); }
public ActionResult Edit(VM_BoxGood_Form m) { if (ModelState.IsValid) { using (var db = new box_omsEntities()) { box_good dbm = db.box_good.Find(m.id); if (m.MAC.ToUpper() != dbm.Mac.ToUpper() && db.box_good.Where(w => w.Mac == m.MAC).Count() > 0) { ModelState.AddModelError("MAC", "商品MAC地址已存在。"); } else { DateTime?_ExpirTime = null; int? _Validity = null; if (m.Validity != null) { if (!System.Text.RegularExpressions.Regex.IsMatch(m.Validity.ToString(), @"^(([1-9]\d*))$")) { ModelState.AddModelError("Validity", "请输入大于0的正整数!"); return(View(m)); } _Validity = Convert.ToInt32(m.Validity); } if (_Validity == null) { _ExpirTime = Convert.ToDateTime("2099-12-12"); } else { _ExpirTime = DateTime.Now.AddMonths(Convert.ToInt32(_Validity)); } dbm.Validity = _Validity; dbm.IP = m.IP; dbm.SysVersion = Convert.ToDouble(m.SysVersion); dbm.Mac = m.MAC; dbm.ActivNumber = m.MAC == null ? "" : BLL.BoxGoodBLL.GetKey(m.MAC, _ExpirTime); dbm.Remark = m.Remark; dbm.UpdateTime = DateTime.Now; dbm.ExpirTime = _ExpirTime; dbm.UpdateUserId = System.Web.HttpContext.Current.Session["UserInfo"] == null ? 0 : (System.Web.HttpContext.Current.Session["UserInfo"] as VM_SyPassport_UserInfo).Id; db.SaveChanges(); return(Json(new { success = true })); } } } return(View(m)); }
/// <summary> /// 根据版本编号得到版本名称(电子书) /// </summary> /// <param name="editionid"></param> /// <returns></returns> public static string BackEditionName(int editionid) { string _editionName = string.Empty; using (var db = new box_omsEntities()) { var _m = db.rp_resource_statist.Where(_ => _.EditionId == editionid && _.ResourceType == 1).FirstOrDefault(); if (_m != null) { _editionName = _m.EditionName; } } return(_editionName); }
/// <summary> /// 根据区域id返回完整地址信息 /// </summary> /// <param name="areaid"></param> /// <returns></returns> public static string BackAreaName(int areaid) { string _name = string.Empty; using (var db = new box_omsEntities()) { var _list = db.oms_district.ToList(); var _marea = _list.Where(_ => _.ID == areaid).FirstOrDefault(); var _mcity = _list.Where(_ => _.ID == _marea.ParentID).FirstOrDefault(); var _pro = _list.Where(_ => _.ID == _mcity.ParentID).FirstOrDefault(); _name = _pro.CodeName + _mcity.CodeName + _marea.CodeName; } return(_name); }
public JsonResult Delete(int id) { using (var db = new box_omsEntities()) { sys_user dbm = db.sys_user.Find(id); db.sys_user_and_role.RemoveRange(db.sys_user_and_role.Where(_ => _.UserId == dbm.UserId)); db.sys_user.Remove(dbm); db.SaveChanges(); } return(Json(new OMS.Common.Model.JsonData { flag = OMS.Common.Model.JsonDataFlag.Succeed })); }
public ActionResult Add(VM_RpCode_Form m) { if (ModelState.IsValid) { using (var db = new box_omsEntities()) { int?_Validity = null; int?_AuthUserCount = null; if (m.Validity != null) { if (!System.Text.RegularExpressions.Regex.IsMatch(m.Validity.ToString(), @"^(([1-9]\d*))$")) { ModelState.AddModelError("Validity", "请输入大于0的正整数!"); return(View(m)); } _Validity = Convert.ToInt32(m.Validity); } if (m.AuthUserCount != null) { if (!System.Text.RegularExpressions.Regex.IsMatch(m.AuthUserCount.ToString(), @"^(([1-9]\d*))$")) { ModelState.AddModelError("AuthUserCount", "请输入大于0的正整数!"); return(View(m)); } _AuthUserCount = Convert.ToInt32(m.AuthUserCount); } string _id = Guid.NewGuid().ToString(); db.rp_cdkey.Add(new rp_cdkey { EntId = m.EnteId, Id = _id, Validity = _Validity, AuthUserCount = _AuthUserCount, UseProv = m.Provinces, UseCity = m.Cityss, UseDist = m.Areass, Remark = m.Remark, UseSchool = m.UseSchool }); Bind(m.English, db, _id, 3); Bind(m.Math, db, _id, 2); Bind(m.Chinese, db, _id, 1); db.SaveChanges(); return(Json(new { success = true })); } } return(View(m)); }