Пример #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Open the config file and get the connection string
            Configuration config =
                ConfigurationManager.OpenExeConfiguration
                    (ConfigurationUserLevel.None);
            ConnectionStringsSection css =
                (ConnectionStringsSection)config.GetSection("connectionStrings");

            _connectionString =
                css.ConnectionStrings["LeadResponse"].ConnectionString;

            _instanceStore = new SqlWorkflowInstanceStore(_connectionString);
            InstanceView view = _instanceStore.Execute
                                    (_instanceStore.CreateInstanceHandle(),
                                    new CreateWorkflowOwnerCommand(),
                                    TimeSpan.FromSeconds(30));

            _instanceStore.DefaultInstanceOwner = view.InstanceOwner;

            // Create the DBExtension
            _dbExtension = new DBExtension(_connectionString);

            // Create a service to handle incoming requests
            SetupHost();

            LoadExistingLeads();
        }
Пример #2
0
        private static void CreateInstanceStoreOwner()
        {
            InstanceHandle = InstanceStore.CreateInstanceHandle();

            var ownerCommand = new CreateWorkflowOwnerCommand();

            ownerCommand.InstanceOwnerMetadata.Add(
                WorkflowHostTypePropertyName, new InstanceValue(WorkflowHostTypeName));

            InstanceStore.DefaultInstanceOwner =
                InstanceStore.Execute(InstanceHandle, ownerCommand, TimeSpan.FromSeconds(30)).InstanceOwner;
        }
Пример #3
0
        private static void SetupInstanceStore()
        {
            instanceStore =
                new SqlWorkflowInstanceStore(@"Data Source=.\SQLEXPRESS;Initial Catalog=SampleInstanceStore;Integrated Security=True;Asynchronous Processing=True");

            InstanceHandle handle = instanceStore.CreateInstanceHandle();
            InstanceView   view   = instanceStore.Execute(handle, new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30));

            handle.Free();

            instanceStore.DefaultInstanceOwner = view.InstanceOwner;
        }
Пример #4
0
        private static InstanceOwner CreateWorkflowInstanceOwner(InstanceStore store, InstanceHandle handle)
        {
            var command = new CreateWorkflowOwnerWithIdentityCommand
            {
                InstanceOwnerMetadata =
                {
                    { WorkflowHostTypePropertyName,         new InstanceValue(WorkflowHostType)                    },
                    { DefinitionIdentityFilterPropertyName, new InstanceValue(WorkflowIdentityFilter.Any)          },
                    { DefinitionIdentitiesPropertyName,     new InstanceValue(new Collection <WorkflowIdentity>()) },
                },
            };

            var owner = store.Execute(handle, command, TimeSpan.FromMinutes(1.0)).InstanceOwner;

            return(owner);
        }
Пример #5
0
        // Configure a Default Owner for the instance store so instances can be re-loaded from WorkflowApplication
        private static InstanceHandle CreateInstanceStoreOwner(InstanceStore store, XName wfHostTypeName)
        {
            InstanceHandle ownerHandle = store.CreateInstanceHandle();

            CreateWorkflowOwnerCommand ownerCommand = new CreateWorkflowOwnerCommand()
            {
                InstanceOwnerMetadata =
                {
                    { WorkflowHostTypePropertyName, new InstanceValue(wfHostTypeName) }
                }
            };

            store.DefaultInstanceOwner = store.Execute(ownerHandle, ownerCommand, TimeSpan.FromSeconds(30)).InstanceOwner;

            return(ownerHandle);
        }
Пример #6
0
        /// <summary>
        /// 创建工作流
        /// </summary>
        /// <param name="parameters">传入的参数</param>
        /// <returns>获取工作流实例的Id值</returns>
        public string Create(IDictionary <string, object> parameters)
        {
            _instanceStore = new SqlWorkflowInstanceStore(connectionString);
            InstanceView view = _instanceStore.Execute
                                    (_instanceStore.CreateInstanceHandle(),
                                    new CreateWorkflowOwnerCommand(),
                                    TimeSpan.FromSeconds(30));

            _instanceStore.DefaultInstanceOwner = view.InstanceOwner;

            WorkflowApplication i = new WorkflowApplication(ActivityXamlServices.Load(path), parameters);

            i.InstanceStore   = _instanceStore;
            i.PersistableIdle = (waiea) => PersistableIdleAction.Unload;
            i.Run();
            return(i.Id.ToString());
        }
