Bladeren bron

修改自动和手动测试

ltwork 1 jaar geleden
bovenliggende
commit
3edede31d7

+ 79 - 6
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/AutoTestViewModel.cs

@@ -382,7 +382,62 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             }
 
         }
-       
+        /// <summary>
+        /// 前置项结果判定
+        /// </summary>
+        /// <returns></returns>
+        private int GetPrecedtionResult()
+        {
+            //前置项
+            int beforeResult = 0;
+
+            if (BeforeConList.Count == 0)
+            {
+                beforeResult = 1;
+            }
+            else
+            {
+                if (SelectLogic == "OR")
+                {
+                    var find = BeforeConList.FirstOrDefault(x => x.TestResult == "通过");
+                    if (find != null)
+                    {
+                        beforeResult = 1;
+                    }
+                    else
+                    {
+                        beforeResult = 0;
+                    }
+                }
+                else
+                {
+                    if (SelectLogic == "AND" || SelectLogic == "ONLY")
+                    {
+                        var find = BeforeConList.FirstOrDefault(x => x.TestResult == "不通过");
+                        if (find != null)
+                        {
+                            beforeResult = 0;
+                        }
+                        else
+                        {
+                            beforeResult = 1;
+
+                        }
+                    }
+                    else
+                    {
+                        if (SelectLogic == "NULL")
+                        {
+
+                            beforeResult = 1;
+
+                        }
+                    }
+                }
+            }
+            return beforeResult;
+
+        }
         /// <summary>
         /// 获取测试结果
         /// </summary>
@@ -596,7 +651,12 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                     _logger.LogInformation($"开始自动测试。方案名{ScheduleName},测试项{TestName}");
                     SendLogToDis($"开始自动测试。方案名{ScheduleName},测试项{TestName}");
                     //测试
-                    await ExecTest();
+                    bool isExec=await ExecTest();
+                    //条件不满足,直接退出
+                    if(!isExec)
+                    {
+                        return;
+                    }
                     SendLogToDis($"自动测试完成。方案名{ScheduleName},测试项{TestName}");
                     _logger.LogInformation($"自动测试完成。方案名{ScheduleName},测试项{TestName}");
                 
@@ -627,8 +687,10 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
           
 
         }
-        private async Task ExecTest()
-        {   //开始时间
+        private async Task<bool> ExecTest()
+        {
+            bool isSucc = true;
+            //开始时间
             startTime = DateTime.Now;
             //增加测试记录主表
             AddTestRecord();
@@ -636,7 +698,18 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             //前置项
             bool preBool = TestPreceditionMethod();
 
-
+            //前置项结果判断
+            int preceditionResult = GetPrecedtionResult();
+            if (preceditionResult == 0)
+            {
+                MessageBoxResult boxResult = MessageBox.Show("前置项条件不满足,若继续运行,点击确认按钮;若取消运行,点击取消按钮", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
+                if (boxResult != MessageBoxResult.OK)
+                {
+                    // 立即取消线程
+                    tokensource.Cancel();
+                    return false;
+                }
+            }
             //输入项
             bool isAction = TestActionMethod();
             
@@ -646,8 +719,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             AddDtltRecord(globalSchDetailId);
             //下一项
             StepIndex = 0;
-        
 
+            return isSucc;
         }
         /// <summary>
         /// 更新测试结果

+ 66 - 1
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/ManualTestViewModel.cs

@@ -339,6 +339,62 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                 _iBizTestRecordService.Edit(findRecord);
             }
 
+        }
+        /// <summary>
+        /// 前置项结果判定
+        /// </summary>
+        /// <returns></returns>
+        private int GetPrecedtionResult()
+        { 
+            //前置项
+            int beforeResult = 0;
+           
+            if (BeforeConList.Count == 0)
+            {
+                beforeResult = 1;
+            }
+            else
+            {
+                if (SelectLogic == "OR")
+                {
+                    var find = BeforeConList.FirstOrDefault(x => x.TestResult == "通过");
+                    if (find != null)
+                    {
+                        beforeResult = 1;
+                    }
+                    else
+                    {
+                        beforeResult = 0;
+                    }
+                }
+                else
+                {
+                    if (SelectLogic == "AND" || SelectLogic == "ONLY")
+                    {
+                        var find = BeforeConList.FirstOrDefault(x => x.TestResult == "不通过");
+                        if (find != null)
+                        {
+                            beforeResult = 0;
+                        }
+                        else
+                        {
+                            beforeResult = 1;
+
+                        }
+                    }
+                    else
+                    {
+                        if (SelectLogic == "NULL")
+                        {
+
+                            beforeResult = 1;
+
+                        }
+                    }
+                }
+            }
+            return beforeResult;
+
         }
         /// <summary>
         /// 判定结果
