当前位置: 首页>>代码示例>>C#>>正文


C# Services.Retrieve方法代码示例

本文整理汇总了C#中Services.Retrieve方法的典型用法代码示例。如果您正苦于以下问题:C# Services.Retrieve方法的具体用法?C# Services.Retrieve怎么用?C# Services.Retrieve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Services的用法示例。


在下文中一共展示了Services.Retrieve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MultiValueAttribute

		public void MultiValueAttribute() {
			Services subject = new Services(Meta, DataConnector);
			Query queryStories = new Query(Oid.FromToken("Story:1063", Meta));
			IAttributeDefinition ownersDef = Meta.GetAttributeDefinition("Story.Owners");
			queryStories.Selection.Add(ownersDef);
			QueryResult resultStories = subject.Retrieve(queryStories);

			Asset story = resultStories.Assets[0];
			Oid oldMember = Oid.FromToken("Member:1001", Meta);
			Oid newMember = Oid.FromToken("Member:20", Meta);
			IEnumerator owners = story.GetAttribute(ownersDef).Values.GetEnumerator();
			Assert.IsTrue(owners.MoveNext());
			Assert.AreEqual(oldMember, owners.Current);
			Assert.IsFalse(owners.MoveNext());

			story.AddAttributeValue(ownersDef, newMember);
			owners = story.GetAttribute(ownersDef).Values.GetEnumerator();
			Assert.IsTrue(owners.MoveNext());
			Assert.AreEqual(oldMember, owners.Current);
			Assert.IsTrue(owners.MoveNext());
			Assert.AreEqual(newMember, owners.Current);
			Assert.IsFalse(owners.MoveNext());

			story.RemoveAttributeValue(ownersDef, oldMember);
			owners = story.GetAttribute(ownersDef).Values.GetEnumerator();
			Assert.IsTrue(owners.MoveNext());
			Assert.AreEqual(newMember, owners.Current);
			Assert.IsFalse(owners.MoveNext());

			story.RemoveAttributeValue(ownersDef, newMember);
			owners = story.GetAttribute(ownersDef).Values.GetEnumerator();
			Assert.IsFalse(owners.MoveNext());
		}
开发者ID:RedwardsiPipeline,项目名称:VersionOne.SDK.NET.APIClient,代码行数:33,代码来源:MultiValueAttributeTester.cs

示例2: OidQueryMultiValueAttribute

		[Test] public void OidQueryMultiValueAttribute()
		{
			var subject = new Services(Meta, DataConnector);
			var q = new Query(Oid.FromToken("Story:1036", Meta));
			var def = Meta.GetAttributeDefinition("Story.Owners");
			q.Selection.Add(def);
			var r = subject.Retrieve(q);
			var a = r.Assets[0];
			var attrib = a.GetAttribute(def);
			Assert.IsNotNull(attrib);
            Assert.That(attrib.Values, Is.Empty);
		}
开发者ID:RedwardsiPipeline,项目名称:VersionOne.SDK.NET.APIClient,代码行数:12,代码来源:ServicesTester.cs

示例3: QueryProjects

		public void QueryProjects() {
			var proxyProvider = new ProxyProvider(new Uri(ProxyPath), ProxyUsername, ProxyPassword);
			IAPIConnector metaConnector = new V1APIConnector(V1Path + "meta.v1/", V1Username, V1Password, false, proxyProvider);
			IMetaModel metaModel = new MetaModel(metaConnector);

			IAPIConnector dataConnector = new V1APIConnector(V1Path + "rest-1.v1/", V1Username, V1Password, false, proxyProvider);
			IServices services = new Services(metaModel, dataConnector);

			var projectType = metaModel.GetAssetType("Scope");
			var scopeQuery = new Query(projectType);
			var result = services.Retrieve(scopeQuery);

			Assert.IsTrue(result.Assets.Count > 0);
		}
开发者ID:nicholsf,项目名称:VersionOne.SDK.NET.APIClient,代码行数:14,代码来源:ProxyTester.cs

