コード例 #1
0
        /**
         * Revise Items
         *
         * @param revisionIds     Map of Revsion IDs
         * @param itemRevs        Array of ItemRevisons
         *
         * @return Map of Old ItemRevsion(key) to new ItemRevision(value)
         *
         * @throws ServiceException         If any partial errors are returned
         */
        public void reviseItems(Hashtable revisionIds, ItemRevision[] itemRevs) //throws ServiceException
        {
            // Get the service stub
            DataManagementService dmService = DataManagementService.getService(Session.getConnection());



            ReviseInfo[] reviseInfo = new ReviseInfo[itemRevs.Length];
            for (int i = 0; i < itemRevs.Length; i++)
            {
                RevisionIds rev = (RevisionIds)revisionIds[i];

                reviseInfo[i] = new ReviseInfo();
                reviseInfo[i].BaseItemRevision = itemRevs[i];
                reviseInfo[i].ClientId         = itemRevs[i].Uid + "--" + i;
                reviseInfo[i].Description      = "describe testRevise";
                reviseInfo[i].Name             = "testRevise";
                reviseInfo[i].NewRevId         = rev.NewRevId;
            }



            // *****************************
            // Execute the service operation
            // *****************************
            ReviseResponse2 revised = dmService.Revise2(reviseInfo);

            // before control is returned the ChangedHandler will be called with
            // newly created Item and ItemRevisions



            // The AppXPartialErrorListener is logging the partial errors returned
            // In this simple example if any partial errors occur we will throw a
            // ServiceException
            if (revised.ServiceData.sizeOfPartialErrors() > 0)
            {
                throw new ServiceException("DataManagementService.revise returned a partial error.");
            }
        }
コード例 #2
0
        public void reviseItem(ModelObject obj) //throws ServiceException
        {
            DataManagementService dmService = DataManagementService.getService(Session.getConnection());
            ReviseInfo            rev       = new ReviseInfo();

            rev.BaseItemRevision = new ItemRevision(null, obj.Uid);
            rev.ClientId         = "Maxtt_Test" + "--" + "01";
            rev.Description      = "describe testRevise";
            rev.Name             = "testRevise";
            rev.NewRevId         = "01";

            //额外的表单属性
            PropertyNameValueInfo info = new PropertyNameValueInfo();

            info.PropertyName   = "object_desc";
            info.PropertyValues = new string[] { "newid1" };

            rev.NewItemRevisionMasterProperties.PropertyValueInfo = new PropertyNameValueInfo[] { info };
            //rev.NewItemRevisionMasterProperties.Form = new Teamcenter.Soa.Client.Model.Strong.Form(null, obj.Uid);

            // *****************************
            // Execute the service operation
            // *****************************
            ReviseResponse2 revised = dmService.Revise2(new ReviseInfo[] { rev });

            // before control is returned the ChangedHandler will be called with
            // newly created Item and ItemRevisions



            // The AppXPartialErrorListener is logging the partial errors returned
            // In this simple example if any partial errors occur we will throw a

            // ServiceException
            if (revised.ServiceData.sizeOfPartialErrors() > 0)
            {
                throw new ServiceException("DataManagementService.revise returned a partial error.");
            }
        }
コード例 #3
0
        public void reviseItem(ModelObject obj, String Name, String longDetail, String productionType, String item_revision_id) //throws ServiceException
        {
            String newVersionNumber = (int.Parse(item_revision_id) + 1).ToString().PadLeft(2, '0');

            DataManagementService dmService = DataManagementService.getService(Session2.getConnection());



            ReviseInfo rev = new ReviseInfo();

            rev.BaseItemRevision = new ItemRevision(null, obj.Uid);
            rev.ClientId         = Name + "/" + newVersionNumber;
            rev.Description      = "";
            rev.Name             = Name;
            rev.NewRevId         = newVersionNumber;

            //额外的表单属性
            PropertyNameValueInfo info = new PropertyNameValueInfo();

            info.PropertyName   = cfg.get("exAttr_productionType");
            info.PropertyValues = new string[] { productionType };

            PropertyNameValueInfo info2 = new PropertyNameValueInfo();

            info2.PropertyName   = cfg.get("exAttr_detail");
            info2.PropertyValues = new string[] { longDetail };


            rev.NewItemRevisionMasterProperties.PropertyValueInfo = new PropertyNameValueInfo[] { info, info2 };

            // *****************************
            ReviseResponse2 revised = dmService.Revise2(new ReviseInfo[] { rev });

            if (revised.ServiceData.sizeOfPartialErrors() > 0)
            {
                throw new ServiceException("DataManagementService.revise returned a partial error." + revised.ServiceData.GetPartialError(0).Messages[0]);
            }
        }