TFS Capacity plan reading from c# - c#

Am doing a reporting tool out of tfs. i was able to read the work item and iteration related information from tfs. How to get the iteration capacity plan information from tfs. using WIQL or any other option. i need to get the information in my c# code.
Thanks in advance for all the help.

It's not able to do this through Client Object Model. Please refer this similar question: TFS 11 2012 API Questions : query capacity and days off
These values are only available from the Server Object Model (there is no Client Object Model equivalent at the moment). The interfaces and objects are all made Internal so even on the server you can't access these values.
internal TeamCapacity GetTeamIterationCapacity(Guid teamId, Guid iterationId);
Declaring Type: Microsoft.TeamFoundation.Server.WebAccess.WorkItemTracking.Common.DataAccess.TeamConfigurationComponent
Assembly: Microsoft.TeamFoundation.Server.WebAccess.WorkItemTracking.Common, Version=12.0.0.0
You could either directly query from the ProjectCollection database from the tables mentioned by James Tupper in this thread.
Or you could also use Rest API to Get a team's capacity or Get a team member's capacity will get a response as below:
{
"values": [
{
"teamMember": {
"id": "8c8c7d32-6b1b-47f4-b2e9-30b477b5ab3d",
"displayName": "Chuck Reinhart",
"uniqueName": "fabrikamfiber3#hotmail.com",
"url": "https://fabrikam-fiber-inc.vssps.visualstudio.com/_apis/Identities/8c8c7d32-6b1b-47f4-b2e9-30b477b5ab3d",
"imageUrl": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=8c8c7d32-6b1b-47f4-b2e9-30b477b5ab3d"
},
"activities": [
{
"capacityPerDay": 0,
"name": null
}
],
"daysOff": [],
"url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/6d823a47-2d51-4f31-acff-74927f88ee1e/748b18b6-4b3c-425a-bcae-ff9b3e703012/_apis/work/teamsettings/iterations/2ec76bfe-ba74-4060-970d-4567a3e997ee/capacities/8c8c7d32-6b1b-47f4-b2e9-30b477b5ab3d"
}
]
}

Iteration objects are part of Project settings, you might need to query the iteration details from there and not from work item.

Related

Why can't I create a valid style via the mapbox api using the examples they provide?

