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
            LoadExistingLeads();
            SetupHost();

            
        }
コード例 #2
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["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();



        }
コード例 #3
0
 /// <summary>
 /// Creates a test host
 /// </summary>
 /// <param name="instanceStore">
 /// The instance store. 
 /// </param>
 /// <returns>
 /// The test host 
 /// </returns>
 private static WorkflowApplicationTest<ActivityWithDelay> CreateTestHost(InstanceStore instanceStore)
 {
     var host = WorkflowApplicationTest.Create(new ActivityWithDelay());
     Debug.Assert(host != null, "host != null");
     host.InstanceStore = instanceStore;
     host.PersistableIdle += args => PersistableIdleAction.Unload;
     return host;
 }
コード例 #4
0
 internal InstanceHandle(InstanceStore store, InstanceOwner owner)
 {
     this.thisLock = new object();
     this.Version = -1L;
     this.Store = store;
     this.Owner = owner;
     this.View = new InstanceView(owner);
     this.IsValid = true;
 }
コード例 #5
0
 internal InstanceHandle(InstanceStore store, InstanceOwner owner)
 {
     this.thisLock = new object();
     this.Version  = -1L;
     this.Store    = store;
     this.Owner    = owner;
     this.View     = new InstanceView(owner);
     this.IsValid  = true;
 }
コード例 #6
0
ファイル: InstanceHandle.cs プロジェクト: uQr/referencesource
        internal InstanceHandle(InstanceStore store, InstanceOwner owner)
        {
            Fx.Assert(store != null, "Shouldn't be possible.");

            Version = -1;
            Store = store;
            Owner = owner;
            View = new InstanceView(owner);
            IsValid = true;
        }
コード例 #7
0
ファイル: InstanceHandle.cs プロジェクト: dox0/DotNet471RS3
        internal InstanceHandle(InstanceStore store, InstanceOwner owner)
        {
            Fx.Assert(store != null, "Shouldn't be possible.");

            Version = -1;
            Store   = store;
            Owner   = owner;
            View    = new InstanceView(owner);
            IsValid = true;
        }
コード例 #8
0
        internal PersistenceProviderDirectory(InstanceStore store, InstanceOwner owner, IDictionary<XName, InstanceValue> instanceMetadataChanges, WorkflowDefinitionProvider workflowDefinitionProvider, WorkflowServiceHost serviceHost,
            DurableConsistencyScope consistencyScope, int maxInstances)
            : this(workflowDefinitionProvider, serviceHost, consistencyScope, maxInstances)
        {
            Fx.Assert(store != null, "InstanceStore must be specified on PPD.");
            Fx.Assert(owner != null, "InstanceOwner must be specified on PPD.");

            this.store = store;
            this.owner = owner;
            this.InstanceMetadataChanges = instanceMetadataChanges;
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: tian1ll1/WPF_Examples
        // Creates and configures a new instance of WorkflowApplication
        private static WorkflowApplication CreateWorkflowApplication(Activity rootActivity, InstanceStore store, XName wfHostTypeName)
        {
            WorkflowApplication wfApp = new WorkflowApplication(rootActivity);

            wfApp.InstanceStore = store;

            Dictionary<XName, object> wfScope = new Dictionary<XName, object>
            {
                 { WorkflowHostTypePropertyName, wfHostTypeName }
            };

            // Add the WorkflowHostType value to workflow application so that it stores this data in the instance store when persisted
            wfApp.AddInitialInstanceValues(wfScope);

            // This statement is optional (see the comments in AbsoluteDelay.CacheMetadata details for more info).
            // wfApp.Extensions.Add<DurableTimerExtension>(() => new DurableTimerExtension());

            // For demonstration purposes the workflow is unloaded as soon as it is idle (and able to persist)
            wfApp.PersistableIdle = delegate(WorkflowApplicationIdleEventArgs idleArgs)
            {
                Console.WriteLine("Workflow unloading...");
                return PersistableIdleAction.Unload;
            };

            // Configure some tracing and synchronization for the other WorkflowApplication events

            wfApp.Unloaded = delegate(WorkflowApplicationEventArgs eargs)
            {
                if (!workflowCompleted)
                {
                    Console.WriteLine("Workflow unloaded");
                }
                else
                {
                    Console.WriteLine("Workflow unloaded after completing");
                }

                workflowUnloadedEvent.Set();
            };

            wfApp.Completed = delegate
            {
                Console.WriteLine("Workflow completed");
                workflowCompleted = true;
            };

            wfApp.Aborted = delegate(WorkflowApplicationAbortedEventArgs abortArgs)
            {
                Console.WriteLine("Workflow aborted (expected in this sample)");
            };

            return wfApp;
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: object/CloudWorkflows
 static WorkflowApplication CreateWorkflowApplication(AccumulatorActivity activity, InstanceStore instanceStore)
 {
     var application = new WorkflowApplication(activity);
     application.InstanceStore = instanceStore;
     application.Completed = new Action<WorkflowApplicationCompletedEventArgs>((e) =>
     {
         _result = (int)e.Outputs["Sum"];
         _more = false;
         _event.Set();
     });
     application.PersistableIdle = new Func<WorkflowApplicationIdleEventArgs, PersistableIdleAction>((e) => PersistableIdleAction.Unload);
     application.Extensions.Add(new Notification(NotifySum));
     return application;
 }
コード例 #11
0
ファイル: InstanceHandle.cs プロジェクト: uQr/referencesource
        internal InstanceHandle(InstanceStore store, InstanceOwner owner, Guid instanceId)
        {
            Fx.Assert(store != null, "Shouldn't be possible here either.");
            Fx.Assert(instanceId != Guid.Empty, "Should be validating this.");

            Version = -1;
            Store = store;
            Owner = owner;
            Id = instanceId;
            View = new InstanceView(owner, instanceId);
            IsValid = true;
            if (Fx.Trace.IsEtwProviderEnabled)
            {
                eventTraceActivity = new EventTraceActivity(instanceId);
            }
        }
コード例 #12
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();

        }
コード例 #13
0
ファイル: Program.cs プロジェクト: tian1ll1/WPF_Examples
        // 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;
        }
