排程(Scheduler)為付費訂閱(Subscription)才能啟用的功能,但也可透過自行開發簡易程式的方式實現。
作法為透過引用 IOM.dll、Aras.Net.dll 來呼叫 Aras Innovator Server 上要定時執行的Method,並透過 Windows 內建的工作排程器來實現排程。
以下為外部程式呼叫 Method 的 C# 程式:
using System;
using Aras.IOM;
class ArasAdapter
{
HttpServerConnection _serverConn;
public ArasAdapter(string url, string db, string user, string password)
{
_serverConn = IomFactory.CreateHttpServerConnection(url, db, user, password);
}
public void ApplyMethod(string method)
{
//Login
Item login_result = _serverConn.Login();
if (login_result.isError())
throw new Exception($"Login failed");
//Initial
Innovator inno = IomFactory.CreateInnovator(conn);
//ApplyMethod
Item applyMethod_result = inno.applyMethod(method, "");
if (applyMethod_result.isError())
throw new Exception($"Apply [{method}] method failed");
//Logout
_serverConn.Logout();
}
}

Leave a comment