From de564e6fd990960ea5796eadfa3b3fda7866a256 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期一, 26 十月 2020 10:53:54 +0800
Subject: [PATCH] V2.510231 1.密码规则修改,修改为:密码必须为8-20个字符,包含字母、数字和符号。 2.APP本地增加登录,密码错误锁定,连续错误5次登录锁定,锁定5分钟。 3.登录界面,增加登录账号的邮箱格式匹配检测。
---
Crabtree/SmartHome/UI/SimpleControl/Phone/AC/UserDeviceToAC.cs | 152 +++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 136 insertions(+), 16 deletions(-)
diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/AC/UserDeviceToAC.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/AC/UserDeviceToAC.cs
index 581f308..a059f8a 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/Phone/AC/UserDeviceToAC.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/AC/UserDeviceToAC.cs
@@ -209,8 +209,8 @@
Button btnMode = new Button () {
X = Application.GetRealWidth (40),
Y = Application.GetRealHeight (40),
- Width = Application.GetRealWidth (100),
- Height = Application.GetRealHeight (100),
+ Width = Application.GetMinRealAverage (100),
+ Height = Application.GetMinRealAverage (100),
Tag = "Mode"
};
acView.AddChidren (btnMode);
@@ -220,8 +220,8 @@
Button btnWind = new Button () {
X = btnMode.Right + Application.GetRealWidth (20),
Y = Application.GetRealHeight (40),
- Width = Application.GetRealWidth (100),
- Height = Application.GetRealHeight (100),
+ Width = Application.GetMinRealAverage (100),
+ Height = Application.GetMinRealAverage (100),
Tag = "Wind"
};
acView.AddChidren (btnWind);
@@ -252,18 +252,21 @@
};
acView.AddChidren (tempSiwtch);
tempSiwtch.MouseUpEventHandler += (sender3, e3) => {
- tempSiwtch.IsSelected = !tempSiwtch.IsSelected;
- ac.Power = tempSiwtch.IsSelected ? (byte)1 : (byte)0;
+
+ //tempSiwtch.IsSelected = !tempSiwtch.IsSelected;
+ //ac.Power = tempSiwtch.IsSelected ? (byte)1 : (byte)0;
+ byte bPower = tempSiwtch.IsSelected ? (byte)0 : (byte)1;
if (ac.Type == DeviceType.CustomAC) {
var acCommon = common as CustomAC;
- acCommon.Power = tempSiwtch.IsSelected ? (byte)1 : (byte)0;
+ acCommon.Power = bPower;
var controlCommand = acCommon.customACControlLists.Find ((obj) => obj.UniversalModeType == acCommon.Power);
if (controlCommand != null) {
Control.ControlBytesSend (Command.SetCommonSwitch, acCommon.SubnetID, acCommon.DeviceID, new byte [] { controlCommand.UniversalID, 255 }, SendCount.Zero);
IO.FileUtils.SaveEquipmentMessage (acCommon, acCommon.LoopID.ToString ());
}
} else {
- acBLL.ControlAC (ac);
+ //acBLL.ControlAC (ac);
+ SendControlAc (ac, bPower);
}
};
@@ -274,10 +277,22 @@
}
}
+
if (devcieCount > 0) {
btnAllON.MouseUpEventHandler += (sender, e) => {
btnAllON.TextColor = SkinStyle.Current.TextColor1;
- controlAllAC (1);
+ Alert alert = new Alert ("",
+ "Open All AC",
+ Language.StringByID (R.MyInternationalizationString.Cancel),
+ Language.StringByID (R.MyInternationalizationString.Confrim));
+ alert.Show ();
+ alert.ResultEventHandler += (sender2, e2) => {
+ if (e2) {
+
+ controlAllAC (1);
+ }
+ };
+ //controlAllAC (1);
};
btnAllON.MouseDownEventHandler += (ss, dd) => {
btnAllON.TextColor = SkinStyle.Current.SelectedColor;
@@ -285,9 +300,20 @@
powerView.AddChidren (btnAllOff);
btnAllOff.MouseUpEventHandler += (sender, e) => {
btnAllOff.TextColor = SkinStyle.Current.TextColor1;
- controlAllAC (0);
+ //controlAllAC (0);
+ Alert alert = new Alert ("",
+ "Close All AC",
+ Language.StringByID (R.MyInternationalizationString.Cancel),
+ Language.StringByID (R.MyInternationalizationString.Confrim));
+ alert.Show ();
+ alert.ResultEventHandler += (sender2, e2) => {
+ if (e2) {
+
+ controlAllAC (0);
+ }
+ };
};
- btnAllON.MouseDownEventHandler += (ss, dd) => {
+ btnAllOff.MouseDownEventHandler += (ss, dd) => {
btnAllOff.TextColor = SkinStyle.Current.SelectedColor;
};
}
@@ -299,6 +325,14 @@
/// </summary>
void controlAllAC (byte b)
{
+ if (CommonPage.IsRemote) {
+ if (!SmartHome.MqttCommon.IsGatewayOnline) {
+ new Alert ("", "Gateway offline" + ErrorCode.ControlFailure, "Close").Show ();
+ return;
+ }
+ }
+ MainPage.Loading.Start ("Sending...");
+
System.Threading.Tasks.Task.Run (() => {
foreach (var room in Room.Lists) {
if (room == null)
@@ -310,9 +344,46 @@
return obj.Type == DeviceType.ACPanel || obj.Type == DeviceType.ACInfrared || obj.Type == DeviceType.HVAC;
});
foreach (var common in list) {
+ //2020-02-10
+ byte [] returnBytes = null;
var acCommon = common as AC;
acCommon.Power = b;
- acBLL.ControlAC (acCommon);
+ //acBLL.ControlAC (acCommon);
+
+ if (acCommon.Type == DeviceType.ACPanel) {
+ returnBytes = Control.ControlBytesSendHasReturn (Command.InstructionPanelKey, acCommon.SubnetID, acCommon.DeviceID, new byte [] { 3, acCommon.Power, acCommon.LoopID });
+ } else if (acCommon.Type == DeviceType.ACDevice || acCommon.Type == DeviceType.HVAC || acCommon.Type == DeviceType.ACInfrared) {
+ returnBytes = Control.ControlBytesSendHasReturn (Command.SetACMode, acCommon.SubnetID, acCommon.DeviceID,
+ new byte [] {acCommon.LoopID,acCommon.TemperatureMode,acCommon.IndoorTemperature,acCommon.CoolTemperature,
+ acCommon.HeatTemperature,acCommon.AutoTemperature,acCommon.ChuShiTemperature,acCommon.RealModeAndFanSpeed,
+ acCommon.Power,acCommon.SetMode,acCommon.SetFanSpeed,acCommon.SetTemperature,acCommon.ShaoFanMode});
+ } else {
+ continue;
+ }
+
+ if (returnBytes == null) {
+ Application.RunOnMainThread (() => {
+ string tipString = Language.StringByID (R.MyInternationalizationString.ControlFailure);
+ var btnTip = new Button () {
+ Height = Application.GetRealHeight (140),
+ Text = acCommon.Name + tipString,// + "..." + controlDeviceIndex.ToString () + @"/" + sceneDeviceCount.ToString (),
+ BackgroundColor = 0xFFD7D7D7,
+ };
+ MainPage.MainFrameLayout.AddChidren (btnTip);
+ btnTip.MouseUpEventHandler += (sender, e) => {
+ btnTip.RemoveFromParent ();
+ };
+
+ System.Threading.Tasks.Task.Run (() => {
+ System.Threading.Thread.Sleep (3000);
+ Application.RunOnMainThread (() => {
+ btnTip.RemoveFromParent ();
+ });
+ });
+
+ });
+ }
+
}
var listCustomAC = room.DeviceList.FindAll ((obj) => {
return obj.Type == DeviceType.CustomAC;
@@ -326,19 +397,36 @@
}
}
}
+
+ Application.RunOnMainThread (() => {
+ MainPage.Loading.Hide ();
+ });
});
}
+
+
+ /// <summary>
+ /// 璇诲彇鏍囧織
+ /// </summary>
+ static bool IsReadingAll = false;
static System.Threading.Thread thread;
/// <summary>
/// 璇诲彇璁惧鐘舵��
/// </summary>
- public static void readAllStatus (bool isRead = false)
+ public static void readAllStatus (bool isRead = false, bool isCheckIsReadingAll = false)
{
+ if (isCheckIsReadingAll) {
+ if (IsReadingAll && !isRead) {
+ Utlis.WriteLine ("IsReadingAll AC 璇诲彇涓�");
+ return;
+ }
+ }
+
if (isRead) {
foreach (Room room in Room.Lists) {
- if (string.IsNullOrEmpty(room.Name)) {
+ if (string.IsNullOrEmpty (room.Name)) {
continue;
}
var list = room.DeviceList.FindAll ((obj) => {
@@ -354,6 +442,7 @@
}
thread = new Thread (() => {
try {
+ IsReadingAll = true;
System.Collections.Generic.List<string> readList = new System.Collections.Generic.List<string> ();
foreach (Room room in Room.Lists) {
var list = room.DeviceList.FindAll ((obj) => {
@@ -374,14 +463,45 @@
Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 8, ac.LoopID, ac.LoopID }, SendCount.Zero);
Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 19, ac.LoopID, ac.LoopID }, SendCount.Zero);
Control.ControlBytesSend (Command.ReadPanleTemp, ac.SubnetID, ac.DeviceID, new byte [] { ac.LoopID }, SendCount.Zero);
- }
+ }
}
+
}
- } catch { } finally {
+ IsReadingAll = false;
+ } catch {
+ IsReadingAll = false;
+ } finally {
thread = null;
}
});
thread.Start ();
}
+
+
+ /// <summary>
+ /// 绌鸿皟鎺у埗锛屽甫杩斿洖缁撴灉
+ /// </summary>
+ /// <param name="mAcData"></param>
+ /// <param name="bPower"></param>
+ void SendControlAc (AC mAcData, byte bPower)
+ {
+ MainPage.Loading.Start ("Sending...");
+ System.Threading.Tasks.Task.Run (() => {
+ byte [] returnBytes = null;
+ if (mAcData.Type == DeviceType.ACPanel) {
+ returnBytes = Control.ControlBytesSendHasReturn (Command.InstructionPanelKey, mAcData.SubnetID, mAcData.DeviceID, new byte [] { 3, bPower, mAcData.LoopID });
+ } else if (mAcData.Type == DeviceType.ACDevice || mAcData.Type == DeviceType.HVAC || mAcData.Type == DeviceType.ACInfrared) {
+
+ returnBytes = Control.ControlBytesSendHasReturn (Command.SetACMode, mAcData.SubnetID, mAcData.DeviceID, new [] { mAcData.LoopID, mAcData.TemperatureMode, mAcData.IndoorTemperature, mAcData.CoolTemperature, mAcData.HeatTemperature, mAcData.AutoTemperature, mAcData.ChuShiTemperature, mAcData.RealModeAndFanSpeed, bPower, mAcData.SetMode, mAcData.SetFanSpeed, mAcData.SetTemperature, mAcData.ShaoFanMode });
+ }
+
+ Application.RunOnMainThread (() => {
+ if (returnBytes == null) {
+ new Alert ("", mAcData.Name + ErrorCode.ControlFailure, "Close").Show ();
+ }
+ MainPage.Loading.Hide ();
+ });
+ });
+ }
}
}
\ No newline at end of file
--
Gitblit v1.8.0