| | |
| | | /// <param name="pra">请求的参数</param>
|
| | | public static bool CheckNotEorrorMsg(ResponsePack revertObj, string RequestName, List<string> listNotShowError = null, object pra = null)
|
| | | {
|
| | | if (listNotShowError != null && listNotShowError.Contains("NotCheck") == true)
|
| | | {
|
| | | //不检测
|
| | | return true;
|
| | | }
|
| | | if (revertObj == null)
|
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | |
| | | var formTemp = UserCenterResourse.DicActionForm[formName];
|
| | | formTemp.CloseForm();
|
| | | UserCenterResourse.DicActionForm.Remove(formName);
|
| | | formTemp = null;
|
| | |
|
| | | return true;
|
| | | }
|
| | |
| | | catch (Exception ex)
|
| | | {
|
| | | //出现未知错误,数据丢失
|
| | | var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnknownErrorAndDataLost));
|
| | | var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError));
|
| | | alert.Show();
|
| | |
|
| | | //Log出力
|
| | |
| | | catch (Exception ex)
|
| | | {
|
| | | //出现未知错误,数据丢失
|
| | | var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnknownErrorAndDataLost));
|
| | | var alert = new ShowMsgControl(ShowMsgType.Error, Language.StringByID(R.MyInternationalizationString.uUnKnownError));
|
| | | alert.Show();
|
| | |
|
| | | //Log出力
|
| | |
| | | //移除ID
|
| | | UserCenterResourse.listActionFormId.Remove(UserCenterResourse.DicActionForm[formName].FormID);
|
| | | //移除画面
|
| | | var formTemp = UserCenterResourse.DicActionForm[formName];
|
| | | UserCenterResourse.DicActionForm.Remove(formName);
|
| | | formTemp = null;
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | //关闭所有接收
|
| | | HdlGatewayReceiveLogic.Current.RemoveAllEvent();
|
| | | //清除升级列表
|
| | | FirmwareUpdateResourse.dicDeviceUpdateList.Clear();
|
| | | FirmwareUpdateResourse.dicGatewayUpdateList.Clear();
|
| | | FirmwareUpdateResourse.dicUpdateList.Clear();
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | |
| | | }
|
| | | catch { }
|
| | |
|
| | | if (noticeDb == true)
|
| | | {
|
| | | //通知云端,已经退出登陆
|
| | | var result = await CommonPage.Instance.RequestHttpsZigbeeBytesResultAsync("ZigbeeUsers/SignOut", null, "GET");
|
| | | }
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //关闭所有打开了的界面
|
| | |
| | | Shared.Common.CommonPage.Instance.AddChidren(formLogin);
|
| | | formLogin.Show(account);
|
| | | });
|
| | |
|
| | | if (noticeDb == true)
|
| | | {
|
| | | //通知云端,已经退出登陆
|
| | | var result = await CommonPage.Instance.RequestHttpsZigbeeBytesResultAsync("ZigbeeUsers/SignOut", null, "GET");
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | |
| | | /// <summary>
|
| | | /// 异步方法执行(仅限切换住宅时调用),刷新个人中心的内存及线程
|
| | | /// </summary>
|
| | | public async static Task<bool> InitUserCenterMenmoryAndThread()
|
| | | /// <param name="ShowPrompted">新追加变量:是否显示提示自动备份的界面</param>
|
| | | /// <returns></returns>
|
| | | public async static Task<bool> InitUserCenterMenmoryAndThread(bool ShowPrompted = true)
|
| | | {
|
| | | //APP缓存加载开始
|
| | | UserCenterResourse.Option.AppCanSignout = false;
|
| | | //还原远程连接变量
|
| | | ZigBee.Device.ZbGateway.AllowRemoteCtrl = true;
|
| | |
|
| | | //只有在住宅ID不一样的时候才做这个操作
|
| | | if (Common.Config.Instance.HomeId != UserCenterResourse.Option.OldHomeStringId
|
| | |
| | | try
|
| | | {
|
| | | //断开远程Mqtt连接
|
| | | ZigBee.Device.ZbGateway.DisConnectRemoteMqttClient();
|
| | | await ZigBee.Device.ZbGateway.DisConnectRemoteMqttClient();
|
| | | }
|
| | | catch { }
|
| | |
|
| | |
| | | {
|
| | | //重新发送命令去绑定断网情况下备份的网关
|
| | | HdlGatewayLogic.Current.ResetComandToBindBackupGateway();
|
| | | //读取隐匿配置
|
| | | await HdlBackupLogic.Current.LoadHideOption();
|
| | | }
|
| | |
|
| | | //初始化缓存成员的信息
|
| | |
| | | HdlGatewayLogic.Current.SynchronizeDbGateway();
|
| | | }
|
| | |
|
| | | //初始化住宅对象
|
| | | Common.Config.Instance.Home = House.GetHouseByHouseId(Common.Config.Instance.HomeId);
|
| | |
|
| | | //初始化房间(郭雪城那边不做处理,需要这里特殊执行一步)
|
| | | Room.RefreshAllRoomByLocation();
|
| | |
|
| | |
| | | HdlGatewayLogic.Current.RefreshAppOldSelectGatewayId();
|
| | |
|
| | | //0:已经同步过,不需要同步,这个时候需要提示备份
|
| | | if (result == 0)
|
| | | if (result == 0 && ShowPrompted == true)
|
| | | {
|
| | | //开启自动备份提示
|
| | | HdlAutoBackupLogic.ShowAutoBackupPromptedForm();
|
| | | }
|
| | | //显示引导界面
|
| | | ShowGuideForm(result);
|
| | | }
|
| | | //APP缓存加载完成
|
| | | UserCenterResourse.Option.AppCanSignout = true;
|
| | |
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 引导界面___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 显示引导界面
|
| | | /// </summary>
|
| | | /// <param name="result">同步结果 -1:异常 0:已经同步过,不需要同步 1:正常同步 2:没有自动备份数据</param>
|
| | | private static void ShowGuideForm(int result)
|
| | | {
|
| | | var checkFile = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, DirNameResourse.GuideFile);
|
| | | if (System.IO.File.Exists(checkFile) == true)
|
| | | {
|
| | | //不需要显示
|
| | | return;
|
| | | }
|
| | | if (result == 2 && Config.Instance.Home.IsOthreShare == false)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | var form = new Guide.GuideHouseForm();
|
| | | form.ShowFrom();
|
| | | });
|
| | | }
|
| | |
|
| | | //创建一个空文件(标识已经完成引导)
|
| | | var file = System.IO.File.Create(checkFile);
|
| | | file.Close();
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 16进制转化_________________________
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <returns></returns>
|
| | | public static string EncryptPassword(string keys, string strPsw)
|
| | | {
|
| | | if (strPsw == string.Empty)
|
| | | try
|
| | | {
|
| | | return strPsw;
|
| | | if (strPsw == string.Empty)
|
| | | {
|
| | | return strPsw;
|
| | | }
|
| | | var des = new System.Security.Cryptography.DESCryptoServiceProvider();
|
| | | byte[] inputByteArray = Encoding.Default.GetBytes(strPsw);
|
| | | des.Key = ASCIIEncoding.ASCII.GetBytes(keys);
|
| | | des.IV = ASCIIEncoding.ASCII.GetBytes(keys);
|
| | | var ms = new System.IO.MemoryStream();
|
| | | var cs = new System.Security.Cryptography.CryptoStream(ms, des.CreateEncryptor(), System.Security.Cryptography.CryptoStreamMode.Write);
|
| | | cs.Write(inputByteArray, 0, inputByteArray.Length);
|
| | | cs.FlushFinalBlock();
|
| | | StringBuilder ret = new StringBuilder();
|
| | | foreach (byte b in ms.ToArray())
|
| | | {
|
| | | ret.AppendFormat("{0:X2}", b);
|
| | | }
|
| | | return ret.ToString().ToLower();
|
| | | }
|
| | | var des = new System.Security.Cryptography.DESCryptoServiceProvider();
|
| | | byte[] inputByteArray = Encoding.Default.GetBytes(strPsw);
|
| | | des.Key = ASCIIEncoding.ASCII.GetBytes(keys);
|
| | | des.IV = ASCIIEncoding.ASCII.GetBytes(keys);
|
| | | var ms = new System.IO.MemoryStream();
|
| | | var cs = new System.Security.Cryptography.CryptoStream(ms, des.CreateEncryptor(), System.Security.Cryptography.CryptoStreamMode.Write);
|
| | | cs.Write(inputByteArray, 0, inputByteArray.Length);
|
| | | cs.FlushFinalBlock();
|
| | | StringBuilder ret = new StringBuilder();
|
| | | foreach (byte b in ms.ToArray())
|
| | | {
|
| | | ret.AppendFormat("{0:X2}", b);
|
| | | }
|
| | | return ret.ToString();
|
| | | catch { return strPsw; }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <returns></returns>
|
| | | public static string DecryptPassword(string keys, string strPsw)
|
| | | {
|
| | | if (strPsw == string.Empty)
|
| | | try
|
| | | {
|
| | | return strPsw;
|
| | | if (strPsw == string.Empty)
|
| | | {
|
| | | return strPsw;
|
| | | }
|
| | | var des = new System.Security.Cryptography.DESCryptoServiceProvider();
|
| | |
|
| | | byte[] inputByteArray = new byte[strPsw.Length / 2];
|
| | | for (int x = 0; x < strPsw.Length / 2; x++)
|
| | | {
|
| | | int i = (Convert.ToInt32(strPsw.Substring(x * 2, 2), 16));
|
| | | inputByteArray[x] = (byte)i;
|
| | | }
|
| | |
|
| | | des.Key = ASCIIEncoding.ASCII.GetBytes(keys);
|
| | | des.IV = ASCIIEncoding.ASCII.GetBytes(keys);
|
| | | var ms = new System.IO.MemoryStream();
|
| | | var cs = new System.Security.Cryptography.CryptoStream(ms, des.CreateDecryptor(), System.Security.Cryptography.CryptoStreamMode.Write);
|
| | | cs.Write(inputByteArray, 0, inputByteArray.Length);
|
| | | cs.FlushFinalBlock();
|
| | |
|
| | | StringBuilder ret = new StringBuilder();
|
| | |
|
| | | return System.Text.Encoding.Default.GetString(ms.ToArray());
|
| | | }
|
| | | var des = new System.Security.Cryptography.DESCryptoServiceProvider();
|
| | |
|
| | | byte[] inputByteArray = new byte[strPsw.Length / 2];
|
| | | for (int x = 0; x < strPsw.Length / 2; x++)
|
| | | {
|
| | | int i = (Convert.ToInt32(strPsw.Substring(x * 2, 2), 16));
|
| | | inputByteArray[x] = (byte)i;
|
| | | }
|
| | |
|
| | | des.Key = ASCIIEncoding.ASCII.GetBytes(keys);
|
| | | des.IV = ASCIIEncoding.ASCII.GetBytes(keys);
|
| | | var ms = new System.IO.MemoryStream();
|
| | | var cs = new System.Security.Cryptography.CryptoStream(ms, des.CreateDecryptor(), System.Security.Cryptography.CryptoStreamMode.Write);
|
| | | cs.Write(inputByteArray, 0, inputByteArray.Length);
|
| | | cs.FlushFinalBlock();
|
| | |
|
| | | StringBuilder ret = new StringBuilder();
|
| | |
|
| | | return System.Text.Encoding.Default.GetString(ms.ToArray());
|
| | | catch { return strPsw; }
|
| | | }
|
| | | #endregion
|
| | |
|