فهرست منبع

添加异常捕获

user_lt 1 سال پیش
والد
کامیت
0c96b379e3

+ 171 - 146
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/AddOrEditSchViewModel.cs

@@ -81,97 +81,106 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             {
                 foreach (var item in getMsg)
                 {
-                    Title = "编辑方案";
-                    int id = Convert.ToInt32(item);
-                    schDtlMainId = id;//全局变量赋值,测试方案明细id
-                    //根据 测试方案明细主键ID 查找测试方案id 及方案名和设备名
-                    var findEntity = _basicPlcTestSchemeDtlService.Find(id);
-                    var findresult = _mapper.Map<bas_plc_test_scheme_dtl, BasicPlcTestSchemeDtlDto>(findEntity);
-                    if (findresult != null)
+                    try
                     {
-                        //根据方案id 在方案表中查找方案名 设备名
-                        int schID = Convert.ToInt32(findresult.SchemeId);
-                        //测试方案
-                        bas_Plc_Test_Scheme = _basicPlcTestSchemeService.Find(schID);
-                        if (bas_Plc_Test_Scheme != null)
-                        {
-                            ScheduleName = bas_Plc_Test_Scheme.scheme_name;
-                            DeviceName = bas_Plc_Test_Scheme.device_name;
 
-                        }
-                        TestName = findresult.ItemName;
-                        SelectTest = findresult.ItemType;
-                        //前置项解析
-                        string preconStr = findresult.Precondition.ToString();
-                        if (!string.IsNullOrEmpty(preconStr))
+                        Title = "编辑方案";
+                        int id = Convert.ToInt32(item);
+                        schDtlMainId = id;//全局变量赋值,测试方案明细id
+                                          //根据 测试方案明细主键ID 查找测试方案id 及方案名和设备名
+                        var findEntity = _basicPlcTestSchemeDtlService.Find(id);
+                        var findresult = _mapper.Map<bas_plc_test_scheme_dtl, BasicPlcTestSchemeDtlDto>(findEntity);
+                        if (findresult != null)
                         {
-                            JsonModel preconditionModel = JsonConvert.DeserializeObject<JsonModel>(preconStr);
-                            BeforeSelectJudge = preconditionModel.ItemType;
-                            SelectLogic = preconditionModel.ItemLogical;
-                            BeforeDetail = preconditionModel.Description;
-                            BeforeConList.Clear();
-                            foreach (var detail in preconditionModel.DetailInfo)
+                            //根据方案id 在方案表中查找方案名 设备名
+                            int schID = Convert.ToInt32(findresult.SchemeId);
+                            //测试方案
+                            bas_Plc_Test_Scheme = _basicPlcTestSchemeService.Find(schID);
+                            if (bas_Plc_Test_Scheme != null)
                             {
-                                BasPlcItemConfigDto basPlcItemConfigDto = new BasPlcItemConfigDto();
-                                basPlcItemConfigDto.Id=detail.Id;
-                                basPlcItemConfigDto.PlcItem = detail.PlcItem;
-                                basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
-                                basPlcItemConfigDto.PlcAddType = detail.PlcAddType;
-                                basPlcItemConfigDto.PlcValue = detail.PlcValue;
-                                basPlcItemConfigDto.Remark = detail.Remark;
-                                BeforeConList.Add(basPlcItemConfigDto);
+                                ScheduleName = bas_Plc_Test_Scheme.scheme_name;
+                                DeviceName = bas_Plc_Test_Scheme.device_name;
+
                             }
-                        }
-                          
-                        //输入项解析
-                        string inStr = findresult.Action.ToString();
-                        if (!string.IsNullOrEmpty(inStr))
-                        {
-                            JsonModel inModel = JsonConvert.DeserializeObject<JsonModel>(inStr);
-                            SelectInJudge = inModel.ItemType;
-                            InSelectLogic = inModel.ItemLogical;
-                            InDetail = inModel.Description;
-                            InConList.Clear();
-                            foreach (var detail in inModel.DetailInfo)
+                            TestName = findresult.ItemName;
+                            SelectTest = findresult.ItemType;
+                            //前置项解析
+                            string preconStr = findresult.Precondition.ToString();
+                            if (!string.IsNullOrEmpty(preconStr))
                             {
-                                BasPlcItemConfigDto basPlcItemConfigDto = new BasPlcItemConfigDto();
-                                basPlcItemConfigDto.Id = detail.Id;
-                                basPlcItemConfigDto.PlcItem = detail.PlcItem;
-                                basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
-                                basPlcItemConfigDto.PlcAddType = detail.PlcAddType;
-                                basPlcItemConfigDto.PlcValue = detail.PlcValue;
-                                basPlcItemConfigDto.Remark = detail.Remark;
-                                InConList.Add(basPlcItemConfigDto);
+                                JsonModel preconditionModel = JsonConvert.DeserializeObject<JsonModel>(preconStr);
+                                BeforeSelectJudge = preconditionModel.ItemType;
+                                SelectLogic = preconditionModel.ItemLogical;
+                                BeforeDetail = preconditionModel.Description;
+                                BeforeConList.Clear();
+                                foreach (var detail in preconditionModel.DetailInfo)
+                                {
+                                    BasPlcItemConfigDto basPlcItemConfigDto = new BasPlcItemConfigDto();
+                                    basPlcItemConfigDto.Id = detail.Id;
+                                    basPlcItemConfigDto.PlcItem = detail.PlcItem;
+                                    basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
+                                    basPlcItemConfigDto.PlcAddType = detail.PlcAddType;
+                                    basPlcItemConfigDto.PlcValue = detail.PlcValue;
+                                    basPlcItemConfigDto.Remark = detail.Remark;
+                                    BeforeConList.Add(basPlcItemConfigDto);
+                                }
                             }
-                        }
-                           
-                        //输出项解析
-                        string outStr = findresult.JudgementResult.ToString();
-                        if(!string.IsNullOrEmpty(outStr))
-                        {
-                            JsonModel outModel = JsonConvert.DeserializeObject<JsonModel>(outStr);
-                            SelectOutJudge = outModel.ItemType;
-                            OutSelectLogic = outModel.ItemLogical;
-                            OutDetail = outModel.Description;
-                            OutConList.Clear();
-                            foreach (var detail in outModel.DetailInfo)
+
+                            //输入项解析
+                            string inStr = findresult.Action.ToString();
+                            if (!string.IsNullOrEmpty(inStr))
+                            {
+                                JsonModel inModel = JsonConvert.DeserializeObject<JsonModel>(inStr);
+                                SelectInJudge = inModel.ItemType;
+                                InSelectLogic = inModel.ItemLogical;
+                                InDetail = inModel.Description;
+                                InConList.Clear();
+                                foreach (var detail in inModel.DetailInfo)
+                                {
+                                    BasPlcItemConfigDto basPlcItemConfigDto = new BasPlcItemConfigDto();
+                                    basPlcItemConfigDto.Id = detail.Id;
+                                    basPlcItemConfigDto.PlcItem = detail.PlcItem;
+                                    basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
+                                    basPlcItemConfigDto.PlcAddType = detail.PlcAddType;
+                                    basPlcItemConfigDto.PlcValue = detail.PlcValue;
+                                    basPlcItemConfigDto.Remark = detail.Remark;
+                                    InConList.Add(basPlcItemConfigDto);
+                                }
+                            }
+
+                            //输出项解析
+                            string outStr = findresult.JudgementResult.ToString();
+                            if (!string.IsNullOrEmpty(outStr))
                             {
-                                BasPlcItemConfigDto basPlcItemConfigDto = new BasPlcItemConfigDto();
-                                basPlcItemConfigDto.Id = detail.Id;
-                                basPlcItemConfigDto.PlcItem = detail.PlcItem;
-                                basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
-                                basPlcItemConfigDto.PlcAddType = detail.PlcAddType;
-                                basPlcItemConfigDto.PlcValue = detail.PlcValue;
-                                basPlcItemConfigDto.Remark = detail.Remark;
-                                OutConList.Add(basPlcItemConfigDto);
+                                JsonModel outModel = JsonConvert.DeserializeObject<JsonModel>(outStr);
+                                SelectOutJudge = outModel.ItemType;
+                                OutSelectLogic = outModel.ItemLogical;
+                                OutDetail = outModel.Description;
+                                OutConList.Clear();
+                                foreach (var detail in outModel.DetailInfo)
+                                {
+                                    BasPlcItemConfigDto basPlcItemConfigDto = new BasPlcItemConfigDto();
+                                    basPlcItemConfigDto.Id = detail.Id;
+                                    basPlcItemConfigDto.PlcItem = detail.PlcItem;
+                                    basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
+                                    basPlcItemConfigDto.PlcAddType = detail.PlcAddType;
+                                    basPlcItemConfigDto.PlcValue = detail.PlcValue;
+                                    basPlcItemConfigDto.Remark = detail.Remark;
+                                    OutConList.Add(basPlcItemConfigDto);
+                                }
                             }
+
                         }
-                       
                     }
+                    catch (Exception ex)
+                    {
+                        _logger.LogError(ex.ToString());
+                    }
+
 
                 }
 
-            }
+        }
         }
 
         #endregion