I amp attempting to create a new mapbox style via the mapbox api. When the create process completes, I am getting a success confirmation back, but I cannot use or view the style after it is created. Based on these docs and these docs, I am sending a payload to this api endpoint:
https://api.mapbox.com/styles/v1/[accountname]
The payload I am sending is this:
{
"version": 8,
"name": "mystyle via api",
"sprite": "mapbox://sprites/mapbox/bright-v8",
"metadata": null,
"sources": {
"mapbox-streets": {
"type": "vector",
"url": "mapbox://mapbox.mapbox-streets-v6"
}
},
"glyphs": null,
"layers": []
}
After sending this payload to the mapbox api, I receive this message back:
{
"version": 8,
"name": "mystyle via api",
"metadata": null,
"sources": {
"mapbox-streets": {
"type": "vector",
"url": "mapbox://mapbox.mapbox-streets-v6"
}
},
"sprite": "mapbox://sprites/[accountname]/ckby5s52p2r9v1hmwgkrzenvw/3teom2ial2ryn2u97lclizpce",
"glyphs": "mapbox://fonts/[accountname]/{fontstack}/{range}.pbf",
"layers": [],
"created": "2020-06-27T21:30:49.047Z",
"id": "ckby5s52p2r9v1hmwgkrzenvw",
"modified": "2020-06-27T21:30:49.047Z",
"owner": "[accountname]",
"visibility": "private"
}
Then I proceed to my account in the portal and I see my new style:
However, something is wrong. The preview icon shows just a transparent graphic. And when I click on the style to view/edit it, I get this cryptic error message "Cannot read property 'mapbox:decompiler' of null":
What am I missing here? I am finding the documentation for this process very spread out through several documents. But I am copying the examples in the snippets verbatim
This is a "valid" style, but it has no layers (see the last field of the JSON), that's why it doesn't display anything. (I know this is verbatim from the example in the Create a style docs)
The key concept here to master is the difference between Sources and Layers. Sources are "data sources": you won't see them unless you have a Layer displaying it. Some types of Sources can contain many layers (see the source-layer property in the Layer object), and/or you might want to display the same source with different stylings across different maps. That's one reason they are separated.
Or, as the Sources docs put it:
Adding a source isn't enough to make data appear on the map because sources don't contain styling details like color or width. Layers refer to a source and give it a visual representation. This makes it possible to style the same source in different ways, like differentiating between types of roads in a highways layer.
Combining the Style object sample with the Layer object sample would give you something like this:
{
"version": 8,
"name": "mystyle via api",
"sprite": "mapbox://sprites/mapbox/bright-v8",
"metadata": null,
"sources": {
"mapbox-streets": {
"type": "vector",
"url": "mapbox://mapbox.mapbox-streets-v6"
}
},
"glyphs": null,
"layers": [
{
"id": "water",
"source": "mapbox-streets",
"source-layer": "water",
"type": "fill",
"paint": {
"fill-color": "#00ffff"
}
}
]
}
Now, keep in mind that the global Mapbox styles contain several layers (maybe up to a couple dozen), with very fine settings such as what type of features should show at which zoom level and with what configurations, etc. Most applications should not need to recreate those from scratch.
If you want to overlay dynamic data (to be decided at runtime), you can use one of the global styles and dynamically add a Layer on top of an untouched default style. The link is for Mapbox GL JS, assuming the UI is browser-based. If the UI is a mobile app, there are corresponding methods in the iOS and Android SDKs.
Now, if you don't need dynamic data at all, consider Mapbox Studio instead. This will allow you to create a custom style (with the default styles as templates if you want) and add/remove layers. For example, if mapbox://styles/mapbox/streets-v11 is almost a perfect fit, but you don't need to (say) show small town names, you can create a custom template in Mapbox Studio and remove just that. In the end, it will you give you a style ID which you can just put into your map like a default (global) style.
Also note that, depending on your case, you may combine both approaches.

Viewing/Collecting Service Fabric ETW Events OnPrem

We are trying to view Service ETW Events in an OnPrem cluster. The long term plan will be to install an ElasticSearch cluster to send the events to. I don't have time to build that out this week, instead I need to understand why my App is blowing up.
We have installed Microsoft Message Analyzer on one of the node servers and I can connect with a live session to view the Cluster ETW Events Service Fabric System Provider.
I would like to be able to view the Application ETW Events. I've followed the instructions in the article here:
https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-diagnostic-collect-logs-without-an-agent
This article seems to focus on 3 files, eventFlowConfig.json, Program.cs and ServiceEventSource.cs.
EventFlowConfig.Json has:
"inputs": [
{
"type": "EventSource",
"sources": [
{ "providerName": "Microsoft-ServiceFabric-Services" },
{ "providerName": "Microsoft-ServiceFabric-Actors" },
{ "providerName": "TMHP-CacheApp-CacheAPI" }
]
}
],
"filters": [
{
"type": "drop",
"include": "Level == Verbose"
}
],
"outputs": [
{
"type": "StdOutput"
}
In program.cs I have:
using (var diagnosticsPipeline = ServiceFabricDiagnosticPipelineFactory.CreatePipeline("CacheApp-CacheAPI-DiagnosticsPipeline"))
{
ServiceRuntime.RegisterServiceAsync("EndpointType",
context => new Endpoint(context)).GetAwaiter().GetResult();
ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(Endpoint).Name);
// Prevents this host process from terminating so services keeps running.
Thread.Sleep(Timeout.Infinite);
}
ServiceEventSource.cs has:
[EventSource(Name = "TMHP-CacheApp-CacheAPI")]
I package and deploy fine, but using MSMA I don't know how to attach to the Application Provider? I think I would be adding a "Custom Provider" but it asks for a GUID. Is there someway to find this Guid? I'm assuming I want to add the customer provider for my specific ServiceFabric Application of type:
"TMHP-CacheApp-CacheAPI"
Thanks in advance,
Greg
I'd recommend that you use PerFView instead, Vance has an article on how to view EventSource based events in PerfView https://blogs.msdn.microsoft.com/vancem/2012/07/09/introduction-tutorial-logging-etw-events-in-c-system-diagnostics-tracing-eventsource/ The '*' in front of the EventSource name is important.
Here's some instructions for how to view actor events, your custom EventSource should be the same pattern.
The Actor and ReliableServices are EventSource based so to view them in PerfView you have to follow the instructions on Vance’s blog. Don't forget the '*'!!!
Start PerfView with a command line like this: perfview /onlyproviders=*Microsoft-ServiceFabric-Actors
You can collect using Collect | Collect | Start Collection. Make sure that the Advanced Options | Additional Providers field contains =*Microsoft-ServiceFabric-Actors
When you finish collecting they are viewable under Events
The Guid of a .NET EventSource based Event Provider is actually based on the name of the provider, it is generated using a hash algorithm. This blog post has a short description of it: https://blogs.msdn.microsoft.com/dcook/2015/09/08/etw-provider-names-and-guids/. You can use the supplied ETWGuid.exe to generate the Guid for your provider:
C:\code> .\EtwGuid.exe TMHP-CacheApp-CacheAPI
TRACELOGGING_DEFINE_PROVIDER(
g_hMyProvider,
"TMHP-CacheApp-CacheAPI",
// {9deef099-8d1a-568a-1618-08ffbb7146b3}
(0x9deef099,0x8d1a,0x568a,0x16,0x18,0x08,0xff,0xbb,0x71,0x46,0xb3));
So the Guid for TMHP-CacheApp-CacheAPI would be 9deef099-8d1a-568a-1618-08ffbb7146b3. This only works for .NET EventSources btw, other Event Providers may have other ways of setting the guid for a provider.
You can then look for that provider in your Microsoft Message Analyzer, PerfView or any other tool for ETW viewing.
As for the Microsoft supplied Event Providers you have three built-in you should look at for Service Fabric:
Microsoft-ServiceFabric - CBD93BC2-71E5-4566-B3A7-595D8EECA6E8 - These ere the 'low-level' Service Fabric activities
Microsoft-ServiceFabric-Actors - (https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-reliable-actors-diagnostics)
Microsoft-ServiceFabric-Services - https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-reliable-services-diagnostics

