public static List<CdnReceivedFtpFile> GetAllQueued() { // Get all received files at status 60 (Queued) var sql = "SELECT f.Id, f.Filename, f.JsonMessage, r.Status FROM CdnReceives r JOIN CdnReceivedFtpFiles f ON f.Id = r.FtpFileId WHERE r.Status = 60"; using (var connection = new SqlConnection(ConnectionString)) using (var command = new SqlCommand(sql, connection)) { connection.Open(); using (var reader = command.ExecuteReader()) { var receivedFiles = new List<CdnReceivedFtpFile>(); while (reader.Read()) { var receivedFile = new CdnReceivedFtpFile { Id = (int)reader["Id"], Filename = reader["Filename"].ToString(), JsonMessage = reader["JsonMessage"].ToString(), Status = (int)reader["Status"] }; receivedFiles.Add(receivedFile); } return receivedFiles; } } }
public static List <CdnReceivedFtpFile> GetAllQueued() { // Get all received files at status 60 (Queued) var sql = "SELECT f.Id, f.Filename, f.JsonMessage, r.Status FROM CdnReceives r JOIN CdnReceivedFtpFiles f ON f.Id = r.FtpFileId WHERE r.Status = 60"; using (var connection = new SqlConnection(ConnectionString)) using (var command = new SqlCommand(sql, connection)) { connection.Open(); using (var reader = command.ExecuteReader()) { var receivedFiles = new List <CdnReceivedFtpFile>(); while (reader.Read()) { var receivedFile = new CdnReceivedFtpFile { Id = (int)reader["Id"], Filename = reader["Filename"].ToString(), JsonMessage = reader["JsonMessage"].ToString(), Status = (int)reader["Status"] }; receivedFiles.Add(receivedFile); } return(receivedFiles); } } }
static void Main(string[] args) { CdnReceivedFtpFile.ConnectionString = "Data Source=localhost;Initial Catalog=CdnLink;uid=CdnLinkUsr;pwd=CdnLinkPasswd"; // Get the list of updates to process var queuedUpdates = CdnReceivedFtpFile.GetAllQueued(); foreach (var update in queuedUpdates) { try { // Deserialize the file contents into a job (load) object var job = Job.FromString(update.JsonMessage); // // PUT YOUR CODE HERE TO PROCESS THE JOB UPDATE // // For CarDeliveryNetwork.Api.Data.Job docs, see: // http://docs.cardeliverynetwork.com/?topic=html/T_CarDeliveryNetwork_Api_Data_Job.htm // // Mark the update as processed by the client update.SetAsClientProcessed(); } catch (Exception ex) { // Mark this update as errored during processing update.SetAsError("ABC123", ex.Message); // May want to re-throw here to exit, or continue processing other updates // throw; } } }