public async Task <SyncDTO> BeginSync(SyncDTO syncDTO) { if (syncDTO.status != AGRConstants.SYNC_TASK.START) { syncDTO.message = "The status of the post data object is inconsistent with the expexted value"; return(syncDTO); } if (syncDTO.id.HasValue && syncDTO.id.Value > 0) { syncDTO.message = "Expected the value of the id property to not be set, ignoring the value sent in."; syncDTO.id = null; } DataWriter.RunNonQueryWithoutParamsStg("erp.truncate_refresh_tables", false); return(await DataWriter.MergeSyncTask(syncDTO)); }
public async Task <SyncDTO> EndSync(SyncDTO syncDTO) { if (syncDTO.status == AGRConstants.SYNC_TASK.START) { syncDTO.message = "The status of the post data object is inconsistent with the expexted value"; return(syncDTO); } if (syncDTO.id == null || syncDTO.id.Value <= 0) { syncDTO.message = "Expected the value of the id property be set, The update failed"; return(syncDTO); } DataWriter.RunNonQueryWithoutParamsStg("erp.merge_refresh_tables", true); return(await DataWriter.MergeSyncTask(syncDTO)); }
public static async Task <SyncDTO> MergeSyncTask(SyncDTO syncDTO) { using (var con = new SqlConnection(StgConnectionString)) { con.Open(); using (var cmd = new SqlCommand("erp.sync_log_update", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@id", syncDTO.id.HasValue ? (object)syncDTO.id.Value : DBNull.Value); cmd.Parameters.AddWithValue("@status", (short)syncDTO.status); cmd.Parameters.AddWithValue("@message", syncDTO.message); var reader = await cmd.ExecuteReaderAsync(); if (reader.HasRows && reader.Read()) { syncDTO.id = reader.GetInt32(0); } return(syncDTO); } } }
public async Task <IHttpActionResult> EndSync([FromBody] SyncDTO syncDTO) { DataContractService service = new DataContractService(); return(Ok(await service.EndSync(syncDTO))); }