How to use a ServiceBus Trigger with a topic/subscription in an Azure Function

I'd like to create an Azure Function that is triggered when a new message is added to a topic/subscription.
For the moment I've created an Azure Function using the ServiceBusQueueTrigger C# Template and I've set the Queue Name to
topicPath + "/Subscriptions/" + subscriptionName
But I've got this exception:
Microsoft.ServiceBus: Cannot get entity 'topic-test/Subscriptions/subscription-test' because it is not of type QueueDescription. Check that you are using method(s) with the correct entity type. System.Runtime.Serialization: Error in line 1 position 1762. Expecting element 'QueueDescription' from namespace 'http://schemas.microsoft.com/netservices/2010/10/servicebus/connect'.. Encountered 'None' with name '', namespace ''. .
I thought the Azure Function was using the MessagingFactory.CreateMessageReceiver to initialize the message pump but not.
Is there any support for topic/subscription for the moment ?
Yes topics are supported, but our UI and templates are behind on that unfortunately - we'll be releasing some updates soon addressing these issues.
For now, you can use the Advanced Editor to edit your trigger binding directly. There you can specify your subscriptionName and topicName values. Here's an example:
{
"bindings": [
{
"type": "serviceBusTrigger",
"name": "message",
"direction": "in",
"subscriptionName": "subscription-test",
"topicName": "topic-test",
}
]
}
In general, since Azure Functions is build atop the WebJobs SDK, our various bindings are mapped directly to their SDK counterparts. For example serviceBusTrigger maps to ServiceBusTriggerAttribute which has SubscriptionName/TopicName properties. Therefore, expect to see the same properties in the Function metadata model.

Getting all files for repository using OctoKit

