From e7385e16297cc9659d0cc0eaf3cdf0786a3d35ce Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期三, 24 十一月 2021 15:49:53 +0800
Subject: [PATCH] 2021-11-24-01

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs |   85 +-
 HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs  |  136 ++--
 .vs/HDL_APP_Project/xs/UserPrefs.xml                    |   26 
 HDL_ON/UI/MainPage.cs                                   |  807 +++++++++++++-------------
 HDL-ON_Android/Application.cs                           |  716 ++++++++++++-----------
 5 files changed, 892 insertions(+), 878 deletions(-)

diff --git a/.vs/HDL_APP_Project/xs/UserPrefs.xml b/.vs/HDL_APP_Project/xs/UserPrefs.xml
index daab1b5..df83ea1 100644
--- a/.vs/HDL_APP_Project/xs/UserPrefs.xml
+++ b/.vs/HDL_APP_Project/xs/UserPrefs.xml
@@ -1,18 +1,6 @@
 锘�<Properties StartupConfiguration="{09712674-2A38-407B-B1E2-560B2C352F9A}|Default">
   <MonoDevelop.Ide.ItemProperties.HDL-ON__iOS PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneSimulatorTarget." />
-  <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs">
-    <Files>
-      <File FileName="HDL_ON/UI/MainPage.cs" Line="111" Column="27" />
-      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs" Line="196" Column="40" />
-      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/Weather.cs" />
-      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/OutdoorEnvironment.cs" />
-      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs" />
-      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs" />
-      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs" />
-      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/FunTypeView.cs" />
-      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/brightnessView.cs" />
-      <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs" Line="911" Column="6" />
-    </Files>
+  <MonoDevelop.Ide.Workbench>
     <Pads>
       <Pad Id="ProjectPad">
         <State name="__root__">
@@ -21,16 +9,14 @@
               <Node name="UI" expanded="True">
                 <Node name="UI2" expanded="True">
                   <Node name="3-Intelligence" expanded="True">
-                    <Node name="Automation" expanded="True">
-                      <Node name="LogicMethod.cs" selected="True" />
-                    </Node>
+                    <Node name="Automation" expanded="True" />
                   </Node>
                 </Node>
+                <Node name="MainPage.cs" selected="True" />
               </Node>
             </Node>
-            <Node name="HDL-ON_Android" expanded="True">
-              <Node name="Properties" expanded="True" />
-            </Node>
+            <Node name="HDL-ON_Android" expanded="True" />
+            <Node name="HDL-ON_iOS" expanded="True" />
           </Node>
         </State>
       </Pad>
@@ -42,7 +28,7 @@
     <String>Shared.Droid.TouchID/Shared.Droid.TouchID.csproj</String>
     <String>Shared.IOS/Shared.IOS.csproj</String>
   </DisabledProjects>
-  <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|iPhoneSimulator" />
+  <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
   <MonoDevelop.Ide.ItemProperties.HDL-ON__Android PreferredExecutionTarget="Android.2ffc9a07" />
   <MonoDevelop.Ide.DebuggingService.Breakpoints>
     <BreakpointStore>
