Reputation: 4127
I have written this code which accesses the Delete method on Web Service x, I will be creating wrappers for each of the methods but I am hitting a blocker on something probably very simple.
My code consists of three methods:
Here is my current code:
public void Delete(string[] Identifiers, string ObjectType)
{
service.deleteAsync(ObjectType, Identifiers);
service.deleteCompleted += new deleteCompletedEventHandler(service_deleteCompleted);
}
void service_deleteCompleted(object sender, deleteCompletedEventArgs e)
{
StoreResults(e.Result);
if (resultsTable.Rows.Count == totalRecords)
{
CSVFile myFile = new CSVFile(",", true);
myFile.Save(resultsTable, outputPath);
Console.WriteLine("Tasks completed");
}
}
public void StoreResults(DeleteResult[] ResultSet)
{
if (resultsTable.Columns.Count < 1)
{
resultsTable.Columns.Add("ID");
resultsTable.Columns.Add("Errors");
resultsTable.Columns.Add("Success");
}
foreach (DeleteResult r in ResultSet)
{
StringBuilder errors = new StringBuilder();
object[] newRow = new object[3];
newRow[0] = r.id;
if (r.errors != null)
{
newRow[1] = errors[0].ToString();
}
else
newRow[1] = "No Errors to Report";
newRow[2] = r.success.ToString();
resultsTable.Rows.Add(newRow);
}
}
A restriction of the webservice is that I can only pass 50 ID's per call, so I have some background code which manages the chunking of source data, what I need to acheive now is to store all of those results in a data table and pass it back.
Upvotes: 0
Views: 548
Reputation: 161831
You have to subscribe first:
public void Delete(string[] Identifiers, string ObjectType)
{
service.deleteCompleted += service_deleteCompleted;
service.deleteAsync(ObjectType, Identifiers);
}
Upvotes: 2