Ejemplo n.º 1
0
        public async Task <ActionResult> Search(string Query, DateTime DateFrom, DateTime DateTo)
        {
            DataManagement.Search model  = null;
            SearchService         search = new Services.SearchService();

            if (User.Identity.IsAuthenticated)
            {
                //some stuff
                model = await search.Search(Query, DateFrom, DateTo, User.Identity.Name);
            }
            else
            {
                model = await search.Search(Query, DateFrom, DateTo, "");
            }
            //ThreadPool.QueueUserWorkItem(_ => search.Search(model.Query, new DateTime(2014, 05, 02), new DateTime(2014, 05, 03)));
            //Thread thread = new Thread(_ => search.Search(Query, new DateTime(2014, 05, 02), new DateTime(2014, 05, 03)));
            //thread.Start();

            /* DataManagement.Search model = new DataManagement.Search();
             * model.Query = Query;
             * model.From = DateFrom;
             * model.To = DateTo;
             * model.SDate = DateTime.Now;
             * Task.Run(async () => await search.Search(model));*/
            if (User.Identity.IsAuthenticated)
            {
                DataManagementService service = new DataManagementService();
                ViewBag.UserData = service.LoadSearch(User.Identity.Name).ToList();
            }
            return(View("Index", model));
        }
        public void GetDataManager()
        {
            var clientTransaction = new TestableClientTransaction();
            var dataManager       = DataManagementService.GetDataManager(clientTransaction);

            Assert.That(dataManager, Is.SameAs(clientTransaction.DataManager));
        }
Ejemplo n.º 3
0
        /**
         * Create ItemMasterForm and ItemRevisionMasterForm
         *
         * @param IMFormName      Name of ItemMasterForm
         * @param IMFormType      Type of ItemMasterForm
         * @param IRMFormName     Name of ItemRevisionMasterForm
         * @param IRMFormType     Type of ItemRevisionMasterForm
         * @param parent          The container object that two
         *                        newly-created forms will be added into.
         * @return ModelObject[]  Array of forms
         *
         * @throws ServiceException         If any partial errors are returned
         */
        public ModelObject[] createForms(String IMFormName, String IMFormType,
                                         String IRMFormName, String IRMFormType,
                                         ModelObject parent, bool saveDB) //throws ServiceException
        {
            //Get the service stub
            DataManagementService dmService = DataManagementService.getService(Session.getConnection());

            FormInfo[] inputs = new FormInfo[2];
            inputs[0]              = new FormInfo();
            inputs[0].ClientId     = "1";
            inputs[0].Description  = "";
            inputs[0].Name         = IMFormName;
            inputs[0].FormType     = IMFormType;
            inputs[0].SaveDB       = saveDB;
            inputs[0].ParentObject = parent;
            inputs[1]              = new FormInfo();
            inputs[1].ClientId     = "2";
            inputs[1].Description  = "";
            inputs[1].Name         = IRMFormName;
            inputs[1].FormType     = IRMFormType;
            inputs[1].SaveDB       = saveDB;
            inputs[1].ParentObject = parent;
            CreateOrUpdateFormsResponse response = dmService.CreateOrUpdateForms(inputs);

            if (response.ServiceData.sizeOfPartialErrors() > 0)
            {
                throw new ServiceException("DataManagementService.createForms returned a partial error.");
            }
            ModelObject[] forms = new ModelObject [inputs.Length];
            for (int i = 0; i < inputs.Length; ++i)
            {
                forms[i] = response.Outputs[i].Form;
            }
            return(forms);
        }
Ejemplo n.º 4
0
        protected DataContainer GetDataContainer(DomainObject domainObject)
        {
            ArgumentUtility.CheckNotNull("domainObject", domainObject);

            return(DataManagementService.GetDataManager(ClientTransaction.Current)
                   .GetDataContainerWithLazyLoad(domainObject.ID, true));
        }
Ejemplo n.º 5
0
        public ExampleForm()
        {
            InitializeComponent();

            MyFormAppSession session = new MyFormAppSession("http://192.168.0.51/tc");
            HomeFolder       home    = new HomeFolder(this);
            Query            query   = new Query(this);
            DataManagement   dm      = new DataManagement(this);

            User user = session.login();

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

            String[] attributes = { "os_username" };

            dmService.GetProperties(new ModelObject[] { user }, attributes);

            appendTxt("User name: " + user.Os_username);

            home.listHomeFolder(user);
            query.queryItems();
            dm.createReviseAndDelete();

            session.logout();
        }
