xm
2021-11-24 e7385e16297cc9659d0cc0eaf3cdf0786a3d35ce
2021-11-24-01

优化地理围栏上报功能
5个文件已修改
1770 ■■■■ 已修改文件
.vs/HDL_APP_Project/xs/UserPrefs.xml 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL-ON_Android/Application.cs 716 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/MainPage.cs 807 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs 85 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs 136 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.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>
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";
                }
                //获取极光推送ID
                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";
        }
        //获取极光推送ID
        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:foreground");
        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正在连接重置状态
      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:foreground");
                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正在连接重置状态
            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()
    {
    }
  }
}
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>
    ///// 公司代码
    ///// 预留第三方定制标记
    ///// 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>
        ///// 公司代码
        ///// 预留第三方定制标记
        ///// 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();
                            ///初始化app数据
                            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();
                        ///初始化app数据
                        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;//正在等待某些操作
                  }
          }
          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;//正在等待某些操作
                        }
                    }
                    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
    }
  }
}
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) =>
                            {
                               //高德坐标转WGS84坐标(高德地图设置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) =>
                          {
                            //高德坐标转WGS84坐标(高德地图设置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
             });
       });
    }
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>();