diff --git a/HDL-ON_Android/Application.cs b/HDL-ON_Android/Application.cs
index 52059fc..b2261ff 100644
--- a/HDL-ON_Android/Application.cs
+++ b/HDL-ON_Android/Application.cs
@@ -18,392 +18,400 @@
 
 namespace HDL_ON_Android
 {
-    /// <summary>
-    /// 璁惧畾涓洪粯璁ゅ惎鍔ㄧ殑Application
-    /// </summary>
-    [Android.App.Application]
-    public class Application : Android.App.Application, Android.App.Application.IActivityLifecycleCallbacks
+  /// <summary>
+  /// 璁惧畾涓洪粯璁ゅ惎鍔ㄧ殑Application
+  /// </summary>
+  [Android.App.Application]
+  public class Application : Android.App.Application, Android.App.Application.IActivityLifecycleCallbacks
+  {
+    static void reStartApp(Android.App.Application application)
     {
-        static void reStartApp(Android.App.Application application)
-        {
-            var intent = new Intent(application, typeof(BaseActivity));
-            intent.AddFlags(ActivityFlags.NewTask);
-            application.StartActivity(intent);
-            Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
-        }
+      var intent = new Intent(application, typeof(BaseActivity));
+      intent.AddFlags(ActivityFlags.NewTask);
+      application.StartActivity(intent);
+      Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
+    }
 
-        public Application(IntPtr handle, Android.Runtime.JniHandleOwnership ownerShip) : base(handle, ownerShip) { }
-        public override void OnCreate()
-        {
-            //娉ㄥ唽鏈鐞嗗紓甯镐簨浠�
-            AppCenter.Start("64ac5859-2cd7-4ef8-a5da-5455e29679ec", typeof(Analytics), typeof(Crashes));
-            if (Shared.Application.Activity != null)
-            {
-                reStartApp(this);
-                return;
-            }
+    public Application(IntPtr handle, Android.Runtime.JniHandleOwnership ownerShip) : base(handle, ownerShip) { }
+    public override void OnCreate()
+    {
+      //娉ㄥ唽鏈鐞嗗紓甯镐簨浠�
+      AppCenter.Start("64ac5859-2cd7-4ef8-a5da-5455e29679ec", typeof(Analytics), typeof(Crashes));
+      if (Shared.Application.Activity != null)
+      {
+        reStartApp(this);
+        return;
+      }
 
-            base.OnCreate();
-            RegisterActivityLifecycleCallbacks(this);
+      base.OnCreate();
+      RegisterActivityLifecycleCallbacks(this);
 
-            initAll();
+      initAll();
 
-        }
+    }
 
 
 
-        /// <summary>
-        /// 鎵�鏈夊垵濮嬪寲鍏ㄩ儴鍦ㄨ繖涓柟娉曞疄鐜�
-        /// </summary>
-        void initAll()
-        {
+    /// <summary>
+    /// 鎵�鏈夊垵濮嬪寲鍏ㄩ儴鍦ㄨ繖涓柟娉曞疄鐜�
+    /// </summary>
+    void initAll()
+    {
 
-            string[] permissions = new string[] { Manifest.Permission.WriteExternalStorage, Manifest.Permission.RecordAudio,
+      string[] permissions = new string[] { Manifest.Permission.WriteExternalStorage, Manifest.Permission.RecordAudio,
             Manifest.Permission.Camera, Manifest.Permission.ProcessOutgoingCalls, Manifest.Permission.GetAccounts};
-            //绂佹灞忓箷闀夸寒
-            BaseActivity.KeepScreenON = false;
-            //闅愯棌铏氭嫙鎸夐敭
-            BaseActivity.IsHideVirualButtons = true;
-            //瀹炵幇瀹夊崜杩斿洖鎸夐敭
-            BaseActivity.BackKeyAction = () =>
-            {
-                try
-                {
-                    var result = MainPage.LoadEvent_BackAction();
-                    switch (result)
-                    {
-                        case 0:
-                            break;
-                        case 1:
-                        case 2:
-                            BaseActivity.VerifyDateTime = DateTime.MaxValue;
-                            break;
-                        default:
-                            BaseActivity.VerifyDateTime = DateTime.MaxValue;
-                            break;
-                    }
-                }
-                catch (Exception ex)
-                {
-                    MainPage.Log(ex.Message);
-                    BaseActivity.VerifyDateTime = DateTime.MaxValue;
-                }
-            };
-
-            init();
-            BaseActivity.OnCreateActoin += (activity, application) =>
-            {
-                Language.CurrentLanguage = "Chinese";
-                Locale locale1 = Locale.Default;
-                var localeList = Resources.Configuration.Locale;
-                if (localeList.Language == "zh")
-                {
-                    Language.CurrentLanguage = "Chinese";
-                }
-                else
-                {
-                    Language.CurrentLanguage = "English";
-                }
-                //鑾峰彇鏋佸厜鎺ㄩ�両D
-                GetJPushRegistrationID(activity);
-
-                BaseActivity.NetworkStateChanged += (int internetStatus) =>
-                {
-                    //if (!IsEnterBackground)
-                    //{
-                    //    ////BusSocket.Stop();
-                    //    //new System.Threading.Thread(() =>
-                    //    //{
-                    //    //    System.Threading.Thread.Sleep(1000);
-                    //    //    //BusSocket.Start();
-                    //    //})
-                    //    //{ IsBackground = true }.Start();
-
-                    //}
-                    //else
-                    //{
-                    //    Console.WriteLine("HHH 缃戠粶鍙樺寲浣嗗浜庡悗鍙�");
-                    //}
-
-                    //缃戠粶鍙樺寲澶勭悊
-                    HDLCommon.Current.UpdateInternetStatus((int)internetStatus, MainPage.IsEnterBackground);
-                };
-            };
-            BaseActivity.RefreshUIAction += (activity) =>
-            {
-                MainPage.Show();
-                checkSomeInfo();
-            };
-            BaseActivity.OnResumeAction += (activity) =>
-            {
-                checkSomeInfo();
-            };
-            BaseActivity.OnDestroyAction += (activity) =>
-            {
-                Console.WriteLine("OnDestroyAction");
-                //BusSocket.Stop();
-                //UserInfo.Current.unlockTime = DateTime.Now;
-            };
-
-
-            HDLUtils.SetAuthoritiesName("com.hdl.onpro.fileProvider");
-
-            //Shared.Application.IsGpsEnable = true;
-            //鑾峰彇缁忕含搴� 
-            Shared.Application.LocationAction = (lon, lat) =>
-            {
-                try
-                {
-                    Shared.Application.LocationAction = null;
-                    new HDL_ON.DAL.Server.HttpServerRequest().GetCityWeatherInfo(lon.ToString(), lat.ToString());
-                    //鍏抽棴瀹氫綅鏈嶅姟
-                    Shared.Application.StopGPSLocationService();
-                }
-                catch (Exception ex)
-                {
-                    Utlis.WriteLine("GetCityInfo catch" + ex.Message);
-                }
-                MainPage.Log($"缁忕含搴�:::{lon}:{lat}");
-            };
-        }
-
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <param name="activity"></param>
-        void GetJPushRegistrationID(BaseActivity activity)
+      //绂佹灞忓箷闀夸寒
+      BaseActivity.KeepScreenON = false;
+      //闅愯棌铏氭嫙鎸夐敭
+      BaseActivity.IsHideVirualButtons = true;
+      //瀹炵幇瀹夊崜杩斿洖鎸夐敭
+      BaseActivity.BackKeyAction = () =>
+      {
+        try
         {
-            try
-            {
-                //淇濆瓨鑾峰彇鐨勬瀬鍏夋湇鍔″櫒涓婄殑娉ㄥ唽ID鍒版湰鍦版枃浠�
-                var tokenID = JPushInterface.GetRegistrationID(activity);
-                Console.WriteLine("RegistrationID:  " + tokenID);
-                if (!string.IsNullOrEmpty(tokenID) && OnAppConfig.Instance.PushDeviceToken != tokenID)
-                {
-                    OnAppConfig.Instance.PushDeviceToken = tokenID;
-                    OnAppConfig.Instance.PhoneName = Android.OS.Build.Manufacturer;
-                    OnAppConfig.Instance.SaveConfig();
-                }
-                int loadTokenCount = 0;
-                System.Threading.Tasks.Task.Run(() =>
-                {
-                    while (string.IsNullOrEmpty(tokenID))
-                    {
-                        System.Threading.Thread.Sleep(1000);
-                        tokenID = JPushInterface.GetRegistrationID(activity);
-                        Console.WriteLine("Sleep.tokenID + " + JPushInterface.GetRegistrationID(activity));
-                        loadTokenCount++;
-                        if (loadTokenCount > 30)
-                        {
-                            break;
-                        }
-                    }
-                    Console.WriteLine("RegistrationID:  " + tokenID);
-                    if (!string.IsNullOrEmpty(tokenID) && OnAppConfig.Instance.PushDeviceToken != tokenID)
-                    {
-                        OnAppConfig.Instance.PushDeviceToken = tokenID;
-                        OnAppConfig.Instance.PhoneName = Android.OS.Build.Manufacturer;
-                        OnAppConfig.Instance.SaveConfig();
-                    }
-                });
+          var result = MainPage.LoadEvent_BackAction();
+          switch (result)
+          {
+            case 0:
+              break;
+            case 1:
+            case 2:
+              BaseActivity.VerifyDateTime = DateTime.MaxValue;
+              break;
+            default:
+              BaseActivity.VerifyDateTime = DateTime.MaxValue;
+              break;
+          }
+        }
+        catch (Exception ex)
+        {
+          MainPage.Log(ex.Message);
+          BaseActivity.VerifyDateTime = DateTime.MaxValue;
+        }
+      };
 
+      init();
+      BaseActivity.OnCreateActoin += (activity, application) =>
+      {
+        Language.CurrentLanguage = "Chinese";
+        Locale locale1 = Locale.Default;
+        var localeList = Resources.Configuration.Locale;
+        if (localeList.Language == "zh")
+        {
+          Language.CurrentLanguage = "Chinese";
+        }
+        else
+        {
+          Language.CurrentLanguage = "English";
+        }
+        //鑾峰彇鏋佸厜鎺ㄩ�両D
+        GetJPushRegistrationID(activity);
+
+        BaseActivity.NetworkStateChanged += (int internetStatus) =>
+              {
+                //if (!IsEnterBackground)
+                //{
+                //    ////BusSocket.Stop();
+                //    //new System.Threading.Thread(() =>
+                //    //{
+                //    //    System.Threading.Thread.Sleep(1000);
+                //    //    //BusSocket.Start();
+                //    //})
+                //    //{ IsBackground = true }.Start();
+
+                //}
+                //else
+                //{
+                //    Console.WriteLine("HHH 缃戠粶鍙樺寲浣嗗浜庡悗鍙�");
+                //}
+
+                //缃戠粶鍙樺寲澶勭悊
+                HDLCommon.Current.UpdateInternetStatus((int)internetStatus, MainPage.IsEnterBackground);
+              };
+      };
+      BaseActivity.RefreshUIAction += (activity) =>
+      {
+        MainPage.Show();
+        checkSomeInfo();
+      };
+      BaseActivity.OnResumeAction += (activity) =>
+      {
+        checkSomeInfo();
+      };
+      BaseActivity.OnDestroyAction += (activity) =>
+      {
+        Console.WriteLine("OnDestroyAction");
+        //BusSocket.Stop();
+        //UserInfo.Current.unlockTime = DateTime.Now;
+      };
+
+
+      HDLUtils.SetAuthoritiesName("com.hdl.onpro.fileProvider");
+
+      //Shared.Application.IsGpsEnable = true;
+      bool isfirst = true;
+      //鑾峰彇缁忕含搴� 
+      Shared.Application.LocationAction = (lon, lat) =>
+      {
+        try
+        {
+          if (isfirst)
+          {
+            //鍙Е鍙戜竴娆�
+            //Shared.Application.LocationAction = null;
+            new HDL_ON.DAL.Server.HttpServerRequest().GetCityWeatherInfo(lon.ToString(), lat.ToString());
+          }
+          isfirst = false;
+          ///鐩戝惉缁忕含搴�
+          HDL_ON.UI.UI2.Intelligence.Automation.LogicMethod.CurrLogicMethod.AppLatAndLonEvent(lon, lat);
+          //鍏抽棴瀹氫綅鏈嶅姟
+          //Shared.Application.StopGPSLocationService();
+        }
+        catch (Exception ex)
+        {
+          Utlis.WriteLine("GetCityInfo catch" + ex.Message);
+        }
+        MainPage.Log($"缁忕含搴�:::{lon}:{lat}");
+      };
+    }
+
+    /// <summary>
+    /// 
+    /// </summary>
+    /// <param name="activity"></param>
+    void GetJPushRegistrationID(BaseActivity activity)
+    {
+      try
+      {
+        //淇濆瓨鑾峰彇鐨勬瀬鍏夋湇鍔″櫒涓婄殑娉ㄥ唽ID鍒版湰鍦版枃浠�
+        var tokenID = JPushInterface.GetRegistrationID(activity);
+        Console.WriteLine("RegistrationID:  " + tokenID);
+        if (!string.IsNullOrEmpty(tokenID) && OnAppConfig.Instance.PushDeviceToken != tokenID)
+        {
+          OnAppConfig.Instance.PushDeviceToken = tokenID;
+          OnAppConfig.Instance.PhoneName = Android.OS.Build.Manufacturer;
+          OnAppConfig.Instance.SaveConfig();
+        }
+        int loadTokenCount = 0;
+        System.Threading.Tasks.Task.Run(() =>
+        {
+          while (string.IsNullOrEmpty(tokenID))
+          {
+            System.Threading.Thread.Sleep(1000);
+            tokenID = JPushInterface.GetRegistrationID(activity);
+            Console.WriteLine("Sleep.tokenID + " + JPushInterface.GetRegistrationID(activity));
+            loadTokenCount++;
+            if (loadTokenCount > 30)
+            {
+              break;
             }
-            catch
-            {
+          }
+          Console.WriteLine("RegistrationID:  " + tokenID);
+          if (!string.IsNullOrEmpty(tokenID) && OnAppConfig.Instance.PushDeviceToken != tokenID)
+          {
+            OnAppConfig.Instance.PushDeviceToken = tokenID;
+            OnAppConfig.Instance.PhoneName = Android.OS.Build.Manufacturer;
+            OnAppConfig.Instance.SaveConfig();
+          }
+        });
 
-            }
-        }
+      }
+      catch
+      {
 
-        public static bool IsShowTip = true;
-        void init()
+      }
+    }
+
+    public static bool IsShowTip = true;
+    void init()
+    {
+      //鎵嬫満鍚嶇О Android.OS.Build.Manufacturer;
+      //OnAppConfig.Instance.PhoneName = Android.OS.Build.Manufacturer;
+      //#if DEBUG
+      //CN.Jpush.Android.Api.JPushInterface.SetDebugMode(true);
+      //#endif
+      CN.Jpush.Android.Api.JPushInterface.Init(this);
+
+    }
+    void checkSomeInfo()
+    {
+      try
+      {
+        IsShowTip = true;
+        var status = isNetworkAvailable(this);
+        int internetStatus = 0;
+        if (!status)
         {
-            //鎵嬫満鍚嶇О Android.OS.Build.Manufacturer;
-            //OnAppConfig.Instance.PhoneName = Android.OS.Build.Manufacturer;
-            //#if DEBUG
-            //CN.Jpush.Android.Api.JPushInterface.SetDebugMode(true);
-            //#endif
-            CN.Jpush.Android.Api.JPushInterface.Init(this);
-
+          internetStatus = 0;
         }
-        void checkSomeInfo()
+
+        var isWifi = isWifiConnected(this);
+        if (isWifi)
         {
-            try
-            {
-                IsShowTip = true;
-                var status = isNetworkAvailable(this);
-                int internetStatus = 0;
-                if (!status)
-                {
-                    internetStatus = 0;
-                }
-
-                var isWifi = isWifiConnected(this);
-                if (isWifi)
-                {
-                    internetStatus = 2;
-                }
-                else
-                {
-                    internetStatus = 1;
-                }
-            }
-            catch (Exception ex)
-            {
-                Console.WriteLine($"android check some info erorr : {ex.Message}");
-            }
+          internetStatus = 2;
         }
-
-        bool isNetworkAvailable(Context context)
+        else
         {
-            var cm = (ConnectivityManager)context.GetSystemService(ConnectivityService);
-            if (cm == null || cm.ActiveNetworkInfo == null)
-            {
-                return false;
-            }
-            else
-            {
-                return cm.ActiveNetworkInfo.IsAvailable;
-            }
+          internetStatus = 1;
         }
+      }
+      catch (Exception ex)
+      {
+        Console.WriteLine($"android check some info erorr : {ex.Message}");
+      }
+    }
 
-        bool isWifiConnected(Context context)
+    bool isNetworkAvailable(Context context)
+    {
+      var cm = (ConnectivityManager)context.GetSystemService(ConnectivityService);
+      if (cm == null || cm.ActiveNetworkInfo == null)
+      {
+        return false;
+      }
+      else
+      {
+        return cm.ActiveNetworkInfo.IsAvailable;
+      }
+    }
+
+    bool isWifiConnected(Context context)
+    {
+      if (context != null)
+      {
+        var mConnectivityManager = (ConnectivityManager)context.GetSystemService
+        (ConnectivityService);
+        var mWiFiNetworkInfo = mConnectivityManager.GetNetworkInfo(ConnectivityType.Wifi);
+        if (mWiFiNetworkInfo != null)
         {
-            if (context != null)
-            {
-                var mConnectivityManager = (ConnectivityManager)context.GetSystemService
-                (ConnectivityService);
-                var mWiFiNetworkInfo = mConnectivityManager.GetNetworkInfo(ConnectivityType.Wifi);
-                if (mWiFiNetworkInfo != null)
-                {
-                    return mWiFiNetworkInfo.IsAvailable;
-                }
-            }
-            return false;
+          return mWiFiNetworkInfo.IsAvailable;
         }
+      }
+      return false;
+    }
 
-        public void OnActivityCreated(Activity activity, Bundle savedInstanceState)
+    public void OnActivityCreated(Activity activity, Bundle savedInstanceState)
+    {
+
+    }
+
+    public void OnActivityDestroyed(Activity activity)
+    {
+      //throw new NotImplementedException ();
+    }
+
+    public void OnActivityPaused(Activity activity)
+    {
+      //throw new NotImplementedException ();
+    }
+
+    public void OnActivityResumed(Activity activity)
+    {
+      //throw new NotImplementedException ();
+    }
+
+    public void OnActivitySaveInstanceState(Activity activity, Bundle outState)
+    {
+      //throw new NotImplementedException ();
+    }
+
+    public void OnActivityStarted(Activity activity)
+    {
+      //throw new NotImplementedException ();
+
+      mCount++;
+      if (mCount == 1)
+      {
+        Console.WriteLine("HHH OnActivityStarted锛歠oreground");
+        BusSocketStart();
+        //鍚庡彴鍥炲埌鍓嶅彴
+        new HDL_ON.UI.AppUnlockPage().LoadPage();
+      }
+    }
+
+    public void OnActivityStopped(Activity activity)
+    {
+
+      mCount--;
+      if (mCount == 0)
+      {
+        Console.WriteLine("HHH OnActivityStopped锛� background");
+        BusSocketStop();
+        //杩涘叆鍚庡彴
+        UserInfo.Current.unlockTime = DateTime.Now;
+
+      }
+    }
+
+
+    public override void OnTerminate()
+    {
+      base.OnTerminate();
+      UnregisterActivityLifecycleCallbacks(this);
+    }
+
+    int mCount;
+
+    ///// <summary>
+    ///// 鏄惁杩涘叆鍚庡彴
+    ///// </summary>
+    //public bool IsEnterBackground = false;
+
+    /// <summary>
+    /// 杩涘叆鍚庡彴鐨勬椂闂�
+    /// </summary>
+    DateTime CloseTime = DateTime.Now;
+
+    /// <summary>
+    /// BusSocketStop
+    /// </summary>
+    void BusSocketStop()
+    {
+      //IsEnterBackground = true;
+      CloseTime = DateTime.Now;
+      MainPage.IsEnterBackground = true;
+      //杩涘叆鍚庡彴mqtt姝e湪杩炴帴閲嶇疆鐘舵��
+      HDL_ON.DAL.Mqtt.MqttClient.RemoteMqttIsConnecting = false;
+      HDL_ON.DriverLayer.UdpSocket._BusSocket.Stop();
+
+    }
+
+    /// <summary>
+    /// BusSocketStart
+    /// </summary>
+    void BusSocketStart()
+    {
+      //IsEnterBackground = false;
+
+      if (CloseTime.AddSeconds(10) < DateTime.Now)
+      {
+        //鍚庡彴瓒呰繃10s灏辨柇寮�MQTT閲嶈繛
+        //if (HDL_ON.DriverLayer.Control.Ins.IsRemote)
         {
-
+          HDL_ON.DAL.Mqtt.MqttClient.DisConnectRemote("closeTime", false);
         }
+      }
 
-        public void OnActivityDestroyed(Activity activity)
-        {
-            //throw new NotImplementedException ();
-        }
+      MainPage.IsEnterBackground = false;
+      HDL_ON.DriverLayer.UdpSocket._BusSocket.Start();
+      HDL_ON.DriverLayer.Control.Ins.SearchLoaclGateway();
+    }
 
-        public void OnActivityPaused(Activity activity)
-        {
-            //throw new NotImplementedException ();
-        }
+    protected override void Dispose(bool disposing)
+    {
+      base.Dispose(disposing);
+    }
 
-        public void OnActivityResumed(Activity activity)
-        {
-            //throw new NotImplementedException ();
-        }
-
-        public void OnActivitySaveInstanceState(Activity activity, Bundle outState)
-        {
-            //throw new NotImplementedException ();
-        }
-
-        public void OnActivityStarted(Activity activity)
-        {
-            //throw new NotImplementedException ();
-
-            mCount++;
-            if (mCount == 1)
-            {
-                Console.WriteLine("HHH OnActivityStarted锛歠oreground");
-                BusSocketStart();
-                //鍚庡彴鍥炲埌鍓嶅彴
-                new HDL_ON.UI.AppUnlockPage().LoadPage();
-            }
-        }
-
-        public void OnActivityStopped(Activity activity)
-        {
-
-            mCount--;
-            if (mCount == 0)
-            {
-                Console.WriteLine("HHH OnActivityStopped锛� background");
-                BusSocketStop();
-                //杩涘叆鍚庡彴
-                UserInfo.Current.unlockTime = DateTime.Now;
-
-            }
-        }
-
-
-        public override void OnTerminate()
-        {
-            base.OnTerminate();
-            UnregisterActivityLifecycleCallbacks(this);
-        }
-
-        int mCount;
-
-        ///// <summary>
-        ///// 鏄惁杩涘叆鍚庡彴
-        ///// </summary>
-        //public bool IsEnterBackground = false;
-
-        /// <summary>
-        /// 杩涘叆鍚庡彴鐨勬椂闂�
-        /// </summary>
-        DateTime CloseTime = DateTime.Now;
-
-        /// <summary>
-        /// BusSocketStop
-        /// </summary>
-        void BusSocketStop()
-        {
-            //IsEnterBackground = true;
-            CloseTime = DateTime.Now;
-            MainPage.IsEnterBackground = true;
-            //杩涘叆鍚庡彴mqtt姝e湪杩炴帴閲嶇疆鐘舵��
-            HDL_ON.DAL.Mqtt.MqttClient.RemoteMqttIsConnecting = false;
-            HDL_ON.DriverLayer.UdpSocket._BusSocket.Stop();
-
-        }
-
-        /// <summary>
-        /// BusSocketStart
-        /// </summary>
-        void BusSocketStart()
-        {
-            //IsEnterBackground = false;
-
-            if (CloseTime.AddSeconds(10) < DateTime.Now)
-            {
-                //鍚庡彴瓒呰繃10s灏辨柇寮�MQTT閲嶈繛
-                //if (HDL_ON.DriverLayer.Control.Ins.IsRemote)
-                {
-                    HDL_ON.DAL.Mqtt.MqttClient.DisConnectRemote("closeTime", false);
-                }
-            }
-
-            MainPage.IsEnterBackground = false;
-            HDL_ON.DriverLayer.UdpSocket._BusSocket.Start();
-            HDL_ON.DriverLayer.Control.Ins.SearchLoaclGateway();
-        }
-
-        protected override void Dispose(bool disposing)
-        {
-            base.Dispose(disposing);
-        }
-
-        /// <summary>
-        /// 鏌ヨ閫氱煡鏉冮檺锛屽苟鎻愮ず
-        /// </summary>
-        public  void QueryNotificationPermission()
-        {
-          
-
-        }
-
+    /// <summary>
+    /// 鏌ヨ閫氱煡鏉冮檺锛屽苟鎻愮ず
+    /// </summary>
+    public void QueryNotificationPermission()
+    {
 
 
     }
 
+
+
+  }
+
 }
diff --git a/HDL_ON/UI/MainPage.cs b/HDL_ON/UI/MainPage.cs
index 63929be..5c0af7d 100644
--- a/HDL_ON/UI/MainPage.cs
+++ b/HDL_ON/UI/MainPage.cs
@@ -8,86 +8,86 @@
 
 namespace HDL_ON
 {
-    public static class MainPage
+  public static class MainPage
+  {
+
+    /// <summary>
+    /// BaseView
+    /// </summary>
+    public static FrameLayout BaseView { get; internal set; }
+    /// <summary>
+    /// BasePageView
+    /// </summary>
+    public static PageLayout BasePageView { get; set; }
+    /// <summary>
+    /// 鐢ㄦ埛鎺у埗鐖跺鍣�
+    /// </summary>
+    public static UserPage UserBasePage;
+    /// <summary>
+    /// 鐗堟湰鍙�
+    /// </summary>
+    public static string VersionString = "1.3.1103";
+    ///// <summary>
+    ///// 瀹㈡埛绔被鍨�
+    ///// </summary>
+    //public static string ClientType = APIClientType.HDL_ON_PRO.ToString();
+
+    /// <summary>
+    /// 
+    /// </summary>
+    public static Entity.CityInfo cityInfo = new Entity.CityInfo();
+    /// <summary>
+    /// 澶╂皵鍒锋柊action
+    /// </summary>
+    public static Action RefreshAir;
+    /// <summary>
+    /// 鍥為��椤甸潰action 娌℃湁闇�瑕佸彲浠ヤ笉鐢�
+    /// </summary>
+    public static Action ReturnRefreshAction;
+    /// <summary>
+    /// 鏃犵櫥褰曟ā寮�
+    /// </summary>
+    public static bool NoLoginMode = false;
+    /// <summary>
+    /// 缃戠粶杩炴帴鐘舵��
+    /// 0:鏃犵綉缁�
+    /// </summary>
+    public static int InternetStatus = 2;
+    /// <summary>
+    /// 鏄惁杩涘叆鍚庡彴
+    /// </summary>
+    public static bool IsEnterBackground = false;
+    /// <summary>
+    /// 褰撳墠鍒嗛〉绱㈠紩
+    /// 0:鏀惰棌
+    /// 1:鍒嗙被
+    /// 2:鏅鸿兘
+    /// 3:涓汉
+    /// </summary>
+    public static int CurPageIndex = 9999;
+
+    ///// <summary>
+    ///// 鍏徃浠g爜
+    ///// 棰勭暀绗笁鏂瑰畾鍒舵爣璁�
+    ///// 0:HDL
+    ///// </summary>
+    //public static int Company = 0;
+
+    /// <summary>
+    /// 鍙虫粦鍚庨��鎻愮ず鎸夐挳
+    /// </summary>
+    public static Button BtnBackIcon;
+    /// <summary>
+    /// 鍚庨��鍙虫粦浜嗗灏戣窛绂伙紝瓒呰繃涓�瀹氳窛绂绘墠瑙﹀彂鍚庨��浜嬩欢
+    /// </summary>
+    public static int StartX = 0;
+    /// <summary>
+    /// 鏄惁鍏ㄩ潰灞忔墜鏈�
+    /// </summary>
+    public static bool Increase
     {
-        
-        /// <summary>
-        /// BaseView
-        /// </summary>
-        public static FrameLayout BaseView { get; internal set; }
-        /// <summary>
-        /// BasePageView
-        /// </summary>
-        public static PageLayout BasePageView { get; set; }
-        /// <summary>
-        /// 鐢ㄦ埛鎺у埗鐖跺鍣�
-        /// </summary>
-        public static UserPage UserBasePage;
-        /// <summary>
-        /// 鐗堟湰鍙�
-        /// </summary>
-        public static string VersionString = "1.3.1103";
-        ///// <summary>
-        ///// 瀹㈡埛绔被鍨�
-        ///// </summary>
-        //public static string ClientType = APIClientType.HDL_ON_PRO.ToString();
-
-        /// <summary>
-        /// 
-        /// </summary>
-        public static Entity.CityInfo cityInfo = new Entity.CityInfo();
-        /// <summary>
-        /// 澶╂皵鍒锋柊action
-        /// </summary>
-        public static Action RefreshAir;
-        /// <summary>
-        /// 鍥為��椤甸潰action 娌℃湁闇�瑕佸彲浠ヤ笉鐢�
-        /// </summary>
-        public static Action ReturnRefreshAction;
-        /// <summary>
-        /// 鏃犵櫥褰曟ā寮�
-        /// </summary>
-        public static bool NoLoginMode = false;
-        /// <summary>
-        /// 缃戠粶杩炴帴鐘舵��
-        /// 0:鏃犵綉缁�
-        /// </summary>
-        public static int InternetStatus = 2;
-        /// <summary>
-        /// 鏄惁杩涘叆鍚庡彴
-        /// </summary>
-        public static bool IsEnterBackground = false;
-        /// <summary>
-        /// 褰撳墠鍒嗛〉绱㈠紩
-        /// 0:鏀惰棌
-        /// 1:鍒嗙被
-        /// 2:鏅鸿兘
-        /// 3:涓汉
-        /// </summary>
-        public static int CurPageIndex = 9999;
-
-        ///// <summary>
-        ///// 鍏徃浠g爜
-        ///// 棰勭暀绗笁鏂瑰畾鍒舵爣璁�
-        ///// 0:HDL
-        ///// </summary>
-        //public static int Company = 0;
-
-        /// <summary>
-        /// 鍙虫粦鍚庨��鎻愮ず鎸夐挳
-        /// </summary>
-        public static Button BtnBackIcon;
-        /// <summary>
-        /// 鍚庨��鍙虫粦浜嗗灏戣窛绂伙紝瓒呰繃涓�瀹氳窛绂绘墠瑙﹀彂鍚庨��浜嬩欢
-        /// </summary>
-        public static int StartX = 0;
-        /// <summary>
-        /// 鏄惁鍏ㄩ潰灞忔墜鏈�
-        /// </summary>
-        public static bool Increase
-        {
-            get
-            {
+      get
+      {
 #if __IOS__
                 if (Application.PhoneType>10)
                 {
@@ -95,15 +95,15 @@
                 }
                 return false;
 #else
-                return false;
+        return false;
 #endif
-            }
-        }
+      }
+    }
 
-        /// <summary>
-        /// 鍦烘櫙鏀寔鐨勫姛鑳藉垪琛�
-        /// </summary>
-        public static List<string> SceneSupportFunctionList = new List<string> {
+    /// <summary>
+    /// 鍦烘櫙鏀寔鐨勫姛鑳藉垪琛�
+    /// </summary>
+    public static List<string> SceneSupportFunctionList = new List<string> {
             SPK.LightCCT,SPK.LightDimming,SPK.LightSwitch,SPK.LightRGB,
             SPK.CurtainRoller,SPK.CurtainSwitch,SPK.CurtainTrietex,
             SPK.AcIr,SPK.AcStandard,SPK.HvacAC,
@@ -114,350 +114,355 @@
         };
 
 
-        static List<string> _RoomNotSupportFunctionList = null;
-        /// <summary>
-        /// 鎴块棿鍔熻兘鍒楄〃涓嶅姞杞界殑鍔熻兘鍒楄〃
-        /// </summary>
-        public static List<string> RoomNotSupportFunctionList
+    static List<string> _RoomNotSupportFunctionList = null;
+    /// <summary>
+    /// 鎴块棿鍔熻兘鍒楄〃涓嶅姞杞界殑鍔熻兘鍒楄〃
+    /// </summary>
+    public static List<string> RoomNotSupportFunctionList
+    {
+      get
+      {
+        if (_RoomNotSupportFunctionList == null)
         {
-            get {
-                if(_RoomNotSupportFunctionList == null)
-                {
-                    _RoomNotSupportFunctionList = new List<string>();
-                    _RoomNotSupportFunctionList.Add(SPK.EnergyStandard);
-                    _RoomNotSupportFunctionList.Add(SPK.MusicStandard);
-                    _RoomNotSupportFunctionList.Add(SPK.AvMusic);
-                    _RoomNotSupportFunctionList.Add(SPK.AirSwitch);
-                    _RoomNotSupportFunctionList.Add(SPK.ElectricEnergy);
-                    _RoomNotSupportFunctionList.AddRange(SPK.EnvironDeviceSpkList());
-                    _RoomNotSupportFunctionList.AddRange(SPK.ArmSensorSpkList());
-                }
-                return _RoomNotSupportFunctionList;
-            }
+          _RoomNotSupportFunctionList = new List<string>();
+          _RoomNotSupportFunctionList.Add(SPK.EnergyStandard);
+          _RoomNotSupportFunctionList.Add(SPK.MusicStandard);
+          _RoomNotSupportFunctionList.Add(SPK.AvMusic);
+          _RoomNotSupportFunctionList.Add(SPK.AirSwitch);
+          _RoomNotSupportFunctionList.Add(SPK.ElectricEnergy);
+          _RoomNotSupportFunctionList.AddRange(SPK.EnvironDeviceSpkList());
+          _RoomNotSupportFunctionList.AddRange(SPK.ArmSensorSpkList());
         }
+        return _RoomNotSupportFunctionList;
+      }
+    }
 
-        public static void Show()
+    public static void Show()
+    {
+      try
+      {
+        Application.DesignWidth = 375;
+        Application.DesignHeight = 667;
+
+        BaseView = Application.MainPage;
+        Application.MainPage.BackgroundColor = CSS_Color.MainBackgroundColor;
+
+
+        //#region 娴嬭瘯
+        //var ddd = new UI.test.TestDialog();
+        //ddd.InitView();
+        //return;
+        //#endregion
+
+        if (string.IsNullOrEmpty(OnAppConfig.Instance.LastLoginUserId))
         {
-            try
-            {
-                Application.DesignWidth = 375;
-                Application.DesignHeight = 667;
-
-                BaseView = Application.MainPage;
-                Application.MainPage.BackgroundColor = CSS_Color.MainBackgroundColor;
-                ///鐩戝惉缁忕含搴�
-                HDL_ON.UI.UI2.Intelligence.Automation.LogicMethod.CurrLogicMethod.AppLatAndLonEvent();
-
-                //#region 娴嬭瘯
-                //var ddd = new UI.test.TestDialog();
-                //ddd.InitView();
-                //return;
-                //#endregion
-
-                if (string.IsNullOrEmpty(OnAppConfig.Instance.LastLoginUserId))
-                {
-                    GoLoginPage();
-                }
-                else
-                {
-                    //鍒ゆ柇闇�涓嶉渶瑕佺櫥褰曪紝鏈夋病鏈夌櫥褰曪紝鎴栬�呯櫥褰曟槸鍚﹁繃鏈燂紝
-                    if (UserInfo.Current == null || !UserInfo.Current.IsLogin)
-                    {
-                        GoLoginPage(UserInfo.Current);
-                    }
-                    else
-                    {
-                        //new System.Threading.Thread(() =>
-                        //{
-                        //    var pm = new DAL.Server.HttpServerRequest();
-                        //    pm.RefreshToken();//鍒锋柊Token
-                        //    pm.GetHomePager();//鍒锋柊浣忓畢淇℃伅
-                        //    pm.GetUserInfo();//鍒锋柊涓汉淇℃伅
-                        //})
-                        //{ IsBackground = true }.Start();
-                        Common.ApiUtlis.Ins.DownloadData();
-                        
-                        GoUserPage(false,true);
-                    }
-                }
-            }
-            catch (Exception ex)
-            {
-                Log("root erorr : " + ex.Message);
-            }
-            finally
-            {
-                //Application.RunOnMainThread(() => {
-                //    Application.HideSoftInput();
-                //});
-            }
+          GoLoginPage();
         }
-
-        /// <summary>
-        /// 杩涘叆鐧诲綍鐣岄潰
-        /// </summary>
-        public static void GoLoginPage(UserInfo userInfo = null)
+        else
         {
-            BaseView.RemoveAll();
-            BaseView.BackgroundColor = CSS_Color.BackgroundColor;
-            var fisrtView = new UI.UI1Login.LoginPage();
-            fisrtView.BackgroundColor = CSS_Color.MainBackgroundColor;
-            BaseView.AddChidren(fisrtView);
-            fisrtView.LoadView(userInfo);
+          //鍒ゆ柇闇�涓嶉渶瑕佺櫥褰曪紝鏈夋病鏈夌櫥褰曪紝鎴栬�呯櫥褰曟槸鍚﹁繃鏈燂紝
+          if (UserInfo.Current == null || !UserInfo.Current.IsLogin)
+          {
+            GoLoginPage(UserInfo.Current);
+          }
+          else
+          {
+            //new System.Threading.Thread(() =>
+            //{
+            //    var pm = new DAL.Server.HttpServerRequest();
+            //    pm.RefreshToken();//鍒锋柊Token
+            //    pm.GetHomePager();//鍒锋柊浣忓畢淇℃伅
+            //    pm.GetUserInfo();//鍒锋柊涓汉淇℃伅
+            //})
+            //{ IsBackground = true }.Start();
+            Common.ApiUtlis.Ins.DownloadData();
+
+            GoUserPage(false, true);
+          }
         }
+      }
+      catch (Exception ex)
+      {
+        Log("root erorr : " + ex.Message);
+      }
+      finally
+      {
+        //Application.RunOnMainThread(() => {
+        //    Application.HideSoftInput();
+        //});
+      }
+    }
 
-        /// <summary>
-        /// 杩涘叆涓婚〉
-        /// </summary>
-        /// <param name="isFirstOpen">濡傛灉鏄涓�娆″惎鍔� 妫�娴嬫牎楠屽瘑鐮�</param>
-        /// <param name="pageShowEvent">涓婚〉鏄剧ず涔嬪悗瑙﹀彂鐨勪簨浠�(娌℃湁浣忓畢鐨勮瘽,鍒欎笉浼氳Е鍙�)</param>
-        public static void GoUserPage(bool downloadData , bool isFirstOpen = false, Action pageShowEvent = null)
-        {     
-            BaseView.RemoveAll();
-            #region 鍚庨��浜嬩欢
-            BasePageView = new PageLayout();
-            BasePageView.ScrollEnabled = false;
-            BasePageView.IsShowPoint = false;
-            BasePageView.PageChange = (sender, e) =>
-            {
-                if (e < BasePageView.ChildrenCount - 1)
-                {
-                    BasePageView.GetChildren(BasePageView.ChildrenCount - 1).RemoveFromParent();
-                }
-                try
-                {
-                    ReturnRefreshAction?.Invoke();
-                    ReturnRefreshAction = null;
-                }
-                catch (Exception ex)
-                {
-                    Log($"鍚庨��浜嬩欢寮傚父:{ex.Message}");
-                }
-            };
-            BaseView.AddChidren(BasePageView);
-            var backView = new FrameLayout()
-            {
-                Y = Application.GetRealHeight(100),
-                Width = Application.GetRealWidth(10),
-                Height = Application.GetRealHeight(440),
-            };
-            BaseView.AddChidren(backView);
+    /// <summary>
+    /// 杩涘叆鐧诲綍鐣岄潰
+    /// </summary>
+    public static void GoLoginPage(UserInfo userInfo = null)
+    {
+      BaseView.RemoveAll();
+      BaseView.BackgroundColor = CSS_Color.BackgroundColor;
+      var fisrtView = new UI.UI1Login.LoginPage();
+      fisrtView.BackgroundColor = CSS_Color.MainBackgroundColor;
+      BaseView.AddChidren(fisrtView);
+      fisrtView.LoadView(userInfo);
+    }
 
-            BtnBackIcon = new Button()
-            {
-                X = -Application.GetRealWidth(100),
-                Gravity = Gravity.CenterVertical,
-                Width = Application.GetRealWidth(88 / 2),
-                Height = Application.GetRealHeight(56 / 2),
-                UnSelectedImagePath = "Public/RightSlideBackIcon.png"
-            };
-            BaseView.AddChidren(BtnBackIcon);
-            backView.MouseMoveEventHandler = (sender, e) =>
-            {
-                if (BasePageView.ChildrenCount <= 1)
-                {
-                    return;
-                }
-                MainPage.Log($"move:{e.X}");
-                if (StartX == 0 && e.X < 30)
-                {
-                    StartX = (int)e.X;
-                }
-                if (StartX < 30)
-                {
-                    if (e.X < Application.GetRealWidth(100))
-                    {
-                        BtnBackIcon.X = (int)e.X - Application.GetRealWidth(100);
-                    }
-                }
-            };
-            backView.MouseDownEventHandler = (sender, e) =>
-            {
-                if (BasePageView.ChildrenCount <= 1)
-                {
-                    return;
-                }
-                MainPage.Log($"down:{e.X}");
-                StartX = (int)e.X;
-                BtnBackIcon.Y = (int)e.Y + Application.GetRealHeight(50);
-            };
-            backView.MouseUpEventHandler = (sender, e) => {
-                MainPage.Log($"up{e.X}");
-                StartX = 0;
-                BtnBackIcon.X = -Application.GetRealWidth(100);
+    /// <summary>
+    /// 杩涘叆涓婚〉
+    /// </summary>
+    /// <param name="isFirstOpen">濡傛灉鏄涓�娆″惎鍔� 妫�娴嬫牎楠屽瘑鐮�</param>
+    /// <param name="pageShowEvent">涓婚〉鏄剧ず涔嬪悗瑙﹀彂鐨勪簨浠�(娌℃湁浣忓畢鐨勮瘽,鍒欎笉浼氳Е鍙�)</param>
+    public static void GoUserPage(bool downloadData, bool isFirstOpen = false, Action pageShowEvent = null)
+    {
+      BaseView.RemoveAll();
+      #region 鍚庨��浜嬩欢
+      BasePageView = new PageLayout();
+      BasePageView.ScrollEnabled = false;
+      BasePageView.IsShowPoint = false;
+      BasePageView.PageChange = (sender, e) =>
+      {
+        if (e < BasePageView.ChildrenCount - 1)
+        {
+          BasePageView.GetChildren(BasePageView.ChildrenCount - 1).RemoveFromParent();
+        }
+        try
+        {
+          ReturnRefreshAction?.Invoke();
+          ReturnRefreshAction = null;
+        }
+        catch (Exception ex)
+        {
+          Log($"鍚庨��浜嬩欢寮傚父:{ex.Message}");
+        }
+      };
+      BaseView.AddChidren(BasePageView);
+      var backView = new FrameLayout()
+      {
+        Y = Application.GetRealHeight(100),
+        Width = Application.GetRealWidth(10),
+        Height = Application.GetRealHeight(440),
+      };
+      BaseView.AddChidren(backView);
 
-                if (e.X > 70)
-                {
-                    if (BasePageView.ChildrenCount > 1)
-                    {
-                        BasePageView.PageIndex = BasePageView.ChildrenCount - 2;
-                    }
-                }
-            };
-            backView.MouseUpOutsideEventHandler = (sender, e) => {
-                MainPage.Log($"up{e.X}");
-                StartX = 0;
-                BtnBackIcon.X = -Application.GetRealWidth(100);
+      BtnBackIcon = new Button()
+      {
+        X = -Application.GetRealWidth(100),
+        Gravity = Gravity.CenterVertical,
+        Width = Application.GetRealWidth(88 / 2),
+        Height = Application.GetRealHeight(56 / 2),
+        UnSelectedImagePath = "Public/RightSlideBackIcon.png"
+      };
+      BaseView.AddChidren(BtnBackIcon);
+      backView.MouseMoveEventHandler = (sender, e) =>
+      {
+        if (BasePageView.ChildrenCount <= 1)
+        {
+          return;
+        }
+        MainPage.Log($"move:{e.X}");
+        if (StartX == 0 && e.X < 30)
+        {
+          StartX = (int)e.X;
+        }
+        if (StartX < 30)
+        {
+          if (e.X < Application.GetRealWidth(100))
+          {
+            BtnBackIcon.X = (int)e.X - Application.GetRealWidth(100);
+          }
+        }
+      };
+      backView.MouseDownEventHandler = (sender, e) =>
+      {
+        if (BasePageView.ChildrenCount <= 1)
+        {
+          return;
+        }
+        MainPage.Log($"down:{e.X}");
+        StartX = (int)e.X;
+        BtnBackIcon.Y = (int)e.Y + Application.GetRealHeight(50);
+      };
+      backView.MouseUpEventHandler = (sender, e) =>
+      {
+        MainPage.Log($"up{e.X}");
+        StartX = 0;
+        BtnBackIcon.X = -Application.GetRealWidth(100);
 
-                if (e.X > 70)
-                {
-                    if (BasePageView.ChildrenCount > 1)
-                    {
-                        BasePageView.PageIndex = BasePageView.ChildrenCount - 2;
-                    }
-                }
-            };
-            #endregion
+        if (e.X > 70)
+        {
+          if (BasePageView.ChildrenCount > 1)
+          {
+            BasePageView.PageIndex = BasePageView.ChildrenCount - 2;
+          }
+        }
+      };
+      backView.MouseUpOutsideEventHandler = (sender, e) =>
+      {
+        MainPage.Log($"up{e.X}");
+        StartX = 0;
+        BtnBackIcon.X = -Application.GetRealWidth(100);
+
+        if (e.X > 70)
+        {
+          if (BasePageView.ChildrenCount > 1)
+          {
+            BasePageView.PageIndex = BasePageView.ChildrenCount - 2;
+          }
+        }
+      };
+      #endregion
 
 
-            //浣撻獙妯″紡
-            if (NoLoginMode)
-            {
-                //璺宠浆椤甸潰----
-                UserBasePage = new UserPage();
+      //浣撻獙妯″紡
+      if (NoLoginMode)
+      {
+        //璺宠浆椤甸潰----
+        UserBasePage = new UserPage();
+        BasePageView.AddChidren(UserBasePage);
+        UserBasePage.LoadPage();
+        BasePageView.PageIndex = 0;
+
+        return;
+      }
+
+      //鍔犺浇Loading鏁堟灉
+      var waitPage = new Loading();
+      BaseView.AddChidren(waitPage);
+      waitPage.Start(Language.StringByID(StringId.PleaseWait));
+
+      //褰撴病鏈変綇瀹呮椂,涓嶈兘璁╁畠寰�涓嬭蛋
+      if (UserInfo.Current.regionList.Count == 0)
+      {
+        waitPage.Hide();
+        var addResidencePage = new BindingResidencePage();
+        BaseView.AddChidren(addResidencePage);
+        addResidencePage.LoadView();
+        return;
+      }
+      new System.Threading.Thread(async () =>
+      {
+        try
+        {
+          Entity.FunctionList.List.Clear();
+          Entity.SpatialInfo.CurrentSpatial.Clear();
+                ///绛夊緟鑾峰彇浣忓畢淇℃伅
+                Application.RunOnMainThread(() =>
+               {
+                if (waitPage != null)
+                {
+                  waitPage.RemoveFromParent();
+                  waitPage = null;
+                }
+
+                      //璺宠浆椤甸潰----
+                      UserBasePage = new UserPage();
                 BasePageView.AddChidren(UserBasePage);
                 UserBasePage.LoadPage();
                 BasePageView.PageIndex = 0;
 
-                return;
-            }
-
-            //鍔犺浇Loading鏁堟灉
-            var waitPage = new Loading();
-            BaseView.AddChidren(waitPage);
-            waitPage.Start(Language.StringByID(StringId.PleaseWait));
-
-            //褰撴病鏈変綇瀹呮椂,涓嶈兘璁╁畠寰�涓嬭蛋
-            if (UserInfo.Current.regionList.Count == 0)
-            {
-                waitPage.Hide();
-                var addResidencePage = new BindingResidencePage();
-                BaseView.AddChidren(addResidencePage);
-                addResidencePage.LoadView();
-                return;
-            }
-            new System.Threading.Thread(async () =>
-            {
-                try
+                if (isFirstOpen)
                 {
-                    Entity.FunctionList.List.Clear();
-                    Entity.SpatialInfo.CurrentSpatial.Clear();
-                    ///绛夊緟鑾峰彇浣忓畢淇℃伅
-                    Application.RunOnMainThread( () =>
-                    {
-                        if (waitPage != null)
-                        {
-                            waitPage.RemoveFromParent();
-                            waitPage = null;
-                        }
-
-                        //璺宠浆椤甸潰----
-                        UserBasePage = new UserPage();
-                        BasePageView.AddChidren(UserBasePage);
-                        UserBasePage.LoadPage();
-                        BasePageView.PageIndex = 0;
-
-                        if (isFirstOpen)
-                        {
-                            //鍚姩瀵嗙爜楠岃瘉
-                            new AppUnlockPage().LoadPage(isFirstOpen);
-                        }
-                        //涓婚〉鍔犺浇瀹屾垚,鍥炶皟浜嬩欢
-                        pageShowEvent?.Invoke();
-                        pageShowEvent = null;
-                    });
+                        //鍚姩瀵嗙爜楠岃瘉
+                        new AppUnlockPage().LoadPage(isFirstOpen);
                 }
-                catch (Exception ex)
-                {
-                    MainPage.Log($"GoUserPage : {ex.Message}");
-                }finally
-                {
-                    Application.RunOnMainThread(() =>
-                    {
-                        if (downloadData)
-                        {
-                            DB_ResidenceData.Instance.EixtAccount();
-                            ///鍒濆鍖朼pp鏁版嵁
-                            Common.ApiUtlis.Ins.DownloadData();
-                        };
-                    });
-                }
-            }).Start();
-
+                      //涓婚〉鍔犺浇瀹屾垚,鍥炶皟浜嬩欢
+                      pageShowEvent?.Invoke();
+                pageShowEvent = null;
+              });
         }
-
-        /// <summary>
-        /// 鍚庨��浜嬩欢
-        /// 0:鍚庨��
-        /// 1:鏈夌瓑寰呯晫闈�
-        /// 2:鏃犳硶鍐嶅悗閫�锛屽彲浠ユ墽琛岄��鍒版闈�
-        /// </summary>
-        public static int LoadEvent_BackAction()
+        catch (Exception ex)
         {
-            int result = 0;
-            Application.RunOnMainThread(() =>
+          MainPage.Log($"GoUserPage : {ex.Message}");
+        }
+        finally
+        {
+          Application.RunOnMainThread(() =>
+                {
+                if (downloadData)
+                {
+                  DB_ResidenceData.Instance.EixtAccount();
+                        ///鍒濆鍖朼pp鏁版嵁
+                        Common.ApiUtlis.Ins.DownloadData();
+                };
+              });
+        }
+      }).Start();
+
+    }
+
+    /// <summary>
+    /// 鍚庨��浜嬩欢
+    /// 0:鍚庨��
+    /// 1:鏈夌瓑寰呯晫闈�
+    /// 2:鏃犳硶鍐嶅悗閫�锛屽彲浠ユ墽琛岄��鍒版闈�
+    /// </summary>
+    public static int LoadEvent_BackAction()
+    {
+      int result = 0;
+      Application.RunOnMainThread(() =>
+      {
+        if (BasePageView == null || BasePageView.ChildrenCount <= 1)
+        {
+          result = 2;//鏃犳硶鍐嶅悗閫�锛屽彲浠ユ墽琛岄��鍒版闈�
+              }
+        if (BasePageView.ChildrenCount > 1)
+        {
+          int index = BasePageView.ChildrenCount - 1;
+          var view = BasePageView.GetChildren(index);
+          if (view.GetType() == typeof(Loading))
+          {
+            var loading = view as Loading;
+            if (loading.CurStatus == false)//鏈変竴浜涚瓑寰呯晫闈㈤殣钘忎簡锛屼絾鏄病鏈夌Щ闄ゅ埌锛岄渶瑕佸厛绉婚櫎
+                  {
+              loading.RemoveFromParent();
+              result = LoadEvent_BackAction();
+            }
+            else
             {
-                if (BasePageView == null || BasePageView.ChildrenCount<=1 )
+              result = 1;//姝e湪绛夊緟鏌愪簺鎿嶄綔
+                  }
+          }
+          else
+          {
+            if (view != null)
+            {
+              if (view.Tag != null)
+              {
+                if (view.Tag.ToString() != "unlockpage")
                 {
-                    result = 2;//鏃犳硶鍐嶅悗閫�锛屽彲浠ユ墽琛岄��鍒版闈�
-                }
-                if (BasePageView.ChildrenCount > 1)
-                {
-                    int index = BasePageView.ChildrenCount - 1;
-                    var view = BasePageView.GetChildren(index);
-                    if (view.GetType() == typeof(Loading))
-                    {
-                        var loading = view as Loading;
-                        if (loading.CurStatus == false)//鏈変竴浜涚瓑寰呯晫闈㈤殣钘忎簡锛屼絾鏄病鏈夌Щ闄ゅ埌锛岄渶瑕佸厛绉婚櫎
-                        {
-                            loading.RemoveFromParent();
-                            result = LoadEvent_BackAction();
-                        }
-                        else
-                        {
-                            result = 1;//姝e湪绛夊緟鏌愪簺鎿嶄綔
-                        }
-                    }
-                    else
-                    {
-                        if (view != null)
-                        {
-                            if(view.Tag!=null )
-                            {
-                                if (view.Tag.ToString() != "unlockpage")
-                                {
-                                    view.RemoveFromParent();
-                                }else
-                                {
-                                    result = 2;
-                                }
-                            }else
-                            {
-                                view.RemoveFromParent();
-                            }
-                        }
-                    }
+                  view.RemoveFromParent();
                 }
                 else
                 {
-                    result = 2;//鏃犳硶鍐嶅悗閫�锛屽彲浠ユ墽琛岄��鍒版闈�
+                  result = 2;
                 }
-            });
-            return result;
+              }
+              else
+              {
+                view.RemoveFromParent();
+              }
+            }
+          }
         }
-
-
-        /// <summary>
-        /// 鑷畾涔夋棩蹇楄緭鍑�
-        /// </summary>
-        public static void Log(string msg)
+        else
         {
-#if DEBUG
-            Console.WriteLine(msg);
-#endif
-        }
-
-
+          result = 2;//鏃犳硶鍐嶅悗閫�锛屽彲浠ユ墽琛岄��鍒版闈�
+              }
+      });
+      return result;
     }
 
+
+    /// <summary>
+    /// 鑷畾涔夋棩蹇楄緭鍑�
+    /// </summary>
+    public static void Log(string msg)
+    {
+#if DEBUG
+      Console.WriteLine(msg);
+#endif
+    }
+
+
+  }
+
 }
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs
index 3d72d3f..a260eab 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs
@@ -11,7 +11,6 @@
     }
     public void Show()
     {
-
       LogicView.TopView topView = new LogicView.TopView();
       this.AddChidren(topView.FLayoutView());
       topView.clickBackBtn.MouseUpEventHandler += (e, sen) =>
@@ -106,12 +105,12 @@
       //瀹ゅ鍙樺寲
       shiwaiView.btnClick.MouseUpEventHandler += (sen, e) =>
       {
-              //if (string.IsNullOrEmpty(Entity.DB_ResidenceData.Instance.CurrentRegion.homeAddress))//.longitude == 0 && Entity.DB_ResidenceData.Instance.CurrentRegion.latitude == 0)
-              //{
-              //    new PublicAssmebly().TipMsg(StringId.tip, StringId.GatewayLocationInformationIsNotConfigured);
-              //    return;
-              //}
-              Weather weather = new Weather();
+        //if (string.IsNullOrEmpty(Entity.DB_ResidenceData.Instance.CurrentRegion.homeAddress))//.longitude == 0 && Entity.DB_ResidenceData.Instance.CurrentRegion.latitude == 0)
+        //{
+        //    new PublicAssmebly().TipMsg(StringId.tip, StringId.GatewayLocationInformationIsNotConfigured);
+        //    return;
+        //}
+        Weather weather = new Weather();
         MainPage.BasePageView.AddChidren(weather);
         weather.Show();
         MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
@@ -215,59 +214,59 @@
          string valueStr = "arrive";
          if (str == Language.StringByID(StringId.daoda))
          {
-                 //鍒拌揪鏌愬湴
-                 valueStr = "arrive";
+           //鍒拌揪鏌愬湴
+           valueStr = "arrive";
          }
          else
          {
-                 //绂诲紑
-                 valueStr = "leave";
+           //绂诲紑
+           valueStr = "leave";
          }
 
 #if __Android__
                  //鐢宠瀹氫綅鏉冮檺
                  ((BaseActivity)Application.Activity).SetGPSLocationPermission((result1) =>
                   {
-                      if (result1 == false) { return; }
+                    if (result1 == false) { return; }
 
                   //鐢宠鍏佽绋嬪簭鍐欏叆澶栭儴瀛樺偍锛屽SD鍗′笂鍐欐枃浠�
                   ((BaseActivity)Application.Activity).SetPermission((result2) =>
                   {
-                      if (result2 == false) { return; }
+                    if (result2 == false) { return; }
                        //璇诲彇鐢佃瘽鐘舵�佹潈闄�
                        ((BaseActivity)Application.Activity).SetPermission((result3) =>
                        {
-                           if (result3 == false) { return; }
+                         if (result3 == false) { return; }
 
-                           //璋冪敤鏂规硶锛岃烦杞〉闈�
-                           GDMapKit.Show((mLatitude, mLongitude, mRadius, name) =>
-                            {
-                               //楂樺痉鍧愭爣杞琖GS84鍧愭爣(楂樺痉鍦板浘璁剧疆GPS)
-                               double out_lng, out_lat;
-                                LogicMethod.CurrLogicMethod.GCJ02_to_WGS84(mLongitude, mLatitude, out out_lng, out out_lat);
-                                Input input = new Input();
-                                input.sid = LogicMethod.CurrLogicMethod.NewSid();
-                                input.condition_type = "8";
-                                Dictionary<string, string> dic = new Dictionary<string, string>();
-                                LogicMethod.CurrLogicMethod.dictionary(dic, "key", "direction");
-                                LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", "=");
-                                LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "string");
-                                LogicMethod.CurrLogicMethod.dictionary(dic, "value", valueStr);
-                                input.condition.Add(dic);
-                               //绾害
-                               input.geo_fence.latitude = out_lat.ToString();
-                               //缁忓害
-                               input.geo_fence.longitude = out_lng.ToString();
-                               //鍗婂緞<鍗曚綅绫�>
-                               input.geo_fence.radius = mRadius.ToString();
-                                AddCondition(input);
-                                LogicMethod.CurrLogicMethod.RemoveAllView();
-                                AddLogic addLogic = new AddLogic();
-                                MainPage.BasePageView.AddChidren(addLogic);
-                                addLogic.Show();
-                                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                         //璋冪敤鏂规硶锛岃烦杞〉闈�
+                         GDMapKit.Show((mLatitude, mLongitude, mRadius, name) =>
+                          {
+                            //楂樺痉鍧愭爣杞琖GS84鍧愭爣(楂樺痉鍦板浘璁剧疆GPS)
+                            double out_lng, out_lat;
+                            LogicMethod.CurrLogicMethod.GCJ02_to_WGS84(mLongitude, mLatitude, out out_lng, out out_lat);
+                            Input input = new Input();
+                            input.sid = LogicMethod.CurrLogicMethod.NewSid();
+                            input.condition_type = "8";
+                            Dictionary<string, string> dic = new Dictionary<string, string>();
+                            LogicMethod.CurrLogicMethod.dictionary(dic, "key", "direction");
+                            LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", "=");
+                            LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "string");
+                            LogicMethod.CurrLogicMethod.dictionary(dic, "value", valueStr);
+                            input.condition.Add(dic);
+                            //绾害
+                            input.geo_fence.latitude = out_lat.ToString();
+                            //缁忓害
+                            input.geo_fence.longitude = out_lng.ToString();
+                            //鍗婂緞<鍗曚綅绫�>
+                            input.geo_fence.radius = mRadius.ToString();
+                            AddCondition(input);
+                            LogicMethod.CurrLogicMethod.RemoveAllView();
+                            AddLogic addLogic = new AddLogic();
+                            MainPage.BasePageView.AddChidren(addLogic);
+                            addLogic.Show();
+                            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
 
-                            }, strname, Language.StringByID(StringId.save), true, latitude, longitude, r);
+                          }, strname, Language.StringByID(StringId.save), true, latitude, longitude, r);
 
                        }, "android.permission.READ_PHONE_STATE");
 
@@ -305,7 +304,7 @@
             MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
           }, strname, Language.StringByID(StringId.save), true, latitude, longitude, r);
 #endif
-             });
+       });
 
 
     }
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
index c6f3113..6c1e70f 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
@@ -827,16 +827,23 @@
     /// <summary>
     /// APP涓婃姤GPS缁忕含搴�
     /// </summary>
