using bizFacade;
using DataLinkMesWork;
using DoWhatPlc;
using MesServerWork;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MisDataSaveDate
{
    public partial class Funtion
    {
       
        private static void Alarm_Insert(ReturnValueString rv)
        {
            string TagID;
            string opName;
            string tagTypeID;
            int TagValue;

            DateTime alarmStartTime;
            DateTime alarmEndTime;
            int TimeDiff;
            string TagOrderBy;
            string Text1;
            string Text2;
            TagID = rv.TagID;
            tagTypeID = rv.TagTypeID;
            opName = rv.OpName;
            TagValue = Convert.ToInt32(rv.TagValue);

            alarmStartTime = Convert.ToDateTime(rv.TimeStampBefore);
            alarmEndTime = Convert.ToDateTime(rv.TimeStamp);
            TimeDiff = Convert.ToInt32(rv.TagKeepTime);
            TagOrderBy = rv.TagOrderBy;
            Text1 = rv.ItemName;
            Text2 = rv.ShaftID;

            Alarm_Insert(TagID, tagTypeID, opName, TagValue,
             alarmStartTime, alarmEndTime, TimeDiff, Text1, Text2, TagOrderBy);
        }

        public static bool Alarm_Insert(string TagID, string tagTypeID, string opName, int TagValue,
             DateTime alarmStartTime, DateTime alarmEndTime, int TimeDiff,
             string Text1, string Text2, string TagOrderBy)
        {


            string produceName = "测量数据工位报警全部_增加数据";
            SqlParameter[] thisParms = new SqlParameter[10];
            thisParms[0] = new System.Data.SqlClient.SqlParameter("@TagID", TagID);
            thisParms[1] = new System.Data.SqlClient.SqlParameter("@TagTypeID", tagTypeID);
            thisParms[2] = new System.Data.SqlClient.SqlParameter("@opName", opName);
            thisParms[3] = new System.Data.SqlClient.SqlParameter("@TagValue", TagValue);
            thisParms[4] = new System.Data.SqlClient.SqlParameter("@alarmStartTime", alarmStartTime);
            thisParms[5] = new System.Data.SqlClient.SqlParameter("@alarmEndTime", alarmEndTime);
            thisParms[6] = new System.Data.SqlClient.SqlParameter("@TimeDiff", TimeDiff);
            thisParms[7] = new System.Data.SqlClient.SqlParameter("@Text1", Text1);
            thisParms[8] = new System.Data.SqlClient.SqlParameter("@Text2", Text2);
            thisParms[9] = new System.Data.SqlClient.SqlParameter("@TagOrderBy", TagOrderBy);
            if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms))
            {

                return true;
            }
            return false;
        }
    }
}
