宜昌华友-原料库
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.

333 lines
10 KiB

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using DBFactory;
using System.ServiceModel;
using System.Text.RegularExpressions;
namespace wcfControlMonitorClient
{
/// <summary>
/// Creator:Richard.liu
///
/// ����ص�ȫ�ֱ����Ķ���
/// </summary>
public static class CStaticClass
{
#region �ͻ��˶�����Ҫ�ĺ���20120428
/// <summary>
/// ʹ����������ʽ��֤�ַ���
/// </summary>
/// <param name="strCode">����֤�ַ���</param>
/// <returns>�Ϸ�����true,���򷵻�false</returns>
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}$";
/// <summary>
/// ������ʽ����
/// </summary>
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<string, int[]> MutiReadSubscriptionDeviceStateReturns = new Dictionary<string, int[]>();
public static Dictionary<string, int[]> MutiReadSubscriptionDeviceSplitReturns = new Dictionary<string, int[]>();
#endregion
/// <summary>
/// ������Ƿ�����
/// </summary>
public static bool Order { get; set; }
/// <summary>
/// �Ƿ���ȡ��������
/// </summary>
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;
}
}
/// <summary>
/// 20110216֧�ֶ���S7Connnection��̬OPC
/// </summary>
public static Dictionary<string, int[]> MutiS7ConnReturns = new Dictionary<string, int[]>();
public static bool WCFOK = false;
static string _userID;
/// <summary>
/// �û�����
/// </summary>
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 = CommonClassLib.AppSettings.dbo;//richard20181022
public static DBOperator dboM = CommonClassLib.AppSettings.dboM;//richard20181022
public static WcfControlMonitor.ControlMonitorClient WcfControl;
static string _manstatus = " F_Status>=-1 ";//Ĭ�ϣ���ʾ��������ȫ������
static string _monstatus = " F_Status>=-1 ";//Ĭ�ϣ���ʾ�豸ָ��ȫ������
/// <summary>
/// ��ʾ��������ȫ������" F_Status>=-1 ";�ȴ�����" F_Status=0 "�����ж���" F_Status=1 "��
/// </summary>
public static string Manstatus
{
get { return CStaticClass._manstatus; }
set { CStaticClass._manstatus = value; }
}
static StringBuilder sql = new StringBuilder();//20140218
/// <summary>
/// ��ʾ�豸ָ��ȫ������" F_Status>=-1 ";�ȴ�����" F_Status=0 "�����ж���" F_Status=1 "��
/// </summary>
public static string Monstatus
{
get { return CStaticClass._monstatus; }
set { CStaticClass._monstatus = value; }
}
static string _movedDeviceAheadTrigger = "1";
/// <summary>
/// �ƶ��豸�Ƿ�����ǰ������ȡ
/// </summary>
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";
/// <summary>
/// �Ѷ��������Ƿ�����Ŀ�����ͻ����к�����
/// </summary>
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";
/// <summary>
/// �豸���������Զ�����·��
/// </summary>
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";
/// <summary>
/// ˫�������������������ȴ���ʱ�䵥λ���룩��Ĭ��120��
/// </summary>
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";
/// <summary>
/// ���ͳ�ʱ��������ʱ�䵥λ���֣���Ĭ��5����//20110608
/// </summary>
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();
}
}
}
}