using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraGrid.Views.Grid;
using SystemX.Product.ALIS.UI.View.InfoList;
using System.Data.SqlClient;
using SystemX.Product.ALIS.Interface;
using static SystemX.Product.ALIS.UI.View.ViewCfg;
using DevExpress.XtraGrid.Columns;
using System.Reflection;
using SystemX.Product.ALIS.UI.Subs;
using System.Threading;

using static CpCommon.ExceptionHandler;
using static PsKGaudi.Parser.PsCCS;
using PsKGaudi.Parser.PsCCSSTDFn;
using CpApplication;
using CpApplication.Manager;
using CpCommon;
using CpTesterPlatform.CpLogUtil;
using static PsCommon.PsCommon;
using System.Xml.Linq;
using PsKGaudi.Parser.PsCCSArea;
using PsKGaudi;
using PsKGaudi.Parser.MacroModuleSkel;
using PsKGaudi.Parser.PsCCSSTDFn.Parameters;
using DevExpress.XtraGrid.Views.Base;
using PsKGaudi.Parser.PsCCSSTDFn;
using System.IO;
using static SystemX.Net.Platform.Common.Util.LogMessage;
using System.Diagnostics;
using SystemX.Common;

namespace SystemX.Product.ALIS.UI.View.InfoList
{
    public class UcTestListViewSub
    {

    }

