xm
2021-12-01 6d73bf6e816570291865674bef8bce8972e4de3f
HDL_ON/UI/UI2/3-Intelligence/Automation/AddLogic.cs
@@ -52,6 +52,9 @@
            viewLayout.AddChidren(addInputTextView.FLayoutView(46, 12));
            ///满足以下条件的View
            LogicView.LogicTypeTitleView titleCondition = new LogicView.LogicTypeTitleView();
            titleCondition.btnText.Width = Application.GetRealWidth(300);
            titleCondition.btnText.Height = Application.GetRealHeight(28);
            titleCondition.btnText.IsMoreLines = true;
            titleCondition.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight);
            titleCondition.btnText.TextID = StringId.andCondition;
            viewLayout.AddChidren(titleCondition.FLayoutView());
@@ -103,7 +106,7 @@
            LogicView.LogicTypeTitleView cyclicTitle = new LogicView.LogicTypeTitleView();
            cyclicTitle.frameLayout.Height = Application.GetRealHeight(50);
            cyclicTitle.frameLayout.Radius = (uint)Application.GetRealHeight(12);
            cyclicTitle.btnText.Text = MainView.GetWeekText(Logic.currlogic);
            cyclicTitle.btnText.Text = MainView.GetCyclicText(Logic.currlogic);
            viewLayout.AddChidren(cyclicTitle.FLayoutView());
            #endregion
@@ -111,24 +114,35 @@
            #region  执行推送 发送通知
            ///上下间隔12像素
            viewLayout.AddChidren(new FrameLayout { Height = Application.GetRealHeight(12) });
            /////执行推送iew
            //LogicView.LogicTypeTitleView push = new LogicView.LogicTypeTitleView();
            //push.frameLayout.Height = Application.GetRealHeight(50);
            //push.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight);
            //push.btnText.TextID = StringId.push;
            //push.btnNextIcon.Width = Application.GetMinRealAverage(36);
            //push.btnNextIcon.Height = Application.GetMinRealAverage(36);
            //push.btnNextIcon.X = Application.GetRealWidth(305);
            //push.btnNextIcon.UnSelectedImagePath = "LogicIcon/off.png";
            //push.btnNextIcon.SelectedImagePath = "LogicIcon/on.png";
            //viewLayout.AddChidren(push.FLayoutView());
            /////发送通知View
            //LogicView.LogicTypeTitleView notification = new LogicView.LogicTypeTitleView();
            //notification.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight);
            //notification.btnText.TextID = StringId.notification;
            //viewLayout.AddChidren(notification.FLayoutView());
            /////上下间隔62像素
            //viewLayout.AddChidren(new FrameLayout { Height = Application.GetRealHeight(62) });
            ///执行推送iew
            LogicView.LogicTypeTitleView push = new LogicView.LogicTypeTitleView();
            push.frameLayout.Height = Application.GetRealHeight(50);
            push.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight);
            push.btnText.TextID = StringId.push;
            push.btnNextIcon.Width = Application.GetRealWidth(36);
            push.btnNextIcon.Height = Application.GetRealWidth(36);
            push.btnNextIcon.X = Application.GetRealWidth(305);
            push.btnNextIcon.UnSelectedImagePath = "LogicIcon/off.png";
            push.btnNextIcon.SelectedImagePath = "LogicIcon/on.png";
            push.btnClick.Width = Application.GetRealWidth(305);
            viewLayout.AddChidren(push.FLayoutView());
            ///发送通知View
            LogicView.LogicTypeTitleView notification = new LogicView.LogicTypeTitleView();
            notification.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight);
            notification.btnText.TextID = StringId.notification;
            notification.btnLine.BackgroundColor = CSS.CSS_Color.textWhiteColor;
            viewLayout.AddChidren(notification.FLayoutView());
            //显示之前推送开关状态
            if (Logic.currlogic.noticeConfig.enable)
            {
                push.btnNextIcon.IsSelected = true;
            }
            else
            {
                push.btnNextIcon.IsSelected = false;
            }
            ///上下间隔62像素
            viewLayout.AddChidren(new FrameLayout { Height = Application.GetRealHeight(40) });
            #endregion
            #region  保存
@@ -153,12 +167,7 @@
            ///或和与点击事件
            titleCondition.btnClick.MouseUpEventHandler += (sender, e) =>
            {
                FrameLayout fLayout = new FrameLayout
                {
                    BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
                };
                this.AddChidren(fLayout);
                AndOrMethod(fLayout, titleCondition.btnText);
                AndOrMethod(titleCondition.btnText);
            };
            ///条件添加点击事件
            addInputIcon.btnClick.MouseUpEventHandler += (sen, e) =>
