private void ExecuteJob(vwJobsToExecute job) { string connString = (string.IsNullOrEmpty(job.ConnectionStringToUse)) ? DefaultConnectionString() : job.ConnectionStringToUse; using (var con = new SqlConnection(connString)) { try { con.Open(); using (var cmd = con.CreateCommand()) { cmd.CommandText = job.SqlToExecute; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.ExecuteNonQuery(); } } catch (SqlException) { Trace.TraceError("SqlException"); throw; } } }
private Guid?StartJob(vwJobsToExecute job) { Guid?retValue = null; using (Entities ctx = new Entities()) { var activityIdParam = new ObjectParameter("ActivityId", typeof(Guid?)); ctx.StartJob(job.JobId, activityIdParam); if (activityIdParam.Value != null && activityIdParam.Value.GetType() != typeof(System.DBNull)) { retValue = (Guid)activityIdParam.Value; } } return(retValue); }