using DataLinkMesWork;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace bizFacade
{
    /// <summary>
    /// 通用BizFaced类
    /// </summary>
    public partial class BaseDataSystemMES
    {
        /// <summary>
        /// 验证质量数据状态哈希表
        /// </summary>
        public static Hashtable QualityVerifyStatus_Hash = new Hashtable();

        /// <summary>
        /// 读取工位质量数据验证状态
        /// </summary>
        /// <param name="OpName"></param>
        /// <returns></returns>
        public static bool QualityVerifyStatus_Hash_Read(string OpName)
        {
            if (QualityVerifyStatus_Hash.Contains(OpName))
            {
                return Convert.ToBoolean(QualityVerifyStatus_Hash[OpName]);

            }
            return false;

        }


        /// <summary>
        /// 写入工位质量数据验证状态
        /// </summary>
        /// <param name="OpName"></param>
        /// <param name="Result"></param>
        public static void QualityVerifyStatus_Hash_Write(string OpName, bool Result)
        {
            if (QualityVerifyStatus_Hash.Contains(OpName))
            {
                QualityVerifyStatus_Hash[OpName] = Result;

            }
            else
            {
                QualityVerifyStatus_Hash.Add(OpName, Result);

            }
        }




        /// <summary>
        /// 部装工位质量数据验证
        /// </summary>
        /// <returns></returns>
        public static bool QulityDataVerify(string OpName, string EngineID_Subline, out string AlarmStr)
        {
            int IsAlarm = 0;
            AlarmStr = "";
            string procedureName;
            procedureName = "测量数据工位_监控系统_部装质量数据验证";
            SqlParameter[] thisParms = new SqlParameter[4];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", OpName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@部装总成号", EngineID_Subline);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@是否报警", IsAlarm);
            thisParms[2].Direction = ParameterDirection.Output;
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@报警工位号", AlarmStr);
            thisParms[3].Direction = ParameterDirection.Output;

            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms))
            {
                IsAlarm = Convert.ToInt32(thisParms[2].Value.ToString());
                AlarmStr = thisParms[3].Value.ToString();

                if (IsAlarm == 0)
                {
                    return true;
                }
            }
            return false;

        }





        /// <summary>
        /// 线外工位质量数据验证
        /// </summary>
        /// <returns></returns>
        public static bool QualityVerifyStatusOutline(string OpName, out string AlarmStr)
        {
            int IsAlarm = 0;
            AlarmStr = "";
            string procedureName;
            procedureName = "测量数据工位_监控系统_线外质量数据验证";
            SqlParameter[] thisParms = new SqlParameter[3];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", OpName);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@是否报警", IsAlarm);
            thisParms[1].Direction = ParameterDirection.Output;
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@报警工位号", AlarmStr);
            thisParms[2].Direction = ParameterDirection.Output;

            if (DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms))
            {
                IsAlarm = Convert.ToInt32(thisParms[1].Value.ToString());
                AlarmStr = thisParms[2].Value.ToString();

                if (IsAlarm == 0)
                {
                    return true;
                }
            }
            return false;

        }

    }
}