@@ -181,10 +190,40 @@
            {
                DateMethod(cyclicTitle.btnText);
            };
            ///是否要推送点击事件
            push.btnNextIcon.MouseUpEventHandler += (sender, e) =>
            {
                //账号列表为空默认推送当前账号
                if (Logic.currlogic.pushConfigs.Count == 0)
                {
                    //初始化对象
                    PushConfigs pushConfigs = new PushConfigs();
                    //默认添加推送当前账号
                    pushConfigs.pushTarget.Add(UserInfo.Current.ID);
                    Logic.currlogic.pushConfigs.Add(pushConfigs);
                }
                push.btnNextIcon.IsSelected = !push.btnNextIcon.IsSelected;
                if (push.btnNextIcon.IsSelected)
                {
                    Logic.currlogic.noticeConfig.enable = true;
                }
                else
                {
                    Logic.currlogic.noticeConfig.enable = false;
                }
            };
            ///输入推送文本
            notification.btnClick.MouseUpEventHandler += (sender, e) =>
            {
                InputPushText inputPushText = new InputPushText();
                MainPage.BasePageView.AddChidren(inputPushText);
                inputPushText.Show();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            ///保存点击事件
            saveView.btnClick.MouseUpEventHandler += (sender, e) =>
            {
                if (Logic.currlogic.input.Count == 0&& Logic.currlogic.output.Count == 0)
                if (Logic.currlogic.input.Count == 0 && Logic.currlogic.output.Count == 0)
                {
                    new LogicView.TipPopView().TipBox(StringId.tip, StringId.conditioncNullOrtargetNull);
                    return;
@@ -199,6 +238,10 @@
                    new LogicView.TipPopView().TipBox(StringId.tip, StringId.targetNull);
                    return;
                }
                Loading loading = new Loading();
                this.AddChidren(loading);
                HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null;
@@ -209,18 +252,21 @@
                    {
                        list.Add(logic.name);
                    }
                    new LogicView.TipPopView().InputBox(StringId.editName, InterfaceDsplaysLogic.GetLogicName(Logic.currlogic), StringId.nameNull, StringId.NameAlreadyExists, list, (logicName) =>
                    new LogicView.TipPopView().InputBox(StringId.editName, InpOrOutLogicMethod.GetLogicName(Logic.currlogic), StringId.nameNull, StringId.NameAlreadyExists, list, (logicName, view
                        ) =>
                    {
                        Logic.currlogic.name = logicName;
                        Logic.currlogic.sid = LogicMethod.NewSid();
                        Logic.currlogic.sid = LogicMethod.CurrLogicMethod.NewSid();
                        loading.Start();
                        new System.Threading.Thread(() =>
                        {
                            try
                            {
                                //发送新加逻辑命令;
                                responsePackNew = Send.AddLogic(Logic.currlogic);
                                if (!MainPage.NoLoginMode)
                                {
                                    //发送新加逻辑命令;
                                    responsePackNew = Send.AddLogic(Logic.currlogic);
                                }
                            }
                            catch { }
@@ -229,10 +275,16 @@
                                Application.RunOnMainThread(() =>
                                {
                                    loading.Hide();
                                    if(MainPage.NoLoginMode)
                                    {
                                        Logic.LogicList.Add(Logic.currlogic);
                                        LogicMethod.CurrLogicMethod.RemoveAllView();
                                        MainView.MainShow();
                                        return;
                                    }
                                    if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
                                    {
                                        //获取逻辑详细返回是一个数组(object类型转换为数组);
                                        var jArray = Newtonsoft.Json.Linq.JArray.Parse(responsePackNew.Data.ToString());
                                        for (int a = 0; a < jArray.Count; a++)
@@ -255,7 +307,7 @@
                                        }
                                        Logic.LogicList.Add(Logic.currlogic);
                                        LogicMethod.RemoveAllView();
                                        LogicMethod.CurrLogicMethod.RemoveAllView();
                                        MainView.MainShow();
                                    }
                                    else if (responsePackNew != null && responsePackNew.Code == "14005")
@@ -272,7 +324,7 @@
                        })
                        { IsBackground = true }.Start();
                    });
                    }, () => { });
                }
                else
@@ -284,7 +336,7 @@
                        try
                        {
                            //发送修改逻辑命令;
                            responsePackNew = Send.updateLogic(Logic.currlogic);
                            responsePackNew = Send.UpdateLogic(Logic.currlogic);
                        }
                        catch { }
@@ -295,14 +347,14 @@
                                loading.Hide();
                                if (responsePackNew != null && responsePackNew.Code == "0")
                                {
                                    LogicMethod.RemoveAllView();
                                    LogicMethod.CurrLogicMethod.RemoveAllView();
                                    MainView.MainShow();
                                }
                                else if (responsePackNew != null && responsePackNew.Code == "14005")
                                {
                                    new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline));
                                }
                                else
                                else
                                {
                                    new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail));
                                }
