wxr
2024-05-07 f16fd06aa226e9f97a27858624d4ea7cf8975d25
HDL-ON_iOS/Other/SkipControl.cs
@@ -18,123 +18,123 @@
        public void SkipSiriView()
        {
            ////var user = new SiriBaseView();
            ////user.View.BackgroundColor = new UIColor(242, 243, 247, 1);
            //var user = new SiriBaseView();
            //user.View.BackgroundColor = new UIColor(242, 243, 247, 1);
            ////HDL_ON_iOS.AppDelegate.rootViewController.PushViewController(user, true);
            //HDL_ON_iOS.AppDelegate.rootViewController.PushViewController(user, true);
            //var sDM = new SiriKit.SceneDateManager();
            //Console.WriteLine($"IsLogin:{sDM.IsLgoin};accessToken:{sDM.AccessToken};refreshToken:{sDM.RefreshToken};RegionUrl:{sDM.RegionUrl};HomeId:{sDM.HomeId}");
            ////NSMutableArray list = new NSMutableArray();
            ////foreach (var localScene in HDL_ON.Entity.FunctionList.List.scenes)
            ////{
            ////    list.Add(new HDLSceneSiri.HDLSiriControlModel()
            ////    {
            ////        UserSceneId = localScene.userSceneId,
            ////        Name = localScene.name,
            ////    });
            ////}
            ////var vc = new HDLSceneSiri.HDLSiriSceneListViewController();
            ////vc.DataSource = list;
            //////vc.TitleName
            //////PresentViewController(vc, true, null);
            ////HDL_ON_iOS.AppDelegate.rootViewController.PushViewController(vc, true);
            ////1.初始化dataList
            //NSMutableArray dataSourceList = new NSMutableArray();
            ////2.初始化场景列表数据
            //HDLSiriShortcutModel sceneModel = new HDLSiriShortcutModel();
            //if (Language.CurrentLanguage == "Chinese")
            //{
            //    sceneModel.Title = "场景";
            //    sceneModel.Content = "将场景添加到快捷指令,即可通过Siri执行";
            //}
            //else
            //{
            //    sceneModel.Title = "Scenes";
            //    sceneModel.Content = "Add the scene to the shortcut, which can be executed through Siri";
            //}
            var sDM = new SiriKit.SceneDateManager();
            Console.WriteLine($"IsLogin:{sDM.IsLgoin};accessToken:{sDM.AccessToken};refreshToken:{sDM.RefreshToken};RegionUrl:{sDM.RegionUrl};HomeId:{sDM.HomeId}");
            //NSMutableArray list = new NSMutableArray();
            //foreach (var localScene in HDL_ON.Entity.FunctionList.List.scenes)
            //{
            //    list.Add(new HDLSiriControlModel()
            //    list.Add(new HDLSceneSiri.HDLSiriControlModel()
            //    {
            //        ControlId = localScene.userSceneId,//不能为空
            //        ControlName = localScene.name,//不能为空
            //        ControlType = "1",//不能为空
            //        ControlJSONStr = "1",//不能为空
            //        ActionName = Language.CurrentLanguage == "Chinese"? "场景": "Scene"//不能为空
            //        UserSceneId = localScene.userSceneId,
            //        Name = localScene.name,
            //    });
            //}
            //sceneModel.List = NSArray.FromArray<HDLSiriControlModel>(list);
            //dataSourceList.Add(sceneModel);
            ////3.初始化安防列表数据
            //HDLSiriShortcutModel securityModel = new HDLSiriShortcutModel();
            //if (Language.CurrentLanguage == "Chinese")
            //{
            //    securityModel.Title = "安防";
            //    securityModel.Content = "将安防添加到快捷指令,即可通过Siri执行";
            //}else
            //{
            //    securityModel.Title = "Security";
            //    securityModel.Content = "Add security to the shortcut, which can be executed through Siri";
            //}
            //NSMutableArray list2 = new NSMutableArray();
            //foreach (var temp in HDL_ON.Entity.FunctionList.List.securities)
            //{
            //    SecurityState securityState = new SecurityState()
            //    {
            //        gatewayId = DB_ResidenceData.Instance.HomeGateway.gatewayId,
            //        sid = temp.sid,
            //        status = "enable",
            //        userSecurityId = temp.userSecurityId
            //    };
            //    var ControlJSONStr = Newtonsoft.Json.JsonConvert.SerializeObject(securityState);
            //    list2.Add(new HDLSiriControlModel()
            //    {
            //        ControlId = temp.userSecurityId,//不能为空
            //        ControlName = temp.name,//不能为空
            //        ControlType = "2",//不能为空
            //        ControlJSONStr = ControlJSONStr,//不能为空
            //        ActionName = Language.CurrentLanguage == "Chinese" ? "安防" : "Security"//不能为空
            //    });
            //}
            //securityModel.List = NSArray.FromArray<HDLSiriControlModel>(list2);
            //dataSourceList.Add(securityModel);
            ////4.跳转Siri添加或者编辑管理页面
            //HDLSceneSiri.HDLSiriSceneListViewController vc = new HDLSceneSiri.HDLSiriSceneListViewController();
            //vc.DataSource = dataSourceList;
            //vc.HomeId = DB_ResidenceData.Instance.CurrentRegion.id;//不能为空
            //if (Language.CurrentLanguage == "Chinese")
            //{
            //    vc.TitleName = "快捷指令";
            //}
            //else
            //{
            //    vc.TitleName = "Shortcut instruction";
            //}
            //var vc = new HDLSceneSiri.HDLSiriSceneListViewController();
            //vc.DataSource = list;
            ////vc.TitleName
            ////PresentViewController(vc, true, null);
            //HDL_ON_iOS.AppDelegate.rootViewController.PushViewController(vc, true);
            //1.初始化dataList
            NSMutableArray dataSourceList = new NSMutableArray();
            //2.初始化场景列表数据
            HDLSiriShortcutModel sceneModel = new HDLSiriShortcutModel();
            if (Language.CurrentLanguage == "Chinese")
            {
                sceneModel.Title = "场景";
                sceneModel.Content = "将场景添加到快捷指令,即可通过Siri执行";
            }
            else
            {
                sceneModel.Title = "Scenes";
                sceneModel.Content = "Add the scene to the shortcut, which can be executed through Siri";
            }
            NSMutableArray list = new NSMutableArray();
            foreach (var localScene in HDL_ON.Entity.FunctionList.List.scenes)
            {
                list.Add(new HDLSiriControlModel()
                {
                    ControlId = localScene.userSceneId,//不能为空
                    ControlName = localScene.name,//不能为空
                    ControlType = "1",//不能为空
                    ControlJSONStr = "1",//不能为空
                    ActionName = Language.CurrentLanguage == "Chinese"? "场景": "Scene"//不能为空
                });
            }
            sceneModel.List = NSArray.FromArray<HDLSiriControlModel>(list);
            dataSourceList.Add(sceneModel);
            //3.初始化安防列表数据
            HDLSiriShortcutModel securityModel = new HDLSiriShortcutModel();
            if (Language.CurrentLanguage == "Chinese")
            {
                securityModel.Title = "安防";
                securityModel.Content = "将安防添加到快捷指令,即可通过Siri执行";
            }else
            {
                securityModel.Title = "Security";
                securityModel.Content = "Add security to the shortcut, which can be executed through Siri";
            }
            NSMutableArray list2 = new NSMutableArray();
            foreach (var temp in HDL_ON.Entity.FunctionList.List.securities)
            {
                SecurityState securityState = new SecurityState()
                {
                    gatewayId = DB_ResidenceData.Instance.HomeGateway.gatewayId,
                    sid = temp.sid,
                    status = "enable",
                    userSecurityId = temp.userSecurityId
                };
                var ControlJSONStr = Newtonsoft.Json.JsonConvert.SerializeObject(securityState);
                list2.Add(new HDLSiriControlModel()
                {
                    ControlId = temp.userSecurityId,//不能为空
                    ControlName = temp.name,//不能为空
                    ControlType = "2",//不能为空
                    ControlJSONStr = ControlJSONStr,//不能为空
                    ActionName = Language.CurrentLanguage == "Chinese" ? "安防" : "Security"//不能为空
                });
            }
            securityModel.List = NSArray.FromArray<HDLSiriControlModel>(list2);
            dataSourceList.Add(securityModel);
            //4.跳转Siri添加或者编辑管理页面
            HDLSceneSiri.HDLSiriSceneListViewController vc = new HDLSceneSiri.HDLSiriSceneListViewController();
            vc.DataSource = dataSourceList;
            vc.HomeId = DB_ResidenceData.Instance.CurrentRegion.id;//不能为空
            if (Language.CurrentLanguage == "Chinese")
            {
                vc.TitleName = "快捷指令";
            }
            else
            {
                vc.TitleName = "Shortcut instruction";
            }
            HDL_ON_iOS.AppDelegate.rootViewController.PushViewController(vc, true);
        }
        public void SetData(bool isLogin, string accessToken, string refreshToken, string regionUrl, string homeId)
        {
            //var sDM = new SiriKit.SceneDateManager();
            //sDM.IsLgoin = isLogin;
            //sDM.AccessToken = accessToken;
            //sDM.RefreshToken = refreshToken;
            //sDM.RegionUrl = regionUrl;
            //sDM.HomeId = homeId;
            var sDM = new SiriKit.SceneDateManager();
            sDM.IsLgoin = isLogin;
            sDM.AccessToken = accessToken;
            sDM.RefreshToken = refreshToken;
            sDM.RegionUrl = regionUrl;
            sDM.HomeId = homeId;
        }
    }
}