系统集成
系统集成组件是一套面向SOA架构模式,服务于流程引擎的企业数据总线。该组件基础是由通过内置适配器与其他接口进行交互的业务服务构成,在转换为氚云内置的数据对象后,我们可以对业务系统接口重新进行组织,并可实现事务管理、事件队列、消息管理、定时作业等处理。
调用第三方接口
1、实现第三方接口
与第三方集成时,根据第三方提供的数据接口要求,定义实现相应的接口参数。
示例:C#语言
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.Services;
///
/// DEMOWebService 的摘要说明
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。
// [System.Web.Script.Services.ScriptService]
public class DEMOWebService : System.Web.Services.WebService
{
public DEMOWebService()
{
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
[WebMethod]
public string GetSchema(string SchemaCode)
{
if (string.Compare(SchemaCode, "customer", true) == 0)
{
H3.BizBus.BizStructureSchema customerSchema = new H3.BizBus.BizStructureSchema();
customerSchema.Add(new H3.BizBus.ItemSchema("pk_customer", "客户ID主键", H3.Data.BizDataType.ShortString, 200, null));
customerSchema.Add(new H3.BizBus.ItemSchema("code", "客户编码", H3.Data.BizDataType.ShortString, 200, null));
customerSchema.Add(new H3.BizBus.ItemSchema("name", "名称", H3.Data.BizDataType.ShortString, 200, null));
customerSchema.Add(new H3.BizBus.ItemSchema("shortname", "简称", H3.Data.BizDataType.ShortString, 200, null));
return H3.BizBus.BizStructureUtility.SchemaToJson(customerSchema);
// 通过H3Yun的程序集实现返回数据转换为Json格式,您也可以自己构造符合格式的Json数据。
}
if (string.Compare(SchemaCode, "supplier", true) == 0)
{
//这里实现其他数据的Schema.
}
return string.Empty;
}
[WebMethod]
public string Invoke(string UserId, string SchemaCode, string MethodName, string Param)
{
H3.BizBus.InvokeResult result = null;
string errorMessage = null;
H3.BizBus.BizStructure parsedParam = null;
string returnResult = string.Empty;
if (string.Compare(SchemaCode, "customer", true) == 0)
{
switch (MethodName)
{
case "Load":
H3.BizBus.BizStructureSchema paramSchema = new H3.BizBus.BizStructureSchema();
paramSchema.Add(new H3.BizBus.ItemSchema("code", "客户编码", H3.Data.BizDataType.ShortString, null));
if (!H3.BizBus.BizStructureUtility.JsonToStructure(paramSchema, Param, out parsedParam, out errorMessage))
{
result = new H3.BizBus.InvokeResult(-1, "解析参数失败:" + errorMessage, null);
}
else
{
// 这里从第三方系统中获取数据,或者实现特定的操作
string code = parsedParam["code"] as string;
string sql = "select * from v_customer where code='" + code + "'";
System.Data.DataTable dt = NCExecuteDataTable(sql);
if (dt != null && dt.Rows.Count > 0)
{
H3.BizBus.BizStructureSchema schema = null;
H3.BizBus.BizStructureUtility.JsonToSchema(this.GetSchema("customer"), out schema, outerrorMessage);
H3.BizBus.BizStructure obj = new H3.BizBus.BizStructure(schema);
obj["pk_customer"] = dt.Rows[0]["pk_customer"];
obj["code"] = dt.Rows[0]["code"]; ;
obj["name"] = dt.Rows[0]["name"]; ;
obj["shortname"] = dt.Rows[0]["shortname"];
result = new H3.BizBus.InvokeResult(1, string.Format("加载对象{0}成功", code), obj);
returnResult = H3.BizBus.BizStructureUtility.InvokeResultToJson(result);
// 通过H3Yun的程序集实现返回数据转换为Json格式,您也可以自己构造符合格式的Json数据。
}
}
break;
default:
break;
}
}
return returnResult;
}
[WebMethod]
public string GetList(string UserId, string SchemaCode, string FilterJson)
{
H3.BizBus.BizStructureSchema schema = null;
string errorMessage = null;
H3.BizBus.BizStructureUtility.JsonToSchema(this.GetSchema("customer"), out schema, out errorMessage);
H3.BizBus.ListResult listResult = null;
// 这里从第三系统中获取数据表集合,查询条件通过解析FilterJson获得。
string sql = "select * from v_customer";
System.Data.DataTable dt = NCExecuteDataTable(sql);
H3.BizBus.BizStructure bizStructure = null;
if (dt != null && dt.Rows.Count > 0)
{
ListBizStructure> lstBizStructure = new ListBizStructure>();
foreach (System.Data.DataRow row in dt.Rows)
{
bizStructure = new H3.BizBus.BizStructure(schema);
bizStructure["pk_customer"] = row["pk_customer"];
bizStructure["code"] = row["code"];
bizStructure["name"] = row["name"];
bizStructure["shortname"] = row["shortname"];
lstBizStructure.Add(bizStructure);
}
listResult = new H3.BizBus.ListResult(1, "获取数据成功", lstBizStructure.ToArray(), lstBizStructure.Count);
}
return H3.BizBus.BizStructureUtility.ListResultToJson(listResult);
// 通过H3Yun的程序集实现返回数据转换为Json格式,您也可以自己构造符合格式的Json数据。
}
[WebMethod]
public string GetSchemaList()
{
Dictionary<string, string> dicSchemaList = new Dictionary<string, string>();
dicSchemaList.Add("customer", "客户信息");
dicSchemaList.Add("supplier", "供应商信息");
dicSchemaList.Add("stock", "库存信息");
System.Web.Script.Serialization.JavaScriptSerializer jsSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
return jsSerializer.Serialize(dicSchemaList);
}
private System.Data.DataTable NCExecuteDataTable(string sql)
{
string connString = System.Configuration.ConfigurationManager.ConnectionStrings["DEMONCDB"] + string.Empty;
System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connString);
connection.Open();
System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(sql, connection);
System.Data.SqlClient.SqlDataAdapter dataAdapter = new System.Data.SqlClient.SqlDataAdapter(command);
System.Data.DataTable dt = new DataTable();
dataAdapter.Fill(dt);
connection.Close();
return dt;
}
}
2、适配器连接点
适配器是氚云和业务系统接口连接的工具。例如业务系统A提供WebService的接口,那么氚云将会提供Web Service方式的适配器与业务系统A做集成。
业务系统接口通过适配器处理后,统一转换成氚云可以调用的内部接口方法,业务服务。
第三方调用氚云
氚云目前支持自定义代码接口,通过新建表单,自定义代码实现第三方调用。
详情请查看章节---OpenAPI示例;
跳转链接 :https://h3yun.com/help/developer.php?CateId=3374