示例4: Asset_with_valid_Guid_Attribute

		public void Asset_with_valid_Guid_Attribute()
		{
			var payloadGuid = Guid.Parse("98771fb4-71b8-42ec-be8b-69414daa020e");

			var subject = new Services(Meta, DataConnector);
			var publicationType = Meta.GetAssetType("Publication");
			var payloadAttribute = publicationType.GetAttributeDefinition("Payload");
			var query = new Query(publicationType);
			query.Selection.Add(payloadAttribute);
			var filter = new FilterTerm(payloadAttribute);
			filter.Equal(payloadGuid);
			query.Filter = filter;
			var result = subject.Retrieve(query);

			var payloadFromResult = (Guid)result.Assets[0].GetAttribute(payloadAttribute).Value;

			Assert.AreEqual(payloadGuid, payloadFromResult);
		}
开发者ID:versionone,项目名称:VersionOne.SDK.NET.APIClient,代码行数:18,代码来源:ServicesTester.cs

示例5: GetMultipleAssetsTest

        public void GetMultipleAssetsTest()
        {
            IMetaModel metaModel = new MetaModel(new VersionOneAPIConnector(_metaUrl));
            IServices services = new Services(
                metaModel,
                new VersionOneAPIConnector(_dataUrl).WithVersionOneUsernameAndPassword(_username, _password));

            var assetType = metaModel.GetAssetType("Story");
            var query = new Query(assetType);
            var nameAttribute = assetType.GetAttributeDefinition("Name");
            var estimateAttribute = assetType.GetAttributeDefinition("Estimate");

            query.Selection.Add(nameAttribute);
            query.Selection.Add(estimateAttribute);
            var result = services.Retrieve(query);

            Assert.Greater(result.Assets.Count, 1);
        }
开发者ID:RedwardsiPipeline,项目名称:VersionOne.SDK.NET.APIClient,代码行数:18,代码来源:GettingStartedTests.cs

示例6: GetSingleAssetTest

        public void GetSingleAssetTest()
        {
            IMetaModel metaModel = new MetaModel(new VersionOneAPIConnector(_metaUrl));
            IServices services = new Services(
                metaModel,
                new VersionOneAPIConnector(_dataUrl).WithVersionOneUsernameAndPassword(_username, _password));

            var memberId = Oid.FromToken("Member:20", metaModel);
            var query = new Query(memberId);
            var nameAttribute = metaModel.GetAttributeDefinition("Member.Name");
            var emailAttribute = metaModel.GetAttributeDefinition("Member.Email");

            query.Selection.Add(nameAttribute);
            query.Selection.Add(emailAttribute);
            var result = services.Retrieve(query);
            Asset member = result.Assets[0];

            Assert.IsNotNull(member);
            Assert.AreEqual("Administrator", member.GetAttribute(nameAttribute).Value);
            Assert.AreEqual("[email protected]", member.GetAttribute(emailAttribute).Value);
        }
开发者ID:RedwardsiPipeline,项目名称:VersionOne.SDK.NET.APIClient,代码行数:21,代码来源:GettingStartedTests.cs

示例7: UpdateScalarAttributeTest

        public void UpdateScalarAttributeTest()
        {
            IMetaModel metaModel = new MetaModel(new VersionOneAPIConnector(_metaUrl));
            IServices services = new Services(
                metaModel,
                new VersionOneAPIConnector(_dataUrl).WithVersionOneUsernameAndPassword(_username, _password));

            var storyId = Oid.FromToken("Story:1094", metaModel);
            var query = new Query(storyId);
            var storyType = metaModel.GetAssetType("Story");
            var nameAttribute = storyType.GetAttributeDefinition("Name");

            query.Selection.Add(nameAttribute);
            var result = services.Retrieve(query);
            var story = result.Assets[0];
            var oldName = story.GetAttribute(nameAttribute).Value.ToString();
            story.SetAttributeValue(nameAttribute, Guid.NewGuid().ToString());
            services.Save(story);

            Assert.AreNotEqual(oldName, story.GetAttribute(nameAttribute).Value.ToString());
        }
开发者ID:RedwardsiPipeline,项目名称:VersionOne.SDK.NET.APIClient,代码行数:21,代码来源:GettingStartedTests.cs

示例8: full_working_example_with_basic_authentication

        public void full_working_example_with_basic_authentication()
        {
            // Setting up a basic connection with the connector and retrieving the Member with the ID 20
            var dataConnector = new VersionOneAPIConnector(_prefix + "rest-1.v1/")
                .WithVersionOneUsernameAndPassword(_username, _password);
            var metaConnector = new VersionOneAPIConnector(_prefix + "meta.v1/");

            IMetaModel metaModel = new MetaModel(metaConnector);
            IServices services = new Services(metaModel, dataConnector);

            var memberId = Oid.FromToken("Member:20", metaModel);
            var query = new Query(memberId);
            var memberName = metaModel.GetAttributeDefinition("Member.Name");
            query.Selection.Add(memberName);

            var result = services.Retrieve(query);
        }
