C3031
2026-01-30 0ab0fde3216783ee2694d8d4bfbb94237e25a4bb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace LB_VisionProcesses.Processes.RecordTool
{
    [Process("绘制工具", Category = "其他工具", Description = "创建绘制工具")]
    public class RecordTool : BaseProcess
    {
        public RecordTool()
        {
            strProcessClass = "LB_VisionProcesses.Processes.RecordTool";
            strProcessName = "绘制工具";
        }
 
        public override bool Run()
        {
            try
            {
                InitRunParams();
 
                Dictionary<string, object> dicInputs = GetInputs();
                foreach (var kvp in dicInputs)
                    Params.Inputs.Add(kvp.Key, kvp.Value);
 
                Result = true;
            }
            catch (Exception ex)
            {
                Msg = $"脚本异常,原因是:{ex.Message}";
                Result = false;
            }
            return Result;
        }
 
        /// <summary>
        /// 获取脚本输入
        /// </summary>
        /// <returns></returns>
        public Dictionary<string, object> GetInputs()
        {
            try
            {
                Dictionary<string, object> dicInputs = new Dictionary<string, object>();
 
                for (int i = 0; i <= Params.Inputs.Count - 1; i++)
                {
                    bool isFindKey = Params.Inputs.GetKey(i, out string key);
                    //忽略不需要的参数
                    if (!isFindKey)
                        continue;
                    dicInputs.TryAdd(key, Params.Inputs[i]);
                }
 
                return dicInputs;
            }
            catch { return new Dictionary<string, object>(); }
        }
    }
}