    public partial class UcTestListView
    {
        public bool CreateInfo(eSelectType SelType, long lChkTime = long.MaxValue)
        {
            bool bCreateInfoResult = true;
            switch (SelType)
            {
                case eSelectType.TestListFile:
                    try
                    {
                        AbsoluteHostName = gridHistView.GetFocusedRowCellValue("Name").ToString();

                        SelectTestListFileInfo.SelectTestListFileNo = nVRFYParameter;

                        //SelectTestListFileInfo.Name = AbsoluteHostName;

                        SelectTestListFileInfo.TestType = gridHistView.GetFocusedRowCellValue("TestType").ToString();
                        SelectTestListFileInfo.Version = gridHistView.GetFocusedRowCellValue("FileVersion").ToString();
                        SelectTestListFileInfo.ProdCode = gridHistView.GetFocusedRowCellValue("ProdCode").ToString();
                        SelectTestListFileInfo.FileName = gridHistView.GetFocusedRowCellValue("FileName").ToString();
                        SelectTestListFileInfo.RegDT = Convert.ToDateTime(gridHistView.GetFocusedRowCellValue("RegDT").ToString());
                        SelectTestListFileInfo.RegUser = gridHistView.GetFocusedRowCellValue("RegUser").ToString();
                        SelectTestListFileInfo.UpdateDT = Convert.ToDateTime(gridHistView.GetFocusedRowCellValue("UpdateDT"));
                        SelectTestListFileInfo.UpdateUser = gridHistView.GetFocusedRowCellValue("UpdateUser").ToString();
                        SelectTestListFileInfo.Comment = gridHistView.GetFocusedRowCellValue("Comment").ToString();
                        SelectTestListFileInfo.Description = gridHistView.GetFocusedRowCellValue("Description").ToString();

                        string strQueryText = $"SELECT X.No, " +
                                       $"X.Name, " +
                                       $"X.TestType, " +
                                       $"X.Version, " +
                                       $"X.ProdCode, " +
                                       $"X.FileName, " +
                                       $"X.TestListData " +
                                       $"FROM [dbo].[STOR_TestListFile] AS X " +
                                       $"WHERE " +
                                       $"No = " + SelectTestListFileInfo.SelectTestListFileNo.Value;

                        DataTable dtQuery = ctrlDB.GetTable(strQueryText);

                        if (XCommons.isHasRow(dtQuery) == false)
                            throw new Exception();

                        SelectTestListFileInfo.TestListFileLoadRawData = new byte[((byte[])dtQuery.Rows[0]["TestListData"]).Length];
                        ((byte[])dtQuery.Rows[0]["TestListData"]).CopyTo(SelectTestListFileInfo.TestListFileLoadRawData, 0);
                    }
                    catch { bCreateInfoResult = false; }
                    finally
                    {
                        if (bCreateInfoResult)
                        {
                            SelectTestListFileInfo.bHasSelectedData = true;

                            if (lChkTime <= 180)
                            {
                                textEditQueryText1.Text = AbsoluteHostName;
                                textEditQueryText2.Text = SelectTestListFileInfo.TestType;
                                textEditQueryText3.Text = SelectTestListFileInfo.Version;
                                textEditQueryText4.Text = SelectTestListFileInfo.ProdCode;
                                textEditQueryText5.Text = SelectTestListFileInfo.FileName;

                                ModifyItem();
                            }
                        }
                        else
                            SelectTestListFileInfo.bHasSelectedData = false;
                    }
                    break;
                case eSelectType.TestListVariant:
                    try
                    {
                        AbsoluteHostName = gridHistView.GetFocusedRowCellValue("P_ProdNo").ToString();

                        SelectTestListVariantInfo.SelectVariantNo = nVRFYParameter;

                        SelectTestListVariantInfo.ProdNo_P = AbsoluteHostName;
                        SelectTestListVariantInfo.TestType = gridHistView.GetFocusedRowCellValue("TestType").ToString();
                        SelectTestListVariantInfo.Version = gridHistView.GetFocusedRowCellValue("FileVersion").ToString();
                        SelectTestListVariantInfo.ProdCode = gridHistView.GetFocusedRowCellValue("ProdCode").ToString();
                        SelectTestListVariantInfo.FileName = gridHistView.GetFocusedRowCellValue("FileName").ToString();
                        SelectTestListVariantInfo.RegDT = Convert.ToDateTime(gridHistView.GetFocusedRowCellValue("RegDT").ToString());
                        SelectTestListVariantInfo.RegUser = gridHistView.GetFocusedRowCellValue("RegUser").ToString();
                        SelectTestListVariantInfo.UpdateDT = Convert.ToDateTime(gridHistView.GetFocusedRowCellValue("UpdateDT"));
                        SelectTestListVariantInfo.UpdateUser = gridHistView.GetFocusedRowCellValue("UpdateUser").ToString();
                        SelectTestListVariantInfo.GroupNo = Convert.ToInt32(gridHistView.GetFocusedRowCellValue("GroupNo"));
                        SelectTestListVariantInfo.Comment = gridHistView.GetFocusedRowCellValue("Comment").ToString();
                        SelectTestListVariantInfo.Description = gridHistView.GetFocusedRowCellValue("Description").ToString();

                        SelectTestListVariantInfo.TestListFileNo = Convert.ToInt32(gridHistView.GetFocusedRowCellValue("TestListFileNo"));
                        SelectTestListVariantInfo.TestListName = gridHistView.GetFocusedRowCellValue("TestListName").ToString();
                    }
                    catch { bCreateInfoResult = false; }
                    finally
                    {
                        if (bCreateInfoResult)
                        {
                            SelectTestListVariantInfo.bHasSelectedData = true;

                            if (lChkTime <= 180)
                            {
                                textEditQueryText1.Text = AbsoluteHostName;
                                textEditQueryText2.Text = SelectTestListVariantInfo.TestType;
                                textEditQueryText3.Text = SelectTestListVariantInfo.Version;
                                textEditQueryText4.Text = SelectTestListVariantInfo.ProdCode;

                                ModifyItem();
                            }
                        }
                        else
                            SelectTestListVariantInfo.bHasSelectedData = false;
                    }
                    break;
                case eSelectType.TestListRelease:
                    try
                    {
                        AbsoluteHostName = gridHistView.GetFocusedRowCellValue("C_ProdNo").ToString();

                        SelectTestListReleaseInfo.ProdNo_C = AbsoluteHostName;
                        SelectTestListReleaseInfo.TestCodeNo = Commons.ConvertTextToTryValue<int>(gridHistView.GetFocusedRowCellValue("TestCodeNo").ToString(), -1);
                        SelectTestListReleaseInfo.VariantNo = Commons.ConvertTextToTryValue<int>(gridHistView.GetFocusedRowCellValue("VariantNo").ToString(), -1);
                        SelectTestListReleaseInfo.Config = gridHistView.GetFocusedRowCellValue("Config").ToString();
                        SelectTestListReleaseInfo.RegDT = Convert.ToDateTime(gridHistView.GetFocusedRowCellValue("RegDT").ToString());
                        SelectTestListReleaseInfo.RegUser = gridHistView.GetFocusedRowCellValue("RegUser").ToString();
                        SelectTestListReleaseInfo.RegUserComment = gridHistView.GetFocusedRowCellValue("RegUserComment").ToString();

                        SelectTestListReleaseInfo.TestCode = gridHistView.GetFocusedRowCellValue("TestCode").ToString();
                        SelectTestListReleaseInfo.ProdNo_P = gridHistView.GetFocusedRowCellValue("P_ProdNo").ToString();
                        SelectTestListReleaseInfo.TestType = gridHistView.GetFocusedRowCellValue("TestType").ToString();
                        SelectTestListReleaseInfo.FileVersion = gridHistView.GetFocusedRowCellValue("FileVersion").ToString();
                        SelectTestListReleaseInfo.ProdCode = gridHistView.GetFocusedRowCellValue("ProdCode").ToString();

                        if (SelectTestListReleaseInfo.VariantNo == -1)
                            throw new Exception();
                    }
                    catch { bCreateInfoResult = false; }
                    finally
                    {
                        if (bCreateInfoResult)
                        {
                            SelectTestListReleaseInfo.bHasSelectedData = true;

                            if (lChkTime <= 180)
                            {
                                textEditQueryText1.Text = AbsoluteHostName;
                                textEditQueryText2.Text = SelectTestListReleaseInfo.TestCode;
                                textEditQueryText3.Text = SelectTestListReleaseInfo.TestType;
                                textEditQueryText4.Text = SelectTestListReleaseInfo.FileVersion;
                                textEditQueryText5.Text = SelectTestListReleaseInfo.ProdCode;
                                textEditQueryText6.Text = SelectTestListReleaseInfo.ProdNo_P;

                                ModifyItem();
                            }
                        }
                        else
                            SelectTestListReleaseInfo.bHasSelectedData = false;
                    }
                    break;
            }

            return bCreateInfoResult;
        }

