You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
4.0 KiB
96 lines
4.0 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Data;
|
|
using CommonLib;
|
|
using DBFactory;
|
|
using ICommLayer;
|
|
using CommLayerFactory;
|
|
|
|
namespace WcfControlMonitorLib
|
|
{
|
|
class CStorageCheck
|
|
{
|
|
public static event RefreshMonitorEventHandler RefreshMonitor;
|
|
public static void OnRefreshMonitor(RefreshMonitorEventArgs e)
|
|
{
|
|
if (RefreshMonitor != null)
|
|
{
|
|
RefreshMonitor(e);
|
|
}
|
|
}
|
|
static DBOperator dbo = CStaticClass.dbo;//20130926
|
|
static DBOperator dboM = CStaticClass.dboM;//20130926
|
|
static StringBuilder sql = new StringBuilder();
|
|
static string dtime = "";
|
|
|
|
static CCommonFunction ccf = new CCommonFunction();
|
|
static Thread mythread;
|
|
static bool exitThread = false;//20091107
|
|
private static void BeginListen()
|
|
{//20091107
|
|
while (!exitThread)
|
|
{
|
|
try
|
|
{
|
|
dtime = DateTime.Now.ToString("u");
|
|
DataView dv = new DataView();
|
|
//DataView dv = new DataView();
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("StorageCheck", "StorageCheck", "校验是否同步库存:", "29999", ",时间:" + dtime.ToString());
|
|
if (dtime.Substring(11, 2) == "02")
|
|
{
|
|
sql.Remove(0, sql.Length);
|
|
sql.Append("select F_IF_CHECK,F_LAST_CHECK_DATE from T_STORAGE_CHECK");//20130226richard.liu
|
|
dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView;
|
|
if (dv.Count > 0)
|
|
{
|
|
if ((dv[0]["F_IF_CHECK"].ToString() == "1") && (dv[0]["F_LAST_CHECK_DATE"].ToString() != dtime.Substring(0,10)))
|
|
{
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("StorageCheck", "StorageCheck", "开始同步库存:", "29999", ",时间:" + DateTime.Now.ToString("u").ToString());
|
|
DataView tempdv = dbo.ExceSQL("SELECT * from ST_CELL where fpalletbarcode != '-'").Tables[0].DefaultView;
|
|
if (tempdv.Count > 0)
|
|
{
|
|
for (int i = 0; i < tempdv.Count; i++)
|
|
{
|
|
dboM.ExecuteSql("insert into IDX_ASRS_INV (LocationID,Palletid,Addtime,READFLAG) VALUES ('"
|
|
+ tempdv[i]["FCELLCODE"].ToString() + "','" + tempdv[i]["fpalletbarcode"].ToString() + "',sysdate,'N')");
|
|
}
|
|
dbo.ExecuteSql(string.Format("UPDATE T_STORAGE_CHECK set F_LAST_CHECK_DATE = '" + dtime.Substring(0, 10) + "'"));
|
|
}
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("StorageCheck", "StorageCheck", "同步库存完毕:", "29999", ",时间:" + DateTime.Now.ToString("u").ToString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
CommonClassLib.CCarryConvert.WriteDarkCasket("StorageCheck", "StorageCheck", "同步库存异常:", "29999", ",时间:" + DateTime.Now.ToString("u").ToString() + ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
Thread.Sleep(600000);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void EndListen()
|
|
{//20091107
|
|
exitThread = true;
|
|
|
|
if (mythread != null)
|
|
{
|
|
mythread.Abort();
|
|
mythread = null;
|
|
}
|
|
}
|
|
public static void StartListen()
|
|
{
|
|
exitThread = false;
|
|
mythread = new Thread(new ThreadStart(BeginListen));
|
|
mythread.IsBackground = true;
|
|
mythread.Start();
|
|
}
|
|
}
|
|
}
|