//-----------------------------------------------------------------------------------------------------------------------------------------// public static void SetDelta(List <SAM_DATA_C> p_ListData, SAM_DATA_C p_RowCurrent, string p_Type) { // Get Previous Record var qry = from tt in p_ListData where tt.ADR_SOURCE.EndsWith(p_Type) && tt.ADR_SOURCE == p_RowCurrent.ADR_SOURCE && tt.ADR_TARGET == p_RowCurrent.ADR_TARGET && tt.DT_UNX < p_RowCurrent.DT_UNX orderby tt.DT_UNX descending select tt; // Set Delta if (qry.Count() > 0) { // Get Previous var p_RowPrevious = qry.First(); // Get Delta Total Int64 p_Total = Convert.ToInt64(p_RowCurrent.TRF_TOTAL - p_RowPrevious.TRF_TOTAL); // Get Delta Second Int64 p_Second = Convert.ToInt64(p_RowCurrent.DT_WIN.Value.Subtract(p_RowPrevious.DT_WIN.Value).TotalSeconds); // Set Delta Value p_RowCurrent.TRF_DELTA = Convert.ToDecimal((p_Total / p_Second) * 8); } }
//-----------------------------------------------------------------------------------------------------------------------------------------// public static Task <int> Step06_Transfer_Data_C(List <SAM_DATA_C> p_ListData) { // Return Async Result return(Task.Run <int>(() => { // Break if (!alfaSAM.IsRunning) { throw new Exception(alfaSAM.BreakMessage); } using (alfaDS DS = new alfaDS()) { // Start DateTime p_Start = DateTime.Now; // Log alfaLog.Add("(ORA) Parallel Transfering DATA_C ... [ Start ]"); // Count int p_Count = 0; foreach (var p_RowCurrent in p_ListData.Where(tt => tt.ADR_SOURCE.EndsWith("c")).ToList()) { // Break if (!alfaSAM.IsRunning) { break; } // Check Double Record if (alfaEntity.SAM_Check_CC(p_RowCurrent) != null) { continue; } // Create SAM_DATA_C p_Row = new SAM_DATA_C(); // SetDelta alfaSAM.SetDelta(p_ListData, p_RowCurrent, "c"); // Assign p_Row.ADR_SOURCE = p_RowCurrent.ADR_SOURCE; p_Row.ADR_TARGET = p_RowCurrent.ADR_TARGET; p_Row.DT_UNX = p_RowCurrent.DT_UNX; p_Row.DT_WIN = p_RowCurrent.DT_WIN; p_Row.TRF_DELTA = p_RowCurrent.TRF_DELTA; p_Row.TRF_TOTAL = p_RowCurrent.TRF_TOTAL; // Add DS.Context.SAM_DATA_C.Add(p_Row); // Save DS.Context.SaveChanges(); // Count p_Count++; } // Log alfaLog.Add("(ORA) Parallel Transfering DATA_C ( " + p_Count.ToString() + " Rows ) ...", alfaDate.GetSec(p_Start)); // Return return p_Count; } })); }