using System; using System.Collections.Generic; using System.Text; using System.Data; using DBFactory; using System.ServiceModel; using System.Text.RegularExpressions; namespace wcfControlMonitorClient { /// /// Creator:Richard.liu /// /// 命令开关等全局变量的定义 /// public static class CStaticClass { #region 客户端订阅需要的函数20120428 /// /// 使用正则表达式验证字符串 /// /// 待验证字符串 /// 合法返回true,否则返回false public static bool GetCodeCheck(string strCode) { Match mCode = Regex.Match(strCode, CStaticClass.StockCodeCheck); if (mCode.Success) { return true; } else { return false; } } static string _stockCodeCheck = "^[B|D|G|P][A-Z][0-9]{4}$"; /// /// 条码格式检查 /// public static string StockCodeCheck { get { return CStaticClass._stockCodeCheck; } set { int aa; if (int.TryParse(_stockCodeCheck, out aa) == true) { CStaticClass._stockCodeCheck = value; } else { CStaticClass._stockCodeCheck = "^[B|D|G|P][A-Z][0-9]{4}$"; } } } public static Dictionary MutiReadSubscriptionDeviceStateReturns = new Dictionary(); public static Dictionary MutiReadSubscriptionDeviceSplitReturns = new Dictionary(); #endregion /// /// 命令开关是否打开 /// public static bool Order { get; set; } /// /// 是否获取调度任务 /// public static bool ObtainManageTask { get; set; } public static FrmClient client; public static Model.MDevice devinfo28; public static int[] AllReturns; static string GetDeviceS7Connection(int deviceindex) {//20110216 DataView dv = dbo.ExceSQL("SELECT F_S7Connection FROM T_Base_Device WHERE (F_DeviceIndex = " + deviceindex + ")").Tables[0].DefaultView; if (dv.Count > 0) { return dv[0]["F_S7Connection"].ToString(); } else { return null; } } /// /// 20110216支持多个S7Connnection组态OPC /// public static Dictionary MutiS7ConnReturns = new Dictionary(); public static bool WCFOK = false; static string _userID; /// /// 用户编号 /// public static string UserID { get { return CStaticClass._userID; } set { CStaticClass._userID = value; } } public static string ClientID { get; set; } public static bool IfRemind { get; set; } public static DBOperator dbo = new DBOperator(); public static DBOperator dboM = new DBOperator("ManConnString", "ManDBFactory"); public static WcfControlMonitor.ControlMonitorClient WcfControl; static string _manstatus = " F_Status>=-1 ";//默认,显示调度任务全部队列 static string _monstatus = " F_Status>=-1 ";//默认,显示设备指令全部队列 /// /// 显示调度任务全部队列" F_Status>=-1 ";等待队列" F_Status=0 ";运行队列" F_Status=1 "; /// public static string Manstatus { get { return CStaticClass._manstatus; } set { CStaticClass._manstatus = value; } } static StringBuilder sql = new StringBuilder();//20140218 /// /// 显示设备指令全部队列" F_Status>=-1 ";等待队列" F_Status=0 ";运行队列" F_Status=1 "; /// public static string Monstatus { get { return CStaticClass._monstatus; } set { CStaticClass._monstatus = value; } } static string _movedDeviceAheadTrigger = "1"; /// /// 移动设备是否被提前触发将取 /// public static string MovedDeviceAheadTrigger { get { return CStaticClass._movedDeviceAheadTrigger; } set { if ((value == "0") || (value == "1")) { CStaticClass._movedDeviceAheadTrigger = value; } else { CStaticClass._movedDeviceAheadTrigger = "1"; } } } static string _outDetectArrowIdleGoods = "1"; /// /// 堆垛机出库是否检测目标输送机空闲和有物 /// public static string OutDetectArrowIdleGoods { get { return CStaticClass._outDetectArrowIdleGoods; } set { if ((value == "0") || (value == "1")) { CStaticClass._outDetectArrowIdleGoods = value; } else { CStaticClass._outDetectArrowIdleGoods = "1"; } } } static string _deviceErrorAutoModifyRoutePath = "0"; /// /// 设备发生故障自动变更路径 /// public static string DeviceErrorAutoModifyRoutePath { get { return CStaticClass._deviceErrorAutoModifyRoutePath; } set { if ((value == "0") || (value == "1")) { CStaticClass._deviceErrorAutoModifyRoutePath = value; } else { CStaticClass._deviceErrorAutoModifyRoutePath = "0"; } } } static string _doubleForkWaitTime = "120"; /// /// 双叉关联入库任务允许等待的时间单位(秒):默认120秒 /// public static string DoubleForkWaitTime { get { return CStaticClass._doubleForkWaitTime; } set { int aa; if (int.TryParse(_doubleForkWaitTime, out aa) == true) { CStaticClass._doubleForkWaitTime = value; } else { CStaticClass._doubleForkWaitTime = "120"; } } } static string _transportTimeout = "5"; /// /// 输送超时最大允许时间单位(分):默认5分钟//20110608 /// public static string TransportTimeout { get { return CStaticClass._transportTimeout; } set { int aa; if (int.TryParse(_transportTimeout, out aa) == true) { CStaticClass._transportTimeout = value; } else { CStaticClass._transportTimeout = "5"; } } } static string _SystemName = "【沈阳新松自动化立体仓库监控系统【客户端】"; public static string SystemName { get { return CStaticClass._SystemName; } set { CStaticClass._SystemName = value; } } public static int GetDeviceKindIdx(int devIdx) { try { string strSql = "SELECT F_DeviceIndex, F_DeviceKindIndex FROM T_Base_Device WHERE F_DeviceIndex=" + devIdx; DataSet ds = dbo.ExceSQL(strSql); DataView dv = ds.Tables[0].DefaultView; if (dv.Count > 0) { return Convert.ToInt32(dv[0]["F_DeviceKindIndex"]); } else return -1; } catch (Exception ex) { throw ex; } } public static int GetLaneWay(int StackDeviceIndex) { //20101124 StringBuilder sql = new StringBuilder(); sql.Append("SELECT F_LaneDeviceIndex FROM T_Base_LaneInfo WHERE (F_StackIndex = ").Append(StackDeviceIndex).Append(")"); DataView dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView; if (dv.Count > 0) { return Convert.ToInt32(dv[0][0]); } else { return -1; } } public static int GetManageTaskIndexfromMonitor(int monitorIdx) { //20140218 DataView dv = new DataView(); try { //20100108 //20101124 sql.Remove(0, sql.Length); sql.Append("SELECT F_ManageTaskIndex FROM T_Monitor_Task WHERE (F_MonitorIndex = ").Append(monitorIdx).Append(")"); dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView; if (dv.Count > 0) { return Convert.ToInt32(dv[0]["F_ManageTaskIndex"]); } else { return -1; } } catch (Exception ex) {//20100108 throw ex; } finally {//20100108 dv.Dispose(); } } public static int GetManageTaskKindIndexFromMonitor(int monitorIdx) {//20140218 DataView dv = new DataView(); try { //20101124 sql.Remove(0, sql.Length); sql.Append("SELECT F_ManageTaskKindIndex FROM T_Monitor_Task WHERE (F_MonitorIndex = ").Append(monitorIdx).Append(")"); dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView; if (dv.Count > 0) { return Convert.ToInt32(dv[0]["F_ManageTaskKindIndex"]); } else { return -1; } } catch (Exception ex) {//20100108 throw ex; } finally {//20100108 dv.Dispose(); } } } }