From f0f63edda354eaf18895f0b92ff6d308bd778176 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期一, 07 十二月 2020 11:01:12 +0800
Subject: [PATCH] Merge branch 'master' into WJC
---
HDL_ON/Entity/Function/Function.cs | 8
HDL_ON/DAL/Server/NewApiRes.cs | 24 +
HDL_ON/Common/HDLCommon.cs | 93 +++++++
HDL_ON/DAL/Server/HttpUtil.cs | 3
HDL_ON/Entity/Room.cs | 116 ++++++--
HDL_ON/DAL/Server/HttpServerRequest.cs | 2
HDL_ON/DAL/DriverLayer/Control.cs | 5
HDL-ON_iOS/AppDelegate.cs | 202 +++++---------
HDL_ON/Entity/FunctionList.cs | 148 +++++++---
HDL-ON_Android/Other/JPush/JPushReceiver.cs | 147 +++++-----
10 files changed, 467 insertions(+), 281 deletions(-)
diff --git a/HDL-ON_Android/Other/JPush/JPushReceiver.cs b/HDL-ON_Android/Other/JPush/JPushReceiver.cs
index 61b99f9..f24b091 100644
--- a/HDL-ON_Android/Other/JPush/JPushReceiver.cs
+++ b/HDL-ON_Android/Other/JPush/JPushReceiver.cs
@@ -1,17 +1,9 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-using Android.App;
+锘�
using Android.Content;
-using Android.OS;
-using Android.Runtime;
-using Android.Views;
-using Android.Widget;
using CN.Jpush.Android.Api;
using CN.Jpush.Android.Service;
using HDL_ON;
+using HDL_ON.DAL.Server;
using Shared;
namespace HDL_ON_Android
@@ -40,11 +32,7 @@
{
base.OnNotifyMessageOpened(context, notificationMessage);
- //App.Paras = p1.NotificationExtras;
-
- //Utlis.ShowTip("鏀跺埌鎺ㄩ�侊細" + p1.NotificationExtras);
- Utlis.WriteLine("鏋佸厜OnNotifyMessageOpened: " + notificationMessage.NotificationContent);
- Utlis.WriteLine("鏋佸厜OnNotifyMessageOpened: " + notificationMessage.NotificationExtras);
+ OpenNotification(context, notificationMessage);
}
/// <summary>
@@ -55,8 +43,18 @@
public override void OnNotifyMessageArrived(Context context, NotificationMessage notificationMessage)
{
base.OnNotifyMessageArrived(context, notificationMessage);
- Utlis.WriteLine("鏋佸厜OnNotifyMessageArrived: " + notificationMessage.NotificationContent);
- Utlis.WriteLine("鏋佸厜OnNotifyMessageArrived: " + notificationMessage.NotificationExtras);
+
+ var pushMes = new JPushMessageInfo()
+ {
+ Title = notificationMessage.NotificationTitle,
+ Content = notificationMessage.NotificationContent,
+ Extras = notificationMessage.NotificationExtras
+ };
+ System.Console.WriteLine("PushMes title : " + pushMes.Title);
+ System.Console.WriteLine("PushMes message : " + pushMes.Content);
+ System.Console.WriteLine("PushMes extras : " + pushMes.Extras);
+
+ HDLCommon.Current.AdjustPushMessage(pushMes);
}
/// <summary>
@@ -72,76 +70,81 @@
}
///// <summary>
- ///// 鏀跺埌鑷畾涔夋秷鎭洖璋�
+ ///// 澶勭悊鏋佸厜淇℃伅鎺ㄩ��
///// </summary>
- ///// <param name="p0"></param>
- ///// <param name="p1"></param>
- //public override void OnMessage(Context p0, CustomMessage p1)
+ ///// <param name="title">鏍囬</param>
+ ///// <param name="message">淇℃伅</param>
+ ///// <param name="extras">璐熻浇鏁版嵁</param>
+ //public void AdjustJiguangMsgPush(JPushMessageInfo JPushMessageInfo)
//{
- // base.OnMessage(p0, p1);
+ // try
+ // {
+
- // Utlis.WriteLine("鏋佸厜OnMessage: " + p1.Message.ToString());
+ // if (JPushMessageInfo.Extras.Contains("Offline") == true)
+ // {
+ // Shared.Application.RunOnMainThread(() =>
+ // {
+ // //璐﹀彿鍦ㄥ埆澶勭櫥闄嗭紝琚涪涓嬬嚎 璺宠浆鍒扮櫥褰曢〉闈�
+ // new Alert(Language.StringByID(StringId.Tip), Language.StringByID(StringId.LoggedOnOtherDevices), Language.StringByID(StringId.Close)).Show();
+ // //2020-12-04 寰呭鍔犻��鍑虹櫥褰曟搷浣�
+ // });
+ // return;
+ // }
+ // else
+ // {
+ // Shared.Application.RunOnMainThread(() =>
+ // {
+ // new Alert(JPushMessageInfo.Title, JPushMessageInfo.Content, Language.StringByID(StringId.Close)).Show();
+ // });
+ // return;
+
+ // }
+ // }
+ // catch
+ // {
+
+ // }
//}
-
-
- /// <summary>
- /// 澶勭悊鏋佸厜淇℃伅鎺ㄩ��
- /// </summary>
- /// <param name="title">鏍囬</param>
- /// <param name="message">淇℃伅</param>
- /// <param name="extras">璐熻浇鏁版嵁</param>
- public void AdjustJiguangMsgPush(NotificationMessage notificationMessage)
- {
- string title = notificationMessage.NotificationTitle;
- System.Console.WriteLine(TAG, " title : " + title);
- string message = notificationMessage.NotificationContent;
- System.Console.WriteLine(TAG, "message : " + message);
- string extras = notificationMessage.NotificationExtras;
- System.Console.WriteLine(TAG, "extras : " + extras);
-
-
- if (extras.Contains("Offline") == true)
- {
-
- Shared.Application.RunOnMainThread(() =>
- {
- //姝ゅ笎鍙峰凡鍦ㄥ埆澶勭櫥褰�,鎮ㄨ杩笅绾�
- //ShowAlert("姝ゅ笎鍙峰凡鍦ㄥ埆澶勭櫥褰�,鎮ㄨ杩笅绾�");
- //璐﹀彿鍦ㄥ埆澶勭櫥闄嗭紝琚涪涓嬬嚎 璺宠浆鍒扮櫥褰曢〉闈�
- HDLCommon.Current.ShowAlert(Language.StringByID(StringId.LoggedOnOtherDevices));
-
- });
- return;
- }
- }
/// <summary>
/// 鎵撳紑娑堟伅鏄剧ず鐣岄潰
/// </summary>
- /// <param name="context">Context.</param>
- /// <param name="bundle">Bundle.</param>
- private void OpenNotification(Context context, Bundle bundle)
+ /// <param name="context"></param>
+ /// <param name="notificationMessage"></param>
+ private void OpenNotification(Context context, NotificationMessage notificationMessage)
{
-
- Intent i = new Intent(context, typeof(BaseActivity));//Intent intent=new Intent( 璧峰缁勪欢瀵硅薄 , 鐩爣 Service.class);
- i.PutExtras(bundle);
- i.SetFlags(ActivityFlags.NewTask);
- context.StartActivity(i);
-
- String extras = bundle.GetString(JPushInterface.ExtraExtra);
- //String myValue = "";
try
{
-
+ var pushMes = new JPushMessageInfo()
+ {
+ Title = notificationMessage.NotificationTitle,
+ Content = notificationMessage.NotificationContent,
+ Extras = notificationMessage.NotificationExtras
+ };
+ System.Console.WriteLine("PushMes title : " + pushMes.Title);
+ System.Console.WriteLine("PushMes message : " + pushMes.Content);
+ System.Console.WriteLine("PushMes extras : " + pushMes.Extras);
+ if (Shared.Application.Activity == null)
+ {
+ var tempIntent = new Intent(context, typeof(Shared.BaseActivity));//Intent intent=new Intent( 璧峰缁勪欢瀵硅薄 , 鐩爣 Service.class);
+ tempIntent.SetFlags(ActivityFlags.BroughtToFront);
+ context.StartActivity(tempIntent);
+
+ HDLCommon.Current.AdjustPushMessage(pushMes);
+ }
+ else
+ {
+ (Shared.Application.Activity as BaseActivity).MoveToFront();
+
+ HDLCommon.Current.AdjustPushMessage(pushMes);
+ }
}
- catch (Exception e)
+ catch
{
- System.Console.WriteLine("JPush", "Unexpected: extras is not a valid json", e);
- return;
- }
-
+ }
}
}
diff --git a/HDL-ON_iOS/AppDelegate.cs b/HDL-ON_iOS/AppDelegate.cs
index 3728f8d..652593e 100644
--- a/HDL-ON_iOS/AppDelegate.cs
+++ b/HDL-ON_iOS/AppDelegate.cs
@@ -8,6 +8,7 @@
using Microsoft.AppCenter.Analytics;
using Microsoft.AppCenter.Crashes;
using HDL_ON.UI;
+using HDL_ON.DAL.Server;
namespace SharedMethod
{
@@ -34,6 +35,7 @@
//}
}
+
}
namespace HDL_ON_iOS
@@ -128,89 +130,13 @@
if (application.ApplicationState == UIApplicationState.Active || application.ApplicationState == UIApplicationState.Background)
{
- NSString key_hiddenJson = new NSString("HiddenJson");
- if (userInfo.ContainsKey(key_hiddenJson))
- {
- var hiddenJson = userInfo["HiddenJson"].ToString();
- if (string.IsNullOrEmpty(hiddenJson))
- {
- return;
- }
- if (hiddenJson.Contains("cmtID"))
- {
- /////鐩墠鏍规嵁杩欎釜鍒ゆ柇鏄惁鏄彲瑙嗗璁叉暟鎹�
- //VideoMethod(hiddenJson);
- }
- else
- {
-
- NSDictionary hiddenJsonDic = userInfo["HiddenJson"] as NSDictionary;
- if (hiddenJsonDic == null)
- {
- return;
- }
- NSString key_Offline = new NSString("Offline");
- if (hiddenJsonDic.ContainsKey(key_Offline))
- {
- string signOut = hiddenJsonDic["Offline"].ToString();
-
- if (signOut == "0")
- {
- //涓嶄笅绾�
- }
- else
- {
- //寮哄埗涓嬬嚎
- //CommonPage.Instance.SingOut();
- HDLCommon.Current.ShowAlert(Language.StringByID(StringId.LoggedOnOtherDevices));
- }
- }
- }
- }
+ HandleNotificationMessageUserInfo(userInfo, false);
}
else
{
- NSString key_hiddenJson = new NSString("HiddenJson");
- if (userInfo.ContainsKey(key_hiddenJson))
- {
-
- var hiddenJson = userInfo["HiddenJson"].ToString();
- if (string.IsNullOrEmpty(hiddenJson))
- {
- return;
- }
-
- if (hiddenJson.Contains("cmtID"))
- {
- /////鐩墠鏍规嵁杩欎釜鍒ゆ柇鏄惁鏄彲瑙嗗璁叉暟鎹�
- //VideoMethod(hiddenJson);
- }
- else
- {
-
- NSDictionary hiddenJsonDic = userInfo["HiddenJson"] as NSDictionary;
- if (hiddenJsonDic == null)
- {
- return;
- }
- NSString key_Offline = new NSString("Offline");
- if (hiddenJsonDic.ContainsKey(key_Offline))
- {
- string signOut = hiddenJsonDic["Offline"].ToString();
-
- if (signOut == "0")
- {
- //涓嶄笅绾�
- }
- else
- {
- //鏍囪涓嬬嚎
- haveToSignOut = true;
- }
- }
- }
- }
+ //Inactive
+ HandleNotificationMessageUserInfo(userInfo, false);
}
completionHandler(UIBackgroundFetchResult.NewData);
@@ -269,12 +195,14 @@
Console.WriteLine("OnActivated");
base.OnActivated(application);
- if (haveToSignOut == true)
- {
- //寮哄埗涓嬬嚎
- //CommonPage.Instance.SingOut();
- HDLCommon.Current.ShowAlert(Language.StringByID(StringId.LoggedOnOtherDevices));
- }
+ //if (haveToSignOut == true)
+ //{
+ ////寮哄埗涓嬬嚎
+ //UserInfo.Current.LastTime = DateTime.MinValue;
+ //UserInfo.Current.headImagePagePath = "LoginIcon/2.png";//閲嶇疆鐢ㄦ埛澶村儚
+ //UserInfo.Current.SaveUserInfo();
+ //HDLCommon.Current.ShowAlert(Language.StringByID(StringId.LoggedOnOtherDevices));
+ //}
}
@@ -342,64 +270,79 @@
}
/// <summary>
- /// 閫�鍑虹櫥褰曟爣璁�
+ /// 澶勭悊閫氱煡娑堟伅
/// </summary>
- bool haveToSignOut;
+ void HandleNotificationMessageUserInfo(NSDictionary userInfo, bool bFinishedLaunching)
+ {
+ try
+ {
+ if (userInfo.ContainsKey(new NSString("aps")))
+ {
+ var aps = userInfo["aps"] as NSDictionary;
+ var alert = aps["alert"] as NSDictionary;
+ var body = alert["body"] as NSString;
+ var title = alert["title"] as NSString;
+ var expandData = "";
+ if (userInfo.ContainsKey(new NSString("expandData")))
+ {
+ expandData = userInfo["expandData"] as NSString;
+ }
+ var pushMes = new JPushMessageInfo()
+ {
+ Title = title,
+ Content = body,
+ Extras = expandData,
+ };
+ System.Console.WriteLine("PushMes title : " + pushMes.Title);
+ System.Console.WriteLine("PushMes message : " + pushMes.Content);
+ System.Console.WriteLine("PushMes extras : " + pushMes.Extras);
+
+ if (bFinishedLaunching)
+ {
+ if (pushMes.Extras != null && pushMes.Extras.Contains("Offline"))
+ {
+ //haveToSignOut = true;
+ //寮哄埗涓嬬嚎
+ UserInfo.Current.LastTime = DateTime.MinValue;
+ UserInfo.Current.headImagePagePath = "LoginIcon/2.png";//閲嶇疆鐢ㄦ埛澶村儚
+ UserInfo.Current.SaveUserInfo();
+ HDLCommon.Current.ShowAlert(Language.StringByID(StringId.LoggedOnOtherDevices));
+ }
+ }
+ else
+ {
+ HDLCommon.Current.AdjustPushMessage(pushMes);
+ }
+
+ }
+ }
+ catch
+ {
+
+ }
+ }
+
+ ///// <summary>
+ ///// 閫�鍑虹櫥褰曟爣璁�
+ ///// </summary>
+ //bool haveToSignOut;
/// <summary>
- /// 澶勭悊閫氱煡
+ /// 鍚姩APP 澶勭悊閫氱煡
/// </summary>
/// <param name="launchOptions"></param>
void DealWithPushMes(NSDictionary launchOptions)
{
- haveToSignOut = false;
+ //haveToSignOut = false;
if (launchOptions != null)
{
// check for a remote notification
if (launchOptions.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
{
NSDictionary userInfo = launchOptions[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
+
if (userInfo != null)
{
- NSString key_hiddenJson = new NSString("HiddenJson");
- if (userInfo.ContainsKey(key_hiddenJson))
- {
- var hiddenJson = userInfo["HiddenJson"].ToString();
- if (!string.IsNullOrEmpty(hiddenJson))
- {
- if (hiddenJson.Contains("cmtID"))
- {
-
- ///鐩墠鏍规嵁杩欎釜鍒ゆ柇鏄惁鏄彲瑙嗗璁叉暟鎹�
- // VideoMethod(hiddenJson);
- }
- else
- {
-
- NSDictionary hiddenJsonDic = userInfo["HiddenJson"] as NSDictionary;
- if (hiddenJsonDic != null)
- {
- NSString key_Offline = new NSString("Offline");
- if (hiddenJsonDic.ContainsKey(key_Offline))
- {
- string signOut = hiddenJsonDic["Offline"].ToString();
-
- if (signOut == "0")
- {
- //涓嶄笅绾�
- }
- else
- {
- //鏍囪涓嬬嚎
- haveToSignOut = true;
- }
- }
-
- }
- }
- }
-
-
- }
+ HandleNotificationMessageUserInfo(userInfo, true);
}
}
@@ -409,5 +352,6 @@
}
+
}
diff --git a/HDL_ON/Common/HDLCommon.cs b/HDL_ON/Common/HDLCommon.cs
index 111a589..3bacd32 100644
--- a/HDL_ON/Common/HDLCommon.cs
+++ b/HDL_ON/Common/HDLCommon.cs
@@ -4,6 +4,7 @@
using HDL_ON.UI.CSS;
using HDL_ON.DAL.Server;
using HDL_ON.UI;
+using HDL_ON.Entity;
namespace HDL_ON
{
@@ -237,7 +238,99 @@
}
}
+ #region 鎺ㄩ�佸鐞�
+ /// <summary>
+ /// 鎺ㄩ�佹秷鎭鐞�
+ /// </summary>
+ /// <param name="jpushMessageInfo"></param>
+ public void AdjustPushMessage(JPushMessageInfo jpushMessageInfo)
+ {
+ try
+ {
+ if (jpushMessageInfo.Extras != null && jpushMessageInfo.Extras.Contains("Offline"))
+ {
+ Shared.Application.RunOnMainThread(() =>
+ {
+ //璐﹀彿鍦ㄥ埆澶勭櫥闄嗭紝琚涪涓嬬嚎 璺宠浆鍒扮櫥褰曢〉闈�
+ new Alert(Language.StringByID(StringId.Tip), Language.StringByID(StringId.LoggedOnOtherDevices), Language.StringByID(StringId.Close)).Show();
+ //2020-12-04 寰呭鍔犻��鍑虹櫥褰曟搷浣�
+ Logout();
+ });
+ return;
+ }
+ else
+ {
+ Shared.Application.RunOnMainThread(() =>
+ {
+ new Alert(jpushMessageInfo.Title, jpushMessageInfo.Content, Language.StringByID(StringId.Close)).Show();
+ });
+ return;
+
+ }
+ }
+ catch
+ {
+
+ }
+ }
+
+ /// <summary>
+ /// 閫�鍑虹櫥褰曟搷浣�
+ /// </summary>
+ public void Logout()
+ {
+ try
+ {
+ Shared.Application.RunOnMainThread(() =>
+ {
+ #region 淇濆瓨鏈湴鏁版嵁鑷虫枃浠跺す
+ string oldRegionRootPath = FileUtils.CreateRegionBackup(DB_ResidenceData.residenceData.CurReginID.ToString());
+ new System.Threading.Thread(() =>
+ {
+ try
+ {
+ var backuplist = FileUtils.ReadFiles();
+ FileUtils.DeleteRegionFiles(oldRegionRootPath);
+ //绉诲姩鏂囦欢
+ foreach (var fileName in backuplist)
+ {
+ System.IO.FileInfo fileInfo = new System.IO.FileInfo(FileUtils.RootPath + fileName);
+ if (fileInfo.Exists)
+ {
+ fileInfo.MoveTo(oldRegionRootPath + fileName);
+ MainPage.Log("move file : " + fileName);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ MainPage.Log($"xxx:{ex.Message}");
+ }
+ finally
+ {
+ FileUtils.DeleteAllFile();
+ }
+ }).Start();
+ #endregion
+
+ ////2.娉ㄩ攢鎺ㄩ��
+ new HttpServerRequest().SignOutPush();
+ //3.璺宠浆鐧诲綍椤甸潰
+ UserInfo.Current.LastTime = DateTime.MinValue;
+ UserInfo.Current.headImagePagePath = "LoginIcon/2.png";//閲嶇疆鐢ㄦ埛澶村儚
+ UserInfo.Current.SaveUserInfo();
+ MainPage.GoLoginPage(UserInfo.Current);
+ DB_ResidenceData.residenceData.EixtAccount();
+ });
+
+ }
+ catch (Exception ex)
+ {
+ MainPage.Log($"xxx:{ex.Message}");
+ }
+ }
+ #endregion
}
}
diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs
index 22e42b4..aeb874a 100644
--- a/HDL_ON/DAL/DriverLayer/Control.cs
+++ b/HDL_ON/DAL/DriverLayer/Control.cs
@@ -228,13 +228,14 @@
function.refreshTime = DateTime.Now;
DAL.Server.HttpServerRequest httpServer = new DAL.Server.HttpServerRequest();
//杩滅▼閫氳
- if (Ins.IsRemote)
+ if (!Ins.IsRemote)
{
//ALink鎺у埗銆丅us鎺у埗浣跨敤鍚屼竴涓帴鍙f帶鍒讹紝鐢变簯绔礋璐hВ鏋�
var apiControlData = function.GetApiControlData(commandDictionary);
var actionObjs = new List<ApiAlinkControlActionObj>();
actionObjs.Add(apiControlData);
- httpServer.ControlDevice(actionObjs);
+ var pack = httpServer.ControlDevice(actionObjs);
+ MainPage.Log($"{pack.Code}:{pack.Data}");
}
//鏈湴閫氳
else
diff --git a/HDL_ON/DAL/Server/HttpServerRequest.cs b/HDL_ON/DAL/Server/HttpServerRequest.cs
index 1b9acae..09c3ea8 100644
--- a/HDL_ON/DAL/Server/HttpServerRequest.cs
+++ b/HDL_ON/DAL/Server/HttpServerRequest.cs
@@ -1833,7 +1833,7 @@
{
Dictionary<string, object> d = new Dictionary<string, object>();
d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID);
- d.Add("gatewayId", DriverLayer.Control.Ins.GatewayId);
+ d.Add("gatewayId", DB_ResidenceData.residenceData.HomeGateway.gatewayId);//DriverLayer.Control.Ins.GatewayId);
d.Add("actions", actionObjs);
var requestJson = HttpUtil.GetSignRequestJson(d);
diff --git a/HDL_ON/DAL/Server/HttpUtil.cs b/HDL_ON/DAL/Server/HttpUtil.cs
index 0e405b0..84a5333 100644
--- a/HDL_ON/DAL/Server/HttpUtil.cs
+++ b/HDL_ON/DAL/Server/HttpUtil.cs
@@ -470,7 +470,8 @@
static string GetTimestamp()
{
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 褰撳湴鏃跺尯
- return ((long)(DateTime.Now - startTime).TotalSeconds).ToString(); // 鐩稿樊绉掓暟
+ return ((long)(DateTime.Now - startTime).TotalMilliseconds).ToString(); // 鐩稿樊绉掓暟
+ //return ((long)(DateTime.Now - startTime).TotalSeconds).ToString(); // 鐩稿樊绉掓暟
}
/// <summary>
diff --git a/HDL_ON/DAL/Server/NewApiRes.cs b/HDL_ON/DAL/Server/NewApiRes.cs
index 54d25de..d0bfa07 100644
--- a/HDL_ON/DAL/Server/NewApiRes.cs
+++ b/HDL_ON/DAL/Server/NewApiRes.cs
@@ -1370,7 +1370,7 @@
/// <summary>
/// 涓婁紶鍥剧墖
/// </summary>
- /// [System.Serializable]
+ [System.Serializable]
public class UploadImageObj
{
/// <summary>
@@ -1394,7 +1394,7 @@
/// <summary>
/// 鏌ヨ鍥剧墖璺緞
/// </summary>
- /// [System.Serializable]
+ [System.Serializable]
public class GetImageUrlObj
{
/// <summary>
@@ -1408,6 +1408,26 @@
#endregion
+ /// <summary>
+ /// 鏋佸厜鎺ㄩ�佹秷鎭�
+ /// </summary>
+ [System.Serializable]
+ public class JPushMessageInfo
+ {
+ /// <summary>
+ /// 鎺ㄩ�佹爣棰�
+ /// </summary>
+ public string Title;
+ /// <summary>
+ /// 鎺ㄩ�佸唴瀹�
+ /// </summary>
+ public string Content;
+ /// <summary>
+ /// 鎺ㄩ�侀檮鍔犳暟鎹�
+ /// </summary>
+ public string Extras;
+
+ }
//#region 鏃ф帴鍙�
///// <summary>
diff --git a/HDL_ON/Entity/Function/Function.cs b/HDL_ON/Entity/Function/Function.cs
index 29ec0d6..1e58983 100644
--- a/HDL_ON/Entity/Function/Function.cs
+++ b/HDL_ON/Entity/Function/Function.cs
@@ -126,6 +126,10 @@
/// </summary>
public bool collect = false;
/// <summary>
+ /// 鏄惁鍦ㄧ嚎
+ /// </summary>
+ public bool online = true;
+ /// <summary>
/// 浜戠鏁版嵁鍒涘缓鐨勬椂闂�
/// </summary>
public string createTime = "";
@@ -368,6 +372,8 @@
public string spk = "";
public List<AlinkControlAttributes> attributes = new List<AlinkControlAttributes>();
+ //[Newtonsoft.Json.JsonIgnore]
+ public BusData bus = new BusData();
}
/// <summary>
@@ -763,6 +769,7 @@
public class BusData
{
public string addresses = "FFFF";
+ [Newtonsoft.Json.JsonIgnore]
public byte SubnetID
{
get
@@ -770,6 +777,7 @@
return Convert.ToByte(addresses.Substring(0, 2), 16);
}
}
+ [Newtonsoft.Json.JsonIgnore]
public byte DeviceID
{
get
diff --git a/HDL_ON/Entity/FunctionList.cs b/HDL_ON/Entity/FunctionList.cs
index c88347c..a48047a 100644
--- a/HDL_ON/Entity/FunctionList.cs
+++ b/HDL_ON/Entity/FunctionList.cs
@@ -124,20 +124,20 @@
case SPK.LightRGB:
case SPK.LightRGBW:
case SPK.LightCCT:
- List.lights.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Light>(functionDataString));
+ _FunctionList.lights.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Light>(functionDataString));
break;
case SPK.CurtainRoller:
case SPK.CurtainShades:
case SPK.CurtainSwitch:
case SPK.CurtainTrietex:
- List.curtains.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Curtain>(functionDataString));
+ _FunctionList.curtains.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Curtain>(functionDataString));
break;
case SPK.AcStandard:
- List.aCs.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<AC>(functionDataString));
+ _FunctionList.aCs.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<AC>(functionDataString));
break;
case SPK.FloorHeatStandard:
//鎭㈠鍦扮儹鏁版嵁
- List.floorHeatings.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<FloorHeating>(functionDataString));
+ _FunctionList.floorHeatings.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<FloorHeating>(functionDataString));
break;
case SPK.SensorPm25:
case SPK.SensorCO2:
@@ -145,19 +145,19 @@
case SPK.SensorTemperature:
case SPK.SensorHumidity:
//鎭㈠鐜鏁版嵁
- List.sensorsEnvironmentalScience.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Sensor>(functionDataString));
+ _FunctionList.sensorsEnvironmentalScience.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Sensor>(functionDataString));
break;
case SPK.ElectricSocket:
//鎭㈠鎻掑骇鏁版嵁
- List.switchSockets.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<SwitchSocket>(functionDataString));
+ _FunctionList.switchSockets.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<SwitchSocket>(functionDataString));
break;
case SPK.ElectricTV:
//鎭㈠鐢佃鏁版嵁
- List.tVs.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<TV>(functionDataString));
+ _FunctionList.tVs.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<TV>(functionDataString));
break;
case SPK.ElectricFan:
//鎭㈠椋庢墖鏁版嵁
- List.fans.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Fan>(functionDataString));
+ _FunctionList.fans.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Fan>(functionDataString));
break;
}
}
@@ -195,14 +195,17 @@
/// </summary>
public List<Function> GetAllDeviceFunctionList()
{
- deviceFunctionList = new List<Function>();
- deviceFunctionList.AddRange(aCs);
- deviceFunctionList.AddRange(lights);
- deviceFunctionList.AddRange(curtains);
- deviceFunctionList.AddRange(floorHeatings);
- deviceFunctionList.AddRange(electricals);
- deviceFunctionList.AddRange(sensorsEnvironmentalScience);
- deviceFunctionList.AddRange(UI.Music.A31MusicModel.A31MusicModelList);
+ if (deviceFunctionList == null)
+ {
+ deviceFunctionList = new List<Function>();
+ deviceFunctionList.AddRange(aCs);
+ deviceFunctionList.AddRange(lights);
+ deviceFunctionList.AddRange(curtains);
+ deviceFunctionList.AddRange(floorHeatings);
+ deviceFunctionList.AddRange(electricals);
+ deviceFunctionList.AddRange(sensorsEnvironmentalScience);
+ deviceFunctionList.AddRange(UI.Music.A31MusicModel.A31MusicModelList);
+ }
try
{
deviceFunctionList.OrderByDescending(o => o.usageCount).ToList();
@@ -305,30 +308,30 @@
switch (f.functionType)
{
case FunctionType.AC:
- aCs.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<AC>(obj.ToString()));
+ _FunctionList.aCs.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<AC>(obj.ToString()));
break;
case FunctionType.FloorHeating:
- floorHeatings.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<FloorHeating>(obj.ToString()));
+ _FunctionList.floorHeatings.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<FloorHeating>(obj.ToString()));
break;
}
break;
case FunctionCategory.Light:
- lights.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Light>(obj.ToString()));
+ _FunctionList.lights.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Light>(obj.ToString()));
break;
case FunctionCategory.Curtain:
- curtains.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Curtain>(obj.ToString()));
+ _FunctionList.curtains.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Curtain>(obj.ToString()));
break;
case FunctionCategory.Electrical:
switch(f.functionType)
{
case FunctionType.TV:
- electricals.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<TV>(obj.ToString()));
+ _FunctionList.electricals.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<TV>(obj.ToString()));
break;
case FunctionType.Socket:
- electricals.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<SwitchSocket>(obj.ToString()));
+ _FunctionList.electricals.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<SwitchSocket>(obj.ToString()));
break;
case FunctionType.Fan:
- electricals.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Fan>(obj.ToString()));
+ _FunctionList.electricals.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Fan>(obj.ToString()));
break;
}
break;
@@ -339,8 +342,8 @@
case FunctionType.CO2:
case FunctionType.PM25:
case FunctionType.Humidity:
- //case FunctionType.Noise:
- sensorsEnvironmentalScience.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Sensor>(obj.ToString()));
+ case FunctionType.Temp:
+ _FunctionList.sensorsEnvironmentalScience.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Sensor>(obj.ToString()));
break;
}
break;
@@ -361,34 +364,41 @@
var deviceList = Newtonsoft.Json.JsonConvert.DeserializeObject<DevcieApiPack>(pack.Data.ToString());
if (deviceList != null)
{
- foreach (var function in deviceList.list)
+ foreach(var localFunction in List.GetAllDeviceFunctionList())
{
- var localFunction = DB_ResidenceData.functionList.GetAllDeviceFunctionList().Find((obj) => obj.deviceId == function.deviceId);
- if (localFunction != null)
+ var newFunction = deviceList.list.Find((obj) => obj.deviceId == localFunction.deviceId);
+ if (newFunction == null)//濡傛灉浜戠鏈�鏂版暟鎹病鏈夎鏉℃暟鎹紝鍒欐湰鍦伴渶瑕佸垹鎺夎鏁版嵁璁板綍
{
- if (localFunction.modifyTime != function.modifyTime)
- {
- localFunction.name = function.name;
- localFunction.collect = function.collect;
- localFunction.modifyTime = function.modifyTime;
- localFunction.createTime = function.createTime;
- localFunction.roomIds = function.roomIds;
- localFunction.bus_Data = function.bus_Data;
- }
- localFunction.SaveFunctionData();
+ List.DeleteFunction(localFunction);
}
else
{
- function.SaveFunctionData();
- List.IniFunctionList(function.savePath);
+ if (localFunction.modifyTime != newFunction.modifyTime)
+ {
+ localFunction.name = newFunction.name;
+ localFunction.collect = newFunction.collect;
+ localFunction.modifyTime = newFunction.modifyTime;
+ localFunction.createTime = newFunction.createTime;
+ localFunction.roomIds = newFunction.roomIds;
+ localFunction.bus_Data = newFunction.bus_Data;
+ new System.Threading.Thread(() =>
+ {
+ localFunction.SaveFunctionData();
+ })
+ { IsBackground = true }.Start();
+ }
+ deviceList.list.Remove(newFunction);//鎿嶄綔瀹岀殑鏁版嵁娓呯悊鎺夛紝鍓╀笅鐨勫氨鏄柊澧炵殑鍔熻兘
}
-
- var funcitonInfoPack = pm.GetDeviceInfoList(new List<string>() { function.deviceId });
- var funcitonInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<Function>(funcitonInfoPack.Data.ToString());
- if (funcitonInfo != null)
+ }
+ //澶勭悊鍓╀笅鐨勬柊澧炲姛鑳�
+ foreach (var newFunction in deviceList.list)
+ {
+ new System.Threading.Thread(() =>
{
-
- }
+ newFunction.SaveFunctionData();
+ List.IniFunctionList(newFunction.savePath);
+ })
+ { IsBackground = true }.Start();
}
}
MainPage.Log($"璇诲彇浜戠璁惧鏁版嵁:\r\n{ pack.Data.ToString()}");
@@ -396,7 +406,6 @@
{
MainPage.Log($"璇诲彇浜戠璁惧鏁版嵁澶辫触:\r\nCode:{pack.Code}; Msg:{pack.message}");
}
-
})
{ IsBackground = true }.Start();
}
@@ -448,6 +457,51 @@
scene.DeleteSign = true;
List.scenes.Remove(scene);
}
+ /// <summary>
+ /// 鍒犻櫎鏈湴鍔熻兘鏂囦欢
+ /// </summary>
+ public void DeleteFunction(Function delTemp)
+ {
+ switch (delTemp.spk)
+ {
+ case SPK.LightSwitch:
+ case SPK.LightDimming:
+ case SPK.LightRGB:
+ case SPK.LightRGBW:
+ case SPK.LightCCT:
+ _FunctionList.lights.Remove(_FunctionList.lights.Find((obj) => obj.deviceId == delTemp.deviceId));
+ break;
+ case SPK.CurtainRoller:
+ case SPK.CurtainShades:
+ case SPK.CurtainSwitch:
+ case SPK.CurtainTrietex:
+ _FunctionList.curtains.Remove(_FunctionList.curtains.Find((obj) => obj.deviceId == delTemp.deviceId));
+ break;
+ case SPK.AcStandard:
+ _FunctionList.aCs.Remove(_FunctionList.aCs.Find((obj) => obj.deviceId == delTemp.deviceId));
+ break;
+ case SPK.FloorHeatStandard:
+ _FunctionList.floorHeatings.Remove(_FunctionList.floorHeatings.Find((obj) => obj.deviceId == delTemp.deviceId));
+ break;
+ case SPK.SensorPm25:
+ case SPK.SensorCO2:
+ case SPK.SensorTVOC:
+ case SPK.SensorTemperature:
+ case SPK.SensorHumidity:
+ _FunctionList.sensorsEnvironmentalScience.Remove(_FunctionList.sensorsEnvironmentalScience.Find((obj) => obj.deviceId == delTemp.deviceId));
+ break;
+ case SPK.ElectricSocket:
+ _FunctionList.switchSockets.Remove(_FunctionList.switchSockets.Find((obj) => obj.deviceId == delTemp.deviceId));
+ break;
+ case SPK.ElectricTV:
+ _FunctionList.tVs.Remove(_FunctionList.tVs.Find((obj) => obj.deviceId == delTemp.deviceId));
+ break;
+ case SPK.ElectricFan:
+ _FunctionList.fans.Remove(_FunctionList.fans.Find((obj) => obj.deviceId == delTemp.deviceId));
+ break;
+ }
+ FileUtils.DeleteFile(delTemp.savePath);
+ }
}
diff --git a/HDL_ON/Entity/Room.cs b/HDL_ON/Entity/Room.cs
index 91e78cd..7d39796 100644
--- a/HDL_ON/Entity/Room.cs
+++ b/HDL_ON/Entity/Room.cs
@@ -122,15 +122,25 @@
{
foreach (var updateTemp in roomUpdateList)
{
+ var localDelRoom = CurrentSpatial.needDeleteRooms.Find((obj) => obj.roomId == updateTemp.roomId);
+ if(localDelRoom!= null)
+ {
+ DelRoom(localDelRoom);
+
+ continue;
+ }
var localRoom = CurrentSpatial.RoomList.Find((obj) => obj.roomId == updateTemp.roomId);
if (localRoom != null)
{
- localRoom.roomName = updateTemp.roomName;
- localRoom.roomImage = updateTemp.roomImage;
- localRoom.parentId = updateTemp.parentId;
- localRoom.createTime = updateTemp.createTime;
- localRoom.modifyTime = updateTemp.modifyTime;
- localRoom.SaveRoomData();
+ if (localRoom.modifyTime != updateTemp.modifyTime)
+ {
+ localRoom.roomName = updateTemp.roomName;
+ localRoom.roomImage = updateTemp.roomImage;
+ localRoom.parentId = updateTemp.parentId;
+ localRoom.createTime = updateTemp.createTime;
+ localRoom.modifyTime = updateTemp.modifyTime;
+ localRoom.SaveRoomData();
+ }
}else
{
updateTemp.SaveRoomData();
@@ -143,6 +153,8 @@
foreach(var newRoom in roomUpdateList)
{
newRoom.SaveRoomData();
+ RoomList.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<Room>(
+ Newtonsoft.Json.JsonConvert.SerializeObject(newRoom)));
}
}
}
@@ -194,7 +206,7 @@
{
try
{
- var floorsDataBytes = FileUtils.ReadFile(dataSavePath);
+ var floorsDataBytes = FileUtils.ReadFile("FloorsData");
if (floorsDataBytes != null)
{
var floorsDataString = System.Text.Encoding.UTF8.GetString(floorsDataBytes);
@@ -262,7 +274,7 @@
if (tRoom != null)
{
FloorList.Remove(floor);
- floor.modifyTime = "";
+ floor.DeleteSign = true;
}
SaveFloorData();
}
@@ -278,16 +290,7 @@
SaveSpatialInfo();
}
- /// <summary>
- /// 淇濆瓨鎴块棿鏁版嵁
- /// </summary>
- public void SaveRoomData()
- {
- var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
- FileUtils.WriteFileByBytes(dataSavePath, ssd);
- MainPage.Log($"Save Room Data {roomName} : {uid}");
- SaveSpatialInfo();
- }
+
#endregion
#region 鎴块棿鍒楄〃
@@ -316,11 +319,40 @@
var roomDataBytes = FileUtils.ReadFile(filePath);
var roomDataString = System.Text.Encoding.UTF8.GetString(roomDataBytes);
var room = Newtonsoft.Json.JsonConvert.DeserializeObject<Room>(roomDataString);
- if (room != null)
+ if (room != null )
{
- rooms.Add(room);
+ if(room.DeleteSign)
+ {
+ needDeleteRooms.Add(room);
+ }else
+ {
+ rooms.Add(room);
+ }
}
}
+ }
+ if(needDeleteRooms.Count>0)
+ {
+ //鍒犻櫎宸茬粡鏍囪闇�瑕佸垹闄ょ殑鎴块棿
+ new System.Threading.Thread(() =>
+ {
+ var delIds = new List<string>();
+ foreach(var delTemp in needDeleteRooms)
+ {
+ delIds.Add(delTemp.roomId);
+ }
+ var pm = new HttpServerRequest();
+ var pack = pm.DeleteRoom(delIds);
+ if (pack.Code == StateCode.SUCCESS)
+ {
+ foreach (var delTemp in needDeleteRooms)
+ {
+ FileUtils.DeleteFile(delTemp.dataSavePath);
+ }
+ needDeleteRooms.Clear();
+ }
+ })
+ { IsBackground = true }.Start();
}
}
catch (Exception ex)
@@ -331,6 +363,12 @@
return rooms;
}
}
+ /// <summary>
+ /// 闇�瑕佸垹闄ょ殑鎴块棿
+ /// 鏈湴鏍囪鍒犻櫎浜嗭紝浣嗘槸鏈嶅姟涓婃病鏈夊垹闄�
+ /// 鏃犳硶涓庢湇鍔″櫒閫氳閫犳垚鍒犻櫎涓嶆垚鍔燂紝閫氳鎴愬姛涔嬪悗瑕侀噸鏂板垹闄�
+ /// </summary>
+ List<Room> needDeleteRooms = new List<Room>();
/// <summary>
/// 澧炲姞鎴块棿
/// </summary>
@@ -346,14 +384,29 @@
/// <param name="room"></param>
public void DelRoom(Room room)
{
- var tRoom = RoomList.Find((obj) => obj.uid == room.uid);
- if (tRoom != null)
+ new System.Threading.Thread(() =>
{
- FileUtils.DeleteFile(room.dataSavePath);
- RoomList.Remove(room);
room.DeleteSign = true;
- }
- room.SaveRoomData();
+ room.SaveRoomData();
+ var tRoom = RoomList.Find((obj) => obj.uid == room.uid);
+ if (tRoom != null)
+ {
+ RoomList.Remove(room);
+ }
+ var temp = needDeleteRooms.Find((obj) => obj.uid == room.uid);
+ if (temp != null)
+ {
+ needDeleteRooms.Add(room);
+ }
+ var pm = new HttpServerRequest();
+ var pack = pm.DeleteRoom(new List<string>() { room.roomId });
+ if (pack.Code == StateCode.SUCCESS)
+ {
+ FileUtils.DeleteFile(room.dataSavePath);
+ needDeleteRooms.Remove(room);
+ }
+ })
+ { IsBackground = true }.Start();
}
/// <summary>
/// 鍒犻櫎鎵�鏈夋埧闂�
@@ -390,7 +443,16 @@
{ IsBackground = true }.Start();
}
-
+ /// <summary>
+ /// 淇濆瓨鎴块棿鏁版嵁
+ /// </summary>
+ public void SaveRoomData()
+ {
+ var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
+ FileUtils.WriteFileByBytes(dataSavePath, ssd);
+ MainPage.Log($"Save Room Data {roomName} : {uid}");
+ SaveSpatialInfo();
+ }
#endregion
}
--
Gitblit v1.8.0