New file |
| | |
| | | using Shared.Common; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using ZigBee.Device; |
| | | |
| | | namespace Shared.Phone |
| | | { |
| | | /// <summary> |
| | | /// 其他没法分类的功能的逻辑 |
| | | /// </summary> |
| | | public class HdlOtherFunctionLogic |
| | | { |
| | | #region ■ 变量声明___________________________ |
| | | |
| | | /// <summary> |
| | | /// 其他没法分类的功能的逻辑 |
| | | /// </summary> |
| | | private static HdlOtherFunctionLogic m_Current = null; |
| | | /// <summary> |
| | | /// 其他没法分类的功能的逻辑 |
| | | /// </summary> |
| | | public static HdlOtherFunctionLogic Current |
| | | { |
| | | get |
| | | { |
| | | if (m_Current == null) |
| | | { |
| | | m_Current = new HdlOtherFunctionLogic(); |
| | | } |
| | | return m_Current; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 经纬度_____________________________ |
| | | |
| | | /// <summary> |
| | | /// 添加App的经纬度上报事件 |
| | | /// </summary> |
| | | public void AddAppLatAndLonEvent() |
| | | { |
| | | Application.LocationAction += (lon, lat) => |
| | | { |
| | | //GPS坐标转成高德坐标 |
| | | double out_lng, out_lat; |
| | | HdlGpsLocationConvertLogic.Current.WGS84_to_GCJ02(lon, lat, out out_lng, out out_lat); |
| | | //上报经纬度 |
| | | this.ReceiveAppLatAndLon(out_lng.ToString(), out_lat.ToString()); |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// App的经纬度上报 |
| | | /// </summary> |
| | | /// <param name="lat"></param> |
| | | /// <param name="lon"></param> |
| | | private void ReceiveAppLatAndLon(string lon, string lat) |
| | | { |
| | | if (HdlCheckLogic.Current.IsAccountLoginOut() == true) |
| | | { |
| | | //如果已经退出登陆的话 |
| | | return; |
| | | } |
| | | HdlThreadLogic.Current.RunThread(async () => |
| | | { |
| | | //经纬度上报采用mqtt的方式上报 |
| | | try |
| | | { |
| | | //发送主题 |
| | | string strTopic = "/ClientToCloud/" + Config.Instance.Guid + "/Report/Location"; |
| | | //发送数据 |
| | | var dic = new Dictionary<string, string>(); |
| | | dic["lon"] = lon; |
| | | dic["lat"] = lat; |
| | | var byteData = Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(dic)); |
| | | |
| | | await ZbGateway.RemoteMqttClient?.PublishAsync(new MQTTnet.MqttApplicationMessage { Topic = strTopic, Payload = byteData, QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.ExactlyOnce } |
| | | , System.Threading.CancellationToken.None); |
| | | |
| | | if (HdlUserCenterResourse.HideOption.WriteGpsPoint == 1) |
| | | { |
| | | string txtvalue = "lon:" + lon + " lat:" + lat; |
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, txtvalue); |
| | | HdlLogLogic.Current.WriteLog(-1, "经纬度上报 " + txtvalue); |
| | | } |
| | | } |
| | | catch { }; |
| | | }, ShowErrorMode.NO); |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |