public void CreatCSVFile(int Location, int WarmType) { string SqlCommand = "Select * From ResinInfo Where WarmLocation = '" + Location + "' And TaskSuccess = '0';"; ResinInfo resininfo = new ResinInfo(); using (connection = new SQLiteConnection()) { // 建立SQLiteDataReader物件 using (SQLiteDataReader reader = ExecuteReader(SqlCommand)) { while (reader.Read()) { ResinInfo ResinInfoCopy = new ResinInfo { LotID = reader["SlotID"].ToString(), LotBottleInfo = reader["LotBottleInfo"].ToString(), ExpiredTime = reader["ExpiredTime"].ToString(), InColdTime = reader["InColdTime"].ToString(), InColdOperator = reader["InColdOperator"].ToString(), InWarmTime = reader["InWarmTime"].ToString(), InWarmOperator = reader["InWarmOperator"].ToString(), TotalWarmTime = Convert.ToInt32((Convert.ToDateTime(reader["WarmedTime"].ToString()) - Convert.ToDateTime(reader["InWarmTime"].ToString())).TotalMinutes).ToString(), TotalWeight = reader["TotalWeight"].ToString(), EmptyWeight = reader["EmptyWeight"].ToString(), OutWarmedTime = Convert.ToDateTime(reader["WarmedTime"].ToString()).ToString("yyyy/MM/dd HH:mm:ss"), OutWarmOperator = reader["OutWarmOperator"].ToString() }; resininfo = ResinInfoCopy; } } } CreatCsv1(resininfo, WarmType); }
public void CreatCsv(ResinInfo Resin) { string DirectoryName = "SendInfo\\" + DateTime.Now.ToString("yyyyMMdd"); string DataName = AppData.exePath + DirectoryName + "\\" + Resin.LotID + ".csv"; if (!Directory.Exists(AppData.exePath + DirectoryName)) { Directory.CreateDirectory(DirectoryName); } string[] ResinBottleInfo = Resin.LotBottleInfo.Split(';'); DateTime InWarmTime = Convert.ToDateTime(Resin.InWarmTime).AddMinutes(Convert.ToDouble(SystemConfig.WarmTime)); string ResinWeight = (Convert.ToDouble(Resin.TotalWeight) - Convert.ToDouble(Resin.EmptyWeight)).ToString(); FileStream Fs = new FileStream(DataName, FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(Fs, Encoding.Default); sw.Write( "膠材資訊\n" + "LotNO:,批號," + Resin.LotID + "\n" + "P/N:,," + ResinBottleInfo[0] + "\n" + "Qty(kg):,," + ResinBottleInfo[3] + "\n" + "EXP Date:,過期時間," + Resin.ExpiredTime + "\n" + "DOM:,," + ResinBottleInfo[5] + "\n" + "\n" + "設備資訊\n" + "InColdTime,入冷藏時間," + Resin.InColdTime + "\n" + "InColdOperator,入冷藏人員," + Resin.InColdOperator + "\n" + "InWarmTime,入回溫時間," + Resin.InWarmTime + "\n" + "InWarmOperator,入回溫人員," + Resin.InWarmOperator + "\n" + "InWarmCompletedTime,回溫完成時間," + InWarmTime.ToString("yyyyMMdd hh:mm:ss") + "\n" + "TotalWarmTime,總回溫時間(m)," + Resin.TotalWarmTime + "(m)\n" + "TotalWeight,膠材總重(g)," + Resin.TotalWeight + "(g)\n" + "EmptyWeight,空膠材重量(g)," + Resin.EmptyWeight + "(g)\n" + "ResinWeight,膠材淨重(g)," + ResinWeight + "(g)\n" + "OutWarmedTime,倒料時間," + Resin.OutWarmedTime + "\n" + "OutWarmOperator,倒料人員," + Resin.OutWarmOperator + "\n" ); sw.Close(); }
public void CreatCsv1(ResinInfo Resin, int WarmType) { DateTime InWarmTime = Convert.ToDateTime(Resin.InWarmTime).AddMinutes(Convert.ToDouble(SystemConfig.WarmTime)); string ResinWeight = (Convert.ToDouble(Resin.TotalWeight) - Convert.ToDouble(Resin.EmptyWeight)).ToString(); string Message = WarmType == 0 ? "回溫中" : (WarmType == 1 ? "回溫正常" : (WarmType == 2 ? "逾時階段(一)" : "逾時階段(二)")); AppendCsvInfo(Resin.LotID, "TotalWarmTime,總回溫時間(m)," + Resin.TotalWarmTime + "(m)\n" + "WarmType,回溫狀況," + Message + "\n" + "TotalWeight,膠材總重(g)," + Resin.TotalWeight + "(g)\n" + "EmptyWeight,空膠材重量(g)," + Resin.EmptyWeight + "(g)\n" + "ResinWeight,膠材淨重(g)," + ResinWeight + "(g)\n" + "OutWarmedTime,倒料時間," + Resin.OutWarmedTime + "\n" + "OutWarmOperator,倒料人員," + Resin.OutWarmOperator + "\n" ); }