コード例 #14
0
ファイル: InstanceHandle.cs プロジェクト: dox0/DotNet471RS3
        internal InstanceHandle(InstanceStore store, InstanceOwner owner, Guid instanceId)
        {
            Fx.Assert(store != null, "Shouldn't be possible here either.");
            Fx.Assert(instanceId != Guid.Empty, "Should be validating this.");

            Version = -1;
            Store   = store;
            Owner   = owner;
            Id      = instanceId;
            View    = new InstanceView(owner, instanceId);
            IsValid = true;
            if (Fx.Trace.IsEtwProviderEnabled)
            {
                eventTraceActivity = new EventTraceActivity(instanceId);
            }
        }
コード例 #15
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();

        }
コード例 #16
0
ファイル: Program.cs プロジェクト: tian1ll1/WPF_Examples
        private static void WaitForRunnableInstance(InstanceStore store, InstanceHandle ownerHandle)
        {
            IEnumerable<InstancePersistenceEvent> events = store.WaitForEvents(ownerHandle, TimeSpan.MaxValue);

            bool foundRunnable = false;

            // Loop through the persistence events looking for the HasRunnableWorkflow event (in this sample, it corresponds with
            // the workflow instance whose timer has expired and is ready to be resumed by the host).
            foreach (InstancePersistenceEvent persistenceEvent in events)
            {
                if (persistenceEvent.Equals(HasRunnableWorkflowEvent.Value))
                {
                    foundRunnable = true;
                    break;
                }
            }

            if (!foundRunnable)
            {
                throw new ApplicationException("Unexpected: No runnable instances found in the instance store");
            }
        }