        public void SetTestListFileFieldInfo()
        {
            dicTestListFileField = new Dictionary<string, Tuple<SqlDbType, int>>();

            dicTestListFileField.Clear();
            dicTestListFileField.Add("Name", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 64));
            dicTestListFileField.Add("TestType", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 8));
            dicTestListFileField.Add("Version", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 4));
            dicTestListFileField.Add("ProdCode", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 4));
            dicTestListFileField.Add("FileName", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 64));
            dicTestListFileField.Add("RegDT", new Tuple<SqlDbType, int>(SqlDbType.DateTime2, 7));
            dicTestListFileField.Add("RegUser", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 32));
            dicTestListFileField.Add("UpdateDT", new Tuple<SqlDbType, int>(SqlDbType.DateTime2, 7));
            dicTestListFileField.Add("UpdateUser", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 32));
            dicTestListFileField.Add("Comment", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 256));
            dicTestListFileField.Add("Description", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 256));
            dicTestListFileField.Add("TestListData", new Tuple<SqlDbType, int>(SqlDbType.Binary, -1));
        }

        public void SetTestListVariantFieldInfo()
        {
            dicTestListVariantField = new Dictionary<string, Tuple<SqlDbType, int>>();

            dicTestListVariantField.Clear();
            dicTestListVariantField.Add("ProdNo_P", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 16));
            /*
            dicTestListVariantField.Add("TestType", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 8));
            dicTestListVariantField.Add("Version", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 4));
            dicTestListVariantField.Add("ProdCode", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 4));
            dicTestListVariantField.Add("FileName", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 64));
            */
            dicTestListVariantField.Add("RegDT", new Tuple<SqlDbType, int>(SqlDbType.DateTime2, 7));
            dicTestListVariantField.Add("RegUser", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 32));
            dicTestListVariantField.Add("UpdateDT", new Tuple<SqlDbType, int>(SqlDbType.DateTime2, 7));
            dicTestListVariantField.Add("UpdateUser", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 32));
            dicTestListVariantField.Add("GroupNo", new Tuple<SqlDbType, int>(SqlDbType.Int, 0));
            dicTestListVariantField.Add("Comment", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 256));
            dicTestListVariantField.Add("Description", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 256));
            dicTestListVariantField.Add("TestListFileNo", new Tuple<SqlDbType, int>(SqlDbType.Int, 0));
        }

        public void SetTestListRelFieldInfo()
        {
            dicTestListReleaseField = new Dictionary<string, Tuple<SqlDbType, int>>();

            dicTestListReleaseField.Clear();
            dicTestListReleaseField.Add("ProdNo_C", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 16));
            dicTestListReleaseField.Add("TestCodeNo", new Tuple<SqlDbType, int>(SqlDbType.Int, 0));
            dicTestListReleaseField.Add("VariantNo", new Tuple<SqlDbType, int>(SqlDbType.Int, 0));
            dicTestListReleaseField.Add("Config", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 32));
            dicTestListReleaseField.Add("RegDT", new Tuple<SqlDbType, int>(SqlDbType.DateTime2, 7));
            dicTestListReleaseField.Add("RegUser", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 32));
            dicTestListReleaseField.Add("RegUserComment", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 256));
        }

        public void SetVRFYReleaseFieldInfo()
        {
            dicVRFYReleaseField = new Dictionary<string, Tuple<SqlDbType, int>>();

            dicVRFYReleaseField.Clear();
            dicVRFYReleaseField.Add("TestlistFileNo", new Tuple<SqlDbType, int>(SqlDbType.Int, 0));
            dicVRFYReleaseField.Add("StepID", new Tuple<SqlDbType, int>(SqlDbType.BigInt, 0));
            dicVRFYReleaseField.Add("Variant", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 32));
            dicVRFYReleaseField.Add("Gate", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 128));
            dicVRFYReleaseField.Add("Activate", new Tuple<SqlDbType, int>(SqlDbType.Bit, 0));
            dicVRFYReleaseField.Add("StepVersion", new Tuple<SqlDbType, int>(SqlDbType.Int, 0));
            dicVRFYReleaseField.Add("Enable", new Tuple<SqlDbType, int>(SqlDbType.Bit, 0));
            dicVRFYReleaseField.Add("Position", new Tuple<SqlDbType, int>(SqlDbType.BigInt, 0));
            dicVRFYReleaseField.Add("StepDesc", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 256));
            dicVRFYReleaseField.Add("UseFunction", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 128));
            dicVRFYReleaseField.Add("MacroParm", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 64));
            dicVRFYReleaseField.Add("Parm", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 64));
            dicVRFYReleaseField.Add("SpecMin", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 128));
            dicVRFYReleaseField.Add("SpecMax", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 128));
            dicVRFYReleaseField.Add("IsGlobal", new Tuple<SqlDbType, int>(SqlDbType.Bit, 0));
            dicVRFYReleaseField.Add("Dim", new Tuple<SqlDbType, int>(SqlDbType.NVarChar, 64));
            dicVRFYReleaseField.Add("UpdateDT", new Tuple<SqlDbType, int>(SqlDbType.DateTime2, 7));
        }

        private SqlParameter GetMakeSqlParameterInfo(Dictionary<string, Tuple<SqlDbType, int>> refField, string strSetName, object objValue)
        {
            if (refField.ContainsKey(strSetName))
            {
                SqlParameter param = null;

                if (refField[strSetName].Item2 != 0)
                    param = new SqlParameter("@" + strSetName, refField[strSetName].Item1, refField[strSetName].Item2);
                else
                    param = new SqlParameter("@" + strSetName, refField[strSetName].Item1);

                param.Value = objValue;
                return param;
            }
            else
                return null;
        }
              
        private void SetVRFYReleaseTableControl(eVRFYControlMode setMode, int setTestListNo, DateTime ctrlDt, List<PsCCSStdFnBase> lstFb, int nLastVersion = -1)
        {
            if (lstFb.Count <= 0)
                return;

            Int64 nStepNum = Int64.MaxValue;

            try
            {
                int iItemNum = lstFb.Count;
                int iPos = 0;

                SqlCommand[] cmds = new SqlCommand[iItemNum];

                string columns = "TestlistFileNo,StepID,Variant,Gate,Activate,StepVersion,Enable,Position,StepDesc,UseFunction,MacroParm,Parm,SpecMin,SpecMax,IsGlobal,Dim,UpdateDT";
                string values = string.Join(",", columns.Split(',').Select(c => string.Format("@{0}", c)));
                string sqlCommandInsert = string.Format("INSERT INTO [VRFY_TestListFileRelease] ({0}) VALUES ({1})", columns, values);

                SetVRFYReleaseFieldInfo();

                int isetVersion = 0;
                int isetEnable = 1;

                foreach (PsCCSStdFnBase fb in lstFb)
                {
                    fb.GetTestStepSummary();

                    isetVersion = 0;
                    isetEnable = 1;

                    //삭제시 Enable -> 0 변경
                    if (setMode == eVRFYControlMode.Delete)
                        isetEnable = 0;

                    if (setMode != eVRFYControlMode.New)
                    {
                        //직전 마지막 스텝 버전 기준 + 1
                        isetVersion = nLastVersion + 1;
                    }

                    cmds[iPos] = new SqlCommand(sqlCommandInsert, ctrlDB.GetConnSqlCmd().Connection);

                    string strMO = (fb.GetMO() != null) ? fb.GetMO() : "";
                    string strFuncName = (fb.GetSTDFnNameAsEnum().ToString() != null) ? fb.GetSTDFnNameAsEnum().ToString() : "";
                    string strDim = (fb.GetDimension().ToString() != null) ? fb.GetDimension().ToString() : "";

                    string[] strSummaryTestSteps = fb.SummaryTestStep;
                    string strMacroParm = (strSummaryTestSteps[6] != null) ? strSummaryTestSteps[6] : "";
                    string strParm = (strSummaryTestSteps[8] != null) ? strSummaryTestSteps[8] : "";

                    string strGetMin = (fb.PairedParmsMinMax.Min != null) ? fb.PairedParmsMinMax.Min : "";
                    string strGetMax = (fb.PairedParmsMinMax.Max != null) ? fb.PairedParmsMinMax.Max : "";

                    nStepNum = fb.StepNum;

                    SqlParameter[] setParams = new SqlParameter[columns.Split(',').Count()];
                    setParams[0] = GetMakeSqlParameterInfo(dicVRFYReleaseField, "TestlistFileNo", setTestListNo);
                    setParams[1] = GetMakeSqlParameterInfo(dicVRFYReleaseField, "StepID", (Int64)fb.StepNum);
                    setParams[2] = GetMakeSqlParameterInfo(dicVRFYReleaseField, "Variant", fb.Variant);
                    setParams[3] = GetMakeSqlParameterInfo(dicVRFYReleaseField, "Gate", fb.Gate);

                    PsKGaudi.Parser.PsCCSDefineEnumTraceability getTracebility = fb.Traceability;
                    PsKGaudi.Parser.PsCCSDefineEnumActivate getActivateState = fb.IsActivate();
                    PsKGaudi.Parser.PsCCSDefineEnumActivate getActivateProperty = fb.Activate;

                    if (getActivateProperty == PsKGaudi.Parser.PsCCSDefineEnumActivate.ACTIVATE)
                        setParams[4] = GetMakeSqlParameterInfo(dicVRFYReleaseField, "Activate", 1);
                    else
                        setParams[4] = GetMakeSqlParameterInfo(dicVRFYReleaseField, "Activate", 0);

                    setParams[5] = GetMakeSqlParameterInfo(dicVRFYReleaseField, "StepVersion", isetVersion);
                    setParams[6] = GetMakeSqlParameterInfo(dicVRFYReleaseField, "Enable", isetEnable);
                    setParams[7] = GetMakeSqlParameterInfo(dicVRFYReleaseField, "Position", (Int64)fb.Position);
                    setParams[8] = GetMakeSqlParameterInfo(dicVRFYReleaseField, "StepDesc", strMO);
                    setParams[9] = GetMakeSqlParameterInfo(dicVRFYReleaseField, "UseFunction", strFuncName);
                    setParams[10] = GetMakeSqlParameterInfo(dicVRFYReleaseField, "MacroParm", strMacroParm);
                    setParams[11] = GetMakeSqlParameterInfo(dicVRFYReleaseField, "Parm", strParm);
                    setParams[12] = GetMakeSqlParameterInfo(dicVRFYReleaseField, "SpecMin", strGetMin);
                    setParams[13] = GetMakeSqlParameterInfo(dicVRFYReleaseField, "SpecMax", strGetMax);

                    if (fb.PairedParmsMinMax.Min.IndexOf("&") >= 0 || fb.PairedParmsMinMax.Max.IndexOf("&") >= 0)
                        setParams[14] = GetMakeSqlParameterInfo(dicVRFYReleaseField, "IsGlobal", 1);
                    else
                        setParams[14] = GetMakeSqlParameterInfo(dicVRFYReleaseField, "IsGlobal", 0);

                    setParams[15] = GetMakeSqlParameterInfo(dicVRFYReleaseField, "Dim", strDim);
                    setParams[16] = GetMakeSqlParameterInfo(dicVRFYReleaseField, "UpdateDT", ctrlDt);

                    cmds[iPos++].Parameters.AddRange(setParams);
                }

                cmds.ToList().ForEach(x => x.ExecuteNonQuery());
            }
            catch(Exception e)
            {
                MessageOutput.ConsoleWrite(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss>>") + @" setVRFYReleaseTableControl() Error. "+ setTestListNo + " " + nStepNum + " " + e.Message, ConsoleColor.Red, LogMessageLevel.FATAL);

                throw;
            }
        }

        private DataTable MakeVRFYTestListReleaseTable()
        {
            // Create a new DataTable titled 'Names.'
            DataTable vrfyTable = new DataTable("VRFY");

            // Add three column objects to the table.
            DataColumn Column0 = new DataColumn();
            Column0.DataType = System.Type.GetType("System.Int64");
            Column0.ColumnName = "No";
            Column0.AutoIncrement = true;
            Column0.AllowDBNull = false;
            vrfyTable.Columns.Add(Column0);

            DataColumn Column1 = new DataColumn();
            Column1.DataType = System.Type.GetType("System.Int32");
            Column1.ColumnName = "TestlistNo";
            vrfyTable.Columns.Add(Column1);

            DataColumn Column2 = new DataColumn();
            Column2.DataType = System.Type.GetType("System.Int64");
            Column2.ColumnName = "StepID";
            vrfyTable.Columns.Add(Column2);

            DataColumn Column3 = new DataColumn();
            Column3.DataType = System.Type.GetType("System.String");
            Column3.ColumnName = "Variant";
            vrfyTable.Columns.Add(Column3);

            DataColumn Column4 = new DataColumn();
            Column4.DataType = System.Type.GetType("System.String");
            Column4.ColumnName = "Gate";
            vrfyTable.Columns.Add(Column4);

            DataColumn Column5 = new DataColumn();
            Column5.DataType = System.Type.GetType("System.Boolean");
            Column5.ColumnName = "Activate";
            vrfyTable.Columns.Add(Column5);

            DataColumn Column6 = new DataColumn();
            Column6.DataType = System.Type.GetType("System.Int32");
            Column6.ColumnName = "StepVersion";
            vrfyTable.Columns.Add(Column6);

            DataColumn Column7 = new DataColumn();
            Column7.DataType = System.Type.GetType("System.Boolean");
            Column7.ColumnName = "Enable";
            vrfyTable.Columns.Add(Column7);

            DataColumn Column8 = new DataColumn();
            Column8.DataType = System.Type.GetType("System.Int64");
            Column8.ColumnName = "Position";
            vrfyTable.Columns.Add(Column8);

            DataColumn Column9 = new DataColumn();
            Column9.DataType = System.Type.GetType("System.String");
            Column9.ColumnName = "StepDesc";
            vrfyTable.Columns.Add(Column9);

            DataColumn Column10 = new DataColumn();
            Column10.DataType = System.Type.GetType("System.String");
            Column10.ColumnName = "UseFunction";
            vrfyTable.Columns.Add(Column10);

            DataColumn Column11 = new DataColumn();
            Column11.DataType = System.Type.GetType("System.String");
            Column11.ColumnName = "MacroParm";
            vrfyTable.Columns.Add(Column11);

            DataColumn Column12 = new DataColumn();
            Column12.DataType = System.Type.GetType("System.String");
            Column12.ColumnName = "Parm";
            vrfyTable.Columns.Add(Column12);

            DataColumn Column13 = new DataColumn();
            Column13.DataType = System.Type.GetType("System.String");
            Column13.ColumnName = "SpecMin";
            vrfyTable.Columns.Add(Column13);

            DataColumn Column14 = new DataColumn();
            Column14.DataType = System.Type.GetType("System.String");
            Column14.ColumnName = "SpecMax";
            vrfyTable.Columns.Add(Column14);

            DataColumn Column15 = new DataColumn();
            Column15.DataType = System.Type.GetType("System.Boolean");
            Column15.ColumnName = "IsGlobal";
            vrfyTable.Columns.Add(Column15);

            DataColumn Column16 = new DataColumn();
            Column16.DataType = System.Type.GetType("System.String");
            Column16.ColumnName = "Dim";
            vrfyTable.Columns.Add(Column16);

            DataColumn Column17 = new DataColumn();
            Column17.DataType = System.Type.GetType("System.DateTime");
            Column17.ColumnName = "UpdateDT";
            vrfyTable.Columns.Add(Column17);

            // Create an array for DataColumn objects.
            DataColumn[] keys = new DataColumn[1];
            keys[0] = Column0;
            vrfyTable.PrimaryKey = keys;

            // Return the new DataTable.
            return vrfyTable;
        }
    }
}
