//using BasicData;
//using MesWork;
//using OpcBasic;
using MesServerWork;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static MesServerWork.MIS_BASE;

namespace MesDataFunction
{
    public class LoadTagTypeCodeID
    {


        public static void Load(string path)
        {
            MIS_BASE.hashtable_TagType = new NameValueCollection();
            MIS_BASE.hashtable_TagTypeTagName = new NameValueCollection();
            MIS_BASE.hashtable_TagTypeChange = new NameValueCollection();
            MIS_BASE.hashtable_MesTagTypeChange = new NameValueCollection();
            MIS_BASE.hashtable_WebTagTypeChange = new NameValueCollection();
            MIS_BASE.hashtable_TagTypeDataType = new NameValueCollection();

            var dt = NPOITest.ExeclHelper.ExcelToDataTable(path, "变量类型代码", true);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                //序号	变量类型	TagTypeDataType	TagName	变量类型代码	TagTypeChange	MesTagTypeChange	WebTagTypeChange	信号点名称	变量类型名称

                var TagTypeDataType = dt.Rows[i]["TagTypeDataType"].ToString();
                var TagName = dt.Rows[i]["TagName"].ToString();
                var 变量类型代码 = dt.Rows[i]["变量类型代码"].ToString();
                var TagTypeChange = dt.Rows[i]["TagTypeChange"].ToString();
                var WebTagTypeChange = dt.Rows[i]["WebTagTypeChange"].ToString();
                var MesTagTypeChange = dt.Rows[i]["MesTagTypeChange"].ToString();

                //OpcOperation.hashtable_TagType.Add(TagName, 变量类型代码);
                //OpcOperation.hashtable_TagTypeTagName.Add(变量类型代码, TagName);
                //OpcOperation.hashtable_TagTypeChange.Add(TagName, TagTypeChange);
                //OpcOperation.hashtable_MesTagTypeChange.Add(TagName, MesTagTypeChange);
                //OpcOperation.hashtable_WebTagTypeChange.Add(TagName, WebTagTypeChange);
                //OpcOperation.hashtable_TagTypeDataType.Add(变量类型代码, TagTypeDataType);
                if (!MIS_BASE.hashtable_TagType.AllKeys.Contains(TagName))
                    MIS_BASE.hashtable_TagType.Add(TagName, 变量类型代码);
                if (!MIS_BASE.hashtable_TagTypeTagName.AllKeys.Contains(变量类型代码))
                    MIS_BASE.hashtable_TagTypeTagName.Add(变量类型代码, TagName);
                if (!MIS_BASE.hashtable_TagTypeChange.AllKeys.Contains(TagName))
                    MIS_BASE.hashtable_TagTypeChange.Add(TagName, TagTypeChange);
                if (!MIS_BASE.hashtable_MesTagTypeChange.AllKeys.Contains(TagName))
                    MIS_BASE.hashtable_MesTagTypeChange.Add(TagName, MesTagTypeChange);
                if (!MIS_BASE.hashtable_WebTagTypeChange.AllKeys.Contains(TagName))
                    MIS_BASE.hashtable_WebTagTypeChange.Add(TagName, WebTagTypeChange);
                if (!MIS_BASE.hashtable_TagTypeDataType.AllKeys.Contains(变量类型代码))
                    MIS_BASE.hashtable_TagTypeDataType.Add(变量类型代码, TagTypeDataType);
            }
            HashtableList.hashtable_TagTypeTagName_Temp = new Hashtable();
            foreach (string key in MIS_BASE.hashtable_TagTypeTagName.Keys)
            {
                HashtableList.hashtable_TagTypeTagName_Temp.Add(key, MIS_BASE.hashtable_TagTypeTagName[key]);
            }
            HashtableList.hashtable_TagTypeDataType_Temp = new NameValueCollection();
            foreach (string key in MIS_BASE.hashtable_TagTypeDataType.Keys)
            {
                HashtableList.hashtable_TagTypeDataType_Temp.Add(key, MIS_BASE.hashtable_TagTypeDataType[key]);
            }
            HashtableList.hashtable_TagType_Temp = new NameValueCollection();
            foreach (string key in MIS_BASE.hashtable_TagType.Keys)
            {
                HashtableList.hashtable_TagType_Temp.Add(key, MIS_BASE.hashtable_TagType[key]);
            }
        }