@@ -420,55 +429,62 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 MessageBox.Show("请填写结果项判定逻辑!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                 return;
             }
-
-            if (Title == "新增方案")
+            try
             {
-                var finsSche = _basicPlcTestSchemeService.FindByName(ScheduleName);
-                //测试方案中已有这个名称
-                if (finsSche != null)
+                if (Title == "新增方案")
                 {
-                    long schID = finsSche.scheme_id;
-                    //在测试方案明细表中查找是否有这个测试方案和测试项
-                    var schDtl = _basicPlcTestSchemeDtlService.FindSchDtlIdBySchIdAndItem(schID, TestName);
-                    //在不为空,说明有这个测试方案和测试项了
-                    if (schDtl != null)
+                    var finsSche = _basicPlcTestSchemeService.FindByName(ScheduleName);
+                    //测试方案中已有这个名称
+                    if (finsSche != null)
                     {
-                        MessageBoxResult boxResult = MessageBox.Show("此测试方案名称已存在此测试项,请填写其他测试项!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
-                        return;
+                        long schID = finsSche.scheme_id;
+                        //在测试方案明细表中查找是否有这个测试方案和测试项
+                        var schDtl = _basicPlcTestSchemeDtlService.FindSchDtlIdBySchIdAndItem(schID, TestName);
+                        //在不为空,说明有这个测试方案和测试项了
+                        if (schDtl != null)
+                        {
+                            MessageBoxResult boxResult = MessageBox.Show("此测试方案名称已存在此测试项,请填写其他测试项!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                            return;
+                        }
+
                     }
-                       
+                    else
+                    {
+                        //增加测试方案到数据库
+                        BasicPlcTestSchemeDto schDto = new BasicPlcTestSchemeDto();
+                        schDto.SchemeName = ScheduleName;
+                        schDto.DeviceName = DeviceName;
+                        schDto.CreateBy = Appsession.UserName;
+                        schDto.CreateTime = DateTime.Now;
+                        schDto.UpdateTime = DateTime.Now;
+                        schDto.UpdateBy = Appsession.UserName;
+                        bas_plc_test_scheme schEntity = _mapper.Map<BasicPlcTestSchemeDto, bas_plc_test_scheme>(schDto);
+                        _basicPlcTestSchemeService.Add(schEntity);
+                    }
+
                 }
                 else
                 {
-                    //增加测试方案到数据库
-                    BasicPlcTestSchemeDto schDto = new BasicPlcTestSchemeDto();
-                    schDto.SchemeName = ScheduleName;
-                    schDto.DeviceName = DeviceName;
-                    schDto.CreateBy = Appsession.UserName;
-                    schDto.CreateTime = DateTime.Now;
-                    schDto.UpdateTime = DateTime.Now;
-                    schDto.UpdateBy = Appsession.UserName;
-                    bas_plc_test_scheme schEntity = _mapper.Map<BasicPlcTestSchemeDto, bas_plc_test_scheme>(schDto);
-                    _basicPlcTestSchemeService.Add(schEntity);
-                }
-               
-            }
-            else
-            {
-                //更新测试方案名称
-                if (Title == "编辑方案")
-                {
-                    if(bas_Plc_Test_Scheme!=null)
+                    //更新测试方案名称
+                    if (Title == "编辑方案")
                     {
-                        bas_Plc_Test_Scheme.scheme_name = ScheduleName;
-                        bas_Plc_Test_Scheme.device_name = DeviceName;
-                        _basicPlcTestSchemeService.Edit(bas_Plc_Test_Scheme);
+                        if (bas_Plc_Test_Scheme != null)
+                        {
+                            bas_Plc_Test_Scheme.scheme_name = ScheduleName;
+                            bas_Plc_Test_Scheme.device_name = DeviceName;
+                            _basicPlcTestSchemeService.Edit(bas_Plc_Test_Scheme);
+                        }
+
                     }
-                    
+
                 }
-                    
-            }
 
+            }
+            catch (Exception ex)
+            {
+                _logger.LogError(ex.ToString());
+            }
+          
             //查找测试方案id
             var finsScheHave = _basicPlcTestSchemeService.FindByName(ScheduleName);
             if (finsScheHave != null)
@@ -511,49 +527,58 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             schDtlDto.UpdateBy = Appsession.UserName;
             bas_plc_test_scheme_dtl schDtlEntity = _mapper.Map<BasicPlcTestSchemeDtlDto, bas_plc_test_scheme_dtl>(schDtlDto);
             schDtlEntity.item_type = StrToItemType(schDtlDto.ItemType);
-            if (Title == "新增方案")
+            try
             {
-
-                bool isAddSucc = _basicPlcTestSchemeDtlService.Add(schDtlEntity);
-                if (isAddSucc)
+                if (Title == "新增方案")
                 {
-                    _logger.LogInformation($"新增方案成功。方案名{ScheduleName},测试项{TestName}");
-                    MessageBoxResult boxResult = MessageBox.Show("新增方案成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+
+                    bool isAddSucc = _basicPlcTestSchemeDtlService.Add(schDtlEntity);
+                    if (isAddSucc)
+                    {
+                        _logger.LogInformation($"新增方案成功。方案名{ScheduleName},测试项{TestName}");
+                        MessageBoxResult boxResult = MessageBox.Show("新增方案成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+                    }
+                    else
+                    {
+                        MessageBoxResult boxResult = MessageBox.Show("更新失败", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                        return;
+                    }
                 }
                 else
                 {
-                    MessageBoxResult boxResult = MessageBox.Show("更新失败", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
-                    return;
-                }
-            }
-            else
-            {
-                if (Title == "编辑方案")
-                {
-                    //修改 必须给主键SchemeDtlId值
-                    //var schDtl = _basicPlcTestSchemeDtlService.FindSchDtlIdBySchIdAndItem(scheduleId, TestName);
-                   // if (schDtl != null)
+                    if (Title == "编辑方案")
                     {
-                        schDtlDto.SchemeDtlId = schDtlMainId;
-                        bas_plc_test_scheme_dtl schDtlEntityEdit = _mapper.Map<BasicPlcTestSchemeDtlDto, bas_plc_test_scheme_dtl>(schDtlDto);
-                        //ItemType 转化
-                        schDtlEntityEdit.item_type = StrToItemType(schDtlDto.ItemType);
-                        bool isSucc = _basicPlcTestSchemeDtlService.Edit(schDtlEntityEdit);
-                        if (isSucc)
-                        {
-                            _logger.LogInformation($"更新方案成功。方案名{ScheduleName},测试项{TestName}");
-                            MessageBoxResult boxResult = MessageBox.Show("更新成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
-                        }
-                        else
+                        //修改 必须给主键SchemeDtlId值
+                        //var schDtl = _basicPlcTestSchemeDtlService.FindSchDtlIdBySchIdAndItem(scheduleId, TestName);
+                        // if (schDtl != null)
                         {
-                            MessageBoxResult boxResult = MessageBox.Show("更新失败", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
-                            return;
+                            schDtlDto.SchemeDtlId = schDtlMainId;
+                            bas_plc_test_scheme_dtl schDtlEntityEdit = _mapper.Map<BasicPlcTestSchemeDtlDto, bas_plc_test_scheme_dtl>(schDtlDto);
+                            //ItemType 转化
+                            schDtlEntityEdit.item_type = StrToItemType(schDtlDto.ItemType);
+                            bool isSucc = _basicPlcTestSchemeDtlService.Edit(schDtlEntityEdit);
+                            if (isSucc)
+                            {
+                                _logger.LogInformation($"更新方案成功。方案名{ScheduleName},测试项{TestName}");
+                                MessageBoxResult boxResult = MessageBox.Show("更新成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+                            }
+                            else
+                            {
+                                MessageBoxResult boxResult = MessageBox.Show("更新失败", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                                return;
+                            }
+
                         }
 
                     }
-
                 }
             }
+            catch(Exception ex)
+            {
+                _logger.LogError(ex.ToString());
+            }
+
+          
 
         }
         /// <summary>

+ 1 - 1
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/BaseConfigViewModel.cs

@@ -242,7 +242,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                     }
                     catch (Exception ex)
                     {
-
+                        _logger.LogError(ex.ToString());
                     }
 
 

+ 83 - 67
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/CopySchViewModel.cs

@@ -126,51 +126,59 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             var finsSche = _basicPlcTestSchemeService.FindByName(schNameAgo);
             if (finsSche != null)
             {
-                //增加测试方案到数据库
-                bas_plc_test_scheme schDto = new bas_plc_test_scheme();
-                schDto.scheme_name = ScheduleName;
-                schDto.device_name = DeviceName;
-                schDto.create_by = Appsession.UserName;
-                schDto.create_time = DateTime.Now;
-                schDto.update_time = DateTime.Now;
-                schDto.update_by = Appsession.UserName;
-                _basicPlcTestSchemeService.Add(schDto);
-                //以前复制的schID
-                long schID = finsSche.scheme_id;
-                //查找此方案下的所有的测试项,并增加到测试项详细表中
-                long? schINewID = _basicPlcTestSchemeService.FindByName(ScheduleName)?.scheme_id;
-                //这里要注意顺序,所以用了SchProjectList循环
-                foreach (var sch in SchProjectList)
+                try
                 {
-                    if(sch.IsSelected)
+                    //增加测试方案到数据库
+                    bas_plc_test_scheme schDto = new bas_plc_test_scheme();
+                    schDto.scheme_name = ScheduleName;
+                    schDto.device_name = DeviceName;
+                    schDto.create_by = Appsession.UserName;
+                    schDto.create_time = DateTime.Now;
+                    schDto.update_time = DateTime.Now;
+                    schDto.update_by = Appsession.UserName;
+                    _basicPlcTestSchemeService.Add(schDto);
+                    //以前复制的schID
+                    long schID = finsSche.scheme_id;
+                    //查找此方案下的所有的测试项,并增加到测试项详细表中
+                    long? schINewID = _basicPlcTestSchemeService.FindByName(ScheduleName)?.scheme_id;
+                    //这里要注意顺序,所以用了SchProjectList循环
+                    foreach (var sch in SchProjectList)
                     {
-                        int dtlId = Convert.ToInt32(sch.Id);
-                        var unit = _basicPlcTestSchemeDtlService.Find(dtlId);
-                        if (unit != null)
+                        if (sch.IsSelected)
                         {
-                            bas_plc_test_scheme_dtl schDtlDto = new bas_plc_test_scheme_dtl();
-                            schDtlDto.scheme_id = schINewID;
-                            schDtlDto.item_name = unit.item_name;
+                            int dtlId = Convert.ToInt32(sch.Id);
+                            var unit = _basicPlcTestSchemeDtlService.Find(dtlId);
+                            if (unit != null)
+                            {
+                                bas_plc_test_scheme_dtl schDtlDto = new bas_plc_test_scheme_dtl();
+                                schDtlDto.scheme_id = schINewID;
+                                schDtlDto.item_name = unit.item_name;
 
-                            schDtlDto.item_type = unit.item_type;
-                            schDtlDto.precondition = unit.precondition;
-                            schDtlDto.precondition_describe = unit.precondition_describe;
-                            schDtlDto.action = unit.action;
-                            schDtlDto.action_describe = unit.action_describe;
-                            schDtlDto.judgement_result = unit.judgement_result;
-                            schDtlDto.judgement_result_describe = unit.judgement_result_describe;
-                            schDtlDto.create_by = Appsession.UserName;
-                            schDtlDto.create_time = DateTime.Now;
-                            schDtlDto.update_time = DateTime.Now;
-                            schDtlDto.update_by = Appsession.UserName;
-                            bool isAddSucc = _basicPlcTestSchemeDtlService.Add(schDtlDto);
+                                schDtlDto.item_type = unit.item_type;
+                                schDtlDto.precondition = unit.precondition;
+                                schDtlDto.precondition_describe = unit.precondition_describe;
+                                schDtlDto.action = unit.action;
+                                schDtlDto.action_describe = unit.action_describe;
+                                schDtlDto.judgement_result = unit.judgement_result;
+                                schDtlDto.judgement_result_describe = unit.judgement_result_describe;
+                                schDtlDto.create_by = Appsession.UserName;
+                                schDtlDto.create_time = DateTime.Now;
+                                schDtlDto.update_time = DateTime.Now;
+                                schDtlDto.update_by = Appsession.UserName;
+                                bool isAddSucc = _basicPlcTestSchemeDtlService.Add(schDtlDto);
 
+                            }
                         }
+
+
                     }
-                    
-                  
+                    _logger.LogInformation($"复制方案成功。方案名{ScheduleName}");
                 }
-                _logger.LogInformation($"复制方案成功。方案名{ScheduleName}");
+                catch(Exception ex)
+                {
+                    _logger.LogError(ex.ToString());
+                }
+               
             }
             RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
         }
@@ -195,44 +203,52 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
             
             if (getMsg != null)
             {
-                foreach (var item in getMsg)
+                try
                 {
-                    schNameAgo = item.ToString();
-                    ScheduleName = schNameAgo + "_copy";
-
-                    var findSche = _basicPlcTestSchemeService.FindByName(schNameAgo);
-                    if (findSche != null)
+                    foreach (var item in getMsg)
                     {
-                       //显示设备名称
-                       DeviceName= findSche.device_name;
-                        long schID = findSche.scheme_id;
-                        //查找此方案下的所有的测试项,并增加到表格
-                        var schDtls = _basicPlcTestSchemeDtlService.QueryList()?.FindAll(x => x.scheme_id == schID);
-                        foreach (var unit in schDtls)
+                        schNameAgo = item.ToString();
+                        ScheduleName = schNameAgo + "_copy";
+
+                        var findSche = _basicPlcTestSchemeService.FindByName(schNameAgo);
+                        if (findSche != null)
                         {
-                            string itemType = string.Empty;
-                            switch (unit.item_type)
-                            {
-                                case 0:
-                                    itemType = "前置项";
-                                    break;
-                                case 1:
-                                    itemType = "PLC点位测试项";
-                                    break;
-                                case 2:
-                                    itemType = "Robot动作测试";
-                                    break;
-                            }
-                            SchProjectList.Add(new SelectItemModel
+                            //显示设备名称
+                            DeviceName = findSche.device_name;
+                            long schID = findSche.scheme_id;
+                            //查找此方案下的所有的测试项,并增加到表格
+                            var schDtls = _basicPlcTestSchemeDtlService.QueryList()?.FindAll(x => x.scheme_id == schID);
+                            foreach (var unit in schDtls)
                             {
-                                Id = unit.scheme_dtl_id,
-                                ItemName = unit.item_name,
-                                ItemType = itemType,
-                            }); ;
+                                string itemType = string.Empty;
+                                switch (unit.item_type)
+                                {
+                                    case 0:
+                                        itemType = "前置项";
+                                        break;
+                                    case 1:
+                                        itemType = "PLC点位测试项";
+                                        break;
+                                    case 2:
+                                        itemType = "Robot动作测试";
+                                        break;
+                                }
+                                SchProjectList.Add(new SelectItemModel
+                                {
+                                    Id = unit.scheme_dtl_id,
+                                    ItemName = unit.item_name,
+                                    ItemType = itemType,
+                                }); ;
 
+                            }
                         }
                     }
                 }
+                catch(Exception ex)
+                {
+                    _logger.LogError(ex.ToString());
+                }
+                
             }
         }
         #region 命令绑定

+ 3 - 3
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/PLCConfigViewModel.cs

@@ -56,8 +56,10 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 if (callback.Result == ButtonResult.OK)
                 {
                     BasPlcItemConfigDto returnValue = callback.Parameters.GetValue<BasPlcItemConfigDto>("ReturnValue");
+                   
                     if (returnValue != null)
                     {
+                       
                         var plcCon = _mapper.Map<BasPlcItemConfigDto, bas_plc_item_config>(returnValue);
                         var findPlcs = allPLCConfigList.FindAll(x => (x.PlcAddress == returnValue.PlcAddress) || (x.PlcItem == returnValue.PlcAddress));
                         foreach(var item in  findPlcs)
@@ -148,14 +150,12 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                         //获得文件路径
                         string localFilePath = saveFileDialog.FileName.ToString();
 
-                        //string filePathWithName = localFilePath + ".xlsx";
-
                         //获取文件内容
                         MiniExcel.SaveAs(localFilePath, PLCItemList);
                     }
                     catch (Exception ex)
                     {
-
+                        _logger.LogError(ex.ToString());
                     }
 
 

+ 0 - 11
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/AutoTestViewModel.cs

@@ -904,12 +904,6 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             //更新测试记录
             AddOrEditTesDtltRecord(globalSchDetailId);
 
-            //判定是否为最后一项
-            //long maxDtlId = _basicPlcTestSchemeDtlService.FindAllBySchId(schId).Select(x => x.scheme_dtl_id).Max();
-            //if (globalSchDetailId == maxDtlId)
-            //{
-            //    MessageBox.Show("已是此测试方案最后一个测试项!", "确认", MessageBoxButton.OK, MessageBoxImage.Information);
-            //}
             return isJudge;
         }
         /// <summary>
@@ -941,11 +935,6 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                                     ProVisibility = Visibility.Visible;
                                 }));
 
-                              
-                                //if (readResult == item.PlcValue)
-                                //{
-                                //    break;
-                                //}
                                 await Task.Delay(1000);
                             }
                         });

