public static void LFKeyEvents_Ini(ref LFKeyEvents lst)
 {
     lst.datetime = " "; lst.Duration = 0; lst.Decription = " "; lst.MatCode = " ";
     lst.Weight = " "; lst.Temp = " "; lst.O2ppm = " "; lst.Ele_C = " ";
     lst.Ele_Si = " "; lst.Ele_Mn = " "; lst.Ele_S = " "; lst.Ele_P = " ";
     lst.Ele_Cu = " "; lst.Ele_As = " "; lst.Ele_Sn = " "; lst.Ele_Cr = " ";
     lst.Ele_Ni = " "; lst.Ele_Mo = " "; lst.Ele_Ti = " "; lst.Ele_Nb = " ";
     lst.Ele_Pb = " ";
 }
        public static List<LFKeyEvents> GetLF_KeyEvents(string HeatID)
        {
            List<LFKeyEvents> LST = new List<LFKeyEvents>();
            LFKeyEvents lst = new LFKeyEvents(); LFKeyEvents_Ini(ref lst);
            string strSQL = "";
            DataTable dt = new DataTable();

            //保存开始时间
            DateTime StartDateTime = DateTime.Now;

            //查找入炉时间,并从中提取事件
            strSQL = "SELECT * FROM LF_HEAT WHERE heat_id='" + HeatID + "'";
            dt = GetDataFromOledb(strSQL, lyqstr);
            if (dt.Rows.Count > 0)
            {
                StartDateTime = Convert.ToDateTime(dt.Rows[0]["strttime"]);

                lst = new LFKeyEvents(); LFKeyEvents_Ini(ref lst);
                lst.Decription = "到站";
                lst.datetime = dt.Rows[0]["strttime"].ToString();
                LST.Add(lst);

                lst = new LFKeyEvents(); LFKeyEvents_Ini(ref lst);
                lst.Decription = "离站";
                lst.datetime = dt.Rows[0]["endtime"].ToString();
                LST.Add(lst);

            }

            //测温事件
            strSQL = "select * FROM TEMPTURE WHERE heat_id='" + HeatID + "' AND device_no='LY210_LF'";
            dt = GetDataFromOledb(strSQL, lyqstr);
            for (int RowIndex = 0; RowIndex < dt.Rows.Count; RowIndex++)
            {
                lst = new LFKeyEvents(); LFKeyEvents_Ini(ref lst);

                lst.Decription = "第" + dt.Rows[RowIndex]["measure_num"].ToString() + "次测温";
                lst.datetime = dt.Rows[RowIndex]["measure_time"].ToString();
                lst.Temp = dt.Rows[RowIndex]["trmpture_value"].ToString();

                LST.Add(lst);
            }
            dt.Dispose();

            //** 加料事件 **//
            strSQL = "SELECT *  FROM addition WHERE heat_id='" + HeatID + "' AND device_no='LY210_LF'";
            dt = GetDataFromOledb(strSQL, lyqstr);
            for (int RowIndex = 0; RowIndex < dt.Rows.Count; RowIndex++)
            {
                lst = new LFKeyEvents(); LFKeyEvents_Ini(ref lst);

                lst.Decription = "第" + dt.Rows[RowIndex]["add_batch"].ToString() + "批加料";
                lst.datetime = dt.Rows[RowIndex]["add_time"].ToString();
                lst.MatName = dt.Rows[RowIndex]["mat_name"].ToString();
                lst.MatCode = dt.Rows[RowIndex]["mat_ID"].ToString();
                lst.Weight = dt.Rows[RowIndex]["weight"].ToString();

                LST.Add(lst);
            }
            dt.Dispose();

            //** 化验值 **//
            strSQL = "SELECT * FROM elem_ana WHERE heat_id='" + HeatID + "' AND device_no='LY210_LF'";
            dt = GetDataFromOledb(strSQL, lyqstr);
            for (int RowIndex = 0; RowIndex < dt.Rows.Count; RowIndex++)
            {
                lst = new LFKeyEvents(); LFKeyEvents_Ini(ref lst);

                lst.Decription = "第" + dt.Rows[RowIndex]["sample_number"].ToString() + "次化验";
                lst.datetime = dt.Rows[RowIndex]["sampletime"].ToString();

                lst.Ele_C = dt.Rows[RowIndex]["ele_c"].ToString();
                lst.Ele_Si = dt.Rows[RowIndex]["ele_si"].ToString();
                lst.Ele_Mn = dt.Rows[RowIndex]["ele_mn"].ToString();

                lst.Ele_S = dt.Rows[RowIndex]["ele_s"].ToString();
                lst.Ele_P = dt.Rows[RowIndex]["ele_p"].ToString();
                lst.Ele_Cu = dt.Rows[RowIndex]["ele_cu"].ToString();

                lst.Ele_As = dt.Rows[RowIndex]["ele_as"].ToString();
                lst.Ele_Sn = dt.Rows[RowIndex]["ele_Sn"].ToString();
                lst.Ele_Cr = dt.Rows[RowIndex]["ele_Cr"].ToString();

                lst.Ele_Ni = dt.Rows[RowIndex]["ele_Ni"].ToString();
                lst.Ele_Mo = dt.Rows[RowIndex]["ele_Mo"].ToString();
                lst.Ele_Ti = dt.Rows[RowIndex]["ele_Ti"].ToString();
                lst.Ele_Nb = dt.Rows[RowIndex]["ele_Nb"].ToString();
                lst.Ele_Pb = dt.Rows[RowIndex]["ele_Pb"].ToString();

                LST.Add(lst);

            }
            dt.Dispose();

            //计算时长
            DateTime cDateTime = new DateTime();
            TimeSpan ts = new TimeSpan();
            for (int I = 0; I < LST.Count; I++)
            {
                if (DateTime.TryParse(LST[I].datetime, out cDateTime))
                {
                    ts = cDateTime - StartDateTime;
                    LST[I].Duration = float.Parse((ts.TotalSeconds / 60.0).ToString("#0.00"));
                }
            }

            //按照时长排序
            LST.Sort(delegate(LFKeyEvents a, LFKeyEvents b) { return a.Duration.CompareTo(b.Duration); });

            return LST;
        }