| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 | using System;using System.Collections.Generic;using System.Data;using System.Linq;using System.Text;using Aitex.Core.RT.DBCore;using Aitex.Core.RT.Event;using Aitex.Core.RT.Log;using Aitex.Sorter.Common;using MECF.Framework.Common.CommonData;namespace Aitex.Sorter.RT.Module.DBRecorder{    /*     */    public class CarrierDataRecorder    {        /// <summary>        ///         /// </summary>        /// <param name="guid">唯一</param>        /// <param name="station">位置</param>        public static void Loaded(string guid, string station)        {            string sql = string.Format("INSERT INTO \"carrier_data\"(\"guid\", \"load_time\", \"station\" )VALUES ('{0}', '{1}', '{2}');",                guid,                DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff"),                station );            DB.Insert(sql);        }        public static void UpdateCarrierId(string guid, string rfid)        {            string sql = string.Format(                "UPDATE \"carrier_data\" SET \"rfid\"='{0}' WHERE \"guid\"='{1}';",                rfid, guid);            DB.Insert(sql);        }        public static void UpdateLotId(string guid, string lotId)        {            string sql = string.Format(                "UPDATE \"carrier_data\" SET \"lot_id\"='{0}' WHERE \"guid\"='{1}';",                lotId, guid);            DB.Insert(sql);        }        public static void UpdateProductCategory(string guid, string productCategory)        {            string sql = string.Format(                "UPDATE \"carrier_data\" SET \"product_category\"='{0}' WHERE \"guid\"='{1}';",                productCategory, guid);            DB.Insert(sql);        }        public static void Unloaded(string guid)        {            string sql = string.Format(                "UPDATE \"carrier_data\" SET \"unload_time\"='{0}' WHERE \"guid\"='{1}';",                DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff"),                guid);            DB.Insert(sql);        }        public static List<HistoryCarrierData> QueryDBCarrier(string sql)        {            List<HistoryCarrierData> result = new List<HistoryCarrierData>();            try            {                DataSet ds = DB.ExecuteDataset(sql);                if (ds == null)                    return result;                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)                {                    HistoryCarrierData ev = new HistoryCarrierData();                    ev.Guid = ds.Tables[0].Rows[i]["guid"].ToString();                         ev.Rfid = ds.Tables[0].Rows[i]["rfid"].ToString();                    ev.LotId = ds.Tables[0].Rows[i]["lot_id"].ToString();                    ev.ProductCategory = ds.Tables[0].Rows[i]["product_category"].ToString();                    ev.Station = ds.Tables[0].Rows[i]["station"].ToString();                    if (!ds.Tables[0].Rows[i]["load_time"].Equals(DBNull.Value))                        ev.LoadTime = ((DateTime)ds.Tables[0].Rows[i]["load_time"]).ToString("yyyy/MM/dd HH:mm:ss.fff");                    if (!ds.Tables[0].Rows[i]["unload_time"].Equals(DBNull.Value))                        ev.UnloadTime = ((DateTime)ds.Tables[0].Rows[i]["unload_time"]).ToString("yyyy/MM/dd HH:mm:ss.fff");                    result.Add(ev);                   }                }                catch (Exception ex)                {                LOG.WriteExeption(ex);            }            return result;        }    }}
 |