I'm making a web app, for tracking Fedex shipments, I currently have about 10,000-15,000 packages daily. I integrated Fedex Api in my System but it takes more tan 20 minutes to get the status of only 1300 packages. Is there a Way to make this faster? I read that you can send 30 packages in one request but can't find a Way to make it work.
Here is a link to another question, that I found but didn't get it to work
Requesting many tracking numbers with Fedex SOAP API with PHP
CODE
{
TrackRequest request = new TrackRequest();
request.WebAuthenticationDetail = new WebAuthenticationDetail();
request.WebAuthenticationDetail.UserCredential = new WebAuthenticationCredential();
request.WebAuthenticationDetail.UserCredential.Key = ""; // Replace "XXX" with the Key
request.WebAuthenticationDetail.UserCredential.Password = ""; // Replace "XXX" with the Password
request.WebAuthenticationDetail.ParentCredential = new WebAuthenticationCredential();
request.WebAuthenticationDetail.ParentCredential.Key = ""; // Replace "XXX" with the Key
request.WebAuthenticationDetail.ParentCredential.Password = ""; // Replace "XXX"
request.ClientDetail = new ClientDetail();
request.ClientDetail.AccountNumber = ""; // Replace "XXX" with the client's account number
request.ClientDetail.MeterNumber = ""; // Replace "XXX" with the client's meter number
request.TransactionDetail = new TransactionDetail();
request.TransactionDetail.CustomerTransactionId = "***Track Request using VC#***"; //This is a reference field for the customer. Any value can be used and will be provided in the response.
request.Version = new VersionId();
// Tracking information
request.SelectionDetails = new TrackSelectionDetail[1] { new TrackSelectionDetail() };
request.SelectionDetails[0].PackageIdentifier = new TrackPackageIdentifier();
request.SelectionDetails[0].PackageIdentifier.Value = TrackNumberGlobal; //"787883551221" Replace "XXX" with tracking number or door tag
request.SelectionDetails[0].PackageIdentifier.Type = TrackIdentifierType.TRACKING_NUMBER_OR_DOORTAG;
request.ProcessingOptions = new TrackRequestProcessingOptionType[1];
request.ProcessingOptions[0] = TrackRequestProcessingOptionType.INCLUDE_DETAILED_SCANS;
return request;
}
private void TrackReplyy(TrackReply reply)
{
foreach (CompletedTrackDetail completedTrackDetail in reply.CompletedTrackDetails)
{
foreach (TrackDetail trackDetail in completedTrackDetail.TrackDetails)
{
SqlCommand cos = new SqlCommand();
cos.CommandText = "Update estatus_fedex SET estadofedex = @estado WHERE fedextracking = @track";
cos.Parameters.AddWithValue("@estado", trackDetail.StatusDetail.Description);
cos.Parameters.AddWithValue("@track", TrackNumberGlobal);
cos.CommandType = CommandType.Text;
cos.Connection = sqlConn;
cos.ExecuteNonQuery();
if (trackDetail.Events != null)
{
foreach (TrackEvent trackevent in trackDetail.Events)
{
if(trackevent.StatusExceptionCode != null)
{
SqlCommand cmd2 = new SqlCommand();
cmd2.CommandText = "UPDATE estatus_fedex SET ExcpetionCode = @codigo WHERE fedextracking = @param2";
cmd2.Parameters.AddWithValue("@codigo", trackevent.StatusExceptionCode);
cmd2.Parameters.AddWithValue("@param2", TrackNumberGlobal);
cmd2.CommandType = CommandType.Text;
cmd2.Connection = sqlConn;
cmd2.ExecuteNonQuery();
if (trackevent.TimestampSpecified)
{
SqlCommand insert = new SqlCommand();
insert.CommandText = "INSERT INTO EstatusFedexHistorial(FedexTracking,EstadoFedex_Hist,ExceptionCode_Hist,Tiempo_Hist,EventDescription) VALUES (@Track,@Estado,@Excepcion,@Tiempo,@Evento)";
insert.Parameters.AddWithValue("@Track", TrackNumberGlobal);
insert.Parameters.AddWithValue("@Estado", trackDetail.StatusDetail.Description);
insert.Parameters.AddWithValue("@Excepcion", trackevent.StatusExceptionCode);
insert.Parameters.AddWithValue("@Tiempo", trackevent.Timestamp);
insert.Parameters.AddWithValue("@Evento", trackevent.EventDescription);
insert.CommandType = CommandType.Text;
insert.Connection = sqlConn;
insert.ExecuteNonQuery();
}
}
else
{
if (trackevent.TimestampSpecified)
{
SqlCommand sqlc = new SqlCommand();
sqlc.CommandText = "INSERT INTO EstatusFedexHistorial(FedexTracking,EstadoFedex_Hist,Tiempo_Hist,EventDescription) VALUES (@Track,@Estado,@Tiempo,@Evento)";
sqlc.Parameters.AddWithValue("@Track", TrackNumberGlobal);
sqlc.Parameters.AddWithValue("@Estado", trackDetail.StatusDetail.Description);
sqlc.Parameters.AddWithValue("@Tiempo", trackevent.Timestamp);
sqlc.Parameters.AddWithValue("@Evento", trackevent.EventDescription);
sqlc.CommandType = CommandType.Text;
sqlc.Connection = sqlConn;
sqlc.ExecuteNonQuery();
}
}
}
}
}
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "UPDATE EstatusFedexHistorial SET Manifiesto = @manifiesto WHERE FedexTracking = @track";
cmd.Parameters.AddWithValue("@manifiesto", manifiesto);
cmd.Parameters.AddWithValue("@track", TrackNumberGlobal);
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConn;
cmd.ExecuteNonQuery();
}
}