예제 #1
0
        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;
            }
        }
예제 #2
0
 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();
     }
 }
예제 #3
0
 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();
     }
 }
예제 #4
0
        //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;
        }
예제 #5
0
        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);
        }
예제 #6
0
        //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);
        }
예제 #7
0
 public static string GetFullJobNameByCofigurationJob(CofigurationJob cofigurationJob)
 {
     return(cofigurationJob.JobName + cofigurationJob.Version);
 }
예제 #8
0
        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;
        }
예제 #9
0
 public static string GetFullJobNameByCofigurationJob(CofigurationJob cofigurationJob)
 {
     return cofigurationJob.JobName + cofigurationJob.Version;
 }
예제 #10
0
 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();
     }
 }
예제 #11
0
 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();
     }
 }