@@ -602,7 +658,16 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                 StartEnalbe = true;
                 return;
             }
-            
+            //前置项结果判断
+            int preceditionResult=GetPrecedtionResult();
+            if( preceditionResult == 0 )
+            {
+                MessageBoxResult boxResult = MessageBox.Show("前置项条件不满足,若继续运行,点击确认按钮;若取消运行,点击取消按钮", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
+                if (boxResult != MessageBoxResult.OK)
+                {
+                    return;
+                }
+            }
             //输入项
             bool isAction=TestActionMethod();
             if (!isAction)

+ 68 - 1
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/RetryTestViewModel.cs

@@ -344,6 +344,62 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                 _iBizTestRecordService.Edit(findRecord);
             }
 
+        }
+        /// <summary>
+        /// 前置项结果判定
+        /// </summary>
+        /// <returns></returns>
+        private int GetPrecedtionResult()
+        {
+            //前置项
+            int beforeResult = 0;
+
+            if (BeforeConList.Count == 0)
+            {
+                beforeResult = 1;
+            }
+            else
+            {
+                if (SelectLogic == "OR")
+                {
+                    var find = BeforeConList.FirstOrDefault(x => x.TestResult == "通过");
+                    if (find != null)
+                    {
+                        beforeResult = 1;
+                    }
+                    else
+                    {
+                        beforeResult = 0;
+                    }
+                }
+                else
+                {
+                    if (SelectLogic == "AND" || SelectLogic == "ONLY")
+                    {
+                        var find = BeforeConList.FirstOrDefault(x => x.TestResult == "不通过");
+                        if (find != null)
+                        {
+                            beforeResult = 0;
+                        }
+                        else
+                        {
+                            beforeResult = 1;
+
+                        }
+                    }
+                    else
+                    {
+                        if (SelectLogic == "NULL")
+                        {
+
+                            beforeResult = 1;
+
+                        }
+                    }
+                }
+            }
+            return beforeResult;
+
         }
         /// <summary>
         /// 判定结果
@@ -616,7 +672,18 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                 StartEnalbe = true;
                 return;
             }
-           
+            //前置项结果判断
+            int preceditionResult = GetPrecedtionResult();
+            if (preceditionResult == 0)
+            {
+                MessageBoxResult boxResult = MessageBox.Show("前置项条件不满足,若继续运行,点击确认按钮;若取消运行,点击取消按钮", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
+                if (boxResult != MessageBoxResult.OK)
+                {
+                    // 立即取消线程
+
+                    return;
+                }
+            }
             //输出项
             bool isJudgeResult = await TestJudgementMethod();
             if (!isJudgeResult)

+ 3 - 3
BlankApp1/BlankApp1/Views/BasicConfigView/AddSchView.xaml

@@ -153,7 +153,7 @@
                                     </Grid.RowDefinitions>
                                     <DockPanel LastChildFill="False">
                                         <TextBlock Text="前置项明细:"   Style="{StaticResource textBlockStyle}" />
-                                        <Button  Content="新增" Height="22" Width="60"  Margin="5,0"  Command="{Binding AddDetailCommand}" CommandParameter="Before" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right"  />
+                                        <Button  Content="新增" Height="22" Width="60"  Margin="10,0"  Command="{Binding AddDetailCommand}" CommandParameter="Before" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right"  />
                                     </DockPanel>
                                     <DataGrid Grid.Row="1"  Style="{StaticResource MyDataGridSyle}"
   ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}" x:Name="DeviceDataGrid" RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"
