wyq 1 рік тому
батько
коміт
14a4dd6578

+ 11 - 2
XdCxRhDW.App/UserControl/CtrlHome.cs

@@ -39,6 +39,7 @@ using DPP_YH_Core.Extensions;
 using static DevExpress.Utils.Drawing.Helpers.NativeMethods;
 using DevExpress.Utils.Filtering;
 using DevExpress.Data.Svg;
+using XdCxRhDw.Dto;
 
 namespace XdCxRhDW.App.UserControl
 {
@@ -904,10 +905,18 @@ namespace XdCxRhDW.App.UserControl
             {
                 try
                 {
-                    var svtItem = TaskSvr.GetTaskSvt();
                     if (tsk.TaskType == EnumTaskType.History)
                     {
-                        var res = await HttpHelper.PostRequestAsync<AjaxResult>(svtItem.modelSvrs.BaseHttpAddr + "/api/HistoryTaskProcessing/Stop", tsk.ID);
+                        //下发任务
+                        var svtItem = TaskSvr.GetTaskSvt();
+                        if (svtItem == null || svtItem.code <= 0)
+                        {
+                            DxHelper.MsgBoxHelper.ShowWarning($"请打开执行历史任务的服务");
+                            return;
+                        }
+                        HistoryTaskStopDto dto = new HistoryTaskStopDto();
+                        dto.ID = tsk.ID;
+                        var res = await HttpHelper.PostRequestAsync<AjaxResult>(svtItem.modelSvrs.BaseHttpAddr + "/api/HistoryTaskProcessing/Stop", dto) ;
                         if (res.code != 200)
                         {
                             DxHelper.MsgBoxHelper.ShowWarning($"停止历史任务的服务失败{res.msg}");

+ 42 - 0
XdCxRhDW.Framework/EnumExtension.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.Linq;
 using System.Reflection;
+using System.Resources;
 using System.Text;
 using System.Threading.Tasks;
 
@@ -34,4 +35,45 @@ public static class EnumExtension
         }
 
     }
+
+    public static T GetEnumByDisplayName<T>(this string displayName) where T : struct
+    {
+        Type type = typeof(T);
+        string[] names = Enum.GetNames(type);
+        string[] array = names;
+        foreach (string text in array)
+        {
+            DisplayAttribute customAttribute = type.GetField(text).GetCustomAttribute<DisplayAttribute>();
+            T result;
+            if (customAttribute == null)
+            {
+                if (text == displayName && Enum.TryParse(text, out result))
+                {
+                    return result;
+                }
+                continue;
+            }
+            string a;
+            if (customAttribute.ResourceType == null && string.IsNullOrEmpty(customAttribute.Name))
+            {
+                a = text;
+            }
+            else if (!(customAttribute.ResourceType != null))
+            {
+                a = (string.IsNullOrEmpty(customAttribute.Name) ? text : customAttribute.Name);
+            }
+            else
+            {
+                ResourceManager resourceManager = new ResourceManager(customAttribute.ResourceType);
+                a = resourceManager.GetString(customAttribute.Name);
+            }
+
+            if (a == displayName && System.Enum.TryParse(text, out result))
+            {
+                return result;
+            }
+        }
+        return (T)System.Enum.Parse(type, "0");
+    }
+   
 }

+ 0 - 1
XdCxRhDW.Framework/HttpHelper.cs

@@ -62,7 +62,6 @@ public class HttpHelper
         var AjaxResult = JsonConvert.DeserializeObject<AjaxResult<T>>(result);
         return AjaxResult;
     }
-
   
     public static async Task<AjaxResult<T>> GetRequestAsync<T>(string url,int timeoutSeconds = 30)
     {

+ 7 - 6
XdCxRhDW.TaskServer/Controllers/HistoryTaskProcessingController.cs

@@ -76,23 +76,24 @@ namespace XdCxRhDW.TaskServer.Controllers
 
 
         /// <summary>
-        /// 
+        /// 历史任务停止
         /// </summary>
-        /// <param name="TaskId"></param>
+        /// <param name="dto"></param>
         /// <returns></returns>
         [HttpPost]
-        public AjaxResult Stop(int TaskId)
+        public AjaxResult Stop(HistoryTaskStopDto dto)
         {
             try
             {
 
-                LogHelper.Info($"接收停止历史任务编号:{TaskId}");
-                var historys = _service.allTask.Where(t => t.TaskDto.ID == TaskId);
+                LogHelper.Info($"接收停止历史任务编号:{dto.ID}");
+                var historys = _service.allTask.Where(t => t.TaskDto.ID == dto.ID);
                 foreach (var item in historys)
                 {
                     item.Stop();
-                    _service.allTask.Remove(item);
+
                 }
+                _service.allTask.Remove(t => t.TaskDto.ID == dto.ID);
                 return Success();
             }
             catch (Exception ex)

+ 1 - 1
XdCxRhDW.TaskServer/Task/HistoryTaskI.cs

@@ -57,7 +57,7 @@ namespace XdCxRhDW.TaskServer.Task
         }
         public virtual void Stop()
         {
-            IsRuning = true;
+            IsRuning = false;
         }
 
         //检测

+ 11 - 1
XdCxRhDW.TaskServer/Task/X2D1Task.cs

@@ -145,6 +145,16 @@ namespace XdCxRhDW.TaskServer.Task
                                             XdSnr = xd.Snr,
                                             SxDfo = sx.Df,
                                             SxSnr = sx.Snr,
+                                            CheckRes = new CheckResDto()
+                                            {
+                                                FileName = deitem.File1,
+                                                ModRate = deitem.ModRate,
+                                                ModType = deitem.ModType,
+                                                SmpCount = deitem.Length,
+                                                SmpStart = deitem.Start,
+                                                UserName = deitem.UserName,
+                                                PosCheckType = deitem.DmcType.GetEnumByDisplayName<EnumPosCheckTypeDto>(),
+                                            }
                                         };
 
                                         await X2D1NoXlAsync(x2D1);
@@ -195,7 +205,7 @@ namespace XdCxRhDW.TaskServer.Task
                 LogHelper.Error($"历史任务获取天线信息失败");
                 return infos;
             }