コード例 #17
0
        /// <summary>
        /// Opens the host
        /// </summary>
        /// <param name="workflowServiceFile">
        /// The workflow service file. 
        /// </param>
        /// <param name="serviceUri">
        /// The service URI. 
        /// </param>
        /// <param name="instanceStore">
        /// The instance Store. 
        /// </param>
        /// <param name="behaviors">
        /// The behaviors. 
        /// </param>
        /// <returns>
        /// The workflow service host 
        /// </returns>
        public static WorkflowServiceTestHost Open(
            string workflowServiceFile, Uri serviceUri, InstanceStore instanceStore, params IServiceBehavior[] behaviors)
        {
            Contract.Requires(!string.IsNullOrWhiteSpace(workflowServiceFile));
            if (string.IsNullOrWhiteSpace(workflowServiceFile))
            {
                throw new ArgumentNullException("workflowServiceFile");
            }

            Contract.Requires(serviceUri != null);
            if (serviceUri == null)
            {
                throw new ArgumentNullException("serviceUri");
            }

            return Open((WorkflowService)XamlServices.Load(workflowServiceFile), serviceUri, instanceStore, behaviors);
        }
コード例 #18
0
 internal WorkflowApplication CreateWorkflowApplication(AccumulatorActivity activity, InstanceStore instanceStore)
 {
     var application = new WorkflowApplication(activity);
     application.InstanceStore = instanceStore;
     application.Unloaded = new Action<WorkflowApplicationEventArgs>((e) =>
         {
             this.Suspended = true;
             this.SyncEvent.Set();
         });
     application.Completed = new Action<WorkflowApplicationCompletedEventArgs>((e) =>
         {
             this.Sum = (int)e.Outputs["Sum"];
             this.Completed = true;
             this.SyncEvent.Set();
         });
     application.PersistableIdle = new Func<WorkflowApplicationIdleEventArgs, PersistableIdleAction>((e) => PersistableIdleAction.Unload);
     application.Extensions.Add(new Notification(NotifySum));
     this.Suspended = false;
     return application;
 }
コード例 #19
0
        /// <summary>
        /// The open.
        /// </summary>
        /// <param name="xamlReader">
        /// The XAML reader. 
        /// </param>
        /// <param name="serviceUri">
        /// The service URI. 
        /// </param>
        /// <param name="instanceStore">
        /// The instance Store. 
        /// </param>
        /// <param name="behaviors">
        /// The behaviors. 
        /// </param>
        /// <returns>
        /// An opened WorkflowServiceTestHost 
        /// </returns>
        public static WorkflowServiceTestHost Open(
            XamlReader xamlReader, Uri serviceUri, InstanceStore instanceStore, params IServiceBehavior[] behaviors)
        {
            Contract.Requires(xamlReader != null);
            if (xamlReader == null)
            {
                throw new ArgumentNullException("xamlReader");
            }

            Contract.Requires(serviceUri != null);
            if (serviceUri == null)
            {
                throw new ArgumentNullException("serviceUri");
            }

            return Open((WorkflowService)XamlServices.Load(xamlReader), serviceUri, instanceStore, behaviors);
        }
コード例 #20
0
        /// <summary>
        /// Opens the host
        /// </summary>
        /// <param name="workflowService">
        /// The workflow service. 
        /// </param>
        /// <param name="serviceEndpoint">
        /// The service endpoint. 
        /// </param>
        /// <param name="instanceStore">
        /// The instance Store. 
        /// </param>
        /// <param name="behaviors">
        /// The behaviors. 
        /// </param>
        /// <returns>
        /// The workflow service host 
        /// </returns>
        public static WorkflowServiceTestHost Open(
            WorkflowService workflowService, 
            EndpointAddress serviceEndpoint, 
            InstanceStore instanceStore, 
            params IServiceBehavior[] behaviors)
        {
            Contract.Requires(workflowService != null);
            if (workflowService == null)
            {
                throw new ArgumentNullException("workflowService");
            }

            Contract.Requires(serviceEndpoint != null);
            if (serviceEndpoint == null)
            {
                throw new ArgumentNullException("serviceEndpoint");
            }

            return Open(workflowService, serviceEndpoint.Uri, instanceStore, behaviors);
        }
コード例 #21
0
ファイル: Program.cs プロジェクト: tian1ll1/WPF_Examples
        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;
        }
