public static StoredArgument From(object argument) { return(new StoredArgument { TypeName = SerializationUtilities.PersistedTypeName(argument.GetType()), Value = JToken.FromObject(argument) }); }
static string SerializeExceptionFilters(IEnumerable <ExceptionFilter> exceptionFilters) { return(JsonConvert.SerializeObject( exceptionFilters.Select(f => new StoredExceptionFilter { TypeName = SerializationUtilities.PersistedTypeName(f.Type), Method = f.Method, Arguments = f.Arguments.Select(StoredArgument.From).ToArray() }))); }
public int CountSuspended(Type type) { return (_connection.ExecuteScalar <int>( "select count(*) from DependableJobs " + "where Type = COALESCE(@Type, Type) and suspended = 1 and InstanceName = @InstanceName", new { Type = type != null ? SerializationUtilities.PersistedTypeName(type) : null, InstanceName = _instanceName })); }
void Insert(IEnumerable <Job> jobs) { var table = JobsDataTable.Create(); foreach (var job in jobs) { var r = table.NewRow(); r["Id"] = job.Id; r["Type"] = SerializationUtilities.PersistedTypeName(job.Type); r["Method"] = job.Method; r["Arguments"] = SerializeArguments(job.Arguments); r["CreatedOn"] = job.CreatedOn; r["RootId"] = job.RootId; if (job.ParentId.HasValue) { r["ParentId"] = job.ParentId; } r["CorrelationId"] = job.CorrelationId; r["Status"] = job.Status.ToString(); r["DispatchCount"] = job.DispatchCount; if (job.RetryOn.HasValue) { r["RetryOn"] = job.RetryOn; } r["Continuation"] = JsonConvert.SerializeObject(job.Continuation, DefaultSerializerSettings); r["ExceptionFilters"] = SerializeExceptionFilters(job.ExceptionFilters); r["Suspended"] = job.Suspended; r["InstanceName"] = _instanceName; table.Rows.Add(r); } table.AcceptChanges(); using (var bulkCopy = new SqlBulkCopy(_connection)) { bulkCopy.DestinationTableName = "DependableJobs"; bulkCopy.WriteToServer(table); } }
public IEnumerable <Job> LoadSuspended(Type forActivityType, int max) { return (_connection.Query( string.Format( "select top {0} {1} from DependableJobs " + "where Type = @Type and suspended = 1 and InstanceName = @InstanceName order by CreatedOn", max, Columns), new { Type = SerializationUtilities.PersistedTypeName(forActivityType), InstanceName = _instanceName }) .Select(Deserialize)); }