黄学彪
2020-12-16 0d9f64668fd7350d6a21fd157e32009a96d98134
ZigbeeApp/Shared/Phone/Common/Logic/HdlSafeguardLogic.cs
File was renamed from ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlSafeguardLogic.cs
@@ -6,7 +6,7 @@
using System.Threading.Tasks;
using ZigBee.Device;
namespace Shared.Phone.UserCenter
namespace Shared.Phone
{
    /// <summary>
    /// <para>安防本地缓存(代码使用)</para>
@@ -107,7 +107,7 @@
                    var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
                    if (temp != null)
                    {
                        string msg = HdlCheckLogic.Current.CheckCommonErrorCode(temp.Error);
                        string msg = HdlCheckLogic.Current.CheckGatewayErrorCode(temp.Error);
                        if (msg != null)
                        {
                            this.ShowTipMsg(msg);
@@ -239,7 +239,7 @@
            //处理设备
            foreach (var data2 in allData.DeviceList)
            {
                string mainKey = LocalDevice.Current.GetDeviceMainKeys(data2.MacAddr, data2.Epoint);
                string mainKey = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(data2.MacAddr, data2.Epoint);
                //传感器设备信息
                var Deviceinfo = new Safeguard.ZoneDeviceListData();
                Deviceinfo.IsBypass = data2.IsBypass;
@@ -250,7 +250,7 @@
                zoneInfo.dicSensor[mainKey] = Deviceinfo;
                //本地是否有这个设备
                CommonDevice device = LocalDevice.Current.GetDevice(mainKey);
                CommonDevice device = HdlDeviceCommonLogic.Current.GetDevice(mainKey);
                if (device != null)
                {
                    //全部设备
@@ -297,10 +297,10 @@
                if (data.Type == 0)
                {
                    //本地是否有这个设备
                    string mainKey = LocalDevice.Current.GetDeviceMainKeys(data.DeviceAddr, data.Epoint);
                    string mainKey = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(data.DeviceAddr, data.Epoint);
                    //报警信息
                    zoneInfo.dicAlarmDevice[mainKey] = data;
                    CommonDevice device = LocalDevice.Current.GetDevice(mainKey);
                    CommonDevice device = HdlDeviceCommonLogic.Current.GetDevice(mainKey);
                    if (device != null)
                    {
                        //全部设备
@@ -549,7 +549,7 @@
                //向防区添加设备失败
                string msg = Language.StringByID(R.MyInternationalizationString.uAddDeviceToZoneFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, returnData);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, returnData);
                this.ShowErrorMsg(msg);
                return null;
@@ -561,20 +561,20 @@
                //一批设备里面,成功添加的
                if (data.Status == 0)
                {
                    listSuccess.Add(LocalDevice.Current.GetDeviceMainKeys(data.MacAddr, data.Epoint));
                    listSuccess.Add(HdlDeviceCommonLogic.Current.GetDeviceMainKeys(data.MacAddr, data.Epoint));
                }
                else if (data.Status == 1)
                {
                    var device = Common.LocalDevice.Current.GetDevice(data.MacAddr, data.Epoint);
                    string msg = Common.LocalDevice.Current.GetDeviceEpointName(device) + "\r\n";
                    var device = HdlDeviceCommonLogic.Current.GetDevice(data.MacAddr, data.Epoint);
                    string msg = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device) + "\r\n";
                    //目标设备不存在
                    msg += Language.StringByID(R.MyInternationalizationString.uTargetDeviceIsNotExsit);
                    this.ShowTipMsg(msg);
                }
                else if (data.Status == 2)
                {
                    var device = Common.LocalDevice.Current.GetDevice(data.MacAddr, data.Epoint);
                    string msg = Common.LocalDevice.Current.GetDeviceEpointName(device) + "\r\n";
                    var device = HdlDeviceCommonLogic.Current.GetDevice(data.MacAddr, data.Epoint);
                    string msg = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device) + "\r\n";
                    //设备已加入其它防区
                    msg += Language.StringByID(R.MyInternationalizationString.uDeviceHadAddToTheOtherGarrison);
                    this.ShowTipMsg(msg);
@@ -735,7 +735,7 @@
                //设备删除失败
                string msg = Language.StringByID(R.MyInternationalizationString.uDeviceDeleteFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, returnData);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, returnData);
                this.ShowErrorMsg(msg);
@@ -747,7 +747,7 @@
            {
                if (data.Status == 0)
                {
                    listKeys.Add(LocalDevice.Current.GetDeviceMainKeys(data.MacAddr, data.Epoint));
                    listKeys.Add(HdlDeviceCommonLogic.Current.GetDeviceMainKeys(data.MacAddr, data.Epoint));
                }
            }
@@ -945,7 +945,7 @@
                //获取安防密码失败
                string msg = Language.StringByID(R.MyInternationalizationString.uGetSafetyPasswordFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, nowPw);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, nowPw);
                if (mode == ShowErrorMode.YES)
                {
@@ -975,7 +975,7 @@
                    //修改用户密码失败
                    string msg = Language.StringByID(R.MyInternationalizationString.uChangedUserPasswordFail);
                    //拼接上【网关回复超时】的Msg
                    msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                    msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                    this.ShowErrorMsg(msg);
                    return false;
@@ -1076,7 +1076,7 @@
                //修改备注信息失败
                string msg = Language.StringByID(R.MyInternationalizationString.uEditorNoteInformationFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowErrorMsg(msg);
                return false;
@@ -1136,7 +1136,7 @@
                //添加报警目标失败
                string msg = Language.StringByID(R.MyInternationalizationString.uAddAlarmTargetFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowErrorMsg(msg);
@@ -1148,8 +1148,8 @@
                {
                    if (data.Type == "0")
                    {
                        var device = Common.LocalDevice.Current.GetDevice(data.DeviceAddr, data.Epoint);
                        string msg = Common.LocalDevice.Current.GetDeviceEpointName(device) + "\r\n";
                        var device = HdlDeviceCommonLogic.Current.GetDevice(data.DeviceAddr, data.Epoint);
                        string msg = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device) + "\r\n";
                        //目标设备不存在
                        msg += Language.StringByID(R.MyInternationalizationString.uTargetDeviceIsNotExsit);
                        this.ShowTipMsg(msg);
@@ -1223,7 +1223,7 @@
                //删除报警目标失败
                string msg = Language.StringByID(R.MyInternationalizationString.uDeleteAlarmTargetFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowErrorMsg(msg);
@@ -1249,7 +1249,7 @@
                if (device.Type == "0")
                {
                    //删除报警设备
                    string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device.DeviceAddr, device.Epoint);
                    string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device.DeviceAddr, device.Epoint);
                    if (zoneInfo.dicAlarmDevice.ContainsKey(mainkeys) == false)
                    {
                        continue;
@@ -1336,7 +1336,7 @@
                //旁路状态设置失败
                string msg = Language.StringByID(R.MyInternationalizationString.uSetByPassStatuFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowErrorMsg(msg);
@@ -1368,7 +1368,7 @@
            if (this.UserPassword == null)
            {
                var data = HdlFileLogic.Current.ReadFileByteContent(DirNameResourse.SafeguardUserPassword);
                var data = HdlFileLogic.Current.ReadFileByteContent(HdlFileNameResourse.SafeguardUserPassword);
                if (data != null)
                {
                    this.UserPassword = System.Text.Encoding.UTF8.GetString(data);
@@ -1386,7 +1386,7 @@
                if (result != GarrisonMode.None && result != GarrisonMode.RemoveGarrison)
                {
                    //保存加密的密码到本地
                    HdlFileLogic.Current.SaveTextToFile(DirNameResourse.SafeguardUserPassword, this.UserPassword);
                    HdlFileLogic.Current.SaveTextToFile(HdlFileNameResourse.SafeguardUserPassword, this.UserPassword);
                }
                return result;
            }
@@ -1436,7 +1436,7 @@
                //布防设置失败
                string msg = Language.StringByID(R.MyInternationalizationString.uSetGarrisonFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowErrorMsg(msg);
                return GarrisonMode.RemoveGarrison;
@@ -1475,7 +1475,7 @@
                    if (result2 != GarrisonMode.None && result2 != GarrisonMode.RemoveGarrison)
                    {
                        //保存加密密码到本地
                        HdlFileLogic.Current.SaveTextToFile(DirNameResourse.SafeguardUserPassword, this.UserPassword);
                        HdlFileLogic.Current.SaveTextToFile(HdlFileNameResourse.SafeguardUserPassword, this.UserPassword);
                    }
                    return result2;
                }
@@ -1549,7 +1549,7 @@
                    //撤防失败
                    string msg = Language.StringByID(R.MyInternationalizationString.uRemoveGarrisonFail);
                    //拼接上【网关回复超时】的Msg
                    msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                    msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                    this.ShowErrorMsg(msg);
                }
@@ -1558,7 +1558,7 @@
                    //布防模式变更失败
                    string msg = Language.StringByID(R.MyInternationalizationString.uChangedGarrisonModeFail);
                    //拼接上【网关回复超时】的Msg
                    msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                    msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                    this.ShowErrorMsg(msg);
                }
@@ -1590,7 +1590,7 @@
                    if (result2 != -1)
                    {
                        //保存到加密密码本地
                        HdlFileLogic.Current.SaveTextToFile(DirNameResourse.SafeguardUserPassword, this.UserPassword);
                        HdlFileLogic.Current.SaveTextToFile(HdlFileNameResourse.SafeguardUserPassword, this.UserPassword);
                    }
                    return result2;
                }
@@ -1717,7 +1717,7 @@
                //设置信息推送失败
                string msg = Language.StringByID(R.MyInternationalizationString.uSetInformationPushFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowErrorMsg(msg);
                return false;
@@ -1764,7 +1764,7 @@
                //获取延时时间失败
                string msg = Language.StringByID(R.MyInternationalizationString.uGetDelayTimeFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowErrorMsg(msg);
                return null;
@@ -1793,7 +1793,7 @@
                //设置延时时间失败
                string msg = Language.StringByID(R.MyInternationalizationString.uSetDelayTimeFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowErrorMsg(msg);
                return false;
@@ -1818,7 +1818,7 @@
                //获取胁迫联系方式信息失败
                string msg = Language.StringByID(R.MyInternationalizationString.uGetCoercePhoneNumberFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowErrorMsg(msg);
                return null;
@@ -1861,7 +1861,7 @@
                    //修改胁迫联系方式失败
                    string msg = Language.StringByID(R.MyInternationalizationString.uChangedCoercePhoneNumberFail);
                    //拼接上【网关回复超时】的Msg
                    msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                    msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                    this.ShowErrorMsg(msg);
                    return false;
@@ -1875,7 +1875,7 @@
                    //修改备注信息失败
                    string msg = Language.StringByID(R.MyInternationalizationString.uEditorNoteInformationFail);
                    //拼接上【网关回复超时】的Msg
                    msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "回复超时");
                    msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, null, "回复超时");
                    this.ShowErrorMsg(msg);
                    return false;
                }
@@ -1922,7 +1922,7 @@
                //删除胁迫联系方式失败
                string msg = Language.StringByID(R.MyInternationalizationString.uDeleteCoercePhoneNumberFail);
                //拼接上【网关回复超时】的Msg
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result);
                this.ShowErrorMsg(msg);
                return false;
@@ -1973,7 +1973,7 @@
            //要考虑它的排列顺序(可以按需求变更编号)
            Dictionary<int, string> dicSort = new Dictionary<int, string>();
            //最大编号
            int MaxNo = listTaskInfo.Count > 4 ? listTaskInfo.Count : 4;
            int MaxNo = 4;
            //开关的位置编号
            int ControlNo = 0;
            //百分比的位置编号
@@ -1984,45 +1984,9 @@
            int modelNo = 3;
            //空调风速的位置编号
            int windNo = 4;
            //其他编号(不理会位置,以列表的顺序为准)
            int otherNo = 100;
            foreach (var info in listTaskInfo)
            {
                #region ■ 晾衣架______
                //★★★★临时处理,后期会删除
                if (info.Epoint != -1)
                {
                    //最高最低处
                    if (info.Epoint == 1)
                    {
                        dicSort[dicSort.Count + otherNo] = info.Data1 == 0 ? Language.StringByID(R.MyInternationalizationString.uTheHighestPoint) : Language.StringByID(R.MyInternationalizationString.uTheLowestPoint);
                    }
                    //风干
                    else if (info.Epoint == 3)
                    {
                        dicSort[dicSort.Count + otherNo] = info.Data1 == 1 ? Language.StringByID(R.MyInternationalizationString.uOpenAirdry) : Language.StringByID(R.MyInternationalizationString.uCloseAirdry);
                    }
                    //烘干
                    else if (info.Epoint == 4)
                    {
                        dicSort[dicSort.Count + otherNo] = info.Data1 == 1 ? Language.StringByID(R.MyInternationalizationString.uOpenDry) : Language.StringByID(R.MyInternationalizationString.uCloseDry);
                    }
                    //消毒
                    else if (info.Epoint == 5)
                    {
                        dicSort[dicSort.Count + otherNo] = info.Data1 == 1 ? Language.StringByID(R.MyInternationalizationString.uOpenDisinfect) : Language.StringByID(R.MyInternationalizationString.uCloseDisinfect);
                    }
                    //照明
                    else if (info.Epoint == 2)
                    {
                        dicSort[dicSort.Count + otherNo] = info.Data1 == 1 ? Language.StringByID(R.MyInternationalizationString.uOpenLighting) : Language.StringByID(R.MyInternationalizationString.uCloseLighting);
                    }
                    //特殊,不能往下走
                    continue;
                }
                #endregion
                #region ■ 开关控制____
                //开关控制
                if (info.TaskType == 1)
@@ -2154,17 +2118,6 @@
                {
                    txtvalue += dicSort[i] + " ";
                }
            }
            //其他的
            MaxNo = otherNo + dicSort.Count;
            for (int i = otherNo; i < MaxNo; i++)
            {
                if (dicSort.ContainsKey(i) == true)
                {
                    txtvalue += dicSort[i] + " ";
                    continue;
                }
                break;
            }
            return txtvalue.Trim();
@@ -2348,7 +2301,7 @@
        /// <returns></returns>
        private string GetDeviceMainKeys(CommonDevice device)
        {
            return Common.LocalDevice.Current.GetDeviceMainKeys(device);
            return HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
        }
        /// <summary>