本文整理汇总了C#中IState.SerializeData方法的典型用法代码示例。如果您正苦于以下问题:C# IState.SerializeData方法的具体用法?C# IState.SerializeData怎么用?C# IState.SerializeData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IState
的用法示例。
在下文中一共展示了IState.SerializeData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetJobState
public void SetJobState(string jobId, IState state)
{
QueueCommand(x =>
{
List<Task> tasks = new List<Task>();
StateDto stateDto = new StateDto
{
Id = ObjectId.GenerateNewId(),
JobId = int.Parse(jobId),
Name = state.Name,
Reason = state.Reason,
CreatedAt = _connection.GetServerTimeUtc(),
Data = JobHelper.ToJson(state.SerializeData())
};
tasks.Add(x.State.InsertOneAsync(stateDto));
tasks.Add(x.Job.UpdateManyAsync(
Builders<JobDto>.Filter.Eq(_ => _.Id, int.Parse(jobId)),
Builders<JobDto>.Update.Set(_ => _.StateId, stateDto.Id)));
tasks.Add(x.Job.UpdateManyAsync(Builders<JobDto>.Filter.Eq(_ => _.Id, int.Parse(jobId)),
Builders<JobDto>.Update.Set(_ => _.StateName, state.Name)));
return Task.WhenAll(tasks.ToArray());
});
}
示例2: AddJobState
public override void AddJobState(string jobId, IState state)
{
QueueCommand(x => x.State.InsertOne(new StateDto
{
Id = ObjectId.GenerateNewId(),
JobId = int.Parse(jobId),
Name = state.Name,
Reason = state.Reason,
CreatedAt = _connection.GetServerTimeUtc(),
Data = JobHelper.ToJson(state.SerializeData())
}));
}
示例3: AddJobState
public override void AddJobState(string jobId, IState state)
{
using (var repository = new Repository()) {
var jobState = new State
{
Id = Guid.NewGuid().ToString(),
JobId = jobId,
Name = state.Name,
Reason = state.Reason,
CreatedAt = DateTime.UtcNow,
Data = JobHelper.ToJson(state.SerializeData())
};
repository.Save(jobState);
}
}
示例4: SetJobState
public void SetJobState(string jobId, IState state)
{
Transaction.HashSetAsync(String.Format(Prefix + "job:{0}", jobId), "State", state.Name);
Transaction.KeyDeleteAsync(String.Format(Prefix + "job:{0}:state", jobId));
var Serialized = new Dictionary<string,string>(state.SerializeData());
Serialized.Add("State", state.Name);
if (state.Reason != null)
{
Serialized.Add("Reason", state.Reason);
}
Transaction.HashSetAsync(String.Format(Prefix + "job:{0}:state", jobId), Serialized.ToHashEntryArray());
AddJobState(jobId, state);
}
示例5: SetJobState
public void SetJobState(string jobId, IState state)
{
QueueCommand(x =>
{
StateDto stateDto = new StateDto
{
Id = ObjectId.GenerateNewId(),
JobId = int.Parse(jobId),
Name = state.Name,
Reason = state.Reason,
CreatedAt = _connection.GetServerTimeUtc(),
Data = JobHelper.ToJson(state.SerializeData())
};
x.State.Insert(stateDto);
x.Job.Update(Query<JobDto>.EQ(_ => _.Id, int.Parse(jobId)),
Update<JobDto>.Set(_ => _.StateId, stateDto.Id));
x.Job.Update(Query<JobDto>.EQ(_ => _.Id, int.Parse(jobId)),
Update<JobDto>.Set(_ => _.StateName, state.Name));
});
}
示例6: SetJobState
public override void SetJobState(string jobId, IState state)
{
string addAndSetStateSql = string.Format(@"
insert into [{0}].State (JobId, Name, Reason, CreatedAt, Data)
values (@jobId, @name, @reason, @createdAt, @data);
update [{0}].Job set StateId = SCOPE_IDENTITY(), StateName = @name where Id = @id;", _storage.GetSchemaName());
QueueCommand(x => x.Execute(
addAndSetStateSql,
new
{
jobId = jobId,
name = state.Name,
reason = state.Reason,
createdAt = DateTime.UtcNow,
data = JobHelper.ToJson(state.SerializeData()),
id = jobId
}));
}
示例7: AddJobState
public override void AddJobState(string jobId, IState state)
{
string addStateSql = string.Format(@"
insert into [{0}].State (JobId, Name, Reason, CreatedAt, Data)
values (@jobId, @name, @reason, @createdAt, @data)", _storage.GetSchemaName());
QueueCommand(x => x.Execute(
addStateSql,
new
{
jobId = jobId,
name = state.Name,
reason = state.Reason,
createdAt = DateTime.UtcNow,
data = JobHelper.ToJson(state.SerializeData())
}));
}
示例8: SetJobState
public void SetJobState(string jobId, IState state)
{
_transaction.QueueCommand(x => x.SetEntryInHash(
String.Format(RedisStorage.Prefix + "job:{0}", jobId),
"State",
state.Name));
_transaction.QueueCommand(x => x.RemoveEntry(
String.Format(RedisStorage.Prefix + "job:{0}:state", jobId)));
var storedData = new Dictionary<string, string>(state.SerializeData());
storedData.Add("State", state.Name);
if (state.Reason != null)
{
storedData.Add("Reason", state.Reason);
}
_transaction.QueueCommand(x => x.SetRangeInHash(
String.Format(RedisStorage.Prefix + "job:{0}:state", jobId),
storedData));
AddJobState(jobId, state);
}
示例9: AddJobState
public void AddJobState(string jobId, IState state)
{
var storedData = new Dictionary<string, string>(state.SerializeData());
storedData.Add("State", state.Name);
storedData.Add("Reason", state.Reason);
storedData.Add("CreatedAt", JobHelper.ToStringTimestamp(DateTime.UtcNow));
_transaction.QueueCommand(x => x.EnqueueItemOnList(
String.Format(RedisStorage.Prefix + "job:{0}:history", jobId),
JobHelper.ToJson(storedData)));
}
示例10: SetJobState
public void SetJobState(string jobId, IState state)
{
_transaction.HashSetAsync(
String.Format(RedisStorage.Prefix + "job:{0}", jobId),
"State",
state.Name);
_transaction.KeyDeleteAsync(String.Format(RedisStorage.Prefix + "job:{0}:state", jobId));
var storedData = new Dictionary<string, string>(state.SerializeData());
storedData.Add("State", state.Name);
if (state.Reason != null)
{
storedData.Add("Reason", state.Reason);
}
_transaction.HashSetAsync(String.Format(RedisStorage.Prefix + "job:{0}:state", jobId),storedData.ToHashEntries());
AddJobState(jobId, state);
}
示例11: SetJobState
public override void SetJobState(string jobId, IState state)
{
using (var repository = new Repository()) {
var jobState = repository.Session.Query<State>().FirstOrDefault(t => t.JobId == jobId);
if (jobState == null) {
jobState = new State
{
CreatedAt = DateTime.UtcNow,
JobId = jobId
};
}
jobState.Reason = state.Reason;
jobState.Name = state.Name;
jobState.Data = JobHelper.ToJson(state.SerializeData());
repository.Save(jobState);
var result = repository.Session.Load<RavenJob>(jobId);
result.StateId = jobState.Id;
result.StateName = state.Name;
result.StateData = JobHelper.ToJson(state.SerializeData());
result.StateReason = state.Reason;
repository.Save(result);
}
}
示例12: SetJobState
public void SetJobState(string jobId, IState state)
{
string addAndSetStateSql = string.Format(@"
EXECUTE BLOCK (jobid INTEGER = @jobid,
name VARCHAR(20) CHARACTER SET UNICODE_FSS = @name,
reason VARCHAR(100) CHARACTER SET UNICODE_FSS = @reason,
createdat TIMESTAMP = @createdat,
data BLOB SUB_TYPE 1 SEGMENT SIZE 80 CHARACTER SET UNICODE_FSS = @data,
id INTEGER = @id)
AS
DECLARE VARIABLE stateid int;
BEGIN
INSERT INTO ""{0}.STATE"" (jobid, name, reason, createdat, data)
VALUES (:jobid, :name, :reason, :createdat, :data) RETURNING id INTO :stateid;
UPDATE ""{0}.JOB""
SET stateid = :stateid, statename = :name WHERE id = :id;
SUSPEND;
END", _options.Prefix);
QueueCommand((con, trx) => con.Execute(
addAndSetStateSql,
new
{
jobId = jobId,
name = state.Name,
reason = state.Reason,
createdAt = DateTime.UtcNow,
data = JobHelper.ToJson(state.SerializeData()),
id = jobId
}, trx));
}
示例13: AddJobState
public void AddJobState(string jobId, IState state)
{
string addStateSql = @"
INSERT INTO """ + _options.SchemaName + @""".""state"" (""jobid"", ""name"", ""reason"", ""createdat"", ""data"")
VALUES (@jobId, @name, @reason, @createdAt, @data);
";
QueueCommand((con, trx) => con.Execute(
addStateSql,
new
{
jobId = Convert.ToInt32(jobId, CultureInfo.InvariantCulture),
name = state.Name,
reason = state.Reason,
createdAt = DateTime.UtcNow,
data = JobHelper.ToJson(state.SerializeData())
}, trx));
}
示例14: SetJobState
public void SetJobState(string jobId, IState state)
{
string addAndSetStateSql = @"
WITH s AS (
INSERT INTO """ + _options.SchemaName + @""".""state"" (""jobid"", ""name"", ""reason"", ""createdat"", ""data"")
VALUES (@jobId, @name, @reason, @createdAt, @data) RETURNING ""id""
)
UPDATE """ + _options.SchemaName + @""".""job"" j
SET ""stateid"" = s.""id"", ""statename"" = @name
FROM s
WHERE j.""id"" = @id;
";
QueueCommand((con, trx) => con.Execute(
addAndSetStateSql,
new
{
jobId = Convert.ToInt32(jobId, CultureInfo.InvariantCulture),
name = state.Name,
reason = state.Reason,
createdAt = DateTime.UtcNow,
data = JobHelper.ToJson(state.SerializeData()),
id = Convert.ToInt32(jobId,CultureInfo.InvariantCulture)
}, trx));
}
示例15: SetJobState
public override void SetJobState(string jobId, IState state)
{
var id = Repository.GetId(typeof(RavenJob), jobId);
var result = _session.Load<RavenJob>(id);
result.History.Insert(0, new StateHistoryDto() {
StateName = state.Name,
Data = state.SerializeData(),
Reason = state.Reason,
CreatedAt = DateTime.UtcNow
});
result.StateData = new StateData() {
Name = state.Name,
Data = state.SerializeData(),
Reason = state.Reason
};
}