本文整理汇总了C#中VersionOne.SDK.APIClient.Query类的典型用法代码示例。如果您正苦于以下问题:C# Query类的具体用法?C# Query怎么用?C# Query使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Query类属于VersionOne.SDK.APIClient命名空间,在下文中一共展示了Query类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
public BuildResult Build(Query query, BuildResult result) {
foreach (var builder in Builders) {
builder.Build(query, result);
}
return result;
}
示例2: GetMostRecentChangeDateTime
public DateTime? GetMostRecentChangeDateTime()
{
var defectType = _meta.GetAssetType("Defect");
var query = new Query(defectType);
var projectAttribute = defectType.GetAttributeDefinition("Scope");
var projectTerm = new FilterTerm(projectAttribute);
projectTerm.Equal(MonitoredProjects.Select(project => project.ScopeId).Cast<Object>().ToArray());
var changeAttribute = defectType.GetAttributeDefinition("ChangeDateUTC");
query.Selection.Add(changeAttribute);
if (_mostRecentChangeDateTime.HasValue)
{
var changeTerm = new FilterTerm(changeAttribute);
changeTerm.Greater(_mostRecentChangeDateTime.Value.ToString("yyyy-MM-ddTHH:mm:ss.fff", CultureInfo.InvariantCulture));
query.Filter = new AndFilterTerm(changeTerm, projectTerm);
} else
{
query.Filter = projectTerm;
}
var result = _services.Retrieve(query);
if (result.TotalAvaliable > 0)
{
foreach (var asset in result.Assets)
{
var projectChangeDateTime = DB.DateTime(asset.GetAttribute(changeAttribute).Value);
if ((!_mostRecentChangeDateTime.HasValue) || (projectChangeDateTime > _mostRecentChangeDateTime))
{
_mostRecentChangeDateTime = projectChangeDateTime;
}
}
}
return _mostRecentChangeDateTime;
}
示例3: GetAssetOid
public static string GetAssetOid(string jiraId, string assetTypeStr)
{
var config = (JiraConnectionConfiguration)ConfigurationManager.GetSection("jiraAttachments");
var metaconnector = new VersionOneAPIConnector(config.V1Connection.ServerUrl + "/meta.v1/");
var dataconnector =
new VersionOneAPIConnector(config.V1Connection.ServerUrl + "/rest-1.v1/")
.WithVersionOneUsernameAndPassword(config.V1Connection.Username, config.V1Connection.Password);
MetaModel metaModel = new MetaModel(metaconnector);
Services services = new Services(metaModel, dataconnector);
var assetType = metaModel.GetAssetType(assetTypeStr);
var query = new Query(assetType);
var jiraIdAttribute = assetType.GetAttributeDefinition(GetV1IdCustomFieldName(assetTypeStr));
query.Selection.Add(jiraIdAttribute);
var jiraIdTerm = new FilterTerm(jiraIdAttribute);
jiraIdTerm.Equal(jiraId);
query.Filter = jiraIdTerm;
var result = services.Retrieve(query);
if (result.Assets.Count == 0)
{
return String.Empty;
}
return result.Assets[0].Oid.ToString();
}
示例4: DoBuild
protected override void DoBuild(Query query, BuildResult result)
{
if (query.AsOf.CompareTo(DateTime.MinValue) > 0)
{
result.QuerystringParts.Add("asof=" + query.AsOf.ToString("yyyy-MM-ddTHH:mm:ss"));
}
}
示例5: QueryForNameAndStatus
public void QueryForNameAndStatus()
{
Oid defectId = Oid.FromToken("Defect:2258150", metaModel);
Query query = new Query(defectId);
IAssetType defectType = metaModel.GetAssetType("Defect");
IAttributeDefinition nameAttribute = defectType.GetAttributeDefinition("Name");
IAttributeDefinition statusAttribute = defectType.GetAttributeDefinition(Entity.StatusProperty);
IAttributeDefinition statusNameAttribute = defectType.GetAttributeDefinition(Entity.StatusNameProperty);
query.Selection.Add(nameAttribute);
query.Selection.Add(statusAttribute);
query.Selection.Add(statusNameAttribute);
QueryResult result = services.Retrieve(query);
Asset defect = result.Assets[0];
string name = defect.GetAttribute(nameAttribute).Value.ToString();
string status = defect.GetAttribute(statusAttribute).Value.ToString();
string statusName = defect.GetAttribute(statusNameAttribute).Value.ToString();
defect.SetAttributeValue(statusAttribute, "StoryStatus:135");
services.Save(defect);
string newStatusName = defect.GetAttribute(statusAttribute).Value.ToString();
Console.WriteLine(string.Format("{0} - {1} ", statusName, newStatusName));
}
示例6: GetSingleListValue
protected Object GetSingleListValue(VersionOne.SDK.APIClient.Attribute attribute)
{
if (attribute.Value != null && attribute.Value.ToString() != "NULL")
{
IAssetType assetType = _metaAPI.GetAssetType("List");
Query query = new Query(assetType);
IAttributeDefinition assetIDAttribute = assetType.GetAttributeDefinition("ID");
query.Selection.Add(assetIDAttribute);
IAttributeDefinition nameAttribute = assetType.GetAttributeDefinition("Name");
query.Selection.Add(nameAttribute);
FilterTerm assetName = new FilterTerm(assetIDAttribute);
assetName.Equal(attribute.Value.ToString());
query.Filter = assetName;
QueryResult result = _dataAPI.Retrieve(query);
return result.Assets[0].GetAttribute(nameAttribute).Value.ToString();
}
else
{
return DBNull.Value;
}
}
示例7: SaveItemAssociations
public static void SaveItemAssociations(Project project)
{
if (project.BuildRuns.Count > 0)
{
// There is no direct association between workitems and affected/included build runs.
// The indirect association occurs by relationship to ChangeSets.
string defectId = project.Defects.First(x => x.Name.Equals("Fix performance SLA on load")).Id;
IAssetType defectType = Program.MetaModel.GetAssetType("Defect");
Query query = new Query(Oid.FromToken(defectId, Program.MetaModel));
IAttributeDefinition foundDefectsDef = defectType.GetAttributeDefinition("FoundInBuildRuns");
IAttributeDefinition completedDef = defectType.GetAttributeDefinition("CompletedInBuildRuns");
IAttributeDefinition changeSetsDef = defectType.GetAttributeDefinition("ChangeSets");
QueryResult result = Program.Services.Retrieve(query);
Asset asset = result.Assets[0];
// Found in first build run and completed in last build run
// Included in build runs 2 and 3 (via ChangeSets)
asset.AddAttributeValue(foundDefectsDef, Oid.FromToken(project.BuildRuns[0].Id, Program.MetaModel));
asset.AddAttributeValue(completedDef, Oid.FromToken(project.BuildRuns[2].Id, Program.MetaModel));
asset.AddAttributeValue(changeSetsDef, Oid.FromToken(project.ChangeSets[1].Id, Program.MetaModel));
asset.AddAttributeValue(changeSetsDef, Oid.FromToken(project.ChangeSets[2].Id, Program.MetaModel));
Program.Services.Save(asset);
string storyId = project.Stories.First(x => x.Name.Equals("List of Books by Author")).Id;
IAssetType storyType = Program.MetaModel.GetAssetType("Story");
query = new Query(Oid.FromToken(storyId, Program.MetaModel));
IAttributeDefinition completedStoryDef = storyType.GetAttributeDefinition("CompletedInBuildRuns");
IAttributeDefinition changeSetsStoryDef = storyType.GetAttributeDefinition("ChangeSets");
result = Program.Services.Retrieve(query);
asset = result.Assets[0];
// Completed in last build run
// Included in build runs 2 and 3 (via ChangeSets)
asset.AddAttributeValue(completedStoryDef, Oid.FromToken(project.BuildRuns[2].Id, Program.MetaModel));
asset.AddAttributeValue(changeSetsStoryDef, Oid.FromToken(project.ChangeSets[1].Id, Program.MetaModel));
asset.AddAttributeValue(changeSetsStoryDef, Oid.FromToken(project.ChangeSets[2].Id, Program.MetaModel));
Program.Services.Save(asset);
storyId = project.Stories.First(x => x.Name.Equals("View Book Details")).Id;
query = new Query(Oid.FromToken(storyId, Program.MetaModel));
result = Program.Services.Retrieve(query);
asset = result.Assets[0];
// Included in all 3 build runs (via ChangeSets)
// Not completed yet
asset.AddAttributeValue(changeSetsStoryDef, Oid.FromToken(project.ChangeSets[0].Id, Program.MetaModel));
asset.AddAttributeValue(changeSetsStoryDef, Oid.FromToken(project.ChangeSets[1].Id, Program.MetaModel));
asset.AddAttributeValue(changeSetsStoryDef, Oid.FromToken(project.ChangeSets[2].Id, Program.MetaModel));
Program.Services.Save( asset );
}
}
示例8: GetLoggedInMemberRole
private string GetLoggedInMemberRole()
{
var query = new Query(Services.LoggedIn);
var defaultRoleAttribute = Services.Meta.GetAssetType(MemberType).GetAttributeDefinition(DefaultRoleNameProperty);
query.Selection.Add(defaultRoleAttribute);
return Services.Localization(defaultRoleAttribute);
}
示例9: FluentQuery
public FluentQuery(
string assetTypeName)
{
RawQuery = new Query(MetaModelProvider.Meta.GetAssetType(assetTypeName));
AssetTypeName = assetTypeName;
WhereCriteria = new List<Tuple<string, object, FilterTerm.Operator>>();
SelectFields = new List<object>();
}
示例10: GetLoggedInMemberRole
private string GetLoggedInMemberRole() {
var query = new Query(Central.Services.LoggedIn);
var defaultRoleAttribute = Central.MetaModel.GetAssetType(MemberType).GetAttributeDefinition(DefaultRoleNameProperty);
query.Selection.Add(defaultRoleAttribute);
var asset = Central.Services.Retrieve(query).Assets[0];
var role = asset.GetAttribute(defaultRoleAttribute);
return Central.Loc.Resolve(role.Value.ToString());
}
示例11: FilterExist
public void FilterExist() {
var assetType = Instance.ApiClient.MetaModel.GetAssetType("Story");
var customFilter = new FilterTerm(assetType.GetAttributeDefinition("Timebox"));
customFilter.Exists();
var query = new Query(assetType) {Filter = customFilter};
Instance.ApiClient.Services.Retrieve(query);
}
示例12: GetDefaultSchedule
public static Asset GetDefaultSchedule()
{
IAssetType assetType = Program.MetaModel.GetAssetType("Schedule");
Query query = new Query(assetType);
IAttributeDefinition nameAttribute = assetType.GetAttributeDefinition("Name");
query.Selection.Add(nameAttribute);
query.Find = new QueryFind("Default Schedule", new AttributeSelection(nameAttribute));
QueryResult result = Program.Services.Retrieve(query);
return result.Assets[0];
}
示例13: Run
public void Run()
{
Log("Get some meta stuff");
IAssetType memberType = Meta.GetAssetType("Member");
Log(memberType.DisplayName);
Log("Perform a query");
var query = new Query(memberType);
QueryResult result = Services.Retrieve(query);
Log(string.Format("Server returned {0} members", result.TotalAvaliable));
}
示例14: CreateUserToDeactivate
public User CreateUserToDeactivate(string username) {
User user = CreateTestUser(username);
user.Deactivate = true;
IAssetType member = model.GetAssetType("Member");
Query query = new Query(member);
FilterTerm term = new FilterTerm(member.GetAttributeDefinition("Username"));
term.Equal(username);
query.Filter = term;
QueryResult result = services.Retrieve(query);
user.V1MemberAsset = result.Assets[0];
return user;
}
示例15: Query
public AssetList Query(string workitemTypeName, IFilterTerm filter)
{
try {
var workitemType = metaModel.GetAssetType(workitemTypeName);
var query = new Query(workitemType) { Filter = filter};
AddSelection(query, workitemTypeName, workitemType);
return services.Retrieve(query).Assets;
} catch (Exception ex) {
throw new VersionOneException(ex.Message);
}
}