I want to get all informations about files from my github repository using octokit
projectis: http://octokitnet.readthedocs.org/en/latest/contributing/
Updated:
what I thought I can do is
getAllFilesFromRepository
that will return json with something like example below for all files in repository
{
"type": "symlink",
"target": "/path/to/symlink/target",
"size": 23,
"name": "some-symlink",
"path": "bin/some-symlink",
"sha": "452a98979c88e093d682cab404a3ec82babebb48",
"url": "https://api.github.com/repos/octokit/octokit.rb/contents/bin/some-symlink",
"git_url": "https://api.github.com/repos/octokit/octokit.rb/git/blobs/452a98979c88e093d682cab404a3ec82babebb48",
"html_url": "https://github.com/octokit/octokit.rb/blob/master/bin/some-symlink",
"download_url": "https://raw.githubusercontent.com/octokit/octokit.rb/master/bin/some-symlink",
"_links": {
"git": "https://api.github.com/repos/octokit/octokit.rb/git/blobs/452a98979c88e093d682cab404a3ec82babebb48",
"self": "https://api.github.com/repos/octokit/octokit.rb/contents/bin/some-symlink",
"html": "https://github.com/octokit/octokit.rb/blob/master/bin/some-symlink"
}
}
Please note
I do not want to download any files at all or write query with multiple calls to retrieve the data.
I'm not sure I understand the question, but please read the Getting Started guide first around the setup you need.
This is an example of how to download the contents of a given repository:
var github = new GitHubClient(...); // TODO: other setup
var contents = await github
.Repository
.Content
.GetAllContents("octokit", "octokit.net");
...
var docs = await github
.Repository
.Content
.GetAllContents("octokit", "octokit.net", "docs");
Change the values to suit the repository you're interested in. If you want to download a non-default branch, use GetAllContentsByRef instead.
GetAllContents method would work fine but one small issue is that it would not iterate recursively through all the sub-folders in your repository. It gives only the files and folders present in the top-level. If you want to list out all the files of your repository, I would suggest you to use the GetRecursive method as follows:
var trees = _gitHubClient.Git.Tree.GetRecursive(_config.Owner, _config.RepositoryId, <<APPROPRIATE SHA>>).Result;
You can get the SHA for the latest commit or as per your requirement.This method would give you a tree response which has sufficient details such as the SHA, Path, Type and Size.

RoutingMissingException using NEST IndexMany<>

I've been working on converting my ElasticSearch (ES) 0.9 code to work with ES 1.0. This has required an upgrade of NEST to the latest pre-release version.
I've been trying to bulk index a set of child documents. I've set up their mapping as:
"stocks": {
"_parent": {
"type": "products"
},
"_timestamp": {
"enabled": true
},
"properties": {
"id": {
"type": "integer",
"index": "not_analyzed"
},
"stock": {
"type": "integer",
"index": "not_analyzed"
}
}
}
This was created in ES 0.9. When I've put this into ES 1.0, it automatically adds a Routing property with 'Required' set to 'true'. A search on Google suggests that this was always required to enable a parent-child document setup but the property never explicitly appeared when I examined the documents in my 0.9 shard.
"Ok..." I think to myself. Next, I have the following code block for NEST:
var bulkParams = postQueue.Select(p => new BulkParameters<Stock>(p) { Parent = p.id.ToString()});
IElasticsearchResponse c = ec.IndexMany(bulkParams, null, "stocks").ConnectionStatus;
This returns a NullReferenceException. After some guesswork I added the Id parameter into the BulkParameters:
var bulkParams = postQueue.Select(p => new BulkParameters<Stock>(p) { Id = p.id.ToString(), Parent = p.id.ToString()});
Which seems to work, but the request returns a error response from ES:
400 Bad Request with JSON error message:
error=RoutingMissingException[routing is required for [test_index]/[stocks]/[xx]]
(where xx is the id of the document)
I'm assuming I have to insert a Routing string somewhere, but I do not know where. I've tried adding a 'Routing' parameter into the BulkParameters but that did not work at all. Can anyone please advise?
The support for IndexMany() with wrapped BulkParameters has been removed in NEST 1.0.0 beta 1
If you want to use a bulk with more advanced parameters you now have to use the Bulk() command.
The beta sadly still shipped with the BulkParameters class in the assembly
This has since been removed in the develop branch and will be released in the next beta update.
So what happens now is that you are actually indexing "bulkparameters``1``" type documents and not "stock" with proper individual bulk metadata set.
See here for an example on how to use Bulk() to index many objects at once while configuring advanced parameters for individual items.

Categories