开发者ID:RedwardsiPipeline,项目名称:VersionOne.SDK.NET.APIClient,代码行数:17,代码来源:VersionOneAPIConnectorExamples.cs

示例9: FilterListOfAssetsTest

        /// <summary>
        /// Use the Filter property of the Query object to filter the results that are returned. 
        /// This query will retrieve only Story assets with a "ToDo" of zero.
        /// </summary>
        public void FilterListOfAssetsTest()
        {
            IMetaModel metaModel = new MetaModel(new VersionOneAPIConnector(_metaUrl));
            IServices services = new Services(
                metaModel,
                new VersionOneAPIConnector(_dataUrl).WithVersionOneUsernameAndPassword(_username, _password));

            var assetType = metaModel.GetAssetType("Task");
            var query = new Query(assetType);
            var nameAttribute = assetType.GetAttributeDefinition("Name");
            var todoAttribute = assetType.GetAttributeDefinition("ToDo");

            query.Selection.Add(nameAttribute);
            query.Selection.Add(todoAttribute);

            var toDoTerm = new FilterTerm(todoAttribute);
            toDoTerm.Equal(0);
            query.Filter = toDoTerm;
            var result = services.Retrieve(query);

            result.Assets.ForEach(asset =>
                    Assert.AreEqual(0, asset.GetAttribute(todoAttribute).Value));
        }
开发者ID:RedwardsiPipeline,项目名称:VersionOne.SDK.NET.APIClient,代码行数:27,代码来源:GettingStartedTests.cs

示例10: ReOpenAnAssetTest

        public void ReOpenAnAssetTest()
        {
            IMetaModel metaModel = new MetaModel(new VersionOneAPIConnector(_metaUrl));
            IServices services = new Services(
                metaModel,
                new VersionOneAPIConnector(_dataUrl).WithVersionOneUsernameAndPassword(_username, _password));

            // create a new story
            var projectId = Oid.FromToken("Scope:0", metaModel);
            var assetType = metaModel.GetAssetType("Story");
            var story = services.New(assetType, projectId);
            var nameAttribute = assetType.GetAttributeDefinition("Name");
            story.SetAttributeValue(nameAttribute, "My New Story");
            services.Save(story);

            // closes the story
            var closeOperation = metaModel.GetOperation("Story.Inactivate");
            var closeId = services.ExecuteOperation(closeOperation, story.Oid);

            //reopens the story
            var activateOperation = metaModel.GetOperation("Story.Reactivate");
            var activeId = services.ExecuteOperation(activateOperation, story.Oid);

            var query = new Query(activeId.Momentless);
            var assetState = metaModel.GetAttributeDefinition("Story.AssetState");
            query.Selection.Add(assetState);
            var result = services.Retrieve(query);
            Asset activeStory = result.Assets[0];

            Assert.AreEqual("Active", activeStory.GetAttribute(assetState).Value.ToString());
        }
开发者ID:RedwardsiPipeline,项目名称:VersionOne.SDK.NET.APIClient,代码行数:31,代码来源:GettingStartedTests.cs

示例11: DeleteAnAssetTest

        public void DeleteAnAssetTest()
        {
            IMetaModel metaModel = new MetaModel(new VersionOneAPIConnector(_metaUrl));
            IServices services = new Services(
                metaModel,
                new VersionOneAPIConnector(_dataUrl).WithVersionOneUsernameAndPassword(_username, _password));

            // create a new story so we can delete it
            var projectId = Oid.FromToken("Scope:0", metaModel);
            var assetType = metaModel.GetAssetType("Story");
            var newStory = services.New(assetType, projectId);
            var nameAttribute = assetType.GetAttributeDefinition("Name");
            newStory.SetAttributeValue(nameAttribute, "My New Story");
            services.Save(newStory);
            // delete the story
            var deleteOperation = metaModel.GetOperation("Story.Delete");
            var deletedId = services.ExecuteOperation(deleteOperation, newStory.Oid);
            var query = new Query(deletedId.Momentless);
            QueryResult result = services.Retrieve(query);

            Assert.AreEqual(0, result.TotalAvaliable);

            // The delete operation returns the Oid with the new Moment of the deleted asset. 
            // Future queries will automatically exclude deleted assets from results.
            // Currently there is no support for undeleting a deleted asset.
        }