-    public void AppLatAndLonEvent()
+    /// <param name="lon">APP GPS缁忓害</param>
+    /// <param name="lat">APP GPS绾害</param>
+    public void AppLatAndLonEvent(double lon, double lat)
     {
-      Application.LocationAction += (lon, lat) =>
-      {
-        ////GPS鍧愭爣杞垚楂樺痉鍧愭爣
-        //double out_lng, out_lat;
-        //this.WGS84_to_GCJ02(lon, lat, out out_lng, out out_lat);
-        //涓婃姤缁忕含搴�
-        this.AutomatedGeofenceStatusReporting(lon, lat);
-      };
+      Console.WriteLine($"GPS缁忓害===={lon}  \nGPS绾害===={lat}");
+      //Application.LocationAction += (lon, lat) =>
+      //{
+      //  Console.WriteLine($"GPS缁忓害===={lon}");
+      //  Console.WriteLine($"GPS绾害===={lat}");
+      //  ////GPS鍧愭爣杞垚楂樺痉鍧愭爣
+      //  //double out_lng, out_lat;
+      //  //this.WGS84_to_GCJ02(lon, lat, out out_lng, out out_lat);
+      //  //涓婃姤缁忕含搴�
+      //  this.AutomatedGeofenceStatusReporting(lon, lat);
+      //};
+      //涓婃姤缁忕含搴�<gps 涓婃姤鏉′欢澶т簬30绉掍笖绉诲姩璺濈澶т簬100绫筹紝涓婃姤缁忕含搴�>
+      this.AutomatedGeofenceStatusReporting(lon, lat);
     }
 
     /// <summary>