コード例 #22
0
        public DefaultWorkflowApplicationHostInstanceStore(InstanceStore instanceStore)
        {
            if(instanceStore == null) throw new ArgumentNullException("instanceStore");

            _instanceStore = instanceStore;            
        }
 internal PersistenceProviderDirectory(InstanceStore store, InstanceOwner owner, IDictionary<XName, InstanceValue> instanceMetadataChanges, Activity workflowDefinition, WorkflowServiceHost serviceHost, DurableConsistencyScope consistencyScope, int maxInstances) : this(workflowDefinition, serviceHost, consistencyScope, maxInstances)
 {
     this.store = store;
     this.owner = owner;
     this.InstanceMetadataChanges = instanceMetadataChanges;
 }
コード例 #24
0
        /// <summary>
        /// The open.
        /// </summary>
        /// <param name="xmlReader">
        /// The xml reader. 
        /// </param>
        /// <param name="serviceEndpoint">
        /// The service endpoint. 
        /// </param>
        /// <param name="instanceStore">
        /// The instance Store. 
        /// </param>
        /// <param name="behaviors">
        /// The behaviors. 
        /// </param>
        /// <returns>
        /// An opened WorkflowServiceTestHost 
        /// </returns>
        public static WorkflowServiceTestHost Open(
            XmlReader xmlReader, 
            EndpointAddress serviceEndpoint, 
            InstanceStore instanceStore, 
            params IServiceBehavior[] behaviors)
        {
            Contract.Requires(xmlReader != null);
            if (xmlReader == null)
            {
                throw new ArgumentNullException("xmlReader");
            }

            Contract.Requires(serviceEndpoint != null);
            if (serviceEndpoint == null)
            {
                throw new ArgumentNullException("serviceEndpoint");
            }

            return Open((WorkflowService)XamlServices.Load(xmlReader), serviceEndpoint, instanceStore, behaviors);
        }
コード例 #25
0
        public void Open()
        {
            this.instanceStore = new SqlWorkflowInstanceStore(connectionString);

            CreateWorkflowOwnerCommand createWorkflowOwnerCommand = new CreateWorkflowOwnerCommand();
            InstanceHandle handle = this.instanceStore.CreateInstanceHandle();

            try
            {
                this.instanceStore.BeginExecute(handle, createWorkflowOwnerCommand, TimeSpan.FromSeconds(30), OnInstanceStoreEndExecute, null);
            }
            catch (InstancePersistenceException persistenceException)
            {
                WriteException(persistenceException, "An error has occured setting up the InstanceStore");
            }
        }
コード例 #26
0
        /// <summary>
        /// Opens the host
        /// </summary>
        /// <param name="workflowService">
        /// The workflow service. 
        /// </param>
        /// <param name="serviceUri">
        /// The service URI. 
        /// </param>
        /// <param name="instanceStore">
        /// The instance Store. 
        /// </param>
        /// <param name="behaviors">
        /// The behaviors. 
        /// </param>
        /// <returns>
        /// The workflow service host 
        /// </returns>
        public static WorkflowServiceTestHost Open(
            WorkflowService workflowService, 
            Uri serviceUri, 
            InstanceStore instanceStore, 
            params IServiceBehavior[] behaviors)
        {
            Contract.Requires(workflowService != null);
            Contract.Requires(serviceUri != null);

            if (workflowService == null)
            {
                throw new ArgumentNullException("workflowService");
            }

            if (serviceUri == null)
            {
                throw new ArgumentNullException("serviceUri");
            }

            var workflowServiceTestHost = new WorkflowServiceTestHost(workflowService, serviceUri);

            if (instanceStore != null)
            {
                workflowServiceTestHost.InstanceStore = instanceStore;
            }

            if (behaviors != null)
            {
                Debug.Assert(workflowServiceTestHost.Host != null, "workflowServiceTestHost.Host != null");
                Debug.Assert(
                    workflowServiceTestHost.Host.Description != null, "workflowServiceTestHost.Host.Description != null");
                Debug.Assert(
                    workflowServiceTestHost.Host.Description.Behaviors != null,
                    "workflowServiceTestHost.Host.Description.Behaviors != null");
                foreach (var serviceBehavior in behaviors)
                {
                    workflowServiceTestHost.Host.Description.Behaviors.Add(serviceBehavior);
                }
            }

            workflowServiceTestHost.Open();
            return workflowServiceTestHost;
        }