Beispiel #1
0
        public List <Workflow> LoadExistingWorkflowsByExternalId(string key)
        {
            SqlManager sql = (SqlManager)Services.GetService(typeof(SqlManager));
            Func <DynObject, string> func = (d) => DynObjectSerializer.Serialize(d).ToString(Newtonsoft.Json.Formatting.None);
            var store = new WorkflowStoreSql(sql, func);

            List <Workflow> workflows = store.LoadByExternalId(key);

            return(workflows);
        }
Beispiel #2
0
        public void InitializeWorkflow()
        {
            var config = new SqlManagerConfiguration()
            {
                ConnectionString      = "Data Source=L00280\\SQLEXPRESS;Initial Catalog=Workflow;Integrated Security=True",
                ProviderInvariantName = "SqlClient"
            };

            DbProviderFactories.RegisterFactory(config.ProviderInvariantName, SqlClientFactory.Instance);

            var serializer = new PartialJsonWorkflowSerializer();

            WorkflowFactory factory = new WorkflowFactory <RunContext>(null, null)
            {
                Serializer = serializer,
            };


            WorkflowStoreSql store = new WorkflowStoreSql(new Bb.Dao.SqlManager(config), factory);



            var w = new Workflow()
            {
                Uuid         = Guid.NewGuid(),
                ExternalId   = Guid.NewGuid().ToString(),
                Change       = ChangeEnum.New,
                Concurency   = 1,
                CreationDate = DateTimeOffset.Now,
                Version      = 1,
                WorkflowName = "work1",
            }.AddEvents
            (
                new Event()
            {
                Uuid         = Guid.NewGuid(),
                Name         = "Event1",
                Change       = ChangeEnum.New,
                CreationDate = DateTimeOffset.Now,
                EventDate    = DateTimeOffset.Now.AddMinutes(-5),
                FromState    = "State1",
                ToState      = "State2",
            }
                .AddActions
                (
                    new PushedAction
            {
                Uuid           = Guid.NewGuid(),
                Name           = Constants.PushReminder,
                Kind           = Constants.PushActionName,
                Change         = ChangeEnum.New,
                ExecuteMessage = new MessageRaw()
                {
                    Header = new MessageHeader(null),
                    Body   = (MessageBlock) new DynObject()
                             .Add("name", "callMethod1")
                             .Add("arguments", new DynObject()
                                  .Add("arg1", "a1")
                                  .Add("arg2", "a2")
                                  ).Resolve(null),
                }
            }
                )
            );

            store.Save(w);

            var items = store.LoadByExternalId(w.ExternalId).First();
        }