wxr
2022-03-15 f461949beb54ae5d3e0353fa49d94800d0af6fbb
增加离线推送
12个文件已修改
311 ■■■■ 已修改文件
HDL_ON/DAL/Mqtt/MqttClient.cs 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/DAL/Server/HttpUtil.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/1-HomePage/HomePage.cs 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/2-Classification/ClassificaitionPublicBLL.cs 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs 87 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/2-Classification/FunctionPage.cs 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/2-Classification/FunctionPageBLL.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/2-Classification/RoomPageBLL.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/3-Intelligence/Automation/FunTpye.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
SiriIntents/Server/HttpUtil.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/DAL/Mqtt/MqttClient.cs
@@ -218,6 +218,12 @@
                        Topic = $"/user/{DB_ResidenceData.Instance.CurrentRegion.id}/app/thing/event/appDeviceRefresh/up",
                        QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce
                    };
                    //设备在线离线状态推送
                    var deviceOnlinePush = new MqttTopicFilter()
                    {
                        Topic = $"/user/{DB_ResidenceData.Instance.CurrentRegion.id}/app/son/session/online",
                        QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce
                    };
                    //appRoomRefresh:房间数据刷新通知
                    var appRoomRefresh = new MqttTopicFilter()
                    {
@@ -253,6 +259,7 @@
                        pirStatus,pirStudy,
                        appDeviceRefresh,appHomeRefresh,appRoomRefresh,residenceChange,
                        topicFilterPush2, topicAlinkStatus ,mqttkeyChange,
                        deviceOnlinePush,
                        securityStatusChange});
                    if (result.Items[0].ResultCode == MQTTnet.Client.Subscribing.MqttClientSubscribeResultCode.GrantedQoS0)
                    {
@@ -345,6 +352,32 @@
                                    //新挤下线主题方案 收到挤下线主题
                                    ReceiveNotifySqueezeAsync(mMes);
                                }
                                //设备在线离线状态推送
                                else if(topic == $"/user/{DB_ResidenceData.Instance.CurrentRegion.id}/app/son/session/online")
                                {
                                    try
                                    {
                                        var mMes = Encoding.UTF8.GetString(e.ApplicationMessage.Payload);
                                        Newtonsoft.Json.Linq.JObject pairs = Newtonsoft.Json.Linq.JObject.Parse(mMes);
                                        var pairSid = pairs.GetValue("sid").ToString();
                                        var pairOnline = pairs.GetValue("online");
                                        if (!string.IsNullOrEmpty(pairSid.ToString()))
                                        {
                                            var function_online = FunctionList.List.Functions.Find((obj) => obj.sid == pairSid);
                                            if (function_online != null){
                                                function_online.online = (bool)pairOnline;
                                                HomePage.LoadEvent_RefreshDevcieOnline(function_online);
                                                FunctionPage.UpdataOnline(function_online);
                                                RoomPage.UpdataOnline(function_online);
                                            }
                                        }
                                    }
                                    catch(Exception ex)
                                    {
                                    }
                                }
                                //App订阅红外宝/网关遥控器添加成功通知
                                else if (topic == $"/user/{DB_ResidenceData.Instance.CurrentRegion.id}/app/thing/topo/found")
                                {
HDL_ON/DAL/Server/HttpUtil.cs
@@ -17,8 +17,8 @@
        /// 固定域名,正式环境
        /// 公共域名就近解析
        /// </summary>
        public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com";
        //public const string GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com";//mmmm
        //public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com";
        public const string GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com";//mmmm
        /// <summary>
        /// RegionMark
        /// </summary>
HDL_ON/UI/UI2/1-HomePage/HomePage.cs
@@ -189,22 +189,35 @@
                //更新链接状态icon颜色
                int ddd = 0;
#if DEBUG
                btnResidenceName.MouseUpEventHandler = (sender, e) =>
                {
                    if (UserInfo.Current.VerOpenDoorPw || string.IsNullOrEmpty(UserInfo.Current.doorPasswordString))
                    //if (UserInfo.Current.VerOpenDoorPw || string.IsNullOrEmpty(UserInfo.Current.doorPasswordString))
                    //{
                    //    var page = new DoorLockUnlockPage(new Function());
                    //    MainPage.BasePageView.AddChidren(page);
                    //    page.LoadView();
                    //    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                    //}
                    //else
                    //{
                    //    Control.Ins.OneKeyUnlocking(new Function(), UserInfo.Current.doorPasswordString);
                    //}
                ddd++;
                    Function function_online = FunctionList.List.GetLightList().Find((obj) => obj.sid == "0001017DB92D2602020100010101");
                    if(ddd%2 == 0)
                    {
                        var page = new DoorLockUnlockPage(new Function());
                        MainPage.BasePageView.AddChidren(page);
                        page.LoadView();
                        MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                        function_online.online = true;
                    }
                    else
                    {
                        Control.Ins.OneKeyUnlocking(new Function(), UserInfo.Current.doorPasswordString);
                        function_online.online = false;
                    }
                    HomePage.LoadEvent_RefreshDevcieOnline(function_online);
                };
#endif
@@ -1327,9 +1340,6 @@
                    UpdataFunctionStates(function);
                }
                if (!function.online)
                {
                    var btnOffline = new Button()
                    {
                        X = btnIcon.Right,
@@ -1338,11 +1348,12 @@
                        TextID = StringId.DeviceOffline,
                        TextColor = CSS_Color.WarningColor,
                        TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                        TextAlignment = TextAlignment.CenterLeft
                    TextAlignment = TextAlignment.CenterLeft,
                    Tag = "OnlineTag",
                    Visible = !function.online
                    };
                    view.AddChidren(btnOffline);
                }
            }
            catch (Exception ex)
            {
HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs
@@ -10,6 +10,52 @@
    public partial class HomePage
    {
        /// <summary>
        /// 更新设备在线状态
        /// </summary>
        public static void LoadEvent_RefreshDevcieOnline(Function function)
        {
            Application.RunOnMainThread(() =>
            {
                if (bodyView != null)
                {
                    foreach (var view in bodyView.functionViews)
                    {
                        if (view.Tag.ToString() == function.sid)
                        {
                            for (int i = 0; i < view.ChildrenCount; i++)
                            {
                                if (view.GetChildren(i).GetType() == typeof(Button))
                                {
                                    var btn = view.GetChildren(i) as Button;
                                    if(btn.Tag == null)
                                    {
                                        continue;
                                    }
                                    if (btn.Tag.ToString() == function.sid)
                                    {
                                        if (function.online)
                                        {
                                            btn.UnSelectedImagePath = "Collection/Functionbg.png";
                                            btn.IsSelected = false;
                                        }
                                        else
                                        {
                                            btn.UnSelectedImagePath = "Collection/FunctionOfflineBg.png";
                                            btn.IsSelected = false;
                                        }
                                    }
                                    else if (btn.Tag.ToString() == "OnlineTag")
                                    {
                                        btn.Visible = !function.online;
                                    }
                                }
                            }
                        }
                    }
                }
            });
        }
        /// <summary>
        /// 更新主页天气
        /// </summary>
        public static void LoadEvent_RefreshAir()
HDL_ON/UI/UI2/2-Classification/ClassificaitionPublicBLL.cs
@@ -1,5 +1,6 @@
using System;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using Shared;
namespace HDL_ON.UI
@@ -16,7 +17,7 @@
        /// <param name="updataFunction"></param>
        public void UpdataStates(Function updataFunction, FrameLayout view, VerticalScrolViewLayout scrolView, Room room = null)
        {
            Application.RunOnMainThread((Action)(() =>
            Application.RunOnMainThread((() =>
            {
                try
                {
@@ -181,5 +182,49 @@
                }
            }));
        }
        public void UpdataOnlineStatus(Function updataFunction, FrameLayout view, VerticalScrolViewLayout scrolView, Room room = null)
        {
            Application.RunOnMainThread(() =>
            {
                try
                {
                    if (view == null || scrolView == null || updataFunction == null)
                    {
                        return;
                    }
                    if (!scrolView.ScrollEnabled)
                    {
                        return;
                    }
                    if (room != null)
                    {
                        if (!updataFunction.roomIds.Contains(room.roomId))
                        {
                            return;
                        }
                    }
                    for (int i = 0; i < scrolView.ChildrenCount; i++)
                    {
                        if (scrolView.GetChildren(i).Tag == null || scrolView.GetChildren(i).Tag.ToString() == "")
                        {
                            continue;
                        }
                        var viewTag = scrolView.GetChildren(i).Tag.ToString();
                        if (scrolView.GetChildren(i).Tag != null && viewTag == updataFunction.spk + updataFunction.sid)
                        {
                            if (scrolView.GetChildren(i).GetType() == typeof(FunctionControlZone)) {
                                var fcView = scrolView.GetChildren(i) as FunctionControlZone;
                                fcView.UpdataOnline(updataFunction.online);
                            }
                        }
                    }
                }catch (Exception ex)
                {
                    MainPage.Log("Function Online status error : " + ex.Message);
                }
            });
        }
    }
}
HDL_ON/UI/UI2/2-Classification/FunctionControlZone.cs
@@ -1,7 +1,6 @@
using System;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using HDL_ON.UI.Music;
using Shared;
namespace HDL_ON.UI
@@ -9,7 +8,7 @@
    public partial class FunctionControlZone : FrameLayout
    {
        #region 区域控件
        static FrameLayout bodyDiv;
        FunctionControlZone bodyDiv;
        /// <summary>
        /// 功能/场景icon
        /// </summary>
@@ -26,6 +25,11 @@
        /// 收藏按钮
        /// </summary>
        Button btnCollectionIcon;
        /// <summary>
        /// 离线文本
        /// </summary>
        Button btnOffline;
        #endregion
        #region 区域变量
@@ -229,7 +233,7 @@
            if (!function.online)
            {
                bodyDiv.BackgroundColor = CSS_Color.PromptingColor2;
                var btnOffline = new Button()
                btnOffline = new Button()
                {
                    X = Application.GetRealWidth(8 + 10 + 32),
                    Y = Application.GetRealHeight(28 + 24),
HDL_ON/UI/UI2/2-Classification/FunctionControlZoneBLL.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using HDL_ON.DriverLayer;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using HDL_ON.UI.Music;
using Shared;
@@ -9,54 +10,60 @@
{
    public partial class FunctionControlZone
    {
        //    /// <summary>
        //    /// 更新开关状态
        //    /// </summary>
        //    /// <param name="upfunc"></param>
        //    public static void UpdataOnOffState(Function upfunc)
        //    {
        //        if(bodyDiv!= null)
        //        {
        //            Application.RunOnMainThread(() => {
        //                if(bodyDiv.Tag.ToString() == upfunc.sid)
        //                {
        //                    for (var o = 0; o < bodyDiv.ChildrenCount; o++)
        //                    {
        //                        if (bodyDiv.GetChildren(o).GetType() == typeof(Button))
        //                        {
        //                            var btn = bodyDiv.GetChildren(o) as Button;
        //                            if (btn.Tag != null)
        //                            {
        //                                if (btn.Tag.ToString() == upfunc.sid + "_Switch")// + "_DimmerBar")
        //                                {
        //                                    btn.IsSelected = upfunc.trait_on_off.curValue.ToString() == "on";
        //                                }
        //                            }
        //                        }
        //                        else if (bodyDiv.GetChildren(o).GetType() == typeof(DiyImageSeekBar))
        //                        {
        //                            var btn = bodyDiv.GetChildren(o) as DiyImageSeekBar;
        //                            if (btn.Tag != null)
        //                            {
        //                                if (btn.Tag.ToString() == upfunc.sid + "_DimmerBar")
        //                                {
        //                                    btn.Progress = Convert.ToInt32(upfunc.GetAttrState(FunctionAttributeKey.Brightness));
        //                                }
        //                            }
        //                        }
        //                    }
        //                }
        //            });
        //        }
        //    }
        /// <summary>
        /// 更新开关状态
        /// 更新在线状态
        /// </summary>
        /// <param name="upfunc"></param>
        public static void UpdataOnOffState(Function upfunc)
        public void UpdataOnline(bool online)
        {
            if(bodyDiv!= null)
            {
                Application.RunOnMainThread(() => {
                    if(bodyDiv.Tag.ToString() == upfunc.sid)
                Application.RunOnMainThread(() =>
                    {
                        for (var o = 0; o < bodyDiv.ChildrenCount; o++)
                        {
                            if (bodyDiv.GetChildren(o).GetType() == typeof(Button))
                            {
                                var btn = bodyDiv.GetChildren(o) as Button;
                                if (btn.Tag != null)
                                {
                                    if (btn.Tag.ToString() == upfunc.sid + "_Switch")// + "_DimmerBar")
                                    {
                                        btn.IsSelected = upfunc.trait_on_off.curValue.ToString() == "on";
                                    }
                                }
                            }
                            else if (bodyDiv.GetChildren(o).GetType() == typeof(DiyImageSeekBar))
                            {
                                var btn = bodyDiv.GetChildren(o) as DiyImageSeekBar;
                                if (btn.Tag != null)
                                {
                                    if (btn.Tag.ToString() == upfunc.sid + "_DimmerBar")
                                    {
                                        btn.Progress = Convert.ToInt32(upfunc.GetAttrState(FunctionAttributeKey.Brightness));
                                    }
                                }
                            }
                        }
                    }
                    bodyDiv.BackgroundColor = online ? CSS_Color.MainBackgroundColor : CSS_Color.PromptingColor2;
                    bodyDiv.btnOffline.Visible = !online;
                });
            }
        }
        /// <summary>
        /// 更新亮度状态
        /// </summary>
        /// <param name="upfunc"></param>
        static void UpdataBrightnessState(Function upfunc)
        {
        }
        /// <summary>
HDL_ON/UI/UI2/2-Classification/FunctionPage.cs
@@ -37,6 +37,7 @@
        public void LoadPage(int titleId)
        {
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
            if (titleId == StringId.Lights)
            {
@@ -65,6 +66,38 @@
            {
                new TopViewDiv(bodyView, Language.StringByID(titleId)).LoadTopView();
            }
#if DEBUG
            Button testBtn = new Button()
            {
                X = Application.GetRealWidth(80),
                Height = Application.GetRealHeight(64),
                BackgroundColor = 0xFFFF0000
            };
            bodyView.AddChidren(testBtn);
            int ddd = 0;
            testBtn.MouseUpEventHandler = (sender, e) => {
                ddd++;
                    Function function_online = FunctionList.List.GetLightList().Find((obj) => obj.sid == "0001017DB92D2602020100010101");
                if (ddd % 2 == 0)
                {
                    function_online.online = true;
                }
                else
                {
                    function_online.online = false;
                }
                HomePage.LoadEvent_RefreshDevcieOnline(function_online);
                FunctionPage.UpdataOnline(function_online);
                RoomPage.UpdataOnline(function_online);
            };
#endif
            /// <summary>
            /// 房间内容显示区域
            /// </summary>
HDL_ON/UI/UI2/2-Classification/FunctionPageBLL.cs
@@ -13,6 +13,10 @@
            new ClassificaitionPublicBLL().UpdataStates(function, bodyView, functionListView);
        }
        public static void UpdataOnline(Function function)
        {
            new ClassificaitionPublicBLL().UpdataOnlineStatus(function, bodyView, functionListView);
        }
    }
HDL_ON/UI/UI2/2-Classification/RoomPageBLL.cs
@@ -14,6 +14,10 @@
        {
            new ClassificaitionPublicBLL().UpdataStates(function, bodyView, functionListView,room);
        }
        public static void UpdataOnline(Function function)
        {
            new ClassificaitionPublicBLL().UpdataOnlineStatus(function, bodyView, functionListView);
        }
        /// <summary>
        /// 加载事件列表
HDL_ON/UI/UI2/3-Intelligence/Automation/FunTpye.cs
@@ -221,9 +221,9 @@
                        funAllAreaView.btnText2.Text = areaView.btnClick.Tag.ToString();
                        UserInfo.Current.logicselectedFunction = areaView.btnClick.Tag.ToString();
                        ///获取单个类型(例如:灯光类。。)设备FunctionType列表<简称:spk列表>
                        var typeFunctionList = LogicMethod.CurrLogicMethod.GetDeviceTypeFunctionList(UserInfo.Current.logicselectedFunction);
                        var typeFunctionList2 = LogicMethod.CurrLogicMethod.GetDeviceTypeFunctionList(UserInfo.Current.logicselectedFunction);
                        ///获取单个灯光类型(例如:灯光1,灯光2。。)设备列表
                        var lists2 = LogicMethod.CurrLogicMethod.GetShowDeviceList(typeFunctionList, functionList);
                        var lists2 = LogicMethod.CurrLogicMethod.GetShowDeviceList(typeFunctionList2, functionList);
                        DeviceListView(vv, lists2);
                    };
SiriIntents/Server/HttpUtil.cs
@@ -16,8 +16,8 @@
        /// 固定域名,正式环境
        /// 公共域名就近解析
        /// </summary>
        public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com";
        //public const string GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com";//mmmm
        //public const string GlobalRequestHttpsHost = "https://nearest.hdlcontrol.com";
        public const string GlobalRequestHttpsHost = "https://test-gz.hdlcontrol.com";//mmmm
        /// <summary>
        /// RegionMark
        /// </summary>