zoukankan      html  css  js  c++  java
  • LcmAdvancerMessage input Object

    LcmAdvancerMessage input object is Business item object, such as Document or Part. for example, 如果你想在一个业务对象的LicfCycleState发生改变的同时,更新其关联对象的LicfCycleState的属性值,那么就需要LcmAdvancerMessage.
    1. define message
       define object message StateChange like LcmAdvancerMessage;
    2. attach message
       attach object message StateChange to PdmItem in server bbksvr;
    3. write method code
    message PdmItem:StateChange
      (
         update:      ObjectPtr       obj::
         update:      ObjectPtr       procHist::
         input :      ObjectPtr       msgProc::
         output:      string*         exitState ::
         output:      string*         advComments ::
         output:      integer*        mfail 
      ) code
    {
       char *mod_name = "PdmItem:StateChange";
       string classN = NULL;                /* class name for BeginDbFrame */
       string a_framename = NULL;           /* database frame name */
       string LCAttr = NULL;                /* pointer to LC state attr */
       integer dstat = OKAY;
       integer indx0 = 0, icnt = 0;
     
       ObjectPtr item = NULL;               /* related object being updated */
       SetOfObjects itemObjs = NULL;        /* related item objects */
       SetOfObjects relObjs = NULL;         /* relation objects */
      
       ObjectPtr genContext = NULL;
     
       *mfail = USC_OKAY;
       *exitState = "PASS";
       *advComments = "States Automatically Updated";
      
     
    // get Life Cycle State from input object(such as Document, Part, etc)
       if (dstat = objGetAttribute(obj, LifeCycleStateAttr, &LCAttr))
       {
           goto EXIT;
       }
     
    // expand AdHocDep relation to get dependent on items
     
       if (dstat = SetUpContext(objClass(obj), obj, &genContext, mfail))
       {
           goto EXIT;
       }
       if (*mfail) goto CLEANUP;
     
       if (dstat = ExpandRelationWithCtxt(AdHocDepClass, obj,
                                          "AdHocDependentOnItems",
                                          genContext,
                                          SC_SCOPE_OF_SESSION,
                                          NULL,
                                          &itemObjs,
                                          &relObjs,
                                          mfail))
       {
           goto EXIT;
       }
     
       if (*mfail) goto CLEANUP;
     
    // update each dependent item
       icnt = low_set_size (itemObjs);
       for ( indx0 = 0; indx0 < icnt; indx0 ++ )
       {
           item = (ObjectPtr) low_set_get (itemObjs, indx0);
     
    // Set Life Cycle State to the same as original object
           if ( dstat = objSetAttribute (item, LifeCycleStateAttr, LCAttr))
           {
               goto EXIT;
           }
     
    // get class name
           if ( dstat = objGetClass (item, &classN))
           {
               goto EXIT;
           }
     
    // begin DB frame
           if ( dstat = BeginDbFrame (classN, &a_framename, mfail))
           {
               goto EXIT;
           }
     
           if ( *mfail ) goto CLEANUP;
     
    // lock and write object to database
           if ( dstat = LockDbObject (item, mfail))
           {
               goto EXIT;
           }
          
           if ( *mfail ) goto CLEANUP;
          
           if ( dstat = UpdateDbObject (item, mfail))
           {
               goto EXIT;
           }
     
           if ( *mfail ) goto CLEANUP;
     
    // end DB frame
           if ( dstat = EndDbFrame (classN, a_framename, mfail))
           {
               goto EXIT;
           }
     
           if ( *mfail ) goto CLEANUP;
       }
     
    CLEANUP:
     
       if ( a_framename )
          freespace ( a_framename );
     
       if ( itemObjs )
          objDisposeAll ( itemObjs );
     
       if ( relObjs )
          objDisposeAll ( relObjs );
     
    EXIT:
     
       if ( dstat != OKAY )
          uiShowFatalError(dstat, WHERE);
       return ( dstat );
    }
    ;
    4. 在流程中使用Message Process, message name is StateChange.
  • 相关阅读:
    Visual Studio 2010单元测试(2)--运行测试并查看代码覆盖率
    实用设计模式之观察者模式
    并查集简单题pku1611
    HDU 4534 郑厂长系列故事——新闻净化(AC自动机+DP)
    求 小于 n 的 质数 几种方式
    MySQL数据库高并发优化配置
    MySQL 对于千万级的大表要怎么优化?
    mysql数据库优化总结
    php 正则表达式怎么匹配标签里面的style?
    MySql数据库优化可以从哪几个方面进行?
  • 原文地址:https://www.cnblogs.com/hcfalan/p/422511.html
Copyright © 2011-2022 走看看