@@ -848,69 +855,78 @@
     {
       List<LogicData> logicDataList = new List<LogicData>();
       logicDataList.Clear();
-      //鑾峰彇閫昏緫ID鍒楄〃
-      var idStr = Send.GetLogicIdList();
-      if (idStr.Code == "0" && idStr.Data != null && idStr.Data.ToString() != "")
+      System.Threading.Tasks.Task.Run(() =>
       {
-        var date = Newtonsoft.Json.JsonConvert.SerializeObject(idStr.Data);
-        logicDataList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LogicData>>(date);
-      }
-      ///鏈夎嚜鍔ㄥ垪琛ㄦ墠澶勭悊
-      if (logicDataList.Count > 0)
-      {
-        ///閬嶅巻鎵�鏈夊垪琛�
-        for (int i = 0; i < logicDataList.Count; i++)
+        try
         {
-          var logicDate = logicDataList[i];
-          ///鑷姩鍖栨病鏈夐厤缃湴鐞嗗洿鏍忎笉澶勭悊
-          if (string.IsNullOrEmpty(logicDate.geo_fence.latitude) || string.IsNullOrEmpty(logicDate.geo_fence.longitude))
+          //鑾峰彇閫昏緫ID鍒楄〃<澶囨敞:濡傛灉鍙拡瀵瑰綋鍓嶆墜鏈虹殑璇濓紝鍙互鐩存帴鎷跨紦瀛樻暟鎹嚜鍔ㄥ寲鍒楄〃閬嶅巻>
+          var idStr = Send.GetLogicIdList();
+          if (idStr.Code == "0" && idStr.Data != null && idStr.Data.ToString() != "")
           {
-            //缁忕含搴︿负绌�,璁や负鑷姩鍖栨病鏈夐厤缃湴鐞嗗洿鏍忥紝涓嶅鐞�;
-            continue;
+            var date = Newtonsoft.Json.JsonConvert.SerializeObject(idStr.Data);
+            logicDataList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LogicData>>(date);
           }
-          //鑷姩鍖栭厤缃緭鍏ユ潯浠剁含搴�
-          double lat = Convert.ToDouble(logicDate.geo_fence.latitude);
-          //鑷姩鍖栭厤缃緭鍏ユ潯浠剁粡搴�
-          double lon = Convert.ToDouble(logicDate.geo_fence.longitude);
-          //鑷姩鍖栭厤缃緭鍏ユ潯浠�<鍦扮悊鍥存爮鍗婂緞><鍗曚綅锛屽叕閲屻�佸崈绫�.绫�>
-          int radius = int.Parse(logicDate.geo_fence.radius);
-          //璁$畻2涓粡绾害涔嬮棿鐨勮窛绂�
-          int r = Infrastructure.Service.Helper.CalculatedDistance.Distance(out_lat, out_lng, lat, lon);
-          //瀹氫箟涓�涓眬閮ㄥ彉閲�
-          string direction = string.Empty;
-          //涓ょ偣璺濈灏忎簬閰嶇疆璺濈<鏃㈣嚜鍔ㄥ寲閰嶇疆杈撳叆鏉′欢鍦扮悊鍥存爮鍗婂緞>,璇存槑杩涘叆鍖哄煙
-          if (r < radius)
+          ///鏈夎嚜鍔ㄥ垪琛ㄦ墠澶勭悊
+          if (logicDataList.Count > 0)
           {
-            //鍒拌揪鏌愬湴
-            direction = "arrive";
-          }
-          else
-          {
-            //绂诲紑
-            direction = "leave";
-          }
-          var isPush = pushList.Find((o) => o.homeId == HomeId && o.userId == UserInfo.Current.ID && o.userLogicId == logicDate.userLogicId && o.arriveOnLeave == direction);
-          if (isPush == null)
-          {
-            //鎺ㄩ�佺粰浜戠鏄惁鎴愬姛
-            bool push = Send.GeoFenceStateReport(logicDate.userLogicId, logicDate.sid, direction);
-            if (push)
+            ///閬嶅巻鎵�鏈夊垪琛�
+            for (int i = 0; i < logicDataList.Count; i++)
             {
-              pushList.Add(new Push
+              var logicDate = logicDataList[i];
+              ///鑷姩鍖栨病鏈夐厤缃湴鐞嗗洿鏍忎笉澶勭悊
+              if (string.IsNullOrEmpty(logicDate.geo_fence.latitude) || string.IsNullOrEmpty(logicDate.geo_fence.longitude))
               {
-                homeId = HomeId,
-                userId = UserInfo.Current.ID,
-                userLogicId = logicDate.userLogicId,
-                arriveOnLeave = direction,
-              });
+                //缁忕含搴︿负绌�,璁や负鑷姩鍖栨病鏈夐厤缃湴鐞嗗洿鏍忥紝涓嶅鐞�;
+                continue;
+              }
+              //鑷姩鍖栭厤缃緭鍏ユ潯浠剁含搴�
+              double lat = Convert.ToDouble(logicDate.geo_fence.latitude);
+              //鑷姩鍖栭厤缃緭鍏ユ潯浠剁粡搴�
+              double lon = Convert.ToDouble(logicDate.geo_fence.longitude);
+              //鑷姩鍖栭厤缃緭鍏ユ潯浠�<鍦扮悊鍥存爮鍗婂緞><鍗曚綅锛屽叕閲屻�佸崈绫�.绫�>
+              int radius = int.Parse(logicDate.geo_fence.radius);
+              //璁$畻2涓粡绾害涔嬮棿鐨勮窛绂�
+              int r = Infrastructure.Service.Helper.CalculatedDistance.Distance(out_lat, out_lng, lat, lon);
+              //瀹氫箟涓�涓眬閮ㄥ彉閲�
+              string direction = string.Empty;
+              //涓ょ偣璺濈灏忎簬閰嶇疆璺濈<鏃㈣嚜鍔ㄥ寲閰嶇疆杈撳叆鏉′欢鍦扮悊鍥存爮鍗婂緞>,璇存槑杩涘叆鍖哄煙
+              if (r < radius)
+              {
+                //鍒拌揪鏌愬湴
+                direction = "arrive";
+              }
+              else
+              {
+                //绂诲紑
+                direction = "leave";
+              }
+              var isPush = pushList.Find((o) => o.homeId == HomeId && o.userId == UserInfo.Current.ID && o.userLogicId == logicDate.userLogicId && o.arriveOnLeave == direction);
+              if (isPush == null)
+              {
+                //鎺ㄩ�佺粰浜戠鏄惁鎴愬姛
+                bool push = Send.GeoFenceStateReport(logicDate.userLogicId, logicDate.sid, direction);
+                if (push)
+                {
+                  ///娣诲姞鍒版帹閫佸垪琛�
+                  pushList.Add(new Push
+                  {
+                    homeId = HomeId,
+                    userId = UserInfo.Current.ID,
+                    userLogicId = logicDate.userLogicId,
+                    sid = logicDate.sid,
+                    arriveOnLeave = direction,
+                  });
+                }
+              }
             }
+
           }
         }
-
-      }
+        catch { }
+      });
     }
     /// <summary>
-    /// 
+    /// 鎺ㄩ�佸垪琛�<杩欓噷鏁版嵁宸茬粡鎺ㄩ�佽繃>
     /// </summary>
     private static List<Push> pushList = new List<Push>();
 

--
Gitblit v1.8.0