|
@@ -9,11 +9,14 @@ namespace UAS_PLCDataReader.DataOperate
|
|
|
{
|
|
|
class DataHelper
|
|
|
{
|
|
|
-
|
|
|
- //泽天外网地址
|
|
|
- private readonly string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=GOLDEN_TEST;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.158)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
|
|
|
- //泽天ERP地址
|
|
|
- public static readonly string ERPAddesss = "http://183.238.39.179:8099/ERP/";
|
|
|
+ //内网地址
|
|
|
+ public static readonly string Address = "192.168.0.158";
|
|
|
+ //外网地址
|
|
|
+ //public static readonly string Address = "183.238.39.179";
|
|
|
+ //外网地址
|
|
|
+ private readonly string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=GOLDEN;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" + Address + ")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
|
|
|
+ //ERP地址
|
|
|
+ public static readonly string ERPAddesss = "http://" + Address + ":8099/ERP/";
|
|
|
//用户选择的数据库的连接字符串
|
|
|
public static string DBConnectionString;
|
|
|
public static OracleConnection connection = null;
|
|
@@ -467,6 +470,7 @@ namespace UAS_PLCDataReader.DataOperate
|
|
|
{
|
|
|
object result = null;
|
|
|
command = new OracleCommand(SQL, connection);
|
|
|
+ Reconnect(command);
|
|
|
if (SQL == null)
|
|
|
return null;
|
|
|
//用来拼接参数的
|
|
@@ -560,18 +564,6 @@ namespace UAS_PLCDataReader.DataOperate
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 为了同步BS端的条码维护,检测时允许问号的存在,在检测时默认将问号换成:Param参数
|
|
|
- /// </summary>
|
|
|
- /// <param name="SQL"></param>
|
|
|
- public void CheckSQL(string SQL)
|
|
|
- {
|
|
|
- SQL = SQL.Replace("?", ":Param");
|
|
|
- command = new OracleCommand(SQL, connection);
|
|
|
- command.ExecuteNonQuery();
|
|
|
- command.Dispose();
|
|
|
- }
|
|
|
-
|
|
|
public int GetDistinctRowCount(string TableName, string Field)
|
|
|
{
|
|
|
DataTable dt = new DataTable();
|
|
@@ -860,41 +852,6 @@ namespace UAS_PLCDataReader.DataOperate
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- //将数据类型的列类型转换为DataTable
|
|
|
- public DataTable DataTypeColumnToDataTable(DataTable dt)
|
|
|
- {
|
|
|
- DataTable dt1 = new DataTable();
|
|
|
- dt1.Rows.Add();
|
|
|
- foreach (DataRow dr in dt.Rows)
|
|
|
- {
|
|
|
- dt1.Columns.Add(dr[0].ToString());
|
|
|
- int index = dt.Rows.IndexOf(dr);
|
|
|
- if (dr[1].ToString() == "NUMBER")
|
|
|
- {
|
|
|
- dt1.Rows[0][index] = 0;
|
|
|
- }
|
|
|
- if (dr[1].ToString() == "VARCHAR2")
|
|
|
- {
|
|
|
- dt1.Rows[0][index] = "这是一段文字";
|
|
|
- }
|
|
|
- if (dr[1].ToString() == "DATE")
|
|
|
- {
|
|
|
- dt1.Rows[0][index] = DateTime.Now.ToString("yyyy-MM-dd");
|
|
|
- }
|
|
|
- if (dr[1].ToString() == "FLOAT")
|
|
|
- {
|
|
|
- dt1.Rows[0][index] = 1.0;
|
|
|
- }
|
|
|
- if (dr[1].ToString() == "CLOB")
|
|
|
- {
|
|
|
- dt1.Rows[0][index] = "一段长文字";
|
|
|
- }
|
|
|
- }
|
|
|
- return dt1;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 通过条件更新
|
|
|
/// </summary>
|
|
@@ -1093,9 +1050,13 @@ namespace UAS_PLCDataReader.DataOperate
|
|
|
return param;
|
|
|
}
|
|
|
|
|
|
- public void Dispose()
|
|
|
+ private void Reconnect(OracleCommand cmd)
|
|
|
{
|
|
|
-
|
|
|
+ if (cmd.Connection.State == ConnectionState.Closed)
|
|
|
+ {
|
|
|
+ cmd.Connection.Open();
|
|
|
+ LogManager.DoLog("超时重连");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|