schangxiang@126.com
2025-11-04 ca398287db3f5ea01f03aac4a85edb13b28100a6
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using DataEntity.Share;
using DriverLib.Engine;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Xml;
using XCommon;
using XCommon.Log;
using XCore;
using XHandler.Controls.Run.Com;
using XHandler.View;
using XHandler.View.MethodProperty;
using XImaging.Automation.Service.Interface;
using XImagingXhandler.XDAL;
using static HxEnum.OperationTypeEnum;
using DataRWDAL;
using NPOI.SS.Formula.Functions;
using System.Windows.Controls;
 
namespace XHandler.Controls
{
    public class SetVariableControl
    {
        string strCurrentCulture = "";
        public RunWnd launchView = null;
        public SetVariableControl(string strCurrentCulture)
        {
            this.strCurrentCulture = strCurrentCulture;
        }
 
        #region 执行变量设置,返回结果字符串
        public bool ExecuteSetVariable(XmlNode xmlEnv, XmlNode methodNode)
        {
            bool result = true;
            if (launchView._cancelSource.IsCancellationRequested)
            {
                result = false;
                return result;
            }
            #region Start Log
            if (strCurrentCulture.Equals("zh-CN"))
            {
                launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】" + Properties.MachineRunResource.strStart.ToString());
            }
            else
            {
                launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】start:");
            }
            #endregion
 
            #region 数据准备 
            bool enablepopwin = methodNode.SelectSingleNode("enablepopwin").InnerText.ToLower()=="true"?true:false;
            string variablename = methodNode.SelectSingleNode("variablename").InnerText;
            string variablevalue = methodNode.SelectSingleNode("variablevalue").InnerText;
            #endregion
 
            if (enablepopwin)
            {
                if (!launchView.isRemotingOper)
                {
                    System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        SetVariablePopwin setVariablePopwin = new SetVariablePopwin(variablename, variablevalue);
                        setVariablePopwin.variablename = variablename;
                        setVariablePopwin.variablevalue = variablevalue;
                        setVariablePopwin.Width = 1920;
                        setVariablePopwin.Height = 1080;
                        setVariablePopwin.WindowStartupLocation= WindowStartupLocation.CenterScreen;
                        setVariablePopwin.ShowDialog();
                        variablevalue = setVariablePopwin.variablevalue;
                    }));
                }
                else
                {
 
                }
            }
            Variable variable = new Variable();
            variable.variablename = variablename;
            variable.variablecurval = variablevalue;
            variable.variableinitval = variablevalue;
            launchView.gloadVariable.Push(variable);
 
            if (strCurrentCulture.Equals("zh-CN"))
            {
                launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】" + Properties.MachineRunResource.strProgress.ToString() 
                    + Properties.Resources.strDataOfVariable+":"+Properties.Resources.strVariable+":"+variable.variablename+" , "
                    +Properties.Resources.strValue+":"+variable.variableinitval.ToString());
            }
            else
            {
                launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】progress: variable list:"+"variable name:"+variable.variablename+","+"variable value:"+variable.variableinitval.ToString());
            }
 
            if (strCurrentCulture.Equals("zh-CN"))
            {
                launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】" + Properties.MachineRunResource.strProgress.ToString() + Properties.MachineRunResource.strEnd.ToString());
            }
            else
            {
                launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】progress: completed.");
            }
 
            return result;
        }
        #endregion
    }
}