I am able to successfully create a token, then create a new customer enrolling them in a particular subscription plan.
I cannot figure out how to capture the customer_id that is created for them by Stripe. I need this in order to make changes later (change plan, update CC, etc.). The code I have for creating the customer is below (I use a reader to get fname, lname, etc. and excluded that here for brevity):
private StripeCustomer CreateCustomer()
{
NameValueCollection nvc = Request.Form;
string tokenID = nvc["stripeToken"];
if (tokenID != null)
{
var tokenService = new StripeTokenService();
StripeToken stripeToken = tokenService.Get(tokenID);
}
var myCustomer = new StripeCustomerCreateOptions();
myCustomer.Email = email;
myCustomer.Description = fname + " " + lname + " (" + email + ")";
myCustomer.TokenId = tokenID;
string plan = "basic";
myCustomer.PlanId = plan;
var customerService = new StripeCustomerService();
StripeCustomer CurrentCustomer = customerService.Create(myCustomer);
}
Maybe I am thinking about this incorrectly (must be), but I was looking for the token to provide the CustomerID initially. Here is what that provides:
id: tok_102znI2MdvjLMWitzgclEEcg
livemode: false
created: 1385241151
used: false
object: "token"
type: "card"
card:
id: card_102znI2MdvjLMWitq44B0MY7
object: "card"
last4: "4242"
type: "Visa"
exp_month: 12
exp_year: 2021
fingerprint: "V2WUOPIgMkP5DGGe"
customer: null
country: "US"
name: null
address_line1: null
address_line2: null
address_city: null
address_state: null
address_zip: null
address_country: null
The token is passed back to me before the customer is created, so that obviously doesn't work.
Chris F had the right idea.
After
StripeCustomer CurrentCustomer = customerService.Create(myCustomer);
I simply needed to add something like
string custid = CurrentCustomer.id;
Then add custid to my database.
You can do this also by :
StripeCustomer currentCustomer = customerService.Create(myCustomer);
currentCustomer.StripeCardList.StripeCards.FirstOrDefault().CustomerId;
Related
I'm learning C# since the past week and databases since a couple of days ago, so if you see something dodgy and you ask yourself "Why did he do that like that?", the answer is probably going to be "Because that's all I know for the moment".
In the title I said "of letters" because if I use a string of numbers, it works.
I have a tiny database with three columns. Id (int), FirstName (text) and LastName (text).
Id is unique, primary key and autoincrements. FirstName is unique. The three are not null.
In that database I have two records:
Id FirstName LastName
3- 6666 2222
4- Test O'Test
This is my method:
public static bool isOnDb(string nombre, string apellido)
{
bool flag = false;
{
try
{
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
{
string tempName = "Test"; // This is temporarily replacing the argument 'nombre'
int tempNum= 3; // More testing. See below
//cnn.Query<Person>($"select * from Person where FirstName = { tempName }", new DynamicParameters());
// This four lines below are just for testing. They are going to be deleted
var output = cnn.Query<Person>($"select * from Person where FirstName = { tempName }", new DynamicParameters());
var person = output.First();
Console.WriteLine("Funciona");
Console.WriteLine($"{ person.Id } - { person.FullName }");
flag = true;
return flag;
}
}
catch (Exception)
{
Console.WriteLine("Derecho a excepcion");
return flag;
}
}
}
Basically, if tempName = "Test", it falls into an exception. But if tempName = "6666" it returns the row.
I also tried selecting by id. That's why tempNum is there.
int tempNum= 4;
var output = cnn.Query<Person>($"select * from Person where Id = { tempNum }", new DynamicParameters());
Well in SQLite the strings are signified by '' so when you pass FirstName = { tempName } and its FirstName = Test it looks for the column called Test in Table person rather than equating it to the 'Test' string
So you can do:
var output = cnn.Query<Person>($"select * from Person where FirstName = '{ tempName }'");
Or better yet:
var people = cnn.Query<Person>("SELECT * FROM PERSON WHERE FirstName = #FirstName", new { FirstName = tempName });
Was writing some units using XUnit until that at some points I bumped into something surprising:
let id = Guid.Empty
let contact = {
Name = {
FirstName = "Marcel"
MiddleInitial = None
LastName = "Patulacci"
}
DateOfBith = new DateTime(1850, 12, 25)
Address = {
Address1 = "41 av 8 Mai 1945"
Address2 = None
City = "Sarcelles"
State = None
Zip = "95200"
}
PhoneNumber = {
DialOutCode = 33
LocalNumber = "766030703"
}
Email = "marcel.patulacci#outlook.com"
}
[<Fact>]
let ``Open an account...``() =
let event = Event.AccountOpened({
AccountId = id
Contact = contact
})
let a = [event]
let b = seq { yield event }
Assert.Equal(a, b)
System.NullReferenceException : Object reference not set to an instance of an object.
It seems surprising especially since considering that the overload used by Assert is:
public static void Equal<T>(IEnumerable<T> expected, IEnumerable<T> actual)
Which states that:
Verifies that two sequences are equivalent, using a default comparer.
Why are they considered different, and why does Assert.Equal raise a System.NullReferenceException?
[EDIT]
System.NullReferenceException : Object reference not set to an instance of an object.
at Domain.Events.AccountOpenedEvent.Equals(Object obj, IEqualityComparer comp)
at Domain.Events.Event.Equals(Object obj, IEqualityComparer comp)
Seems
type PersonalName = {
FirstName: string;
MiddleInitial: string option;
LastName: string;
}
type Address = {
Address1: string;
Address2: string option ;
City: string;
State: string option;
Zip: string;
}
type PhoneNumber = {
DialOutCode : int;
LocalNumber: string
}
type Contact = {
Name: PersonalName;
DateOfBith: DateTime
Email: string;
Address: Address;
PhoneNumber: PhoneNumber
}
type AccountOpenedEvent = {
AccountId: Guid
Contact: Contact
}
type Event =
| AccountOpened of AccountOpenedEvent
It turns out one of the fields of event was null, but not event itself.
The problem resided in the id and contact that were defined right above the test / [<Fact>]:
let id = Guid.Empty
let contact = {
Name = {
FirstName = "Marcel"
MiddleInitial = None
LastName = "Patulacci"
}
DateOfBith = new DateTime(1850, 12, 25)
Address = {
Address1 = "41 av 8 Mai 1945"
Address2 = None
City = "Sarcelles"
State = None
Zip = "95200"
}
PhoneNumber = {
DialOutCode = 33
LocalNumber = "766030703"
}
Email = "marcel.patulacci#outlook.com"
}
[<Fact>]
let ``Open an account...``() =
let event = Event.AccountOpened({
AccountId = id
Contact = contact
})
let a = [event]
let b = seq { yield event }
Assert.Equal(a, b)
The thing is when running the test independently the id and contact are not initialized, hence even though event was not null, contact was null (id being a Guid aka a struct it has a value anyway).
Since F# works with structural equality, if one of the field is not initialized it was enough to have a field null to make the Assert failed at some point in its implementation.
There are a few solutions / workarounds:
Defining those variables directly in the unit test body.
Defining methods which produce those values out of the unit test body
let getId() = Guid.Empty
let getContact() = {
Name = {
FirstName = "Marcel"
MiddleInitial = None
LastName = "Patulacci"
}
DateOfBith = new DateTime(1850, 12, 25)
Address = {
Address1 = "41 av 8 Mai 1945"
Address2 = None
City = "Sarcelles"
State = None
Zip = "95200"
}
PhoneNumber = {
DialOutCode = 33
LocalNumber = "766030703"
}
Email = "marcel.patulacci#outlook.com"
}
[<Fact>]
let ``Open an account...``() =
let id = getId()
let contact = getContact()
let event = Event.AccountOpened({
AccountId = id
Contact = contact
})
let a = [event]
let b = seq { yield event }
Assert.Equal(a, b)
While those workarounds work, I am surprised that the variables declared right above the unit test function are not considered when the test is running / and are uninitialized.
It might worth to shoot another question about why this is the case.
This is surprising in the sense that if a function can be defined and returning pretty much the same thing as those variables it means that let is also properly compiled, so why this is not the case with the variables?
I am trying to work with Dictionary<> along with List<> for searching purpose. I know, I can do this easily with List<> as follows:
var con = (from c in db.Customers
where c.Status == status
select c).ToList();
But preferred and tried to implement the above with Dictionary<>. My concept (We all know that) is using the key/value will increase the search option performance. This looks simple and stuck a bit. Here what I've tried:
static void Main(string[] args)
{
Dictionary<string, Customer> custDictionary = new Dictionary<string, Customer>(); //Dictionary declared
List<Customer> lst = new List<Customer>(); //List of objects declared
Customer aCustomer = new Customer(); //Customer object created
/**Assign values - Starts**/
aCustomer.CustomerId = 1001;
aCustomer.CustomerName = "John";
aCustomer.Address = "On Earth";
aCustomer.Status = "Active";
aCustomer.CustomerId = 1002;
aCustomer.CustomerName = "James";
aCustomer.Address = "On Earth";
aCustomer.Status = "Inactive";
/**Assign values - Ends**/
custDictionary.Add(aCustomer.Status, aCustomer); //Added to the dictionary with key and value
string status = Console.ReadLine().ToUpper();
if (custDictionary.ContainsKey(status)) //If key found in the dictionary
{
Customer cust = custDictionary[status];
Console.WriteLine(cust.CustomerId + " " + cust.CustomerName); //Outputs the final result - Right now no result found here
}
Console.ReadKey();
}
public class Customer
{
public int CustomerId { get; set; }
public string CustomerName { get; set; }
public string Address { get; set; }
public string Status { get; set; }
}
Unfortunately, the above doesn't return any result. What I am trying is to get customer details by passing status key and again passed Customer object as the value. I am not sure what I am missing here.
One more thing, in real-life projects, we get database results as list. So in this scenario, if Dictionary<> is used, I believe, the database results should be kept as follows:
lst.Add(aCustomer); //As database will have more result or data simply
On the other hand, I believe, the dictionary should look like the below:
Dictionary<string, List<Customer>> custDictionary = new Dictionary<string, List<Customer>>();
My question - Is it a good idea to pass a list of objects in the dictionary for the key/vale pair and I've tried using so. But didn't get the output yet.
Note: This sounds like a novice question and yes, it's. I've tried to search online and still studying it. I apology to ask such a question and would expect some answers if there are any better ways to do the above.
UPDATED
If you want to store them in a list, you can do the following code. To select the items, you can then use Linq, and in this way you don't have the issue of duplicate values in a dictionary:
var lst = new List<Customer>(); //List of objects declared
lst.AddRange(
new List<Customer>() {
new Customer()
{
CustomerId = 1001,
CustomerName = "John",
Address = "On Earth",
Status = "Active"
},
new Customer()
{
CustomerId = 1002,
CustomerName = "James",
Address = "On Earth",
Status = "Inactive"
}
}
);
var status = Console.ReadLine();
var selected = lst.Where(x => x.Status.ToUpper() == status.ToUpper()).ToList();
foreach (var item in selected)
{
Console.WriteLine(item.CustomerId + " " + item.CustomerName);
}
UPDATE 2
If you want to add the above list in a dictionary, you can do as follows:
var custDictionary = new Dictionary<string, List<Customer>>();
// the above code for the list
custDictionary.Add("keyname", lst);
ORIGINAL ANSWER
You are saving one customer only since you are overwriting the first customer with the second one:
Dictionary<string, Customer> custDictionary = new Dictionary<string, Customer>();
List<Customer> lst = new List<Customer>();
// Add first customer
var aCustomer = new Customer()
{
CustomerId = 1001,
CustomerName = "John",
Address = "On Earth",
Status = "Active"
};
custDictionary.Add(aCustomer.Status.ToUpper(), aCustomer);
// Add second customer
var bCustomer = new Customer()
{
CustomerId = 1002,
CustomerName = "James",
Address = "On Earth",
Status = "Inactive"
};
custDictionary.Add(bCustomer.Status.ToUpper(), bCustomer);
Also you need to store the Status as uppercase, since you are checking if the status exist in uppercase:
string status = Console.ReadLine().ToUpper();
if (custDictionary.ContainsKey(status)) //If key found in the dictionary
{
Customer cust = custDictionary[status];
Console.WriteLine(cust.CustomerId + " " + cust.CustomerName); //Outputs the final result - Right now no result found here
}
Console.ReadKey();
If you already has the list and want to create a Dictionary<string, List<Customer>> you can do it with this:
Dictionary<string, List<Customer>> dict =
list.GroupBy(c=>c.Status.ToUpper()).ToDictionary(g => g.Key, g=> g.ToList());
And iterate it:
foreach (var customer in dict[status.ToUpper()])
{
}
But,
I don't see the value in doing so. if you need to get all the customers with a specific status stay with what you have - a simple linq query.
Even if you are adding status as key, there are 2 problems with your code.
You need to create 2 objects to create 2 customers, one by one. You are adding customer only once, and assigning values twice.
Console.ReadLine().ToUpper() - Remove the ToUpper() since you are adding values in mixed case. If you want to do that, initialize dictionary with StringComparer.InvariantCultureIgnoreCase.
This will work for you.
Dictionary<string, Customer> custDictionary = new Dictionary<string, Customer>(StringComparer.InvariantCultureIgnoreCase); //Dictionary declared
List<Customer> lst = new List<Customer>(); //List of objects declared
Customer aCustomer = new Customer(); //Customer object created
/**Assign values - Starts**/
aCustomer.CustomerId = 1001;
aCustomer.CustomerName = "John";
aCustomer.Address = "On Earth";
aCustomer.Status = "Active";
custDictionary.Add(aCustomer.Status, aCustomer); //Added to the dictionary with key and value
Customer bCustomer = new Customer(); //Customer object created
bCustomer.CustomerId = 1002;
bCustomer.CustomerName = "James";
bCustomer.Address = "On Earth";
bCustomer.Status = "Inactive";
custDictionary.Add(bCustomer.Status, bCustomer); //Added to the dictionary with key and value
string status = Console.ReadLine().ToUpper();
if (custDictionary.ContainsKey(status)) //If key found in the dictionary
{
Customer cust = custDictionary[status];
Console.WriteLine(cust.CustomerId + " " + cust.CustomerName); //Outputs the final result - Right now no result found here
}
Console.ReadLine();
First of all your dictionary key should be customerId not status. it will be a good practice to check if dictionary contains the key other wise it will throw the exception already same key is added. so its better to check then perform add or update in the dictionary.
static void Main(string[] args)
{
Dictionary<string, Customer> custDictionary = new Dictionary<string, Customer>(); //Dictionary declared
List<Customer> lst = new List<Customer>(); //List of objects declared
Customer aCustomer = new Customer(); //Customer object created
/**Assign values - Starts**/
aCustomer.CustomerId = 1001;
aCustomer.CustomerName = "John";
aCustomer.Address = "On Earth";
aCustomer.Status = "Active";
if (!custDictionary.ContainsKey(aCustomer.CustomerId))
custDictionary.Add(aCustomer.CustomerId, aCustomer);
else
custDictionary[aCustomer.CustomerId] = aCustomer;
aCustomer.CustomerId = 1002;
aCustomer.CustomerName = "James";
aCustomer.Address = "On Earth";
aCustomer.Status = "Inactive";
/**Assign values - Ends**/
if (!custDictionary.ContainsKey(aCustomer.CustomerId))
custDictionary.Add(aCustomer.CustomerId, aCustomer);
else
custDictionary[aCustomer.CustomerId] = aCustomer;
string status = Console.ReadLine().ToUpper();
if (custDictionary.ContainsKey(aCustomer.CustomerId)) //If key found in the dictionary
{
Customer cust = custDictionary[aCustomer.CustomerId];
Console.WriteLine(cust.CustomerId + " " + cust.CustomerName); //Outputs the final result - Right now no result found here
}
Console.ReadKey();
}
Your are not getting any output because your are converting your input to uppercase while you have insert the keys in pascalcase and in case of C# collections keys are case sensitive. in this way your input does not matched to any key in collection
change your line number : 29 to this code
string status = Console.ReadLine();
and insert "Inactive" from you console this key exist in your collection
so you will desired result..
I already create extension for APReleaseCheckProcess. I need to send RefNbr of document where DocType = 'REF' (send RefNbr of Vendor Refund) to another database.
I used this code below.
public static class APReleaseCheckProcess
{
public static void APPaymentRowPersisted(PXCache sender, PXRowPersistedEventArgs e)
{
string serverJade, dbJade, userJade, passJade;
serverJade = "BS-DEV64\\SQL2014"; //--- Server Jade : 192.168.10.13
dbJade = "SGL"; //--- DB Jade Live : SGL || DB Jade test : SGL_TEST
userJade = "sa"; //--- User ID : sa
passJade = "Admin1"; //--- Password : sa_091073
if (e.TranStatus == PXTranStatus.Completed && e.Operation == PXDBOperation.Update)
{
var doc = e.Row as APPayment;
#region Doc Type = Vendor Refund
if (doc != null && doc.Released == true && doc.DocType == "REF")
{
foreach (APAdjust oldadj in PXSelect<APAdjust,
Where<
APAdjust.adjgDocType, Equal<Required<APPayment.docType>>,
And<APAdjust.adjgRefNbr, Equal<Required<APPayment.refNbr>>,
And<APAdjust.adjNbr, Less<Required<APPayment.lineCntr>>>>>>
.Select(sender.Graph, doc.DocType, doc.RefNbr, doc.LineCntr))
{
string refNbr = oldadj.AdjdRefNbr;
string docType = oldadj.AdjdDocType;
// I need to retrieve InvoiceNbr from this query below using BQL statement:
string InvNbr = "select InvoiceNbr from APInvoice where CompanyID = 2 and RefNbr = refnbr";
// query to send to another database
using (SqlConnection conJade = new SqlConnection("server = " + serverJade + "; database = " + dbJade + "; user = " + userJade + "; password = " + passJade + ""))
{
string qRefund = "update b set b.cano = "+doc.RefNbr+"" +
"from evmaster as b " +
"inner join evmaster as a on a.svno = b.vchno " +
"where a.vchno = "+InvNbr+"";
conJade.Open();
using (SqlCommand comJade = new SqlCommand(qRefund, conJade))
{
SqlDataReader sdr = comJade.ExecuteReader();
sdr.Close();
}
}
}
}
#endregion
}
}
}
How to write the code to generate query above using BQL in Acumatica Customize project.
Assuming you want to run the query for the company of the logged in user, without error checking that would be:
((APInvoice)PXSelect<APInvoice, Where<APInvoice.refNbr, Equal<Required<APInvoice.refNbr>>>>.Select(sender.Graph, refNbr)).InvoiceNbr
If you need to run the query for a company other than the company of the logged in user, the recommended way is to put the data in a table without a CompanyID field.
The isolation of companies is strongly enforced by BQL, and you won't be able to retrieve data from another company unless you're logged into this company. The ORM also takes care of returning you the data from other company IDs if this data is split/shared with another company. For tables that don't contain a CompanyID field, the system returns all the data contained in this table.
I'm trying to write a project reporting tool in WPF / C#. I want to access all the project names on our TFS (Team Foundation Server), and then display statistics for each work item in a given project.
I've got the project names, but getting the actual work items is what's giving me a hard time. Here's what I've got so far:
public const string tfsLocation = "http://whatever";
// get the top list of project names from the team foundation server
public List<string> LoadProjectList()
{
var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tfsLocation));
var workItemStore = new WorkItemStore(tpc);
var projects = (from Project project in workItemStore.Projects select project.Name).ToList();
return projects;
}
public string GetProjectInfo(string targetProject)
{
string info = String.Empty;
var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tfsLocation));
var workItemStore = new WorkItemStore(tpc);
foreach (Project project in workItemStore.Projects)
{
if (project.Name == targetProject)
{
info += String.Format("Project: {0}\n\n", project.Name);
info += "Work Item Types:\n";
foreach (WorkItemType item in project.WorkItemTypes)
{
info += String.Format("- {0}\n", item.Name);
info += String.Format(" - Description: {0}\n", item.Description);
info += " - Field Definitions:\n";
foreach (FieldDefinition field in item.FieldDefinitions)
{
info += String.Format(" - {0}\n", field.Name);
}
info += "\n";
}
}
}
return info;
}
GetProjectInfo sends back some helpful info about what's in each project, but so far it looks like I'm only seeing the definitions of what the WorkItems consist of, and not the actual WorkItems themselves. I think the programming I've written is looking in the wrong place.
From Microsoft's definition of WorkItem,
(http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.workitemtracking.client.workitem.aspx)
it looks like it's inside WorkItemTracking.Client, but not inside the WorkItemStore, and I'm not sure where to go to access it.
FINAL VERSION:
Here's the updated version of my function, after referencing the below answer. This just returns a long string of the work item names with new lines between, for printing out, which is all I'm trying to get working (for now).
public string GetProjectInfo(string targetProject)
{
string info = String.Empty;
var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tfsLocation));
WorkItemStore workItemStore = new WorkItemStore(tpc);
Query query = new Query(workItemStore, "SELECT * FROM WorkItems WHERE [System.TeamProject] = #project", new Dictionary<string, string>() { { "project", targetProject } });
WorkItemCollection wic = query.RunQuery();
foreach (WorkItem item in wic)
{
info += String.Format("{0}\n", item.Title);
}
return info;
}
You need to use WIQL queries to get actual work items you are interested in, e.g. to get all work items for a particular project:
using Microsoft.TeamFoundation.WorkItemTracking.Client;
Query query = new Query(
workItemStore,
"select * from issue where System.TeamProject = #project",
new Dictionary<string, string>() { { "project", project.Name } }
);
var workItemCollection = query.RunQuery();
foreach(Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem workItem in workItemCollection)
{
/*Get work item properties you are interested in*/
foreach(Microsoft.TeamFoundation.WorkItemTracking.Client.Field field in workItem.Fields)
{
/*Get field value*/
info += String.Format("Field name: {0} Value: {1}\n", field.Name, field.Value);
}
}
I do need to extract the linked Work Item (Testcases) as well with the Bug. I have created a query and it extracts both. But my issue is while i print the Work Items Fields, All of the prints separately, with no trace of which Bug is linked to which Testcase. How can I achieve that.
public async Task<IList<WorkItem>> QueryOpenBugs(string project)
{
var credentials = new VssBasicCredential(string.Empty, this.personalAccessToken);
// create a wiql object and build our query
var wiql = new Wiql()
{
// NOTE: Even if other columns are specified, only the ID & URL are available in the WorkItemReference
//Query = "Select [Id] " +
// "From WorkItems " +
// "Where [Work Item Type] = 'Bug' " +
// "And [System.TeamProject] = '" + project + "' " +
// "And [System.State] = 'Resolved' " +
// "Order By [State] Asc, [Changed Date] Desc",
Query = "Select [System.Id],[System.WorkItemType],[System.Title]" +
"From workitemLinks " +
"Where ([Source].[System.WorkItemType] = 'Bug' " +
"And [Source].[System.TeamProject] = '" + project + "' " +
"And [Source].[System.State] = 'Resolved' )" +
"And ([Target].[System.TeamProject] = '" + project + "' " +
"And [Target].[System.WorkItemType] = 'Test Case' )",
};
using (var httpClient = new WorkItemTrackingHttpClient(this.uri, credentials))
{
// execute the query to get the list of work items in the results
var result = await httpClient.QueryByWiqlAsync(wiql).ConfigureAwait(false);
var ids = result.WorkItemRelations.Select(item => item.Target.Id).ToArray();
// some error handling
if (ids.Length == 0)
{
return Array.Empty<WorkItem>();
}
// build a list of the fields we want to see
var fields = new[] { "System.Id", "System.Title", "System.State" , "System.IterationPath", "System.Tags", "Microsoft.VSTS.Common.StateChangeDate", "System.WorkItemType", "Microsoft.VSTS.TCM.AutomationStatus"};
// get work items for the ids found in query
return await httpClient.GetWorkItemsAsync(ids, fields, result.AsOf).ConfigureAwait(false);
}
}
/// <summary>
/// Execute a WIQL (Work Item Query Language) query to print a list of open bugs.
/// </summary>
/// <param name="project">The name of your project within your organization.</param>
/// <returns>An async task.</returns>
public async Task PrintOpenBugsAsync(string project)
{
var workItems = await this.QueryOpenBugs(project).ConfigureAwait(false);
Console.WriteLine("Query Results: {0} items found", workItems.Count);
// loop though work items and write to console
//Select - BugID , TestCaseID , TestSuiteID{} , ResolvedDate , AutomationStatus{}
foreach (var workItem in workItems)
{
string WorkItemType = (string)workItem.Fields["System.WorkItemType"];
if (WorkItemType == "Bug")
{
Console.WriteLine("The Bugs are:\n\n");
Console.WriteLine(
"{0}\t{1}\t{2}\t{3}\t{4}",
workItem.Id,
workItem.Fields["System.Title"],
workItem.Fields["System.State"],
// workItem.Fields["System.RelatedLinks"],
workItem.Fields["Microsoft.VSTS.Common.StateChangeDate"],
workItem.Fields["System.WorkItemType"]);
Console.WriteLine("\n");
}
else
{
Console.WriteLine("The TestCases are:\n\n");
Console.WriteLine(
"{0}\t{1}\t{2}\t{3}\t{4}",
workItem.Id,
workItem.Fields["System.Title"],
workItem.Fields["System.State"],
workItem.Fields["Microsoft.VSTS.TCM.AutomationStatus"],
workItem.Fields["System.WorkItemType"]);
Console.WriteLine("\n");
}