Ejemplo n.º 6
0
        /**
         * Reserve Revision IDs
         *
         * @param items       Array of Items to reserve Ids for
         *
         * @return Map of RevisionIds
         *
         * @throws ServiceException  If any partial errors are returned
         */
        public Hashtable generateRevisionIds(Item[] items) //throws ServiceException
        {
            // Get the service stub
            DataManagementService dmService = DataManagementService.getService(MyFormAppSession.getConnection());

            GenerateRevisionIdsResponse response = null;

            GenerateRevisionIdsProperties[] input = null;
            input = new GenerateRevisionIdsProperties[items.Length];

            for (int i = 0; i < items.Length; i++)
            {
                GenerateRevisionIdsProperties property = new GenerateRevisionIdsProperties();
                property.Item     = items[i];
                property.ItemType = "";
                input[i]          = property;
            }

            // *****************************
            // Execute the service operation
            // *****************************
            response = dmService.GenerateRevisionIds(input);

            // The AppXPartialErrorListener is logging the partial errors returned
            // In this simple example if any partial errors occur we will throw a
            // ServiceException
            if (response.ServiceData.sizeOfPartialErrors() > 0)
            {
                throw new ServiceException("DataManagementService.generateRevisionIds returned a partial error.");
            }

            return(response.OutputRevisionIds);
        }
        public void UnloadAll_Transactions()
        {
            TestableClientTransaction.EnsureDataAvailable(DomainObjectIDs.Order1);
            EnsureEndPointLoadedAndComplete(_collectionEndPointID);
            Assert.That(TestableClientTransaction.DataManager.DataContainers[DomainObjectIDs.Order1], Is.Not.Null);
            Assert.That(TestableClientTransaction.DataManager.GetRelationEndPointWithoutLoading(_collectionEndPointID), Is.Not.Null);

            using (TestableClientTransaction.CreateSubTransaction().EnterDiscardingScope())
            {
                var middleTransaction = ClientTransaction.Current;
                middleTransaction.EnsureDataAvailable(DomainObjectIDs.Order3);
                Assert.That(DataManagementService.GetDataManager(middleTransaction).DataContainers[DomainObjectIDs.Order3], Is.Not.Null);

                using (middleTransaction.CreateSubTransaction().EnterDiscardingScope())
                {
                    ClientTransaction.Current.EnsureDataAvailable(DomainObjectIDs.Order4);
                    Assert.That(DataManagementService.GetDataManager(ClientTransaction.Current).DataContainers[DomainObjectIDs.Order4], Is.Not.Null);

                    UnloadService.UnloadAll(middleTransaction);

                    Assert.That(DataManagementService.GetDataManager(ClientTransaction.Current).DataContainers[DomainObjectIDs.Order4], Is.Null);
                    Assert.That(DataManagementService.GetDataManager(middleTransaction).DataContainers[DomainObjectIDs.Order3], Is.Null);
                    Assert.That(TestableClientTransaction.DataManager.DataContainers[DomainObjectIDs.Order1], Is.Null);
                }
            }
        }
Ejemplo n.º 8
0
 public ActionResult Index()
 {
     if (User.Identity.IsAuthenticated)
     {
         DataManagementService service = new DataManagementService();
         ViewBag.UserData = service.LoadSearch(User.Identity.Name).ToList();
     }
     return(View());
 }
        public static void initialize()
        {
            session = new Teamcenter.ClientX.Session(serverHost);

            dmService = DataManagementService.getService(Teamcenter.ClientX.Session.getConnection());
            //prefService = PreferenceManagementService.getService(Session.getConnection());
            sessionService = SessionService.getService(Teamcenter.ClientX.Session.getConnection());
            queryService   = SavedQueryService.getService(Teamcenter.ClientX.Session.getConnection());
            fileMgtService = FileManagementService.getService(Teamcenter.ClientX.Session.getConnection());
        }
