private void InsertRecordJob(T job, CofigurationJob configJob, RunningJob runnerjob) { var xmlObject = SerializeToXml(job); var fullname = typeof(T).FullName; var jobid = JobUtilHelper.InsertRecordJob(xmlObject, fullname, commandJobHandler.CofigurationJob, runnerjob); if (runningJob.JobId == null) { runningJob.JobId = jobid; } }
public static void UpdateStatus(Guid recordid, int status, CofigurationJob cofigurationJob) { using (var connection = GetSqlConnection(GetConectionString())) { var command = new SqlCommand(@"dbo.GS_UpdateRecord", connection); command.Parameters.AddWithValue("@recordid", recordid); command.Parameters.AddWithValue("@status", status); command.Parameters.AddWithValue("@isDelSuccess", cofigurationJob.IsDeleteSuccessRows); // command.Parameters.AddWithValue("@retry", record.Retry); command.CommandType = System.Data.CommandType.StoredProcedure; connection.Open(); command.ExecuteNonQuery(); } }
public static Guid InsertRecordJob(string xmlObject, string fullname, CofigurationJob configJob, RunningJob runnerjob) { using (var connection = GetSqlConnection(GetConectionString())) { var command = new SqlCommand(@"dbo.GS_InsertRecordJob", connection); command.Parameters.AddWithValue("@jobName", JobUtilHelper.GetFullJobNameByCofigurationJob(configJob)); command.Parameters.AddWithValue("@MaxRetries", configJob.MaxRetries); command.Parameters.AddWithValue("@ModelXml", xmlObject); command.Parameters.AddWithValue("@ModelTypeXml", fullname); command.Parameters.AddWithValue("@historyId", runnerjob.ID); command.CommandType = System.Data.CommandType.StoredProcedure; connection.Open(); var jobid = (Guid)command.ExecuteScalar(); return(jobid); //if (runningJob.JobId == null) // runningJob.JobId = (Guid)command.ExecuteScalar(); //else // command.ExecuteNonQuery(); } }
//public static DateTime? GetLastJobDate(CofigurationJob configJob) //{ // DateTime lastDate = DateTime.Now; // bool succeeded = false; // using (var connection = GetSqlConnection(GetConectionString())) // { // SqlCommand command = new SqlCommand(@"dbo.GS_GetLastJobDate", connection); // command.Parameters.AddWithValue("@JobName", GetFullJobNameByCofigurationJob(configJob)); // // command.Parameters.AddWithValue("@MaxRetries", commandJobHandler.CofigurationJob.MaxRetries); // command.CommandType = System.Data.CommandType.StoredProcedure; // connection.Open(); // var drOutput = command.ExecuteReader(); // while (drOutput.Read()) // { // if (DateTime.TryParse(drOutput["StartedAt"].ToString(), out lastDate)) // succeeded = true; // } // } // if (succeeded) // return (DateTime?)lastDate; // else // return null; //} public static Guid? GetJobIdByJobName(CofigurationJob cofigurationJob) { Guid? jobid = null; var jobname = GetFullJobNameByCofigurationJob(cofigurationJob); using (var connection = new SqlConnection(GetConectionString())) { //SqlCommand command = new SqlCommand(@"dbo.GS_GetJobIdByJobName", connection); SqlCommand command = new SqlCommand(@"dbo.GS_GetJobIdByName", connection); command.Parameters.AddWithValue("@jobName", jobname); command.Parameters.AddWithValue("@MaxRetries", cofigurationJob.MaxRetries); command.CommandType = System.Data.CommandType.StoredProcedure; connection.Open(); var returnJobid = command.ExecuteScalar(); if (returnJobid is Guid) { jobid = (Guid)returnJobid; } } return jobid; }
public static DateTime?GetLastJob(CofigurationJob configJob) { DateTime?getlastDate = null; DateTime lastDate = DateTime.Now; int page, total = 0; Guid jobid = Guid.Empty; using (var connection = GetSqlConnection(GetConectionString())) { SqlCommand command = new SqlCommand(@"dbo.GS_GetLastJobDate", connection); command.Parameters.AddWithValue("@JobName", GetFullJobNameByCofigurationJob(configJob)); command.CommandType = System.Data.CommandType.StoredProcedure; connection.Open(); var drOutput = command.ExecuteReader(); ; while (drOutput.Read()) { DateTime.TryParse(drOutput["d"].ToString(), out lastDate); getlastDate = lastDate; } } return(null); }
//public static DateTime? GetLastJobDate(CofigurationJob configJob) //{ // DateTime lastDate = DateTime.Now; // bool succeeded = false; // using (var connection = GetSqlConnection(GetConectionString())) // { // SqlCommand command = new SqlCommand(@"dbo.GS_GetLastJobDate", connection); // command.Parameters.AddWithValue("@JobName", GetFullJobNameByCofigurationJob(configJob)); // // command.Parameters.AddWithValue("@MaxRetries", commandJobHandler.CofigurationJob.MaxRetries); // command.CommandType = System.Data.CommandType.StoredProcedure; // connection.Open(); // var drOutput = command.ExecuteReader(); // while (drOutput.Read()) // { // if (DateTime.TryParse(drOutput["StartedAt"].ToString(), out lastDate)) // succeeded = true; // } // } // if (succeeded) // return (DateTime?)lastDate; // else // return null; //} public static Guid?GetJobIdByJobName(CofigurationJob cofigurationJob) { Guid?jobid = null; var jobname = GetFullJobNameByCofigurationJob(cofigurationJob); using (var connection = new SqlConnection(GetConectionString())) { //SqlCommand command = new SqlCommand(@"dbo.GS_GetJobIdByJobName", connection); SqlCommand command = new SqlCommand(@"dbo.GS_GetJobIdByName", connection); command.Parameters.AddWithValue("@jobName", jobname); command.Parameters.AddWithValue("@MaxRetries", cofigurationJob.MaxRetries); command.CommandType = System.Data.CommandType.StoredProcedure; connection.Open(); var returnJobid = command.ExecuteScalar(); if (returnJobid is Guid) { jobid = (Guid)returnJobid; } } return(jobid); }
public static string GetFullJobNameByCofigurationJob(CofigurationJob cofigurationJob) { return(cofigurationJob.JobName + cofigurationJob.Version); }
public static DateTime? GetLastJob(CofigurationJob configJob) { DateTime? getlastDate = null; DateTime lastDate = DateTime.Now; int page, total = 0; Guid jobid = Guid.Empty; using (var connection = GetSqlConnection(GetConectionString())) { SqlCommand command = new SqlCommand(@"dbo.GS_GetLastJobDate", connection); command.Parameters.AddWithValue("@JobName", GetFullJobNameByCofigurationJob(configJob)); command.CommandType = System.Data.CommandType.StoredProcedure; connection.Open(); var drOutput = command.ExecuteReader(); ; while (drOutput.Read()) { DateTime.TryParse(drOutput["d"].ToString(), out lastDate); getlastDate = lastDate; } } return null; }
public static string GetFullJobNameByCofigurationJob(CofigurationJob cofigurationJob) { return cofigurationJob.JobName + cofigurationJob.Version; }
public static Guid InsertRecordJob(string xmlObject, string fullname, CofigurationJob configJob, RunningJob runnerjob) { using (var connection = GetSqlConnection(GetConectionString())) { var command = new SqlCommand(@"dbo.GS_InsertRecordJob", connection); command.Parameters.AddWithValue("@jobName", JobUtilHelper.GetFullJobNameByCofigurationJob(configJob)); command.Parameters.AddWithValue("@MaxRetries", configJob.MaxRetries); command.Parameters.AddWithValue("@ModelXml", xmlObject); command.Parameters.AddWithValue("@ModelTypeXml", fullname); command.Parameters.AddWithValue("@historyId", runnerjob.ID); command.CommandType = System.Data.CommandType.StoredProcedure; connection.Open(); var jobid = (Guid)command.ExecuteScalar(); return jobid; //if (runningJob.JobId == null) // runningJob.JobId = (Guid)command.ExecuteScalar(); //else // command.ExecuteNonQuery(); } }