当前位置: 首页>>代码示例>>C#>>正文


C# IState.SerializeData方法代码示例

本文整理汇总了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());
            });
        }
开发者ID:peterdamm,项目名称:Hangfire.Mongo,代码行数:27,代码来源:MongoWriteOnlyTransaction.cs

示例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())
     }));
 }
开发者ID:Trov,项目名称:Hangfire.Mongo,代码行数:12,代码来源:MongoWriteOnlyTransaction.cs

示例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);
            }
        }
开发者ID:krivulcik,项目名称:hangfire-ravendb,代码行数:16,代码来源:RavenWriteOnlyTransaction.cs

示例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);
        }
开发者ID:okusnadi,项目名称:Hangfire.Redis.StackExchange,代码行数:17,代码来源:RedisWriteOnlyTransaction.cs

示例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));
			});
		}
开发者ID:sirchas,项目名称:Hangfire.Mongo,代码行数:22,代码来源:MongoWriteOnlyTransaction.cs

示例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
                }));
        }
开发者ID:AndreyTsvetkov,项目名称:Hangfire,代码行数:19,代码来源:SqlServerWriteOnlyTransaction.cs

示例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())
                }));
        }
开发者ID:AndreyTsvetkov,项目名称:Hangfire,代码行数:17,代码来源:SqlServerWriteOnlyTransaction.cs

示例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);
        }
开发者ID:richardprice,项目名称:HangFire,代码行数:24,代码来源:RedisWriteOnlyTransaction.cs

示例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)));
        }
开发者ID:richardprice,项目名称:HangFire,代码行数:11,代码来源:RedisWriteOnlyTransaction.cs

示例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);
        }
开发者ID:IntranetFactory,项目名称:Hangfire.Redis.StackExchange,代码行数:19,代码来源:RedisWriteOnlyTransaction.cs

示例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);
            }
        }
开发者ID:krivulcik,项目名称:hangfire-ravendb,代码行数:29,代码来源:RavenWriteOnlyTransaction.cs

示例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));
 }
开发者ID:yonglehou,项目名称:Hangfire.Firebird,代码行数:33,代码来源:FirebirdWriteOnlyTransaction.cs

示例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));
        }
开发者ID:andesantis,项目名称:Hangfire.PostgreSql,代码行数:18,代码来源:PostgreSqlWriteOnlyTransaction.cs

示例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));
        }
开发者ID:andesantis,项目名称:Hangfire.PostgreSql,代码行数:26,代码来源:PostgreSqlWriteOnlyTransaction.cs

示例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
            };
        }
开发者ID:cady-io,项目名称:hangfire-ravendb,代码行数:18,代码来源:RavenWriteOnlyTransaction.cs


注:本文中的IState.SerializeData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。