@@ -462,33 +514,29 @@
        /// <param name="button">显示文本</param>
        public void WeekMethod(FrameLayout fLayout, Button button)
        {
            List<string> weekStr = new List<string> {
             Language.StringByID(StringId.monday),
             Language.StringByID(StringId.tuesday),
             Language.StringByID(StringId.wednesday),
             Language.StringByID(StringId.thursday),
             Language.StringByID(StringId.friday),
             Language.StringByID(StringId.saturday),
             Language.StringByID(StringId.sunday),
            };
            //定义一个局部weekList列表用来记录选中数据;
            List<string> weekStateList = new List<string>();
            weekStateList.Clear();
            PublicInterface weekView = new PublicInterface();
            if (Logic.currlogic.cycle.type == "week")
            {
                var list = GetWeekString(Logic.currlogic.cycle.value, "int");
                //数据转换
                var list = weekView.GetWeekString(Logic.currlogic.cycle.value, "int");
                //加载之前保存的数据
                weekStateList.AddRange(list);
            }
            PublicInterface weekView = new PublicInterface();
            weekView.MultiSelectShow(fLayout, weekStr, Language.StringByID(StringId.cyclic), weekStateList
            var weekListStr = weekView.GetViewList("week");
            weekView.MultiSelectShow(fLayout, weekListStr, Language.StringByID(StringId.cyclic), weekStateList
               , (list) =>
               {
                   var statelist = GetWeekString(list, "str");
                   //选中数据处理
                   var statelist = weekView.GetWeekString(list, "str");
                   string textStr = MainView.GetWeekString(statelist);
                   //显示选中数据
                   button.Text = textStr;
                   //封装数据
                   Logic.currlogic.cycle.type = "week";
                   Logic.currlogic.cycle.value = statelist;
                   button.Text = MainView.GetWeekString(statelist);
               });
        }
@@ -503,30 +551,33 @@
            PublicInterface weekView = new PublicInterface();
            weekView.MonSelectShow(fLayout, Logic.currlogic, (monList) =>
                {
                    //选中数据处理
                    string textStr = MainView.GetMonString(monList);
                    //显示选中数据
                    button.Text = textStr;
                    //封装数据
                    Logic.currlogic.cycle.type = "mon";
                    Logic.currlogic.cycle.value = monList;
                    button.Text = MainView.GetMonString(monList);
                });
        }
        /// <summary>
        /// 满足条件
        /// </summary>
        /// <param name="fLayout">弹框主控件</param>
        /// <param name="button">显示文本</param>
        public void AndOrMethod(FrameLayout fLayout, Button button)
        public void AndOrMethod(Button button)
        {
            List<string> strList = new List<string> {
             Language.StringByID(StringId.andCondition),
             Language.StringByID(StringId.orCondition),
            };
            ///之前的状态文本
            string currCondition = button.Text;
            PublicInterface conditionView = new PublicInterface();
            conditionView.SingleSelectionShow(fLayout, strList, Language.StringByID(StringId.meetTheCondition), currCondition
            var strList = conditionView.GetViewList("andor");
            conditionView.SingleSelectionShow(this, strList, Language.StringByID(StringId.meetTheCondition), currCondition
               , (stateValue) =>
               {
                   //界面显示选中值
                   button.Text = stateValue;
                   //封装数据
                   if (stateValue == Language.StringByID(StringId.orCondition))
                   {
                       Logic.currlogic.relation = "or";
@@ -535,105 +586,12 @@
                   {
                       Logic.currlogic.relation = "and";
                   }
                   button.Text = stateValue;
               });
        }
        /// <summary>
        /// 星期周期转换值的方法
        /// </summary>
        /// <param name="list"></param>
        /// <param name="str_or_int"></param>
        /// <returns></returns>
        public List<string> GetWeekString(List<string> list, string str_or_int)
        {
            string weekTextName = "";
            List<string> stateList = new List<string>();
            for (int i = 0; i < list.Count; i++)
            {
                var s = list[i];
                if (str_or_int == "int")
                {
                    switch (s)
                    {
                        case "1":
                            {
                                weekTextName = Language.StringByID(StringId.monday);
                            }
                            break;
                        case "2":
                            {
                                weekTextName = Language.StringByID(StringId.tuesday);
                            }
                            break;
                        case "3":
                            {
                                weekTextName = Language.StringByID(StringId.wednesday);
                            }
                            break;
                        case "4":
                            {
                                weekTextName = Language.StringByID(StringId.thursday);
                            }
                            break;
                        case "5":
                            {
                                weekTextName = Language.StringByID(StringId.friday);
                            }
                            break;
                        case "6":
                            {
                                weekTextName = Language.StringByID(StringId.saturday);
                            }
                            break;
                        case "0":
                            {
                                weekTextName = Language.StringByID(StringId.sunday);
                            }
                            break;
                    }
                }
                else
                {
                    if (Language.StringByID(StringId.monday) == s)
                    {
                        weekTextName = "1";
                    }
                    else if (Language.StringByID(StringId.tuesday) == s)
                    {
                        weekTextName = "2";
                    }
                    else if (Language.StringByID(StringId.wednesday) == s)
                    {
                        weekTextName = "3";
                    }
                    else if (Language.StringByID(StringId.thursday) == s)
                    {
                        weekTextName = "4";
                    }
                    else if (Language.StringByID(StringId.friday) == s)
                    {
                        weekTextName = "5";
                    }
                    else if (Language.StringByID(StringId.saturday) == s)
                    {
                        weekTextName = "6";
                    }
                    else if (Language.StringByID(StringId.sunday) == s)
                    {
                        weekTextName = "0";
                    }
                }
                stateList.Add(weekTextName);
            }
            return stateList;
        }
    }
}