/// <summary>
        /// 保存分析模型传感器报警等级
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            try
            {
                AnalysistemplatealarmlevelGetByAnalysistemplateIdRequest request = new AnalysistemplatealarmlevelGetByAnalysistemplateIdRequest();
                request.AnalysistemplateId = _analysistemplateId;
                var alarmlevel = _AnalysistemplatealarmlevelService.GetAnalysistemplatealarmlevelByAnalysistemplateId(request).Data;

                int level = 0;
                if (this.cbxlevel.SelectedIndex == 1)
                {
                    level = 4;
                }
                else if (this.cbxlevel.SelectedIndex == 2)
                {
                    level = 3;
                }
                else if (this.cbxlevel.SelectedIndex == 3)
                {
                    level = 2;
                }
                else if (this.cbxlevel.SelectedIndex == 4)
                {
                    level = 1;
                }
                else
                {
                    level = 0;
                }

                //如果不存在则新增报警等级配置
                if (alarmlevel == null)
                {
                    if (level != 0)
                    {
                        alarmlevel    = new Jc_AnalysistemplatealarmlevelInfo();
                        alarmlevel.Id = IdHelper.CreateLongId().ToString();
                        alarmlevel.AnalysisModelId = _analysistemplateId;
                        alarmlevel.Level           = level;

                        _AnalysistemplatealarmlevelService.AddAnalysistemplatealarmlevel(new AnalysistemplatealarmlevelAddRequest
                        {
                            AnalysistemplatealarmlevelInfo = alarmlevel
                        });
                    }
                }
                else
                {
                    //如果level==0,则删除报警等级配置;反之修改报警等级配置
                    if (level == 0)
                    {
                        _AnalysistemplatealarmlevelService.DeleteAnalysistemplatealarmlevel(new AnalysistemplatealarmlevelDeleteRequest
                        {
                            Id = alarmlevel.Id
                        });
                    }
                    else
                    {
                        alarmlevel.Level = level;
                        _AnalysistemplatealarmlevelService.UpdateAnalysistemplatealarmlevel(new AnalysistemplatealarmlevelUpdateRequest
                        {
                            AnalysistemplatealarmlevelInfo = alarmlevel
                        });
                    }
                }

                this.StaticMsg.Caption = "保存成功!";
            }
            catch (Exception ex)
            {
                LogHelper.Info("保存传感器报警等级配置失败!" + ex.Message);
                this.StaticMsg.Caption = "保存失败!";
            }
        }
Beispiel #2
0
 public Basic.Framework.Web.BasicResponse <Sys.Safety.DataContract.Jc_AnalysistemplatealarmlevelInfo> AddAnalysistemplatealarmlevel(Sys.Safety.Request.Analysistemplatealarmlevel.AnalysistemplatealarmlevelAddRequest analysistemplatealarmlevelRequest)
 {
     return(_AnalysistemplatealarmlevelService.AddAnalysistemplatealarmlevel(analysistemplatealarmlevelRequest));
 }