Пример #7
0
        /// <summary>
        /// 加载工作流
        /// </summary>
        /// <param name="id">工作流的唯一标示</param>
        /// <param name="bookMark">标签名称</param>
        /// <param name="ids">恢复指定名称的书签的时候,传入的参数</param>
        /// <returns>工作流的加载的状态</returns>
        public string Load(string id, object inputs = null)
        {
            _instanceStore = new SqlWorkflowInstanceStore(connectionString);
            InstanceView view = _instanceStore.Execute
                                    (_instanceStore.CreateInstanceHandle(),
                                    new CreateWorkflowOwnerCommand(),
                                    TimeSpan.FromSeconds(30));

            _instanceStore.DefaultInstanceOwner = view.InstanceOwner;

            WorkflowApplication i = new WorkflowApplication(ActivityXamlServices.Load(path));

            i.InstanceStore   = _instanceStore;
            i.PersistableIdle = (waiea) => PersistableIdleAction.Unload;
            i.Load(new Guid(id));
            return(i.ResumeBookmark(bookMark, inputs).GetString());
        }
Пример #8
0
        private static void DeleteWorkflowInstanceOwner(InstanceStore store, InstanceOwner owner, Guid instanceId)
        {
            InstanceHandle handle = null;

            var command = new DeleteWorkflowOwnerCommand();

            try
            {
                handle = store.CreateInstanceHandle(owner, instanceId);
                store.Execute(handle, command, TimeSpan.FromMinutes(1.0));
                store.DefaultInstanceOwner = null;
            }
            finally
            {
                handle?.Free();
            }
        }
Пример #9
0
        private static InstanceHandle CreateOwnerHandle(InstanceStore store)
        {
            var ownerHandle = store.CreateInstanceHandle();

            var instanceView = store.Execute(ownerHandle,
                                             new CreateWorkflowOwnerCommand()
            {
                InstanceOwnerMetadata =
                {
                    { WorkflowHostTypePropertyName, new InstanceValue(HostTypeName) }
                }
            }
                                             , TimeSpan.FromSeconds(5)
                                             );

            store.DefaultInstanceOwner = instanceView.InstanceOwner;

            return(ownerHandle);
        }
Пример #10
0
        static void Main(string[] args)
        {
            InstanceStore store = CreateInstanceStore();
            //InstanceStore store = CreateCustomInstanceStore();

            ItemSupportExtension extension = new ItemSupportExtension();

            extension.AddItemDefinition(101, 1.23M, 10);
            extension.AddItemDefinition(202, 2.34M, 20);
            extension.AddItemDefinition(303, 3.45M, 30);
            DisplayInventory("Before Execution", extension);

            Guid instanceId = Guid.Empty;

            StartNewInstance(ref instanceId, store, extension);
            Boolean isRunning = true;

            while (isRunning)
            {
                Console.WriteLine(
                    "Enter ItemId and Quantity (Ex: 101 1) or [Enter] to quit");
                String input = Console.ReadLine();
                if (!String.IsNullOrEmpty(input))
                {
                    AddItem(instanceId, store, extension, input);
                }
                else
                {
                    OrderComplete(instanceId, store, extension);
                    isRunning = false;
                }
            }

            DisplayInventory("After Execution", extension);

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();

            store.Execute(store.CreateInstanceHandle(),
                          new DeleteWorkflowOwnerCommand(), TimeSpan.FromSeconds(10));
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Open the config file and get the connection string


            Configuration            config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            ConnectionStringsSection css    = (ConnectionStringsSection)config.GetSection("connectionStrings");

            _connectionString = css.ConnectionStrings["LeadGenerator"].ConnectionString;

            _dbExtension   = new DBExtension(_connectionString);
            _instanceStore = new SqlWorkflowInstanceStore(_connectionString);
            InstanceView view = _instanceStore.Execute(_instanceStore.CreateInstanceHandle(), new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30));

            _instanceStore.DefaultInstanceOwner = view.InstanceOwner;


            // Set up the tracking participants
            CreateTrackingParticipant();
            CreateETWTrackingParticipant();
            CreateSqlTrackingParticipant();

            LoadExistingLeads();
        }