using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using Newtonsoft.Json.Linq;
|
|
namespace Shared.Phone.UserCenter
|
{
|
/// <summary>
|
/// 全局接收网关推送的的逻辑(为了执行速度,尽可能的别加耗时的操作)
|
/// </summary>
|
public class HdlGatewayReceiveLogic
|
{
|
#region ■ 全局接收___________________________
|
|
/// <summary>
|
/// 全局接收网关推送的的逻辑(为了执行速度,尽可能的别加耗时的操作)
|
/// </summary>
|
/// <param name="gatewayId">网关ID</param>
|
/// <param name="topic">主题</param>
|
/// <param name="receiveData">接收的数据</param>
|
public static void GatewayOverallMsgReceive(string gatewayId, string topic, JObject receiveData)
|
{
|
if (topic == "AppNoLogin")
|
{
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
//登录密匙已经过期,请重新登录
|
string msg = Language.StringByID(R.MyInternationalizationString.uTokenIsOldAndLoginAgain);
|
var contr = new ShowMsgControl(ShowMsgType.Tip, msg);
|
contr.Show();
|
|
UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account, false);
|
});
|
}
|
else if (topic == "BeingSqueezedOffline")
|
{
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
//此帐号已在别处登录,您被迫下线
|
string msg = Language.StringByID(R.MyInternationalizationString.uHadBeenLoginAndOffLine);
|
var contr = new ShowMsgControl(ShowMsgType.Tip, msg);
|
contr.Show();
|
|
UserCenterLogic.ReLoginAgain(UserCenterResourse.UserInfo.Account, false);
|
});
|
}
|
|
try
|
{
|
if (HdlGatewayLogic.Current.IsGatewayExist(gatewayId) == false)
|
{
|
//不是自己绑定的网关,则不处理
|
return;
|
}
|
//门锁上报
|
if (topic == gatewayId + "/Alarms/SendAlarmInform")
|
{
|
//保存门锁报警信息到本地
|
HdlAlarmsLogic.Current.SaveDoorLockAlarmInfo(receiveData);
|
|
}
|
//通过外部方式布防撤防成功时报告
|
else if (topic == gatewayId + "/Security/EnOrWithdrawSucceedReport")
|
{
|
SecurityEnOrWithdrawSucceedReport(receiveData);
|
}
|
}
|
catch (Exception ex)
|
{
|
//Log出力
|
HdlLogLogic.Current.WriteLog(ex);
|
}
|
}
|
|
#endregion
|
|
#region ■ 通过外部方式布防撤防_______________
|
|
/// <summary>
|
/// 通过外部方式布防撤防
|
/// </summary>
|
/// <param name="receiveData">接收的数据</param>
|
private static void SecurityEnOrWithdrawSucceedReport(JObject receiveData)
|
{
|
var data = Newtonsoft.Json.JsonConvert.DeserializeObject<SecurityEnOrWithdrawResult>(receiveData["Data"].ToString());
|
if (data.EnOrWithdraw == -1 || data.ModeId == -1 || data.OperationWay == -1)
|
{
|
return;
|
}
|
var garrison = GarrisonMode.None;
|
if (data.EnOrWithdraw == 0)
|
{
|
//在家布防
|
if (data.ModeId == 1) { garrison = GarrisonMode.AtHome; }
|
//离家布防
|
else if (data.ModeId == 2) { garrison = GarrisonMode.RemoveHome; }
|
}
|
else if (data.EnOrWithdraw == 1)
|
{
|
//撤防
|
garrison = GarrisonMode.RemoveGarrison;
|
}
|
string appendText = string.Empty;
|
//自动化
|
if (data.OperationWay == 0) { appendText = "(" + Language.StringByID(R.MyInternationalizationString.uLogicOperation) + ")"; }
|
//按键操作
|
else if (data.OperationWay == 1) { appendText = "(" + Language.StringByID(R.MyInternationalizationString.uPanelOperation) + ")"; }
|
|
//保存报警信息然后推送到界面上
|
HdlAlarmsLogic.Current.SaveSafeguardAlarmInfo(garrison, appendText, true);
|
}
|
|
/// <summary>
|
/// 通过外部方式布防撤防的接收结果
|
/// </summary>
|
private class SecurityEnOrWithdrawResult
|
{
|
/// <summary>
|
/// 0:布防成功 1:撤防成功
|
/// </summary>
|
public int EnOrWithdraw = -1;
|
/// <summary>
|
/// 安防模式id
|
/// </summary>
|
public int ModeId = -1;
|
/// <summary>
|
/// 外部布撤防方式-> 0:执行逻辑动作 1:按键操作
|
/// </summary>
|
public int OperationWay = -1;
|
}
|
|
#endregion
|
}
|
}
|