        public static void Load(DataTable dt)
        {
            MIS_BASE.hashtable_TagType = new NameValueCollection();
            MIS_BASE.hashtable_TagTypeTagName = new NameValueCollection();
            MIS_BASE.hashtable_TagTypeChange = new NameValueCollection();
            MIS_BASE.hashtable_MesTagTypeChange = new NameValueCollection();
            MIS_BASE.hashtable_WebTagTypeChange = new NameValueCollection();
            MIS_BASE.hashtable_TagTypeDataType = new NameValueCollection();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                //序号	变量类型	TagTypeDataType	TagName	变量类型代码	TagTypeChange	MesTagTypeChange	WebTagTypeChange	信号点名称	变量类型名称
                var TagTypeDataType = dt.Rows[i]["TagTypeDataType"].ToString();
                var TagName = dt.Rows[i]["TagName"].ToString();
                var 变量类型代码 = dt.Rows[i]["变量类型代码"].ToString();
                var TagTypeChange = dt.Rows[i]["TagTypeChange"].ToString();
                var WebTagTypeChange = dt.Rows[i]["WebTagTypeChange"].ToString();
                var MesTagTypeChange = dt.Rows[i]["MesTagTypeChange"].ToString();
                if (!MIS_BASE.hashtable_TagType.AllKeys.Contains(TagName))
                    MIS_BASE.hashtable_TagType.Add(TagName, 变量类型代码);
                if (!MIS_BASE.hashtable_TagTypeTagName.AllKeys.Contains(变量类型代码))
                    MIS_BASE.hashtable_TagTypeTagName.Add(变量类型代码, TagName);
                if (!MIS_BASE.hashtable_TagTypeChange.AllKeys.Contains(TagName))
                    MIS_BASE.hashtable_TagTypeChange.Add(TagName, TagTypeChange);
                if (!MIS_BASE.hashtable_MesTagTypeChange.AllKeys.Contains(TagName))
                    MIS_BASE.hashtable_MesTagTypeChange.Add(TagName, MesTagTypeChange);
                if (!MIS_BASE.hashtable_WebTagTypeChange.AllKeys.Contains(TagName))
                    MIS_BASE.hashtable_WebTagTypeChange.Add(TagName, WebTagTypeChange);
                if (!MIS_BASE.hashtable_TagTypeDataType.AllKeys.Contains(变量类型代码))
                    MIS_BASE.hashtable_TagTypeDataType.Add(变量类型代码, TagTypeDataType);
            }
            HashtableList.hashtable_TagTypeTagName_Temp = new Hashtable();
            foreach (string key in MIS_BASE.hashtable_TagTypeTagName.Keys)
            {
                HashtableList.hashtable_TagTypeTagName_Temp.Add(key, MIS_BASE.hashtable_TagTypeTagName[key]);
            }
            HashtableList.hashtable_TagTypeDataType_Temp = new NameValueCollection();
            foreach (string key in MIS_BASE.hashtable_TagTypeDataType.Keys)
            {
                HashtableList.hashtable_TagTypeDataType_Temp.Add(key, MIS_BASE.hashtable_TagTypeDataType[key]);
            }
            HashtableList.hashtable_TagType_Temp = new NameValueCollection();
            foreach (string key in MIS_BASE.hashtable_TagType.Keys)
            {
                HashtableList.hashtable_TagType_Temp.Add(key, MIS_BASE.hashtable_TagType[key]);
            }
        }

    }

}
