| | |
| | | /// <param name="checkAuthority">是否检测权限,该参数不能省略</param>
|
| | | /// <param name="obj">一个类</param>
|
| | | /// <param name="listNotShowError">不需要显示错误的错误类别(接口返回的错误类别),如果包含,则会返回【true】</param>
|
| | | /// <param name="setAgain">当发送失败时,是否重发,默认不重发</param>
|
| | | public static bool GetResultStatuByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = false)
|
| | | /// <param name="setAgain">当发送失败时,是否重发,默认重发</param>
|
| | | public static bool GetResultStatuByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = true)
|
| | | {
|
| | | if (HdlWifiLogic.Current.CanAccessHttp == false && setAgain == false)
|
| | | {
|
| | | //当前无法访问网络(当需要重新发送时,跳过这个判断)
|
| | | ShowNotNetMsg(listNotShowError);
|
| | | return false;
|
| | | }
|
| | | //获取接口的连接模式
|
| | | var connectMode = GetHttpConnectMode(checkAuthority);
|
| | | //获取从接口那里取到的比特数据
|
| | | var byteData = GettByteResponsePack(RequestName, connectMode, obj);
|
| | | if (byteData == null && setAgain == true)
|
| | | if (byteData == null)
|
| | | {
|
| | | if (setAgain == false)
|
| | | {
|
| | | //不指定重发
|
| | | //当前无法访问网络
|
| | | ShowNotNetMsg(RequestName, listNotShowError);
|
| | | return false;
|
| | | }
|
| | | byteData = ResetByteRequestHttps(RequestName, checkAuthority, obj);
|
| | |
| | | /// <param name="checkAuthority">是否检测权限,该参数不能省略</param>
|
| | | /// <param name="obj">一个类</param>
|
| | | /// <param name="listNotShowError">不需要显示错误的错误类别(接口返回的错误类别),如果包含,则会返回【true】</param>
|
| | | /// <param name="setAgain">当发送失败时,是否重发,默认不重发</param>
|
| | | /// <param name="setAgain">当发送失败时,是否重发,默认重发</param>
|
| | | /// </param>
|
| | | public static string GetResultCodeByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = false)
|
| | | public static string GetResultCodeByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = true)
|
| | | {
|
| | | if (HdlWifiLogic.Current.CanAccessHttp == false && setAgain == false)
|
| | | {
|
| | | //当前无法访问网络(当需要重新发送时,跳过这个判断)
|
| | | ShowNotNetMsg(listNotShowError);
|
| | | return "Error";
|
| | | }
|
| | |
|
| | | //获取接口的连接模式
|
| | | var connectMode = GetHttpConnectMode(checkAuthority);
|
| | | //获取从接口那里取到的比特数据
|
| | |
| | | {
|
| | | if (setAgain == false)
|
| | | {
|
| | | //不指定重发
|
| | | //当前无法访问网络
|
| | | ShowNotNetMsg(RequestName, listNotShowError);
|
| | | return "Error";
|
| | | }
|
| | | byteData = ResetByteRequestHttps(RequestName, checkAuthority, obj);
|
| | |
| | | /// <param name="checkAuthority">是否检测权限,该参数不能省略</param>
|
| | | /// <param name="obj">一个类</param>
|
| | | /// <param name="listNotShowError">不需要显示错误的错误类别(接口返回的错误类别),如果包含,则会返回【true】</param>
|
| | | /// <param name="setAgain">当发送失败时,是否重发,默认不重发</param>
|
| | | /// <param name="setAgain">当发送失败时,是否重发,默认重发</param>
|
| | | /// </param>
|
| | | public static string GetResponseDataByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = false)
|
| | | public static string GetResponseDataByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = true)
|
| | | {
|
| | | if (HdlWifiLogic.Current.CanAccessHttp == false && setAgain == false)
|
| | | {
|
| | | //当前无法访问网络(当需要重新发送时,跳过这个判断)
|
| | | ShowNotNetMsg(listNotShowError);
|
| | | return null;
|
| | | }
|
| | | //获取接口的连接模式
|
| | | var connectMode = GetHttpConnectMode(checkAuthority);
|
| | | //获取从接口那里取到的比特数据
|
| | |
| | | {
|
| | | if (setAgain == false)
|
| | | {
|
| | | //不指定重发
|
| | | //当前无法访问网络
|
| | | ShowNotNetMsg(RequestName, listNotShowError);
|
| | | return null;
|
| | | }
|
| | | byteData = ResetByteRequestHttps(RequestName, checkAuthority, obj);
|
| | |
| | | /// <param name="checkAuthority">是否检测权限,该参数不能省略</param>
|
| | | /// <param name="obj">一个类</param>
|
| | | /// <param name="listNotShowError">不需要显示错误的错误类别(接口返回的错误类别),如果包含,则会返回【true】</param>
|
| | | /// <param name="setAgain">当发送失败时,是否重发,默认不重发</param>
|
| | | public static byte[] GetByteResponseDataByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = false)
|
| | | /// <param name="setAgain">当发送失败时,是否重发,默认重发</param>
|
| | | public static byte[] GetByteResponseDataByRequestHttps(string RequestName, bool checkAuthority, object obj, List<string> listNotShowError = null, bool setAgain = true)
|
| | | {
|
| | | if (HdlWifiLogic.Current.CanAccessHttp == false && setAgain == false)
|
| | | {
|
| | | //当前无法访问网络(当需要重新发送时,跳过这个判断)
|
| | | ShowNotNetMsg(listNotShowError);
|
| | | return null;
|
| | | }
|
| | | //获取接口的连接模式
|
| | | var connectMode = GetHttpConnectMode(checkAuthority);
|
| | | //获取从接口那里取到的比特数据
|
| | |
| | | {
|
| | | if (setAgain == false)
|
| | | {
|
| | | //不指定重发
|
| | | //当前无法访问网络
|
| | | ShowNotNetMsg(RequestName, listNotShowError);
|
| | | return null;
|
| | | }
|
| | | revertObj = ResetByteRequestHttps(RequestName, checkAuthority, obj);
|
| | |
| | | if (count == 3)
|
| | | {
|
| | | //显示没有网络的Msg
|
| | | ShowNotNetMsg(null);
|
| | | ShowNotNetMsg(RequestName, null);
|
| | | break;
|
| | | }
|
| | | }
|
| | |
| | | /// <summary>
|
| | | /// 显示没有网络的Msg
|
| | | /// </summary>
|
| | | private static void ShowNotNetMsg(List<string> listNotShowError)
|
| | | private static void ShowNotNetMsg(string RequestName, List<string> listNotShowError)
|
| | | {
|
| | | if (listNotShowError != null && listNotShowError.Contains("NotCheck") == true)
|
| | | {
|
| | | //不检测
|
| | | return;
|
| | | }
|
| | | //HdlLogLogic.Current.WriteLog(-1, "当前无网络连接:" + RequestName);
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | // 当前无网络连接,请确认网络
|
| | |
| | | #endregion
|
| | |
|
| | | #region ■ 刷新本地缓存_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 刷新本地所有缓存
|
| | | /// 刷新本地所有缓存(目前此方法只提供给恢复备份数据使用)
|
| | | /// </summary>
|
| | | public static void RefreshAllMemory()
|
| | | {
|
| | | //刷新住宅对象
|
| | | RefreshHomeObject();
|
| | | //根据模板文件,恢复数据
|
| | | TemplateData.TemplateCommonLogic.Current.RecoverDataByTemplateBinFile();
|
| | | //强制生成设备和网关文件
|
| | | TemplateData.TemplateCommonLogic.Current.CreatDeviceAndGatewayFileFromMemoryByForce();
|
| | | //刷新本地网关文件
|
| | | HdlGatewayLogic.Current.ReFreshByLocal();
|
| | | //刷新本地设备
|
| | |
| | | //断开远程Mqtt连接,重新连接
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | HdlGatewayLogic.Current.ClearAllRealGateway();
|
| | | HdlGatewayLogic.Current.ClearAllRealGatewayConection(true);
|
| | | await ZigBee.Device.ZbGateway.DisConnectRemoteMqttClient();
|
| | | }, ShowErrorMode.NO);
|
| | | }
|
| | |
| | | /// </summary>
|
| | | public static void RefreshHomeObject()
|
| | | {
|
| | | //备份的数据,有可能是主人自己上传的,如果管理员登陆时,他获取的备份数据有点特殊
|
| | | //比如下面这三个东西在主账号那里是不需要的
|
| | | bool isOthreShare = Config.Instance.Home.IsOthreShare;
|
| | | int accountType = Config.Instance.Home.AccountType;
|
| | | string mainMark = Config.Instance.Home.MainUserDistributedMark;
|
| | | double Longitude = Config.Instance.Home.Longitude;
|
| | | double Latitude = Config.Instance.Home.Latitude;
|
| | | //还原住宅对象
|
| | | Config.Instance.Home = HdlResidenceLogic.Current.GetHouseByHouseId(Config.Instance.Home.Id);
|
| | | Config.Instance.Home.IsOthreShare = isOthreShare;
|
| | | Config.Instance.Home.AccountType = accountType;
|
| | | Config.Instance.Home.MainUserDistributedMark = mainMark;
|
| | | Config.Instance.Home.Longitude = Longitude;
|
| | | Config.Instance.Home.Latitude = Latitude;
|
| | | var home = HdlResidenceLogic.Current.GetHouseByHouseId(Config.Instance.Home.Id);
|
| | |
|
| | | //刷新楼层
|
| | | Config.Instance.Home.FloorDics = home.FloorDics;
|
| | | Config.Instance.Home.CurrentFloorId = string.Empty;
|
| | | if (Config.Instance.Home.TemplateMode == -1)
|
| | | {
|
| | | Config.Instance.Home.TemplateMode = home.TemplateMode;
|
| | | if (Config.Instance.Home.TemplateMode == -1)
|
| | | {
|
| | | //默认初始值
|
| | | Config.Instance.Home.TemplateMode = 1;
|
| | | }
|
| | | }
|
| | |
|
| | | Config.Instance.Home.Save(false);
|
| | |
|
| | | //主页需要重新刷新
|
| | | UserView.UserPage.Instance.RefreshAllForm = true;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | //设定一个时间
|
| | | Config.Instance.LoginDateTime = new DateTime(1970, 1, 1);
|
| | | Config.Instance.Save();
|
| | | //清空当前住宅id
|
| | | Config.Instance.HomeId = string.Empty;
|
| | | //收起左菜单
|
| | | CommonPage.Instance.CloseLeftMenu();
|
| | | //关闭全部弹窗
|
| | | ShowMsgControl.CloseAllMsgDialog();
|
| | | //关闭所有打开了的界面
|
| | | CloseAllOpenForm();
|
| | | CloseAllOpenForm(null, false);
|
| | |
|
| | | //显示登陆画面
|
| | | var formLogin = new Login.AccountLoginForm();
|
| | |
| | |
|
| | | //清空当前住宅id
|
| | | Config.Instance.HomeId = string.Empty;
|
| | | HdlGatewayLogic.Current.ClearAllRealGateway();
|
| | | HdlGatewayLogic.Current.ClearAllRealGatewayConection(false);
|
| | |
|
| | | //断开远程Mqtt连接
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | |
| | | //收起左菜单
|
| | | CommonPage.Instance.CloseLeftMenu();
|
| | | //关闭所有打开了的界面
|
| | | CloseAllOpenForm();
|
| | | CloseAllOpenForm(null, false);
|
| | |
|
| | | //显示登陆画面
|
| | | var formLogin = new Login.AccountLoginForm();
|
| | |
| | | /// 关闭所有打开了的界面
|
| | | /// </summary>
|
| | | /// <param name="tagetFrom">目标界面,如果指定了的话,则关闭目标界面上层的全部界面(它自身不关闭)</param>
|
| | | public static void CloseAllOpenForm(string tagetFrom = null)
|
| | | /// <param name="refreshMainPage">当关闭的界面达到主页时,是否刷新主页</param>
|
| | | public static void CloseAllOpenForm(string tagetFrom = null, bool refreshMainPage = true)
|
| | | {
|
| | | while (UserView.HomePage.Instance.ChildrenCount > 0)
|
| | | {
|
| | |
| | | }
|
| | | else if (view is UserView.UserPage)
|
| | | {
|
| | | //刷新主页
|
| | | if (refreshMainPage == true)
|
| | | {
|
| | | UserView.UserPage.Instance.ReFreshControl();
|
| | | }
|
| | | return;
|
| | | }
|
| | | else
|
| | |
| | | HdlGatewayLogic.Current.ResetComandToBindBackupGateway();
|
| | | //读取隐匿配置
|
| | | HdlBackupLogic.Current.LoadHideOption();
|
| | | //调试:强制开启后台调试App功能
|
| | | if (UserCenterResourse.HideOption.StartDebugApp == 1)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | var form = new HideOption.HideOptionMainForm();
|
| | | form.AddForm();
|
| | | });
|
| | | ProgressBar.Close(true);
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | //关闭所有接收
|
| | |
| | | //断开远程Mqtt连接,重新连接
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | HdlGatewayLogic.Current.ClearAllRealGateway();
|
| | | HdlGatewayLogic.Current.ClearAllRealGatewayConection(true);
|
| | | await ZigBee.Device.ZbGateway.DisConnectRemoteMqttClient();
|
| | | }, ShowErrorMode.NO);
|
| | |
|
| | | //刷新APP前一次选择的网关ID(可以反复调用,需要在网关初始化完了之后才能调用)
|
| | | HdlGatewayLogic.Current.RefreshAppOldSelectGatewayId();
|
| | |
|
| | | //加载模板缓存
|
| | | //TemplateData.TemplateCommonLogic.Current.LoadLocalTemplateMemoryData();
|
| | |
|
| | | //0:已经同步过,不需要同步,这个时候需要提示备份
|
| | | if (result == 0 && ShowPrompted == true)
|
| | |
| | | System.Threading.Thread.Sleep(30);
|
| | | if (hadNet == 1)
|
| | | {
|
| | | try
|
| | | {
|
| | | bool canReceiveGw = false;
|
| | | foreach (var gateway in UserCenterResourse.DicReceiveGatewayTest.Values)
|
| | | {
|
| | | if (gateway.HomeId == Config.Instance.Home.Id)
|
| | | {
|
| | | //能够搜索得到网关
|
| | | canReceiveGw = true;
|
| | | break;
|
| | | }
|
| | | }
|
| | | UserCenterResourse.DicReceiveGatewayTest = null;
|
| | | //设置远程连接的初始值
|
| | | ZigBee.Device.ZbGateway.IsRemote = canReceiveGw == false;
|
| | | if (canReceiveGw == false)
|
| | | {
|
| | | //如果是远程的话,追加等待时间
|
| | | System.Threading.Thread.Sleep(1500);
|
| | | }
|
| | | }
|
| | | catch { }
|
| | | //住宅切换时,检测网关连接情况
|
| | | CheckGatewayConnection();
|
| | |
|
| | | }
|
| | | UserCenterResourse.DicReceiveGatewayTest = null;
|
| | | }
|
| | | //APP缓存加载完成
|
| | | UserCenterResourse.AccountOption.AppCanSignout = true;
|
| | | if (Shared.Phone.Device.Logic.Send.If_Exist == "1")
|
| | | {
|
| | | //以本地状态为主打开GPS服务
|
| | | Application.StartGPSLocationService();
|
| | | }
|
| | |
|
| | | return true;
|
| | | }
|
| | |
| | | HdlRoomLogic.Current.RefreshAllRoomByLocation();
|
| | | //刷新左边刷新房间视图列表
|
| | | HdlRoomLogic.Current.RefreshRoomListView();
|
| | | //加载模板缓存
|
| | | //TemplateData.TemplateCommonLogic.Current.LoadLocalTemplateMemoryData();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | Common.Logic.SoneLogicList.Clear();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 住宅切换时,检测网关连接情况
|
| | | /// </summary>
|
| | | private static void CheckGatewayConnection()
|
| | | {
|
| | | try
|
| | | {
|
| | | bool canReceiveGw = false;
|
| | | foreach (var gateway in UserCenterResourse.DicReceiveGatewayTest.Values)
|
| | | {
|
| | | if (gateway.HomeId == Config.Instance.Home.Id)
|
| | | {
|
| | | //能够搜索得到网关
|
| | | canReceiveGw = true;
|
| | | break;
|
| | | }
|
| | | }
|
| | | UserCenterResourse.DicReceiveGatewayTest = null;
|
| | | //设置远程连接的初始值
|
| | | ZigBee.Device.ZbGateway.IsRemote = canReceiveGw == false;
|
| | | if (canReceiveGw == false)
|
| | | {
|
| | | //如果是远程的话,追加等待时间
|
| | | System.Threading.Thread.Sleep(1500);
|
| | | }
|
| | | }
|
| | | catch { }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化登陆账号的信息_______________
|