-            infos.Add(result.data.recTx==null? new TxInfo() { TxType = EnumTxType.Rec }: result.data.recTx);
+            infos.Add(result.data.recTx == null ? new TxInfo() { TxType = EnumTxType.Rec } : result.data.recTx);
             infos.Add(result.data.cdbTx == null ? new TxInfo() { TxType = EnumTxType.Cdb } : result.data.cdbTx);
             infos.Add(result.data.cxTx == null ? new TxInfo() { TxType = EnumTxType.Cx } : result.data.cxTx);
             infos.Add(result.data.refLoc == null ? new TxInfo() { TxType = EnumTxType.Ref } : result.data.refLoc);

+ 1 - 0
XdCxRhDw.Dto/02.XdCxRhDW.Dto.csproj

@@ -61,6 +61,7 @@
     <Compile Include="DetectResDto.cs" />
     <Compile Include="CpuCgResDto.cs" />
     <Compile Include="FileUploadResDto.cs" />
+    <Compile Include="HistoryTaskStopDto.cs" />
     <Compile Include="PosDto\CheckResDto.cs" />
     <Compile Include="PosDto\RHNoXlPosDto.cs" />
     <Compile Include="PosDto\RHNoXlNoParPosDto.cs" />

+ 2 - 2
XdCxRhDw.Dto/EnumPosResTypeDto.cs

@@ -196,12 +196,12 @@ namespace XdCxRhDW.Dto
         /// <summary>
         /// DAMA
         /// </summary>
-        [Display(Name = "DAMA")]
+        [Display(Name = "DAMA检测")]
         DAMA,
         /// <summary>
         /// IBS
         /// </summary>
-        [Display(Name = "IBS")]
+        [Display(Name = "IBS检测")]
         IBS,
         /// <summary>
         /// 能量检测

+ 16 - 0
XdCxRhDw.Dto/HistoryTaskStopDto.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace XdCxRhDW.Dto
+{
+    public class HistoryTaskStopDto
+    {
+        /// <summary>
+        /// 任务ID
+        /// </summary>
+        public int ID { get; set; }
+    }
+}