@@ -237,7 +237,7 @@ Command="{Binding DataContext.DeleteBeforeCommand, RelativeSource={RelativeSourc
                                     </Grid.RowDefinitions>
                                     <DockPanel LastChildFill="False">
                                         <TextBlock Text="输入项明细:"   Style="{StaticResource textBlockStyle}" />
-                                        <Button  Content="新增" Height="22" Width="60"  Margin="5,0"  Command="{Binding AddDetailCommand}" CommandParameter="In" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right"  />
+                                        <Button  Content="新增" Height="22" Width="60"  Margin="10,0"  Command="{Binding AddDetailCommand}" CommandParameter="In" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right"  />
                                     </DockPanel>
                                     <DataGrid Grid.Row="1"  Style="{StaticResource MyDataGridSyle}"
                                     ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}" RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"
@@ -325,7 +325,7 @@ Command="{Binding DataContext.DeleteInCommand, RelativeSource={RelativeSource Mo
                                     </Grid.RowDefinitions>
                                     <DockPanel LastChildFill="False">
                                         <TextBlock Text="结果项明细:"   Style="{StaticResource textBlockStyle}" />
-                                        <Button  Content="新增" Height="22" Width="60"  Margin="5,0"  Command="{Binding AddDetailCommand}" CommandParameter="Out" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right"  />
+                                        <Button  Content="新增" Height="22" Width="60"  Margin="10,0"  Command="{Binding AddDetailCommand}" CommandParameter="Out" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right"  />
                                     </DockPanel>
                                     <DataGrid Grid.Row="1"  Style="{StaticResource MyDataGridSyle}"
   ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}"  RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"

+ 3 - 3
BlankApp1/BlankApp1/Views/BasicConfigView/EditItemDetailView.xaml

@@ -151,7 +151,7 @@
                                     </Grid.RowDefinitions>
                                     <DockPanel LastChildFill="False">
                                         <TextBlock Text="前置项明细:"   Style="{StaticResource textBlockStyle}" />
-                                        <Button  Content="新增" Height="22" Width="60"  Margin="5,0"  Command="{Binding AddDetailCommand}" CommandParameter="Before" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right"  />
+                                        <Button  Content="新增" Height="22" Width="60"  Margin="10,0"  Command="{Binding AddDetailCommand}" CommandParameter="Before" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right"  />
                                     </DockPanel>
                                 <DataGrid Grid.Row="1"  Style="{StaticResource MyDataGridSyle}"
   ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}" x:Name="DeviceDataGrid" RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"
@@ -235,7 +235,7 @@ Command="{Binding DataContext.DeleteBeforeCommand, RelativeSource={RelativeSourc
                                     </Grid.RowDefinitions>
                                     <DockPanel LastChildFill="False">
                                         <TextBlock Text="输入项明细:"   Style="{StaticResource textBlockStyle}" />
-                                        <Button  Content="新增" Height="22" Width="60"  Margin="5,0"  Command="{Binding AddDetailCommand}" CommandParameter="In" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right"  />
+                                        <Button  Content="新增" Height="22" Width="60"  Margin="10,0"  Command="{Binding AddDetailCommand}" CommandParameter="In" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right"  />
                                     </DockPanel>
                                 <DataGrid Grid.Row="1" Style="{StaticResource MyDataGridSyle}"
                                 ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}" RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"
@@ -323,7 +323,7 @@ Command="{Binding DataContext.DeleteInCommand, RelativeSource={RelativeSource Mo
                                     </Grid.RowDefinitions>
                                     <DockPanel LastChildFill="False">
                                         <TextBlock Text="结果项明细:"   Style="{StaticResource textBlockStyle}" />
-                                        <Button  Content="新增" Height="22" Width="60"  Margin="5,0"  Command="{Binding AddDetailCommand}" CommandParameter="Out" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right"  />
+                                        <Button  Content="新增" Height="22" Width="60"  Margin="10,0"  Command="{Binding AddDetailCommand}" CommandParameter="Out" Style="{StaticResource NormalButtonStyle}" DockPanel.Dock="Right"  />
                                     </DockPanel>
                                 <DataGrid Grid.Row="1"  Style="{StaticResource MyDataGridSyle}"
                                  ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}"  RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"

