示例#1
0
        /// <summary>
        /// 将OldFolder文件夹下的modelObjects剪切到NewFolder文件夹下。
        /// 如果OldFolder=null,则是将modelObjects复制到NewFolder文件夹下。
        /// </summary>
        /// <param name="NewFolder">新文件夹</param>
        /// <param name="OldFolder">旧文件夹,可以等于null</param>
        /// <param name="modelObjects">移动的内容</param>
        public void MoveFile(Teamcenter.Soa.Client.Model.Strong.Folder NewFolder
                             , Teamcenter.Soa.Client.Model.Strong.Folder OldFolder
                             , ModelObject[] modelObjects)
        {
            DataManagementService dmService = DataManagementService.getService(Session.getConnection());
            var mtf = new Teamcenter.Services.Strong.Core._2007_01.DataManagement.MoveToNewFolderInfo();

            mtf.NewFolder     = NewFolder;
            mtf.ObjectsToMove = modelObjects;
            mtf.OldFolder     = OldFolder;
            dmService.MoveToNewFolder(new Teamcenter.Services.Strong.Core._2007_01.DataManagement.MoveToNewFolderInfo[] { mtf });
        }
        /**
         * List the contents of the Home folder.
         *
         */
        public void listHomeFolder(User user)
        {
            Folder home = null;

            WorkspaceObject[] contents = null;

            // Get the service stub
            DataManagementService dmService = DataManagementService.getService(Session.getConnection());

            try
            {
                // User was a primary object returned from the login command
                // the Object Property Policy should be configured to include the
                // 'home_folder' property. However the actuall 'home_folder' object
                // was a secondary object returned from the login request and
                // therefore does not have any properties associated with it. We will need to
                // get those properties explicitly with a 'getProperties' service request.
                home = user.Home_folder;
            }
            catch (NotLoadedException e)
            {
                Console.Out.WriteLine(e.Message);
                Console.Out.WriteLine("The Object Property Policy ($TC_DATA/soa/policies/Default.xml) is not configured with this property.");
                return;
            }

            try
            {
                ModelObject[] objects    = { home };
                String[]      attributes = { "contents" };

                // *****************************
                // Execute the service operation
                // *****************************
                dmService.GetProperties(objects, attributes);


                // The above getProperties call returns a ServiceData object, but it
                // just has pointers to the same object we passed into the method, so the
                // input object have been updated with new property values
                contents = home.Contents;
            }
            // This should never be thrown, since we just explicitly asked for this
            // property
            catch (NotLoadedException /*e*/) {}

            Console.Out.WriteLine("");
            Console.Out.WriteLine("Home Folder:");
            Session.printObjects(contents);
        }