NPPYQ的学习笔记

每天进步一点点

导航

以编程方式读取BizTalk流程信息

BizTalk(2006版),提供了类似的三层API给我们使用,它们分别是:高级编程语言调用的ExplorerOM,脚本调用的WMI和命令行工具BtsTask.exe/BtsDeploy.exe.今天特意参考着技术文档,调用一些DLL测试了下ExplorerOM方法读取流程信息.

测试程序

BizTalk安装路径下的Developer Tools目录中有很多dll,今天只小测试了下,只引用了Microsoft.BizTalk.ExplorerOM.dll,该DLL还附带一个Microsoft.BizTalk.ExplorerOM.xml说明文档.

如图:

技术文档:

代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using Microsoft.BizTalk.ExplorerOM;

namespace TestWinApp.Forms
{
    
public partial class FormBtsOrc : Form
    
{

        
private BtsCatalogExplorer bts_CatalogExplorer = new BtsCatalogExplorer();

        
public FormBtsOrc()
        
{
            InitializeComponent();
        }


        
private void FormBtsOrc_Load(object sender, EventArgs e)
        
{
            txtBtsSrvIP.Text 
= ConfigurationManager.ConnectionStrings["bizTalkServer"].ConnectionString;
        }


        
private void btnGetOrcs_Click(object sender, EventArgs e)
        
{
            bts_CatalogExplorer.ConnectionString 
= txtBtsSrvIP.Text.Trim();
            DataTable m_dtBtsOrcs 
= new DataTable();

            DataColumn m_dcApplicationName 
= new DataColumn("Application");
            m_dcApplicationName.DataType 
= System.Type.GetType("System.String");
            m_dtBtsOrcs.Columns.Add(m_dcApplicationName);

            DataColumn m_dcCount 
= new DataColumn("Count", System.Type.GetType("System.Int32"));
            m_dtBtsOrcs.Columns.Add(m_dcCount);

            DataColumn m_dcOrchName 
= new DataColumn("Orchestration", System.Type.GetType("System.String"));
            m_dtBtsOrcs.Columns.Add(m_dcOrchName);

            DataColumn m_dcStates 
= new DataColumn("States", System.Type.GetType("System.String"));
            m_dtBtsOrcs.Columns.Add(m_dcStates);

            DataColumn m_dcHostName 
= new DataColumn("HostName", System.Type.GetType("System.String"));
            m_dtBtsOrcs.Columns.Add(m_dcHostName);

            
//System.Collections.ArrayList l_list = new System.Collections.ArrayList();
            
//l_list.AddRange(bts_CatalogExplorer.Applications);

            DataRow l_row;
            
for (int i = 0; i < bts_CatalogExplorer.Applications.Count; i++)
            
{
                l_row 
= m_dtBtsOrcs.NewRow();
                l_row[
0= bts_CatalogExplorer.Applications[i].Name;
                l_row[
1= bts_CatalogExplorer.Applications[i].Orchestrations.Count;
                m_dtBtsOrcs.Rows.Add(l_row);

                
for (int j = 0; j < bts_CatalogExplorer.Applications[i].Orchestrations.Count; j++)
                
{
                    l_row 
= m_dtBtsOrcs.NewRow();
                    
//l_row[0] = bts_CatalogExplorer.Applications[i].Name;
                    l_row[1= j+1;
                    l_row[
2= bts_CatalogExplorer.Applications[i].Orchestrations[j].FullName;
                    l_row[
3= bts_CatalogExplorer.Applications[i].Orchestrations[j].Status.ToString();
                    l_row[
4= bts_CatalogExplorer.Applications[i].Orchestrations[j].Host;
                    m_dtBtsOrcs.Rows.Add(l_row);
                }

            }

            dataGridView_BTS.DataSource 
= m_dtBtsOrcs;
        }


    }

}


程序运行结果:

用到的类:

BtsCatalogExplorer

Provides the implementation for the IBtsCatalogExplorer interface.重要的编程接口类,通过属性ConnectionString 可以读取设置的服务器上各个流程信息.

如图:

Application

Represents a logical grouping of BizTalk Server artifacts. This class cannot be inherited.主要是保存了单个"应用程序"的信息(名称,底下的流程等)和相应操作.

如图:

BtsOrchestration

Provides the implementation for the IBtsOrchestration interface.主要是保存单个流程的信息(名称,端口,是否启动等)和相应的操作.

如图:

总结:

还有很多可以实现的操作,比如新建端口,查询挂起的流程,启动流程,停止流程等,BizTalk都能提供一些类和方法实现.待日后用到时再好好研究.

BizTalk提供的这些编程接口,虽然总体来说很多时候根本用不到,因为可以直接用自带的Biztalk管理工具实现.但是在不能直接登陆服务器上的情况下,很多还是比较实用的.

posted on 2008-06-18 18:27  NPPYQ  阅读(573)  评论(1编辑  收藏  举报