+ 8 - 0
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/ManualTestViewModel.cs

@@ -575,6 +575,10 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             {
                 case "人工判定":
                     //弹出确认的对话框
+                    if(string.IsNullOrEmpty(BeforeDetail))
+                    {
+                        return true;
+                    }
                     MessageBoxResult boxResult = MessageBox.Show(BeforeDetail, "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
                     if (boxResult == MessageBoxResult.OK)
                     {
@@ -597,6 +601,10 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                     {
                         case "NULL":
                             //弹出确认的对话框
+                            if (string.IsNullOrEmpty(BeforeDetail))
+                            {
+                                return true;
+                            }
                             MessageBoxResult boxResultAuto = MessageBox.Show(BeforeDetail, "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
                             if (boxResultAuto == MessageBoxResult.OK)
                             {

+ 6 - 2
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/QueryViewModel.cs

@@ -69,7 +69,11 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
 
 
         #region 私有方法
-
+        /// <summary>
+        /// pdf报告相关信息
+        /// </summary>
+        /// <param name="schDtlId"></param>
+        /// <returns></returns>
         private InvoiceModel GetReportPLCInfo(int schDtlId)
         {
             //测试方案明细主键ID
@@ -374,7 +378,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                     }
                     catch (Exception ex)
                     {
-
+                        _logger.LogError(ex.ToString());
                     }
 
 

+ 2 - 2
BlankApp1/BlankApp1/Views/BusinessManageView/WritePLCView.xaml

@@ -23,12 +23,12 @@
         <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Center">
             <TextBlock Text="PLC地址:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0" TextAlignment="Right" Width="80"/>
             <!--<ComboBox  Height="28" Width="120" ItemsSource="{Binding PLCVars}" SelectedItem="{Binding SelectPLCVar}" />-->
-            <TextBox  Height="28" Width="120" Text="{Binding PLCAddr}" />
+            <TextBox  Height="28" Width="120" Text="{Binding PLCAddr}" IsReadOnly="True" />
         </StackPanel>
 
         <StackPanel Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Center">
             <TextBlock Text="数据值:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0" TextAlignment="Right" Width="80"/>
-            <TextBox  Height="28" Width="120" Text="{Binding PLCValue}" />
+            <TextBox  Height="28" Width="120" Text="{Binding PLCValue}" IsReadOnly="True" />
         </StackPanel>
 
         <StackPanel Orientation="Horizontal" Grid.Row="3" HorizontalAlignment="Center">