This commit is contained in:
XingCheng3
2026-05-26 09:41:24 +08:00
commit dff0156cdd
1329 changed files with 88153 additions and 0 deletions

View File

@@ -0,0 +1,176 @@
using System.Data.SqlClient;
using System.Data;
using System;
using System.Threading;
using DataLinkMesWork;
using NPOI.SS.Formula.Functions;
using Opc.Ua;
using System.Windows.Forms;
namespace MisDataFunDll
{
public partial class MisDataFun
{
public static void GetApiAuth(string apiName, out string Username, out string Password, out int ApiTimeout, out string ApiUrl, out string code, out string message)
{
DataTable dt = new DataTable();
Username = "";
Password = "";
ApiTimeout = 50000;
ApiUrl = "";
code = "99998";
message = "MOM_基础数据_接口列表_获取基本参数_出错";
try
{
string produceName = "MOM_基础数据_接口列表_获取基本参数";
SqlParameter[] thisParms = new SqlParameter[1];
thisParms[0] = new System.Data.SqlClient.SqlParameter("@接口名称", apiName);
if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt))
{
if (dt.Rows.Count > 0)
{
ApiTimeout = Convert.ToInt32(dt.Rows[0]["超时时间"]);
Username = dt.Rows[0]["授权账号"].ToString();
Password = dt.Rows[0]["授权密码"].ToString();
ApiUrl = dt.Rows[0]["访问地址"].ToString();
code = "0";
message = "";
}
}
}
catch (Exception err)
{
message = err.Message.ToString();
}
}
public static void GetApiParams(string apiName, string opName, out string code, out string message, out DataTable dt)
{
dt = new DataTable();
code = "99998";
message = "获取基本参数出错!";
try
{
string produceName = "MOM_基础数据_接口参数_获取基本参数";
SqlParameter[] thisParms = new SqlParameter[1];
thisParms[0] = new System.Data.SqlClient.SqlParameter("@接口名称", apiName);
if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt))
{
if (dt.Rows.Count > 0)
{
code = "0";
message = "";
}
}
}
catch (Exception err)
{
message = err.Message.ToString();
}
}
public static void GetApiParams_operation(string opName, out string operation, out string resource, out string code, out string message)
{
DataTable dt = new DataTable();
operation = "";
resource = "";
code = "99997";
message = "获取工位operation与resource失败";
try
{
string produceName = "MOM_基础数据_接口参数_获取基本参数_工位代码";
SqlParameter[] thisParms = new SqlParameter[1];
thisParms[0] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt))
{
if (dt.Rows.Count > 0)
{
operation = dt.Rows[0]["operation"].ToString();
resource = dt.Rows[0]["resource"].ToString();
code = "0";
message = "";
}
}
}
catch (Exception err)
{
}
}
public static void GetApiEnable(string apiName, string opName, string sfc, out string enable, out DataTable dt)
{
enable = "0";
dt = new DataTable();
try
{
string produceName = "MOM_基础数据_接口列表_获取接口状态";
SqlParameter[] thisParms = new SqlParameter[3];
thisParms[0] = new System.Data.SqlClient.SqlParameter("@接口名称", apiName);
thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
thisParms[2] = new System.Data.SqlClient.SqlParameter("@EngineID", sfc);
if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out dt))
{
if (dt.Rows.Count > 0)
{
enable = dt.Rows[0]["接口状态"].ToString();
}
}
}
catch (Exception err)
{
}
}
public static void GetApiStatus_EngineID(string apiName, string opName, string sfc, out string initCode, out string initTime)
{
initCode = "99999"; // 非0都是 未成功进站/出站
initTime = ""; //
try
{
string produceName = "MOM_接口列表_MOBY_获取接口状态";
SqlParameter[] thisParms = new SqlParameter[3];
thisParms[0] = new System.Data.SqlClient.SqlParameter("@接口名称", apiName);
thisParms[1] = new System.Data.SqlClient.SqlParameter("@工位号", opName);
thisParms[2] = new System.Data.SqlClient.SqlParameter("@工件编号", sfc);
if (DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out DataTable dt))
{
if (dt.Rows.Count > 0)
{
initCode = dt.Rows[0]["initCode"].ToString();
initTime = dt.Rows[0]["initTime"].ToString();
}
}
}
catch (Exception err)
{
}
}
public static void RecordApiContent(string apiName, string opName, string sfc, string requestTime, string requestContent, string responseTime, string totalTime, string code, string message)
{
try
{
string produceName = "MOM_接口_Moby_更新";
SqlParameter[] thisParms = new SqlParameter[9];
thisParms[0] = new SqlParameter("@接口名称", apiName);
thisParms[1] = new SqlParameter("@工位号", opName);
thisParms[2] = new SqlParameter("@发动机号", sfc);
thisParms[3] = new SqlParameter("@请求时间", requestTime);
thisParms[4] = new SqlParameter("@请求内容", requestContent);
thisParms[5] = new SqlParameter("@返回时间", responseTime);
thisParms[6] = new SqlParameter("@返回代码", code);
thisParms[7] = new SqlParameter("@返回内容", message);
thisParms[8] = new SqlParameter("@累积用时", totalTime);
DataAccess.ExecuteStoredProcedure(produceName, ref thisParms, out DataTable dt);
}
catch (Exception err)
{
}
}
}
}