I took the event handler out and I'm sure I've tried that before. It's still not working right now. I got 700+ entries in Fiddler this time but, due to randomness of success, this could be less if I run this later on in the day. I've posted the original code and what I've done to it.
Contractor's code:
if (tasksToSend.Count > 0)
{
this.stoneTasks = tasksToSend.ToList();
foreach (AssignTaskCriteria task in tasksToSend)
{
this.MinimumNumberOfRequests = 0;
this.MaximumNumberOfRequests = 0;
this.NumberOfRequestsReceived = 0;
this.IsIndeterminate = false;
this.BusyContent = "Updating the task \n" + "Please wait...";
this.IsBusy = true;
var proxy = new WorkOrderServiceClient();
proxy.AssignCrewCompleted += this.ProxyUpdateTaskCompleted;
proxy.AssignCrewAsync(task, this.currentRequestUserStateID);
this.MaximumNumberOfRequests++;
}
}
My modifications:
if (tasksToSend.Count > 0)
{
this.stoneTasks = tasksToSend.ToList();
this.MinimumNumberOfRequests = 0;
this.MaximumNumberOfRequests = 0;
this.NumberOfRequestsReceived = 0;
WorkOrderServiceClient proxy;
proxy = new WorkOrderServiceClient();
proxy.AssignCrewCompleted += this.ProxyUpdateTaskCompleted;
foreach (AssignTaskCriteria task in tasksToSend)
{
this.IsIndeterminate = false;
this.BusyContent = "Updating the task \n" + "Please wait...";
this.IsBusy = true;
proxy.AssignCrewAsync(task, this.currentRequestUserStateID);
this.MaximumNumberOfRequests++;
}
}
Contractor's complete method... it only used to check the success of the first update because of that max = 0 at the beginning of the loop. I rewrote this whole method.
public void ProxyUpdateTaskCompleted(object sender, AssignCrewCompletedEventArgs e)
{
if (((Guid)e.UserState).CompareTo(this.currentRequestUserStateID) == 0)
{
this.NumberOfRequestsReceived++;
if (this.NumberOfRequestsReceived == this.MaximumNumberOfRequests)
{
if (e.Error == null)
{
if (e.fault == null)
{
if (e.Result != null && e.Result.resultField.CompareTo("SUCCESS") == 0)
{
this.IsBusy = false;
this.DisplayAssignTaskMessage();
this.UpdateViewTaskDataGrid("AssignTask");
this.UpdateTaskOnMap();
this.CloseConfigAssignTask();
}
else
{
this.IsBusy = false;
this.ShowErrorMessage("Error updating the Task \n");
}
}
else
{
this.IsBusy = false;
this.ShowErrorMessage(string.Format("Error updating the Task: {0}", e.fault));
}
}
else
{
this.IsBusy = false;
this.ShowErrorMessage(string.Format("Error updating the Task: {0}", e.Error.Message));
}
}
}
}