/// <summary> /// 根据设备标识获取站点信息 /// </summary> /// <param name="deviceID">设备标识</param> /// <returns></returns> public SiteDevice GetSiteDeviceByDeviceID(string deviceID) { SiteDevice d = DB.Load <SiteDevice, PK_SiteDevice>(new PK_SiteDevice { DeviceID = deviceID }); return(d); }
/// <summary> /// 站点设备注册(设备信息注册,设备所属注册) /// </summary> /// <param name="obj"></param> /// <returns></returns> public int Add(SiteDevice obj, string moduleCode) { obj.ID = Utils.getGUID(); IList <DBState> dblist = new List <DBState>(); dblist.Add(new DBState { Name = obj.MAP_INSERT, Param = obj.ToDict(), Type = ESqlType.INSERT }); dblist.Add(new DBState { Name = "INSERT_SiteDevice_Module", Param = new { ModuleCode = moduleCode, DeviceID = obj.DeviceID }.toStrObjDict(), Type = ESqlType.INSERT }); return(DB.Execute(dblist)); }
/// <summary> /// 平台登录 /// </summary> /// <returns></returns> //public ActionResult UserLogin() //{ // StrObjectDict dict = GetParams(); // string username = dict.GetString("UserName"); // string password = dict.GetString("PassWord"); // if (string.IsNullOrEmpty(username) && string.IsNullOrEmpty(password)) // { // return this.MyJson(0, "用户名或密码不能为空"); // } // if (Utils.GetString(base.HttpContext.Application["REGCODE"]) == "false") // { // return this.MyJson(0, "系统未注册,请先注册!"); // } // else // { // StrObjectDict u = LoginManager.Instance.GetByUserNameAndPwd(username, password); // if (u == null) // { // return this.MyJson(0, "用户名或者密码错误"); // } // if (u.ContainsKey("IsInvalid") && u["IsInvalid"].ToString() == "1") // { // return this.MyJson(0, "你的帐号不可用,请联系管理员"); // } // //登录成功,放入会话中保存 // HttpContext.Session["LOGINED"] = true; // LoginSession.Current.Refresh(u); // HttpCookie httpCookie = new HttpCookie(CookieContext.EmployeeID, username); // httpCookie.Expires = System.DateTime.Now.AddYears(1); // HttpContext.Response.Cookies.Add(httpCookie); // return this.MyJson(1, u); // } //} /// <summary> /// 登陆(所有终端平台通用) /// </summary> /// <returns></returns> public ActionResult Index() { StrObjectDict dict = GetParams(); string deviceID = dict.GetString("DeviceID"); string userName = dict.GetString("UserName"); string pwd = dict.GetString("Password"); string moduleCode = dict.GetString("ModuleCode"); #region 检查参数有效性 if (moduleCode != "WebBrowser" && string.IsNullOrEmpty(deviceID)) { return(this.MyJson(0, "参数为空:DeviceID")); } if (string.IsNullOrEmpty(userName)) { return(this.MyJson(0, "参数为空:UserName")); } if (string.IsNullOrEmpty(pwd)) { return(this.MyJson(0, "参数为空:Password")); } #endregion //检查设备是否可用 if (moduleCode != "WebBrowser") { SiteDevice device = SiteManager.Instance.GetSiteDeviceByDeviceID(deviceID); if (device == null || device.Enable == 0) { return(this.MyJson(-999, "该设备未注册或者已禁用,请联系系统管理人员")); } } //检查帐号合法性 StrObjectDict u = LoginManager.Instance.GetByUserNameAndPwd(userName, pwd); if (u == null) { return(this.MyJson(-999, "用户名或者密码错误")); } if (u.ContainsKey("IsInvalid") && u["IsInvalid"].ToString() == "1") { return(this.MyJson(-999, "你的帐号不可用,请联系管理员")); } //登陆成功,放入会话中保存 LoginSession.Current.Refresh(u); IList <StrObjectDict> userinfo = LoginManager.Instance.GetRoleAndDefault(u); if (userinfo.Count > 0) { IList <StrObjectDict> list = new List <StrObjectDict>(); foreach (var item in userinfo) { list.Add(item); } u["RoleData"] = list; //u["Role"] = userinfo[0]["Role"]; //u["DefaultFunction"] = userinfo[0]["DefaultFunction"]; //u["URL"] = userinfo[0]["URL"]; //u["DefaultName"] = userinfo[0]["DefaultName"]; } return(this.MyJson(1, u)); }
/// <summary> /// 1.检查站点设备 /// 2.注册站点设备,保存内容:所属机构,站点设备相关信息,应用模块代码 /// </summary> /// <returns></returns> public ActionResult Index() { StrObjectDict dict = GetParams(); object pointID = dict.GetObject("PointID"); object orgID = dict.GetObject("OrgID"); object pointInfo = dict.GetObject("PointInfo"); object moduleCode = dict.GetObject("ModuleCode"); #region 检查参数是否正确 if (pointID == null || string.IsNullOrEmpty(pointID.ToString())) { return(this.MyJson(0, "参数错误:PointID")); } if (orgID == null || string.IsNullOrEmpty(orgID.ToString())) { return(this.MyJson(1, "参数错误:OrgID")); } if (pointInfo == null || string.IsNullOrEmpty(pointInfo.ToString())) { return(this.MyJson(0, "参数错误:PointInfo")); } if (moduleCode == null || string.IsNullOrEmpty(moduleCode.ToString())) { return(this.MyJson(0, "参数错误:ModuleID")); } #endregion //检查设备是否已经注册 SiteDevice device = SiteManager.Instance.GetSiteDeviceByDeviceID(pointID.ToString()); if (device == null || string.IsNullOrEmpty(device.ID)) { int deviceCount = 99;//通过授权文件查询出授权使用的设备数量 int regDeviceCount = SiteManager.Instance.GetSiteDeviceCount(); if (deviceCount <= regDeviceCount) { return(this.MyJson(0, "已超过允许注册设备的最大数量,请联系管理员!")); } //未注册同时也没有超过设备允许注册的最大数量,则自动注册该设备 int result = SiteDeviceManager.Instance.Add(new SiteDevice { DeviceID = pointID.ToString(), DeviceInfo = pointInfo.ToString(), Enable = 1, IsMobile = 1, RegTime = DateTime.Now, Remark = "", DeptID = orgID.ToString() }, moduleCode.ToString()); if (result < 1) { return(this.MyJson(0, "设备注册失败,请联系管理员!")); } } return(this.MyJson(1)); }