private async Task ProcessIpsPendingItem(string ipsEventId, string[] itemList) { var statAdapter = new Adapters.Oal.dbo_status_code_event_newAdapter(); var statPendingPolly = await Policy.Handle <SqlException>(e => e.IsTimeout()) .WaitAndRetryAsync(RetryCount, WaitInterval) .ExecuteAndCaptureAsync(async() => await statAdapter.LoadOneAsync(ipsEventId)); if (null != statPendingPolly.FinalException) { throw new Exception("Process Stat Pending Polly Error", statPendingPolly.FinalException); } var stat = statPendingPolly.Result; var statItems = new List <Adapters.Oal.dbo_status_code_event_new>(); var ipsAdapter = new Adapters.Oal.dbo_ips_importAdapter(); var ipsItems = new List <Adapters.Oal.dbo_ips_import>(); foreach (var item in itemList) { if (IsIpsImportItem(item)) { var ips = await CreateStatIpsImport(stat, item); ipsItems.Add(ips); } } foreach (var item in ipsItems) { var pr = Policy.Handle <SqlException>(e => e.IsDeadlockOrTimeout()) .WaitAndRetryAsync(RetryCount, WaitInterval) .ExecuteAndCaptureAsync(() => ipsAdapter.InsertAsync(item)); var result = await pr; if (result.FinalException != null) { throw result.FinalException; // send to dead letter queue } System.Diagnostics.Debug.Assert(result.Result > 0, "Should be at least 1 row"); } }
private async Task ProcessStatPendingItem(string statEventId, string[] itemList) { var statAdapter = new Adapters.Oal.dbo_status_code_event_newAdapter(); var statPendingPolly = await Policy.Handle <SqlException>(e => e.IsTimeout()) .WaitAndRetryAsync(RetryCount, WaitInterval) .ExecuteAndCaptureAsync(async() => await statAdapter.LoadOneAsync(statEventId)); if (null != statPendingPolly.FinalException) { throw new Exception("Process Stat Pending Polly Error", statPendingPolly.FinalException); } var stat = statPendingPolly.Result; var statItems = new List <Adapters.Oal.dbo_status_code_event_new>(); foreach (var item in itemList) { var console = IsConsole(item); var child = stat.Clone(); child.id = GenerateId(34); child.consignment_no = item; child.data_flag = "1"; child.item_type_code = console ? "02" : "01"; statItems.Add(child); } foreach (var item in statItems) { item.date_created_oal_date_field = item.date_created_oal_date_field.ToValidSqlDateTime(); item.date_field = item.date_field.ToValidSqlDateTime(); var pr = Policy.Handle <SqlException>(e => e.IsDeadlockOrTimeout()) .WaitAndRetryAsync(RetryCount, WaitInterval) .ExecuteAndCaptureAsync(() => statAdapter.InsertAsync(item)); var result = await pr; if (result.FinalException != null) { throw result.FinalException; // send to dead letter queue } System.Diagnostics.Debug.Assert(result.Result > 0, "Should be at least 1 row"); } }