wei
2021-08-27 eda3fb873e59544ff36301b51e05aef64f87b0f9
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());
@@ -129,8 +132,8 @@
            notification.btnText.TextID = StringId.notification;
            notification.btnLine.BackgroundColor = CSS.CSS_Color.textWhiteColor;
            viewLayout.AddChidren(notification.FLayoutView());
            if (Logic.currlogic.pushConfigs.Count > 0)
            //显示之前推送开关状态
            if (Logic.currlogic.noticeConfig.enable)
            {
                push.btnNextIcon.IsSelected = true;
            }
@@ -141,7 +144,7 @@
            ///上下间隔62像素
            viewLayout.AddChidren(new FrameLayout { Height = Application.GetRealHeight(40) });
            #endregion
            #region  保存
            ///保存View
            LogicView.SaveView saveView = new LogicView.SaveView();
@@ -188,47 +191,25 @@
                DateMethod(cyclicTitle.btnText);
            };
            ///是否要推送点击事件
            //初始化对象
            PushConfigs pushConfigs = new PushConfigs();
            if (Logic.currlogic.pushConfigs.Count > 0)
            {
                pushConfigs = Logic.currlogic.pushConfigs[0];
            }
            else
            {
                if (!string.IsNullOrEmpty(UserInfo.Current.userMobileInfo))
                {
                    //默认推送当前账号
                    pushConfigs.pushTarget.Add(UserInfo.Current.userMobileInfo);
                }
                else
                {
                    //默认推送当前账号
                    pushConfigs.pushTarget.Add(UserInfo.Current.userEmailInfo);
                }
            }
            push.btnNextIcon.MouseUpEventHandler += (sender, e) =>
            {
               push.btnNextIcon.IsSelected = !push.btnNextIcon.IsSelected;
                //账号列表为空默认推送当前账号
                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)
                {
                    if (Logic.currlogic.pushConfigs.Count > 0)
                    {
                        //清空之前旧配置数据
                        Logic.currlogic.pushConfigs.Clear();
                    }
                    //增加配置数据
                    Logic.currlogic.pushConfigs.Add(pushConfigs);
                    Logic.currlogic.noticeConfig.enable = true;
                }
                else
                {
                    if (Logic.currlogic.pushConfigs.Count > 0)
                    {
                        //默认取第一个赋值
                        pushConfigs = Logic.currlogic.pushConfigs[0];
                        //清空配置数据
                        Logic.currlogic.pushConfigs.Clear();
                    }
                    Logic.currlogic.noticeConfig.enable = false;
                }
            };
            ///输入推送文本
@@ -236,18 +217,13 @@
            {
                InputPushText inputPushText = new InputPushText();
                MainPage.BasePageView.AddChidren(inputPushText);
                inputPushText.Show(pushConfigs);
                inputPushText.Show();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                inputPushText.action += (pushConfigsIfon) =>
                {
                    //赋值
                    pushConfigs = pushConfigsIfon;
                };
            };
            ///保存点击事件
            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;
@@ -262,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;
@@ -272,19 +252,21 @@
                    {
                        list.Add(logic.name);
                    }
                    new LogicView.TipPopView().InputBox(StringId.editName, InpOrOutLogicMethod.GetLogicName(Logic.currlogic), StringId.nameNull, StringId.NameAlreadyExists, list, (logicName,view
                    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 { }
@@ -293,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++)
@@ -319,7 +307,7 @@
                                        }
                                        Logic.LogicList.Add(Logic.currlogic);
                                        LogicMethod.RemoveAllView();
                                        LogicMethod.CurrLogicMethod.RemoveAllView();
                                        MainView.MainShow();
                                    }
                                    else if (responsePackNew != null && responsePackNew.Code == "14005")
@@ -336,7 +324,7 @@
                        })
                        { IsBackground = true }.Start();
                    },()=> { });
                    }, () => { });
                }
                else
@@ -359,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));
                                }
@@ -536,7 +524,7 @@
                //加载之前保存的数据
                weekStateList.AddRange(list);
            }
            var weekListStr= weekView.GetViewList("week");
            var weekListStr = weekView.GetViewList("week");
            weekView.MultiSelectShow(fLayout, weekListStr, Language.StringByID(StringId.cyclic), weekStateList
               , (list) =>
               {
@@ -564,7 +552,7 @@
            weekView.MonSelectShow(fLayout, Logic.currlogic, (monList) =>
                {
                    //选中数据处理
                    string textStr= MainView.GetMonString(monList);
                    string textStr = MainView.GetMonString(monList);
                    //显示选中数据
                    button.Text = textStr;
                    //封装数据
@@ -603,8 +591,7 @@
        }
    }
}