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)); }
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 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 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 })); }
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 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)); }
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)); }
public JsonResult Delete(int id) { using (var db = new box_omsEntities()) { db.rp_cdkey_and_edition.RemoveRange(db.rp_cdkey_and_edition.Where(_ => _.rp_cdkey.rp_enterprise.EntId == id)); db.rp_cdkey.RemoveRange(db.rp_cdkey.Where(_ => _.EntId == id)); db.rp_enterprise.Remove(db.rp_enterprise.Find(id)); db.SaveChanges(); } return(Json(new OMS.Common.Model.JsonData { flag = OMS.Common.Model.JsonDataFlag.Succeed })); }
public ActionResult Edit(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); } rp_cdkey rpc = db.rp_cdkey.Where(_ => _.Id == m.Id).FirstOrDefault(); rpc.EntId = m.EnteId; rpc.Validity = _Validity; rpc.AuthUserCount = _AuthUserCount; rpc.UseProv = m.Provinces; rpc.UseCity = m.Cityss; rpc.UseDist = m.Areass; rpc.Remark = m.Remark; rpc.UseSchool = m.UseSchool; //先删除然后重新添加 db.rp_cdkey_and_edition.RemoveRange(db.rp_cdkey_and_edition.Where(_ => _.CdKey == m.Id)); Bind(m.English, db, m.Id, 3); Bind(m.Math, db, m.Id, 2); Bind(m.Chinese, db, m.Id, 1); db.SaveChanges(); return(Json(new { success = true })); } } return(View(m)); }
public void Post([FromBody] AM_BoxSysUpdateSuccessPost m) { using (var db = new box_omsEntities()) { var good = db.box_good.Where(w => w.Mac == m.mac).FirstOrDefault(); var update_log = db.box_update_sys_log.Where(w => w.BoxId == good.BoxId && w.State == 1).FirstOrDefault();//获取该盒子当前正在更新的更新包 update_log.State = 2; update_log.FinishTime = DateTime.Now; good.SysVersion = db.box_update_sys.Find(update_log.UpdateId).VNumber; db.SaveChanges(); } }
public JsonResult Delete(int id) { using (var db = new box_omsEntities()) { db.box_good_online.RemoveRange(db.box_good_online.Where(_ => _.BoxId == id)); db.box_update_sys_log.RemoveRange(db.box_update_sys_log.Where(_ => _.BoxId == id)); db.box_subject_edition.RemoveRange(db.box_subject_edition.Where(_ => _.BoxId == id)); db.box_resource_statist.RemoveRange(db.box_resource_statist.Where(_ => _.BoxId == id)); db.box_resource_statist_day.RemoveRange(db.box_resource_statist_day.Where(_ => _.BoxId == id)); db.box_good.Remove(db.box_good.Find(id)); db.SaveChanges(); } return(Json(new OMS.Common.Model.JsonData { flag = OMS.Common.Model.JsonDataFlag.Succeed })); }
public ActionResult Add(VM_SyUser_Form m) { if (ModelState.IsValid) { using (var db = new box_omsEntities()) { if (db.sys_user.Where(w => w.Account == m.Account).Count() > 0) { ModelState.AddModelError("Account", "帐号已存在。");//帐号已存在 } else { sys_user dbm = db.sys_user.Add(new sys_user { Account = m.Account, Password = OMS.Common.Function.MD5Encrypt("123456"), Name = m.Name, State = m.State }); if (!string.IsNullOrWhiteSpace(m.ids)) { string[] _ids = m.ids.Split(','); for (int i = 0; i < _ids.Length; i++) { if (string.IsNullOrWhiteSpace(_ids[i])) { continue; } db.sys_user_and_role.Add(new sys_user_and_role() { UserId = dbm.UserId, RoleId = Convert.ToInt32(_ids[i]), CreateTime = DateTime.Now }); } } db.SaveChanges(); return(Json(new { success = true })); } } } return(View(m)); }
public ActionResult Edit(VM_SyUser_Form m) { if (ModelState.IsValid) { using (var db = new box_omsEntities()) { sys_user dbm = db.sys_user.Find(m.Id); if (dbm.Account != m.Account && db.sys_user.Where(w => w.Account == m.Account).Count() > 0) { ModelState.AddModelError("Account", "帐号已存在。");//帐号已存在 } else { dbm.Account = m.Account; dbm.Name = m.Name; dbm.State = m.State; //先删除然后重新添加 db.sys_user_and_role.RemoveRange(db.sys_user_and_role.Where(_ => _.UserId == dbm.UserId)); if (!string.IsNullOrWhiteSpace(m.ids)) { string[] _ids = m.ids.Split(','); for (int i = 0; i < _ids.Length; i++) { if (string.IsNullOrEmpty(_ids[i])) { continue; } db.sys_user_and_role.Add(new sys_user_and_role() { UserId = dbm.UserId, RoleId = Convert.ToInt32(_ids[i]), CreateTime = DateTime.Now }); } } db.SaveChanges(); return(Json(new { success = true })); } } } return(View(m)); }
public JsonData Post([FromBody] AM_RpKeyActivePost m) { string ip = ((System.Web.HttpContextWrapper)Request.Properties["MS_HttpContext"]).Request.UserHostAddress; string key = ""; using (var db = new box_omsEntities()) { rp_cdkey dbm = db.rp_cdkey.Where(_ => _.Id == m.id).FirstOrDefault(); if (dbm == null) { return(new JsonData { flag = JsonDataFlag.ValidFailed, msg = "无效的激活码!" }); } if (dbm.ActiveTime != null && dbm.ActiveMac != m.mac)//同一个激活码在同一台电脑上可以被无限激活(防止重装系统后原激活码无法使用) { return(new JsonData { flag = JsonDataFlag.ValidFailed, msg = "激活码已被使用!" }); } if (dbm.Validity == null) { dbm.ExpirTime = Convert.ToDateTime("2099-12-12"); } else { dbm.ExpirTime = DateTime.Now.AddMonths(Convert.ToInt32(dbm.Validity)); } key = OMS.Common.SecurityHelper.Encrypt(string.Format("{0}|{1}|{2}", m.id, ((DateTime)dbm.ExpirTime).ToString("yyyy-MM-dd"), m.mac), "a%k8h5.o"); dbm.ActiveTime = DateTime.Now; dbm.ActiveMac = m.mac; dbm.ActiveDisk = m.disk; dbm.ActiveIp = ip; dbm.ActiveCode = key; db.SaveChanges(); } return(new JsonData { flag = JsonDataFlag.Succeed, data = key }); }
public ActionResult Add(VM_SyRole_Form m) { if (ModelState.IsValid) { using (var db = new box_omsEntities()) { if (db.sys_role.Where(w => w.RoleName == m.RoleName).Count() > 0) { ModelState.AddModelError("RoleName", "角色名已存在。"); return(View(m)); } sys_role _model = db.sys_role.Add(new sys_role { RoleName = m.RoleName, Remark = m.Remark }); if (!string.IsNullOrWhiteSpace(m.ids)) { string[] _ids = m.ids.Split(','); for (int i = 0; i < _ids.Length; i++) { if (string.IsNullOrWhiteSpace(_ids[i])) { continue; } db.sys_role_and_auth.Add(new sys_role_and_auth() { Id = Guid.NewGuid().ToString(), RoleId = _model.RoleId, LeftId = Convert.ToInt32(_ids[i]) }); } } db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(m)); }
public ActionResult Edit(VM_BoxGood_Form1 m) { if (ModelState.IsValid) { if (m.UseUserName.Length > 10) { ModelState.AddModelError("UseUserName", "输入的字符不能超过10个!"); return(View(m)); } if (m.SchoolName.Length > 20) { ModelState.AddModelError("SchoolName", "输入的字符不能超过20个!"); return(View(m)); } using (var db = new box_omsEntities()) { box_good dbm = db.box_good.Find(m.id); dbm.UpdateTime = DateTime.Now; dbm.UpdateUserId = System.Web.HttpContext.Current.Session["UserInfo"] == null ? 0 : (System.Web.HttpContext.Current.Session["UserInfo"] as VM_SyPassport_UserInfo).Id; dbm.State = m.State; dbm.Prov = m.Prov.ToString(); dbm.City = m.City.ToString(); dbm.Area = m.Area.ToString(); dbm.UseUserName = m.UseUserName; dbm.SchoolName = m.SchoolName; //先删除然后重新添加 db.box_subject_edition.RemoveRange(db.box_subject_edition.Where(_ => _.BoxId == m.id)); Bind(m.English, db, dbm.BoxId, 3); Bind(m.Math, db, dbm.BoxId, 2); Bind(m.Chinese, db, dbm.BoxId, 1); db.SaveChanges(); return(Json(new { success = true })); } } return(View(m)); }
public ActionResult Add(VM_BoxUpdateSys_Form m) { if (ModelState.IsValid) { using (var db = new box_omsEntities()) { if (db.box_update_sys.Where(w => w.VNumber == m.VNumber).Count() > 0) { ModelState.AddModelError("VNumber", "版本号已存在。"); return(View(m)); } if (m.File == null) { ModelState.AddModelError("File", "请选择要导入的zip包"); return(View(m)); } if (Path.GetExtension(m.File.FileName).ToLower() != ".zip") { ModelState.AddModelError("File", "只能上传zip格式的包"); return(View(m)); } box_update_sys dbm = new box_update_sys { VNumber = (double)m.VNumber, Principal = m.Principal, Cause = m.Cause, IsPublish = false }; dbm.PackUrl = UploadZip(m.File, ((double)m.VNumber).ToString("f2").Replace(".", "_")); db.box_update_sys.Add(dbm); db.SaveChanges(); return(RedirectToAction("Index", "BoxUpdate")); } } return(View(m)); }
/// <summary> /// 根据网卡MAC地址获取该商品的更新包列表 /// </summary> /// <param name="id">MAC地址</param> /// <returns>返回:更新包列表</returns> public JsonData Get(string id) { List <string> list = new List <string>(); using (var db = new box_omsEntities()) { var good = db.box_good.Where(w => w.Mac == id).FirstOrDefault(); var pack = db.box_update_sys.OrderBy(o => o.VNumber).Where(w => w.VNumber > good.SysVersion && w.IsPublish == true).FirstOrDefault(); list.Add(pack.PackUrl); list.Add(pack.VNumber.ToString()); db.box_update_sys_log.Add(new box_update_sys_log { BoxId = good.BoxId, UpdateId = pack.Id, State = 1, StartTime = DateTime.Now }); db.SaveChanges(); } return(new JsonData { flag = JsonDataFlag.Succeed, data = list }); }
public ActionResult Add(VM_BoxGood_Form m) { if (ModelState.IsValid) { using (var db = new box_omsEntities()) { if (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)); } box_good dbm = new box_good { Mac = m.MAC, ActivNumber = m.MAC == null ? "" : BLL.BoxGoodBLL.GetKey(m.MAC, _ExpirTime), SysVersion = Convert.ToDouble(m.SysVersion), State = 1, IsCanUpdate = true, IsActiv = false, Total = 0, Remark = m.Remark, CreateTime = DateTime.Now, CreateUserId = GetUserId(), IP = m.IP, ExpirTime = _ExpirTime, Validity = _Validity }; box_good _m = db.box_good.Add(dbm); db.SaveChanges(); db.box_good_online.Add(new box_good_online { BoxId = _m.BoxId }); db.SaveChanges(); return(Json(new { success = true })); } } } return(View(m)); }
/// <summary> /// 资源平台定时任务 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TimedEventByRp(object sender, System.Timers.ElapsedEventArgs e) { try { string omsUrl = System.Configuration.ConfigurationManager.AppSettings["OMS_URL"].ToString(); string boxLogUrl = string.Format("{0}\\Files\\Rp\\Logs", omsUrl); if (Directory.Exists(boxLogUrl)) { var files = Directory.GetFiles(boxLogUrl, "*.xml"); if (files != null && files.Length > 0) { foreach (var file in files) { XmlDocument doc = new XmlDocument(); doc.Load(file); XmlNode logs = doc.SelectSingleNode("Logs"); var datas = logs.SelectNodes("Datas"); if (datas != null && datas.Count > 0) { using (var db = new box_omsEntities()) { foreach (XmlNode data in datas) { ResMod rm = JsonHelper.DeserializeJsonToObject <ResMod>(data["Content"].InnerText); string id = DataHelper.BackId(rm.ActiveCode); if (string.IsNullOrWhiteSpace(id)) { continue; } if (rm.ResourceType == "1" || rm.ResourceType == "3") { db.rp_resource_statist.Add(new rp_resource_statist() { Id = Guid.NewGuid().ToString(), Cd_key = id, EditionId = Convert.ToInt32(rm.EditionId), EditionName = rm.EditionName, ResourceType = Convert.ToInt32(rm.ResourceType), SubjectId = Convert.ToInt32(rm.SubjectId), Type = Convert.ToInt32(data["Type"].InnerText), CreateTime = Convert.ToDateTime(data["Time"].InnerText), RoleName = rm.RoleName, SchoolName = rm.SchoolName, UserName = rm.Account }); } else if (rm.ResourceType == "2") { int _type = 0; switch (rm.EditionName) { case "英语一年级": _type = 1; break; case "英语二年级": _type = 2; break; case "英语三年级": _type = 3; break; case "英语四年级": _type = 4; break; case "英语五年级": _type = 5; break; case "英语六年级": _type = 6; break; } db.rp_resource_statist.Add(new rp_resource_statist() { Id = Guid.NewGuid().ToString(), Cd_key = id, EditionName = rm.EditionName, ResourceType = Convert.ToInt32(rm.ResourceType), Type = _type, CreateTime = Convert.ToDateTime(data["Time"].InnerText), RoleName = rm.RoleName, SchoolName = rm.SchoolName, UserName = rm.Account }); } db.SaveChanges(); } } File.Delete(file);//删除文件 } } } } } catch (Exception ex) { WriteErrLog("资源平台定时任务出错:" + ex.ToString()); } }
/// <summary> /// 盒子定时任务 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TimedEvent(object sender, System.Timers.ElapsedEventArgs e) { try { string omsUrl = System.Configuration.ConfigurationManager.AppSettings["OMS_URL"].ToString(); string boxLogUrl = string.Format("{0}\\Files\\Box\\Logs", omsUrl); if (Directory.Exists(boxLogUrl)) { var files = Directory.GetFiles(boxLogUrl, "*.xml"); if (files != null && files.Length > 0) { foreach (var file in files) { XmlDocument doc = new XmlDocument(); doc.Load(file); XmlNode logs = doc.SelectSingleNode("Logs"); var datas = logs.SelectNodes("Datas"); if (datas != null && datas.Count > 0) { string mac = ""; string gcode = ""; DateTime?date = null; using (var db = new box_omsEntities()) { foreach (XmlNode data in datas) { if (mac == "") { mac = data["Mac"].InnerText; } if (gcode == "") { gcode = db.box_good.Where(w => w.Mac == mac).Select(s => s.Code).FirstOrDefault(); } if (date == null) { date = DateTime.Parse(data["Time"].InnerText).Date; } //01.操作oms_box_resource_statist表 box_resource_statist m = new box_resource_statist(); m.Id = Guid.NewGuid().ToString(); m.Mac = mac; var good = db.box_good.Where(w => w.Mac == mac).FirstOrDefault(); if (good != null) { m.BoxId = good.BoxId; } m.CreateDate = DateTime.Parse(data["Time"].InnerText); if (!string.IsNullOrWhiteSpace(data["Subject"].InnerText)) { m.Subject = int.Parse(data["Subject"].InnerText); } if (!string.IsNullOrWhiteSpace(data["Edition"].InnerText)) { m.Edition = int.Parse(data["Edition"].InnerText); } m.Type = int.Parse(data["Type"].InnerText); if (good != null) { if (good.FirstRunTime == null) { good.FirstRunTime = DateTime.Parse(data["Time"].InnerText); } good.RunTime = DateTime.Parse(data["Time"].InnerText); } if (data["TypeName"] != null) { m.TypeName = data["TypeName"].InnerText; } db.box_resource_statist.Add(m); db.SaveChanges(); } } File.Delete(file);//删除文件 } } } } } catch (Exception ex) { WriteErrLog(ex.ToString()); } }