[K2 Blackpearl] 部署SmartObject Service

编写SmartObject Service:传送门

现在已经编写好了SmartObject Service,接下来需要进行部署,在K2 Blackpearl Server中注册该service。基本步骤如下:

  1. 编译SmartObject Service代码,生成DLL
  2. 在K2 Server中注册SmartObject Service
  3. 创建SmartObject Service实例

编译SmartObject Service代码,生成DLL

在K2 Server中注册SmartObject Service

编译后的DLL需要拷贝到K2 Server中特定的目录下,\\Program Files\K2 blackpearl\ServiceBroker,然后使用工具BrokerManagement.exe向K2 Server注册service。

打开工具BrokerManagement.exe,选择ConfigServices.

在service节点上,点击右键Register New Service Type

填写service的基础信息。

service注册成功后,创建service实例

进入K2 blackpearl Workspace,依次进入Management Console>mydemain>SmartObjects>Services>WroxCustomService,点击Add按钮。

这里列出GetConfigSection中注册的配置信息,填写适当的值。

Next,填写实例的基本信息。保存。

更新SmartObject Service

  1. 停止K2 Service服务
  2. 替换SmartObject Service的DLL文件
  3. 通过工具BrokerManagement.exe更新

测试SmartObject Service

        private void GetSmartObject()
        {
            SmartObjectClientServer server = new SmartObjectClientServer();

            try
            {
                SCConnectionStringBuilder connectionString = new SCConnectionStringBuilder();
                connectionString.Authenticate = true;
                connectionString.Host = "mydemo";
                connectionString.Integrated = true;
                connectionString.IsPrimaryLogin = true;
                connectionString.Port = 5555;
                connectionString.WindowsDomain = "mydemain";
                connectionString.SecurityLabelName = "K2";

                server.CreateConnection();
                server.Connection.Open(connectionString.ToString());

                SmartObject custom = server.GetSmartObject("WroxCustomObject");

                //custom.Properties["Account"].Value = @"my.demo";
                //custom.MethodToExecute = "FindOne";
                //server.ExecuteScalar(custom);

                //string eID = custom.Properties["EmployeeID"].Value.ToString();

                Equals customEq = new SourceCode.SmartObjects.Client.Filters.Equals();
                customEq.Left = new PropertyExpression("EmployeeID", PropertyType.Text);
                customEq.Right = new ValueExpression(string.Empty, PropertyType.Text);

                Not customN = new Not();
                customN.Predicate = customEq;

                StartsWith customSW = new StartsWith();
                customSW.Left = new PropertyExpression("EmployeeID", PropertyType.Text);
                customSW.Right = new ValueExpression("01", PropertyType.Text);

                And customAnd = new And();
                customAnd.Left = customN;
                customAnd.Right = customSW;

                SmartListMethod smList = custom.ListMethods[0];
                custom.MethodToExecute = smList.Name;
                custom.Properties["Account"].Value = @"fei";
                smList.Filter = customAnd;
                SmartObjectList sols = server.ExecuteList(custom);

                foreach (SmartObject so in sols.SmartObjectsList)
                {
                    foreach (SmartProperty sp in so.Properties)
                    {
                        Response.Write(sp.Name + "" + sp.Value);
                        Response.Write("<br />");
                    }
                }
            }
            catch(Exception ex)
            { 
            
            }
        }

posted @ 2012-10-16 19:53  一只小小菜鸟  阅读(809)  评论(0编辑  收藏  举报