+ 6 - 6
BlankApp1/BlankApp1/Views/BasicConfigView/EditSchView.xaml

@@ -74,13 +74,13 @@
 
 
                
-                <Grid Grid.Row="1"  Margin="5">
+                <Grid Grid.Row="1"  Margin="0">
                     <StackPanel Orientation="Vertical">
                         <StackPanel Orientation="Horizontal" >
                             <TextBlock Text="▊"  TextAlignment="Center" VerticalAlignment="Center" Foreground="#409EFF" Margin="5,0,5,0"/>
                             <TextBlock Text="测试项列表"  Style="{StaticResource NormalTextBlockStyle}" Margin="0,0,5,0"/>
                         </StackPanel>
-                    <DockPanel LastChildFill="False" >
+                        <DockPanel LastChildFill="False" >
              
                         <StackPanel Orientation="Horizontal">
                             <TextBlock Text="测试项名称:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
@@ -90,7 +90,7 @@
                             <TextBlock Text="测试项类型:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
                             <ComboBox  Height="28" Width="160" ItemsSource="{Binding TestKinds}" SelectedItem="{Binding SelectTest}" />
                         </StackPanel>
-                        <Button  Content="新增测试项" Width="80"  Margin="5,0"  Command="{Binding AddItemCommand}" Style="{StaticResource NormalButtonStyle}"  DockPanel.Dock="Right">
+                        <Button  Content="新增测试项" Width="80"  Margin="10,0"  Command="{Binding AddItemCommand}" Style="{StaticResource NormalButtonStyle}"  DockPanel.Dock="Right">
                             <Button.CommandParameter>
                                 <MultiBinding Converter="{ StaticResource ResourceKey=TwoParConverter}">
                                     <Binding Path="DeviceKindName"  ></Binding>
@@ -106,9 +106,9 @@
                        
                       
                     </DockPanel>
-                    <DataGrid    Style="{StaticResource MyDataGridSyle}"
+                        <DataGrid    Style="{StaticResource MyDataGridSyle}"
  ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}"  RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2" 
-ItemsSource="{Binding SchProjectList}" VerticalScrollBarVisibility="Visible" >
+ItemsSource="{Binding SchProjectList}" VerticalScrollBarVisibility="Visible"  Margin="0,5,0,0">
                             <b:Interaction.Triggers>
                                 <b:EventTrigger EventName="SelectionChanged">
                                     <b:InvokeCommandAction Command="{Binding DgSelectChangeCommand}" 
@@ -121,7 +121,7 @@ ItemsSource="{Binding SchProjectList}" VerticalScrollBarVisibility="Visible" >
                                 <DataGridTextColumn Header="前置项描述" Binding="{Binding BeforeDetail}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                                 <DataGridTextColumn Header="输入项描述" Binding="{Binding InDetail}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                                 <DataGridTextColumn Header="输出项描述" Binding="{Binding OutDetail}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                                <DataGridTemplateColumn Header="操作" Width="200" CellStyle="{StaticResource MyDataGridCellStyle}">
+                                <DataGridTemplateColumn Header="操作" Width="210" CellStyle="{StaticResource MyDataGridCellStyle}">
                                     <DataGridTemplateColumn.CellTemplate>
                                         <DataTemplate>
                                             <StackPanel Orientation="Horizontal">

+ 1 - 1
BlankApp1/BlankApp1/Views/BusinessManageView/TestResultDetailView.xaml

@@ -133,7 +133,7 @@
                         <TextBlock Text="前置项明细:"   Style="{StaticResource textBlockStyle}" />
 
                     </DockPanel>
-                    <DataGrid Style="{StaticResource MyDataGridSyle}"
+                    <DataGrid Grid.Row="1" Style="{StaticResource MyDataGridSyle}"
              ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}" x:Name="DeviceDataGrid" RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  
                ItemsSource="{Binding BeforeConList}"  >
                         <DataGrid.Columns >