开发者ID:RedwardsiPipeline,项目名称:VersionOne.SDK.NET.APIClient,代码行数:26,代码来源:GettingStartedTests.cs

示例12: UpdateMultiValueRelationTest

        public void UpdateMultiValueRelationTest()
        {
            IMetaModel metaModel = new MetaModel(new VersionOneAPIConnector(_metaUrl));
            IServices services = new Services(
                metaModel,
                new VersionOneAPIConnector(_dataUrl).WithVersionOneUsernameAndPassword(_username, _password));

            var storyId = Oid.FromToken("Story:1124", metaModel);
            var query = new Query(storyId);
            var storyType = metaModel.GetAssetType("Story");
            var ownersAttribute = storyType.GetAttributeDefinition("Owners");

            query.Selection.Add(ownersAttribute);

            var result = services.Retrieve(query);
            var story = result.Assets[0];
            var values = story.GetAttribute(ownersAttribute).Values;
            var owners = values.Cast<object>().ToList();

            if (owners.Count >= 1) story.RemoveAttributeValue(ownersAttribute, owners[0]);

            services.Save(story);
        }
开发者ID:RedwardsiPipeline,项目名称:VersionOne.SDK.NET.APIClient,代码行数:23,代码来源:GettingStartedTests.cs

示例13: UpdateSingleValueRelationTest

        public void UpdateSingleValueRelationTest()
        {
            IMetaModel metaModel = new MetaModel(new VersionOneAPIConnector(_metaUrl));
            IServices services = new Services(
                metaModel,
                new VersionOneAPIConnector(_dataUrl).WithVersionOneUsernameAndPassword(_username, _password));

            var storyId = Oid.FromToken("Story:1094", metaModel);
            var query = new Query(storyId);
            var storyType = metaModel.GetAssetType("Story");
            var sourceAttribute = storyType.GetAttributeDefinition("Source");
            query.Selection.Add(sourceAttribute);
            var result = services.Retrieve(query);
            var story = result.Assets[0];
            var oldSource = story.GetAttribute(sourceAttribute).Value.ToString();
            story.SetAttributeValue(sourceAttribute, GetNextSourceId(oldSource));
            services.Save(story);
        }
开发者ID:RedwardsiPipeline,项目名称:VersionOne.SDK.NET.APIClient,代码行数:18,代码来源:GettingStartedTests.cs

示例14: HistoryAsOfTimeTest

        public void HistoryAsOfTimeTest()
        {
            IMetaModel metaModel = new MetaModel(new VersionOneAPIConnector(_metaUrl));
            IServices services = new Services(
                metaModel,
                new VersionOneAPIConnector(_dataUrl).WithVersionOneUsernameAndPassword(_username, _password));

            var storyType = metaModel.GetAssetType("Story");
            var query = new Query(storyType, true);
            var nameAttribute = storyType.GetAttributeDefinition("Name");
            var estimateAttribute = storyType.GetAttributeDefinition("Estimate");
            query.Selection.Add(nameAttribute);
            query.Selection.Add(estimateAttribute);

            query.AsOf = DateTime.Now.AddDays(-7);
            QueryResult result = services.Retrieve(query);

            Assert.AreNotEqual(0, result.TotalAvaliable);
        }
开发者ID:RedwardsiPipeline,项目名称:VersionOne.SDK.NET.APIClient,代码行数:19,代码来源:GettingStartedTests.cs

示例15: Asset_with_null_Guid_Attribute

		public void Asset_with_null_Guid_Attribute()
		{
			var subject = new Services(Meta, DataConnector);
			var query = new Query(Oid.FromToken("Publication:12346", Meta));

			var publicationType = Meta.GetAssetType("Publication");
			var payloadAttribute = publicationType.GetAttributeDefinition("Payload");
			query.Selection.Add(payloadAttribute);

			try
			{
				subject.Retrieve(query);
			}
			catch (ArgumentNullException ex)
			{
				Assert.AreEqual("Cannot coerce a NULL value to a Guid\r\nParameter name: value", ex.Message);
				return;
			}

			Assert.Fail("Expected to raise ArgumentNullException, but did not.");
		}
开发者ID:versionone,项目名称:VersionOne.SDK.NET.APIClient,代码行数:21,代码来源:ServicesTester.cs


注:本文中的Services.Retrieve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。