From 9f326f4000847e6167d8166fa2f6a66f53cb3734 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期四, 17 十二月 2020 09:07:13 +0800 Subject: [PATCH] 新云端Ver1.3 --- ZigbeeApp/Shared/Phone/Common/Logic/HdlOtherFunctionLogic.cs | 95 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 95 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Common/Logic/HdlOtherFunctionLogic.cs b/ZigbeeApp/Shared/Phone/Common/Logic/HdlOtherFunctionLogic.cs new file mode 100644 index 0000000..5d26844 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/Common/Logic/HdlOtherFunctionLogic.cs @@ -0,0 +1,95 @@ +锘縰sing 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 () => + { + //缁忕含搴︿笂鎶ラ噰鐢╩qtt鐨勬柟寮忎笂鎶� + 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 + } +} -- Gitblit v1.8.0