Ejemplo n.º 10
0
        public void GetState_Invalidated_AfterMarkInvalid()
        {
            var stateBeforeChange = _cachingListener.GetState(_notYetLoadedOrder.ID);

            _transaction.ExecuteInScope(() => DataManagementService.GetDataManager(_transaction).MarkInvalid(_notYetLoadedOrder));
            var stateAfterChange = _cachingListener.GetState(_notYetLoadedOrder.ID);

            Assert.That(stateBeforeChange, Is.EqualTo(StateType.NotLoadedYet));
            Assert.That(stateAfterChange, Is.EqualTo(StateType.Invalid));
        }
Ejemplo n.º 11
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 });
        }
Ejemplo n.º 12
0
 public DAController(DaService daService, MailService mailService, IHostingEnvironment env, DataManagementService dataManagementService, ModelDerivativeService modelDerivativeService)
 {
     this.daService              = daService;
     this.mailService            = mailService;
     this.env                    = env;
     this.dataManagementService  = dataManagementService;
     this.modelDerivativeService = modelDerivativeService;
     baseUrl = "https://osmdemo.azurewebsites.net";
     if (env.IsDevelopment())
     {
         baseUrl = "https://localhost:44319";
     }
 }
        /**
         * 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);
        }
Ejemplo n.º 14
0
        /** Uploads a single file using the FileManagement utilities. */
        public void uploadSingleFile(FileManagementUtility fmsFileManagement, DataManagementService dmService)
        {
            GetDatasetWriteTicketsInputData[] inputs = { getSingleGetDatasetWriteTicketsInputData(dmService) };
            ServiceData response = fmsFileManagement.PutFiles(inputs);

            if (response.sizeOfPartialErrors() > 0)
            {
                System.Console.Out.WriteLine("FileManagementService single upload returned partial errrors: " + response.sizeOfPartialErrors());
            }

            // Delete all objects created
            ModelObject[] datasets = { inputs[0].Dataset };
            dmService.DeleteObjects(datasets);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 找TC的文件位置,如果没有则创建。
        /// 如:"10原材料-1011钢材",分隔符为"-",根目录为"XY"。
        /// 最终会返回 XY-->10原材料文件夹目录中的1011钢材文件夹。
        /// XY
        ///  |
        ///  --10原材料
        ///     |
        ///     ---1011钢材
        /// </summary>
        /// <param name="FolderName">文件夹路径</param>
        /// <param name="RootFolder">根目录</param>
        /// <param name="SplitStr">文件夹路径分隔符</param>
        /// <returns></returns>
        public ModelObject findFolder(string FolderName, ModelObject RootFolder, string SplitStr)
        {
            ModelObject resul = null;

            var arry = Regex.Split(FolderName, SplitStr, RegexOptions.IgnoreCase);


            //取第一层级
            var CurrentFolderName = arry[0];


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

            dmService.GetProperties(new ModelObject[] { RootFolder }, new string[] { "contents" });
            var contents = ((Teamcenter.Soa.Client.Model.Strong.Folder)RootFolder).Contents;

            for (int i = 0, len = contents.Length; i < len; i++)
            {
                if (contents[i].Object_string.Equals(CurrentFolderName) && null != findModel(cfg.get("query_builder_folder_name")
                                                                                             , new string[] { cfg.get("query_builder_folder_queryKey1"), cfg.get("query_builder_folder_queryKey2") }
                                                                                             , new string[] { CurrentFolderName, "XY_GROUP" }))
                {
                    resul = contents[i];
                    break;
                }
            }
            if (null == resul)
            {
                //创建文件夹
                var cf = new Teamcenter.Services.Strong.Core._2006_03.DataManagement.CreateFolderInput();
                cf.Name = CurrentFolderName;
                cf.Desc = @"XY_GROUP";
                Teamcenter.Services.Strong.Core._2006_03.DataManagement.CreateFoldersResponse cfr = dmService.CreateFolders(new Teamcenter.Services.Strong.Core._2006_03.DataManagement.CreateFolderInput[] { cf }, RootFolder, "child");
                resul = cfr.Output[0].Folder;
            }

            //如果分组后数组大于1,则递归
            if (arry.Length > 1)
            {
                arry[0] = "";
                string RestStr = string.Join(SplitStr, arry);
                RestStr = RestStr.Substring(SplitStr.Length, RestStr.Length - SplitStr.Length);
                return(findFolder(RestStr, resul, SplitStr));
            }
            else
            {
                return(resul);
            }
        }
Ejemplo n.º 16
0
        protected void CheckEndPointExists(RelationEndPointID endPointID, bool shouldEndPointExist)
        {
            ArgumentUtility.CheckNotNull("endPointID", endPointID);

            var endPoint = DataManagementService.GetDataManager(ClientTransaction.Current).GetRelationEndPointWithoutLoading(endPointID);

            if (shouldEndPointExist)
            {
                Assert.That(endPoint, Is.Not.Null, "End point '{0}' does not exist.", endPointID);
            }
            else
            {
                Assert.That(endPoint, Is.Null, "End point '{0}' should not exist.", endPointID);
            }
        }
Ejemplo n.º 17
0
        protected void CheckDataContainerExists(DomainObject domainObject, bool dataContainerShouldExist)
        {
            ArgumentUtility.CheckNotNull("domainObject", domainObject);

            var dataContainer = DataManagementService.GetDataManager(ClientTransaction.Current).DataContainers[domainObject.ID];

            if (dataContainerShouldExist)
            {
                Assert.That(dataContainer, Is.Not.Null, "Data container '{0}' does not exist.", domainObject.ID);
            }
            else
            {
                Assert.That(dataContainer, Is.Null, "Data container '{0}' should not exist.", domainObject.ID);
            }
        }
Ejemplo n.º 18
0
        /** Upload some files using the FileManagement utilities. */
        public void uploadFiles()
        {
            FileManagementUtility fmsFileManagement = new FileManagementUtility(Session.getConnection());
            DataManagementService dmService         = DataManagementService.getService(Session.getConnection());

            try
            {
                uploadSingleFile(fmsFileManagement, dmService);
                uploadMultipleFiles(fmsFileManagement, dmService);
            }
            finally
            {
                // Close FMS connection when done
                fmsFileManagement.Term();
            }
        }
Ejemplo n.º 19
0
        private static bool UsePersistentProperty(DomainObject domainObject, PropertyInfo property)
        {
            ArgumentUtility.CheckNotNull("domainObject", domainObject);
            ArgumentUtility.CheckNotNull("property", property);

            if (!ReflectionUtility.IsRelationType(property.PropertyType))
            {
                return(true);
            }

            var dataManager = DataManagementService.GetDataManager(domainObject.DefaultTransactionContext.ClientTransaction);
            var endPointID  = RelationEndPointID.Create(domainObject.ID, property.DeclaringType, property.Name);
            var endPoint    = dataManager.GetRelationEndPointWithLazyLoad(endPointID);

            return(endPoint.IsDataComplete);
        }
Ejemplo n.º 20
0
        public void DataContainerMapUnregistering_IgnoresNonNewObjects()
        {
            var middleTopTransaction = CreateSubTransactionAndClearListeners(_rootTransaction);

            var domainObject  = middleTopTransaction.ExecuteInScope(() => DomainObjectIDs.Order1.GetObject <Order> ());
            var dataContainer = DataManagementService.GetDataManager(middleTopTransaction).GetDataContainerWithoutLoading(domainObject.ID);

            Assert.That(dataContainer, Is.Not.Null);

            var middleBottomTransaction = CreateSubTransactionAndClearListeners(middleTopTransaction);
            var subTransaction          = CreateSubTransactionAndClearListeners(middleBottomTransaction);

            _listener.DataContainerMapUnregistering(middleTopTransaction, dataContainer);

            Assert.That(middleBottomTransaction.IsInvalid(DomainObjectIDs.Order1), Is.False);
            Assert.That(subTransaction.IsInvalid(DomainObjectIDs.Order1), Is.False);
        }
Ejemplo n.º 21
0
        public UploadDownloadFsc3(User user)
        {
//            String[] FMS_Bootstrap_Urls = new string[] { host };
//            String cacheDir = "c:\\work\\";

            dservice          = DataManagementService.getService(PDMConnection.ClientX.Session.getConnection());
            fmservice         = FileManagementService.getService(PDMConnection.ClientX.Session.getConnection());
            fmsFileManagement = new FileManagementUtility(PDMConnection.ClientX.Session.getConnection(), null, null, new[] { "" }, "C:\\WORK\\");

            try {
                homeFolder = user.Home_folder;
            } catch (NotLoadedException e) {
                Console.WriteLine(e.StackTrace);
            }

            setObjectPolicy();
        }
Ejemplo n.º 22
0
        /** Uploads multiple files using the FileManagement utilities. */
        public void uploadMultipleFiles(FileManagementUtility fMSFileManagement, DataManagementService dmService)
        {
            GetDatasetWriteTicketsInputData[] inputs = getMultipleGetDatasetWriteTicketsInputData(dmService);
            ServiceData response = fMSFileManagement.PutFiles(inputs);

            if (response.sizeOfPartialErrors() > 0)
            {
                System.Console.Out.WriteLine("FileManagementService multiple upload returned partial errrors: " + response.sizeOfPartialErrors());
            }

            // Delete all objects created
            ModelObject[] datasets = new ModelObject[inputs.Length];
            for (int i = 0; i < inputs.Length; ++i)
            {
                datasets[i] = inputs[i].Dataset;
            }
            dmService.DeleteObjects(datasets);
        }
Ejemplo n.º 23
0
        protected void CheckVirtualEndPointExistsAndComplete(RelationEndPointID endPointID, bool shouldEndPointExist, bool shouldDataBeComplete)
        {
            ArgumentUtility.CheckNotNull("endPointID", endPointID);
            CheckEndPointExists(endPointID, shouldEndPointExist);

            if (shouldEndPointExist)
            {
                var endPoint = DataManagementService.GetDataManager(ClientTransaction.Current).GetRelationEndPointWithoutLoading(endPointID);
                if (shouldDataBeComplete)
                {
                    Assert.That(endPoint.IsDataComplete, Is.True, "End point '{0}' should have complete data.", endPoint.ID);
                }
                else
                {
                    Assert.That(endPoint.IsDataComplete, Is.False, "End point '{0}' should not have complete data.", endPoint.ID);
                }
            }
        }
Ejemplo n.º 24
0
        /**
         * Delete the Items
         *
         * @param items     Array of Items to delete
         *
         * @throws ServiceException    If any partial errors are returned
         */
        public void deleteItems(Item[] items) //throws ServiceException
        {
            // Get the service stub
            DataManagementService dmService = DataManagementService.getService(MyFormAppSession.getConnection());

            // *****************************
            // Execute the service operation
            // *****************************
            ServiceData serviceData = dmService.DeleteObjects(items);

            // The AppXPartialErrorListener is logging the partial errors returned
            // In this simple example if any partial errors occur we will throw a
            // ServiceException
            if (serviceData.sizeOfPartialErrors() > 0)
            {
                throw new ServiceException("DataManagementService.deleteObjects returned a partial error.");
            }
        }
Ejemplo n.º 25
0
        public string demo()
        {
            string res = string.Empty;
            DataManagementService dmService = DataManagementService.getService(Session2.getConnection());

            try
            {
                ModelObject itemReversion = findModel(cfg.get("query_builder_lastestRevisionById_name")
                                                      , new string[] { cfg.get("query_builder_lastestRevisionById_queryKey") }, new string[] { "JLD100158" });
                var data = dmService.GetProperties(new ModelObject[] { itemReversion }, new string[] { "WL_REV_013" });
                res = itemReversion.GetProperty("").ModelObjectValue.Uid;
            }
            catch (Exception e)
            {
                res = "";
            }
            return(res);
        }
Ejemplo n.º 26
0
        private void createRelations(ModelObject modObjprimary, ModelObject modObjSecondary, String sRelationName)
        {
            var dmService = DataManagementService.getService(Session.getConnection());


            Relationship[] relationShips = new Relationship[1];
            relationShips[0]                 = new Relationship();
            relationShips[0].ClientId        = "One" + (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;
            relationShips[0].PrimaryObject   = modObjprimary;
            relationShips[0].SecondaryObject = modObjSecondary;
            relationShips[0].RelationType    = sRelationName;
            CreateRelationsResponse response = dmService.CreateRelations(relationShips);

            if (response.ServiceData.sizeOfPartialErrors() > 0)
            {
                //ProcessServiceDataForPartialErrors(response.serviceData);
            }
        }
Ejemplo n.º 27
0
        private static void getUsers(ModelObject[] objects)
        {
            if (objects == null)
            {
                return;
            }

            DataManagementService dmService    = DataManagementService.getService(Session.getConnection());
            ArrayList             unKnownUsers = new ArrayList();

            for (int i = 0; i < objects.Length; i++)
            {
                if (!(objects[i] is WorkspaceObject))
                {
                    continue;
                }

                WorkspaceObject wo = (WorkspaceObject)objects[i];

                User owner = null;
                try
                {
                    owner = (User)wo.Owning_user;
                    String userName = owner.User_name;
                }
                catch (NotLoadedException /*e*/)
                {
                    if (owner != null)
                    {
                        unKnownUsers.Add(owner);
                    }
                }
            }
            User[] users = new User[unKnownUsers.Count];
            unKnownUsers.CopyTo(users);
            String[] attributes = { "user_name" };


            // *****************************
            // Execute the service operation
            // *****************************
            dmService.GetProperties(users, attributes);
        }
Ejemplo n.º 28
0
 public void updateItem(String codeNumber, String name, String longDetail)
 {
     try
     {
         DataManagementService dmService = DataManagementService.getService(Session2.getConnection());
         ModelObject           itemObj   = findModel(cfg.get("query_builder_ItemById_name")
                                                     , new string[] { cfg.get("query_builder_ItemById_queryKey") }, new string[] { codeNumber });
         var item = new ItemElementProperties();
         item.ItemElement = itemObj;
         item.Name        = name;
         //Hashtable kv = new Hashtable();
         //kv.Add("object_desc", longDetail);
         //item.ItemElemAttributes = kv;
         CreateOrUpdateItemElementsResponse rsp = dmService.CreateOrUpdateItemElements(new ItemElementProperties[] { item });
     }
     catch (Exception)
     {
     }
 }
Ejemplo n.º 29
0
        public void DataContainerMapUnregistering_MarksNewObjectsInvalidInSubtransactions()
        {
            var middleTopTransaction = CreateSubTransactionAndClearListeners(_rootTransaction);

            var domainObject  = middleTopTransaction.ExecuteInScope(() => Order.NewObject());
            var dataContainer = DataManagementService.GetDataManager(middleTopTransaction).GetDataContainerWithoutLoading(domainObject.ID);

            Assert.That(dataContainer, Is.Not.Null);

            var middleBottomTransaction = CreateSubTransactionAndClearListeners(middleTopTransaction);
            var subTransaction          = CreateSubTransactionAndClearListeners(middleBottomTransaction);

            _listener.DataContainerMapUnregistering(middleTopTransaction, dataContainer);

            Assert.That(middleBottomTransaction.IsInvalid(domainObject.ID), Is.True);
            Assert.That(ClientTransactionTestHelper.CallGetInvalidObjectReference(middleBottomTransaction, domainObject.ID), Is.SameAs(domainObject));
            Assert.That(subTransaction.IsInvalid(domainObject.ID), Is.True);
            Assert.That(ClientTransactionTestHelper.CallGetInvalidObjectReference(subTransaction, domainObject.ID), Is.SameAs(domainObject));
        }
Ejemplo n.º 30
0
        public void changeOnwer(String userName, ModelObject modl)
        {
            DataManagementService dmService = DataManagementService.getService(Session.getConnection());


            //ModelObject user = findUser(userName);
            ModelObject user = findModel(cfg.get("query_builder_userByUname_name")
                                         , new string[] { cfg.get("query_builder_userByUname_queryKey") }, new string[] { userName });

            if (null == user)
            {
                throw new Exception("构建器查找用户失败,请确认申请人在TC是否存在。");
            }

            //根据USER查找GROUP
            dmService.GetProperties(new ModelObject[] { user }, new string[] { "default_group" });
            ModelObject userGroup = user.GetProperty("default_group").ModelObjectValue;

            if (null == userGroup)
            {
                throw new Exception("构建器查找用户组失败。");
            }


            ObjectOwner[] ownerData = new ObjectOwner[1];

            ObjectOwner ownrObj = new ObjectOwner();

            ownrObj.Object = modl;
            ownrObj.Group  = (Teamcenter.Soa.Client.Model.Strong.Group)userGroup;
            ownrObj.Owner  = (Teamcenter.Soa.Client.Model.Strong.User)user;
            ownerData[0]   = ownrObj;


            ServiceData returnData = dmService.ChangeOwnership(ownerData);

            if (returnData.sizeOfPartialErrors() > 0)
            {
                throw new Exception("修改所有者失败" + returnData.GetPartialError(0).Messages[0]);
            }
        }