CrabtreeOn,印度客户定制APP,迁移2.0平台版本
JLChen
2021-02-25 c0379d078e7919c9934085da038e8e3c20dee85a
Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/HelpView.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Shared.SimpleControl.Phone.Music;
using SmartHome;
namespace Shared.SimpleControl.Phone
{
@@ -128,6 +129,20 @@
            };
            msgView.AddChidren (btnMail);
            btnMail.MouseUpEventHandler += (e, e2) => {
#if DEBUG
                GetDeviceList ();
                var ud = new UniversalDevice () { LoopID = 1, SubnetID = 1, DeviceID = 100, ActionType = 2, Name = "通用开关", obj1 = 1, TargetType = 0 };
                ud.SendBytes = new List<byte> () { 1, 0 };
                //IO.FileUtils.SaveEquipmentMessage (ud, ud.LoopID.ToString ());
                //var ud2 = new UniversalDevice () { LoopID = 2, SubnetID = 1, DeviceID = 100, ActionType = 2, Name = "通用开关2", obj1 = 1, TargetType = 0 };
                //ud2.SendBytes = new List<byte> () { 2, 255 };
                //IO.FileUtils.SaveEquipmentMessage (ud2, ud2.LoopID.ToString ());
#endif
            };
            var btnMail2 = new Button () {
                X = Application.GetRealWidth (100),
                Y = btnMail.Bottom,
@@ -138,6 +153,13 @@
                TextAlignment = TextAlignment.CenterLeft,
            };
            msgView.AddChidren (btnMail2);
            btnMail2.MouseUpEventHandler += (e, e2) => {
#if DEBUG
                upload ();
#endif
            };
            var btnFAQ = new Button () { 
                Height = Application.GetRealHeight(100),
@@ -150,6 +172,15 @@
            };
            AddChidren (btnFAQ);
            btnFAQ.MouseUpEventHandler += (e,e2) =>{
#if DEBUG
                UploadSecneList ();
                //upload ();
#endif
            };
   
            var btnLine = new Button () { 
@@ -160,5 +191,95 @@
            AddChidren (btnLine);
        }
        /// <summary>
        ///
        /// </summary>
        void upload ()
        {
            MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.load));
            System.Threading.Tasks.Task.Run (() => {
                try {
                    var RES = HDLLinkUtlis.Current.UploadOidAndSidList ();
                    Application.RunOnMainThread (() => {
                        if (RES) {
                            Utlis.ShowTip ("上传成功");
                        } else {
                            Utlis.ShowTip ("上传失败");
                        }
                    });
                } catch {
                    MainPage.FailureToServer ();
                } finally {
                    Application.RunOnMainThread (() => {
                        MainPage.Loading.Hide ();
                    });
                }
            });
        }
        /// <summary>
        ///
        /// </summary>
        void UploadSecneList ()
        {
            MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.load));
            System.Threading.Tasks.Task.Run (() => {
                try {
                    var RES = HDLLinkUtlis.Current.UploadSecneList ();
                    Application.RunOnMainThread (() => {
                        if (RES) {
                            Utlis.ShowTip ("上传成功");
                        } else {
                            Utlis.ShowTip ("上传失败");
                        }
                    });
                } catch {
                    MainPage.FailureToServer ();
                } finally {
                    Application.RunOnMainThread (() => {
                        MainPage.Loading.Hide ();
                    });
                }
            });
        }
        /// <summary>
        ///
        /// </summary>
        void GetDeviceList ()
        {
            MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.load));
            System.Threading.Tasks.Task.Run (() => {
                try {
                    var deviceResult = HttpServerRequest.Current.GetDeviceList ();
                    if (deviceResult.Code == StateCode.SUCCESS) {
                        var deviceList = Newtonsoft.Json.JsonConvert.DeserializeObject<DevcieFunctionRes> (deviceResult.Data.ToString ());
                        CommonConfig.Current.FunctionList = deviceList.list;
                        CommonConfig.Current.Save ();
                       Utlis.WriteLine ("deviceList Count" + deviceList.list.Count);
                    } else {
                        Utlis.ShowTip ("设备列表");
                    }
                    //Application.RunOnMainThread (() => {
                    //});
                } catch {
                    MainPage.FailureToServer ();
                } finally {
                    Application.RunOnMainThread (() => {
                        MainPage.Loading.Hide ();
                    });
                }
            });
        }
    }
}