private void GetDeviceTracking(int DeviceID) { MG_DAL.SQLServerOperating sqlHelper = new MG_DAL.SQLServerOperating(); string strSql = "select d.DeviceID,d.SerialNumber,DeviceName,l.OLat,l.OLng,l.LastCommunication DeviceDate,l.Speed,l.Course,l.DataContext from devices d inner join LKLocation l on l.DeviceID=d.DeviceiD where d.DeviceID =@DeviceID and d.deleted=0";// model=213 and dic = sqlHelper.Selects(strSql, new SqlParameter[] { new SqlParameter("DeviceID", DeviceID) }).toDictionary(); Geocoding geo = new Amap(); Gps gps = geo.Translate(dic["OLat"], dic["OLng"]); //Gps gps = Utils.gps84_To_Gcj02(dic["OLat"], dic["OLng"]); dic["OLat"] = gps.getWgLat().ToString(); dic["OLng"] = gps.getWgLon().ToString(); dic["Address"] = gps.Address; dic["CourseName"] = Utils.GetCoureName(dic["Course"]); var dc = dic["DataContext"]; var doorStatus = "未知"; if (dc.Split('-').Length > 3 && !string.IsNullOrEmpty(dc.Split('-')[3])) { dc = dc.Split('-')[3]; if (dc.Equals("0")) { doorStatus = "打开"; } else { doorStatus = "关闭"; } } dic["DataContext"] = doorStatus;// = dic["DataContext"].Split('-')[3]; //0--- 主电断开, 1-----主电连接 Response.Write(Utils.ToJson(dic)); Response.End(); }
/// <summary> /// 根据用户ID判断该用户是否在含短信通知功能用户账号体系下的 /// </summary> /// <param name="UserID"></param> /// <returns></returns> public static bool IsSMSNotice(string UserID) { //var ids = System.Configuration.ConfigurationManager.AppSettings["SMSNotice"].ToString(); //if (string.IsNullOrEmpty(ids)) //{ // return false; //} // UserID 是4927 的表示 该用户下的账号有 报警短信通知功能 string strSql = "with temp(UserID,ParentID) as" + "( select UserID, ParentID from Users where UserID = " + lib.Config.SMSNoticeUserID + "union all select Users.UserID, Users.ParentID from Users, temp where Users.ParentID = temp.UserID and users.Deleted = 0" + ")select UserID from temp where UserID= " + UserID; MG_DAL.SQLServerOperating s = new MG_DAL.SQLServerOperating(); DataTable dt = s.Selects(strSql); if (dt.Rows.Count <= 0) { return(false); } //List<Dictionary<string, string>> listDic = s.Selects(strSql).toListDictionary(); ////目前只有澳博旗下所有用户 才会 发送 报警短信通知 3437 澳博美谷 总账号的UserID 870是xietong //if (listDic.Where(l => l.ContainsValue(UserID)).Count() <= 0) // //{ // return false; //} return(true); }
protected void Page_Load(object sender, EventArgs e) { string deviceid = Request.QueryString["deviceid"]; open_id = Request.QueryString["openid"]; // imei = Request.QueryString["imei"]; if (!string.IsNullOrEmpty(deviceid) && !string.IsNullOrEmpty(open_id)) { try { device_id = Convert.ToInt32(deviceid); MG_DAL.SQLServerOperating s = new MG_DAL.SQLServerOperating(); string strSql = @"select DeviceID,SerialNumber,DeviceName,PhoneNum,ActiveDate,HireExpireDate,u.UserID,u.UserName,di.DataText,cast((datediff(DAY,ActiveDate,GETDATE()) + 0.1)/(datediff(DAY,ActiveDate,HireExpireDate)+0.1) as numeric(10,2)) as UseSituation, datediff(MM,GETDATE(),HireExpireDate) TheRest, (select count(*) from devices where Deleted=0 and UserID=d.UserID) DeviceCount, (select count(*) from devices where Deleted=0 and UserID=d.UserID and HireExpireDate > GETDATE() and HireExpireDate <= DATEADD(MM,1,GETDATE())) ExpireCount from devices d inner join Users u on u.UserID=d.UserID inner join dictionary di on di.DataValue = d.Model where d.Deleted=0 and DeviceID=@DeviceID"; DataTable dt = s.Selects(strSql, new SqlParameter[] { new SqlParameter("DeviceID", device_id) }); //X11 8 50 开头的 都是60一年,其他都是120一年 60 100 130 120 200 250 if (dt.Rows.Count <= 0) { return; } DataRow DeviceInfo = dt.Rows[0]; var expire = Convert.ToDateTime(DeviceInfo["HireExpireDate"].ToString()); expire_date = expire.ToString("yyyy-MM-dd"); if (expire < DateTime.Now) { use_situation = 100; } else { use_situation = Convert.ToInt32(Convert.ToDouble(DeviceInfo["UseSituation"].ToString()) * 100); } user_name = DeviceInfo["UserName"].ToString(); imei = DeviceInfo["SerialNumber"].ToString(); device_count = DeviceInfo["DeviceCount"].ToString(); expire_count = DeviceInfo["ExpireCount"].ToString(); device_name = string.IsNullOrEmpty(DeviceInfo["DeviceName"].ToString()) ? DeviceInfo["SerialNumber"].ToString() : DeviceInfo["DeviceName"].ToString(); user_id = Convert.ToInt32(DeviceInfo["UserID"].ToString()); int.TryParse(DeviceInfo["TheRest"].ToString(), out the_rest); the_rest = the_rest - 1; if (the_rest < 0) { the_rest = 0; } MG_BLL.Pay.MgooOrders.Orders o = new MG_BLL.Pay.MgooOrders.Orders(); PriceList = o.GetPriceList(DeviceInfo["DataText"].ToString()); } catch (Exception) { } } }
public string SendCommand(string deviceid) { try { MG_DAL.SQLServerOperating s = new MG_DAL.SQLServerOperating(); string imei = s.Selects("select SerialNumber from devices where deviceid=@deviceid and Deleted=0", new SqlParameter[] { new SqlParameter("deviceid", deviceid) }).Rows[0]["SerialNumber"].toStringEmpty(); string cmd = "VTR-SCommand-" + imei + "-TY"; string res = Utils.SendTcpCmd(cmd); Utils.log(" MG_BLL.DeviceManager.SendCommand:" + cmd + "," + res); if (res == "1") { return("success"); } { return("error"); } } catch (Exception e) { Utils.log("MG_BLL.DeviceManager.SendCommand Error:" + e.Message + "-" + e.StackTrace + "-" + e.Source); return("error"); } }