We've a requirement to pass a custom query variable to filter the TFS records by running saved TFS query.
As we have #Me, #Project, #Today and [Any] can we use a custom variable like below, if yes how can we do this or is there any better approach for this.
UserEmailAddress = #EmailAddress, to get the records which matches the #EmailAddress which is passed from C# source code and we will add the variable and call the saved TFS query.
var variables = new Dictionary<string, string>() { { "project", "ESE_Proj" }, {"EmailAddress", "test} };
wiQuery = new Query(wiStore(), query.QueryText, variables);
wiTrees = wiQuery.RunLinkQuery();
Field name of a Work Item Type, we have created work item types, say example Person is a work item type with UserEmailAddress as field in it. I want to create a query in tfs such that user can call query from c# by passing email address by taking it from text box and run the query for the entered email address –
You will not be able to store the query in TFS. While you can create and use custom variables in c# with the API TFS has no understanding of them.
You can only use #me, #project, #today, and #currentiteration in a stored query.
Ok, got it. Because the query is also used by the rest of the team in the team explorer. I left the #project in there, but when I need it, I replace #project with the actual project name.
Related
i'am working with thingsboard as a plateform to supervise my sensors ,and i want to know if there is any way to add in my dashboard a field that allow me to write comments and those comments will be written in postgresql database ?
i Tried to use input widget but it dosent work
it's a bit harder to make comments that will not overwrite previous comments since you would keep those comments under server attributes (you can't work with postgreSQL directly from ThingsBoard).
Solution to that is that you have input widget and then RPC call to rule chain where you would need to have some script that would put new comment as new field to the JSON array. This obviously requires a bit advanced knowledge about TB.
Also you could probably do that thru "Custom action (with HTML template)".
UPDATE:
The easiest way you can have comments :
Create JSON server attribute on entity (Device, Asset)
(Optional) Create filter that will return only one entity
Create "Update JSON attribute" widget and point it to the server attribute of entity on which you have done first step (help your self with step 2.)
a. have something like this in that window: {"comments":[{"ts":1665472792000,"value":"My comm1"},{"ts":1668163473000,"value":"My comm2"}]}
Create "HTML Value Card" widget, which also points to that entity and it's server attribute
In "HTML Value Card" widget use this code in server attribute post-processing function:
var comm = parsed["comments"]
var returnValue = '';
if (comm){
var commLength = comm.length;
}
for (var i=0;i<commLength;i++){
returnValue += "<span>"+comm[i]["value"]+"<span><br>";
}
return returnValue;
This code in HTML of "HTML Value Card": ${nameOfYourServerAttribute}
Yes, you will have to manually add comments directly to JSON, I don't have time to write some widget for that.
Take a look at my example:
I'm new to Umbraco, so this may not even be feasible. I've created my own Datatype using Archetype and want to be able to get an instance of that type on the page by type, not alias.
I know that I can do the following:
model.Content.GetPropertyValue("myAlias")
But I want to know if it's feasible to get the property by the type. Something along the lines of:
model.Content.GetPropertiesByType("TypeName")
which would return a list of controls on the page of that type?
Is this feasible?
It's possible, but not exactly straight forward.
Take a look at the available Umbraco Data Services - you'll need to retrieve the DataTypeDefinitions from the DataTypeService and retrieve the ContentType for the Model's IPublishedContent using the ContentTypeService.
Once you have these, you can match up the PropertyTypes on the ContentType with the retrieved DataTypeDefionitions based on the PropertyType's DataTypeDefinitionId.
The PropertyTypes have an Alias property which will match up with the Property Aliases on the Content itself.
You can use the content service if you get the id of the datatype you trying to find the multiples of from the url when you edit/create the datatype.
#foreach (var p in ApplicationContext.Current.Services.ContentService.GetById(Model.Content.Id).PropertyTypes.Where(p => p.DataTypeDefinitionId == -89))
{
<p>#p.DataTypeDefinitionId</p>
}
I'll try to explain what I'm trying to do. I have 2 tables in my application. One is Project and the other is Bug. One proyect can have several bugs.
I'm able to add/edit/delete projects. To each project in the database I added an ActionLink so if you click over its name, it should show all the bugs related to that project.
I tell "should show" because I'm able to see the new page with the ID on the URL which is fine, but I haven't been able to assign a specific Project ID to the BUG.
For example:
BUG has description, status, date...and Project ID (which i would like to use to filter my bugs)
So what I would like to do is to get the ID of the project which has been clicked, so when I hit create action, i can store the ProjectID in the BugDatabase with all other values that are stored automatically by MVC.
Are you passing the value with the action link?
#Html.ActionLink(
"BUG",
"PROJECT",
"Project",
new {
ProjectId = myProjectId,
}
)
As per a question that I asked yesterday I was trying to find a way to dynamically create more text boxes and have those map to my view's model so upon post to the server it will grab all the dynamically(js) generated text boxes and post that to an object such as a List.
To give an example of this confusing question:
I have a textbox that is labeled "Primary Contact" and the ticket creator can enter the contacts name and phone number into this box. What I want to do essentially is, switch this to three text boxes. One for Name, Email and PhoneNumber instead of one box. Then I will create some javascript that will dynamically create three more boxes to add another contact to this List collection. Then when the user submits the form to modify or create the ticket it passes this collection inside the model to the controller. However with petapoco it is a little confusing. Let me show you the controller:
[HttpPost]
public ActionResult ModifyTicket(Ticket model)
{
string userString = User.Identity.Name.Replace("ONHOLD\\", "");
if (ModelState.IsValid)
{
model.CreatedDate = DateTime.Now;
model.LastUpdateBy = Util.GetEmployeeIdByName(userString);
model.LastUpdate = DateTime.Now;
model.IsComplete = false;
model.ClientString = Util.GetClientNameById(model.ClientId);
model.LocationString = Util.GetLocationNameById(model.LocationId);
model.Update();
SuccessMessage = "You have successfully updated ticket number: " + model.TicketId + " for the following client: " + model.ClientString + ".";
return RedirectToAction("Index");
}
ErrorMessage = "Woops! Something went wrong, please check back in a few moments, if the problem persists please contact development.";
return RedirectToAction("Index");
}
The simple answer to this would be that my database model would contain a List object for this exact reason. However, I am using PetaPoco and I'm not entirely sure how it would be done. I could manually add in a collection to my Database model but when I regenerate my model based on any database schema changes I will lose any changes I've made to the file.
I am also using a partial class that my view uses for validation using DataAnnotations. However this class is identical to the database model it just contains DataAnnotations to provide client-side validation.
If anyone understands what I'm trying to accomplish I would be more than happyto provide more information to clarify any missing pieces. I just need a resolution to this as I can't find a solid way to go about resolving this issue!
Not entirely sure what you mean but it's easy to model bind from/to a list with MVC as you may already know. As for saving a deep object like this I'd use the [Ignore] attribute on the Ticket.List so it isn't persisted and handle it separately. I'd load the Contacts in separately from the Ticket object then manually add them to the Ticket object, alternatively use a join query and try the one-to-many approach to load it all in one go.
I think you're expecting Petapoco to update all in one? This won't happen you'll need to break it up. Hard to say from what you've written so far. There won't be a long list of contacts (from the sounds of it) so just insert or update them one by one.
Well that might help, or might not.
I have a Person class with two properties: name and address. I want to build a GSP page which allows for 10 users to be created at one time. This is how I'm implementing it and was wondering if there is a better way:
First, make 20 text boxes in the GSP page - 10 with someperson.name and 10 with someperson.address field names (make these in a loop or code them all individually, doesn't matter).
Second, process the submitted data in the controller. The someperson object has the submitted data, but in a not-so-nice structure ([name: ['Bob', 'John'], address: ['Address 1', 'Address 2']]), so I call transpose() on this to be able to access name, address pairs.
Then, build a list of Person objects using the pairs obtained from the previous step and validate/save them.
Finally, if validation fails (name cannot be null) then do something... don't know what yet! I'm thinking of passing the collection of Person objects to the GSP where they are iterated using a loop and if hasErrors then show them... Don't know how to highlight the fields which failed validation...
So, is there a better way (I should probably ask WHAT IS the better way)?
You should use Grails' data-binding support by declaring a command object like this
class PersonCommand {
List<Person> people = []
}
If you construct your form so that the request parameters are named like this:
person[0].name=bob
person[0].address=england
person[1].name=john
person[1].address=ireland
The data will be automatically bound to the personCommand argument of this controller action
class MyController {
def savePeople = {PersonCommand personCommand->
}
}
If you call personCommand.validate() it might in turn call validate() on each Person in people (I'm not sure). If it doesn't you can do this yourself by calling
boolean allPersonsValid = personCommand.people.every {it.validate()}
At this point you'll know whether all Person instances are valid. If they are not, you should pass the PersonCommand back to the GSP and you can use the Grails tags:
<g:eachError>
<g:hasErrors>
<g:renderErrors>
to highlight the fields in errors. If you're not exactly sure how to use these tags to do the highlight, I suggest you run grails generate-all for a domain class and look at the GSP code it generates.