You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Mesnac.Codd.Session;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Data.SqlClient;
|
|
|
|
|
using Mesnac.Log;
|
|
|
|
|
namespace SqlDb
|
|
|
|
|
{
|
|
|
|
|
public class DbHandler
|
|
|
|
|
{
|
|
|
|
|
public DbHelper dbHelper;
|
|
|
|
|
public string constr = System.Configuration.ConfigurationManager.AppSettings["SqlString"];
|
|
|
|
|
public DbHandler()
|
|
|
|
|
{
|
|
|
|
|
initDB();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void initDB()
|
|
|
|
|
{
|
|
|
|
|
DbSession dbsession = new DbSession(SqlClientFactory.Instance, constr);
|
|
|
|
|
dbHelper = new DbHelper(dbsession);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据计划id获取当前所有计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="planid"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public string GetNGStation(string barcode)
|
|
|
|
|
{
|
|
|
|
|
if (dbHelper == null)
|
|
|
|
|
{
|
|
|
|
|
return "9997";
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = "";
|
|
|
|
|
string sql = "SELECT TOP(1) b.StationCode FROM dbo.T_SY_TraceState a "+
|
|
|
|
|
"LEFT JOIN dbo.T_BD_SubStation b ON a.NGStationID=b.StationID " +
|
|
|
|
|
"WHERE SemiBarcode_A='" + barcode + "' ORDER BY BeginTime DESC";
|
|
|
|
|
dbHelper.CommandText = sql;
|
|
|
|
|
object obj = dbHelper.ToScalar();
|
|
|
|
|
if (string.IsNullOrEmpty(obj.ToString()))
|
|
|
|
|
{
|
|
|
|
|
return "9999";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return obj.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogService.Instance.Debug("获取NG工位失败:" + ex.ToString());
|
|
|
|
|
//ICSharpCode.Core.LoggingService.Error("获取NG工位失败:" + ex.Message, ex);
|
|
|
|
|
return "9998";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|