protected internal override Activity LoadCompletedContextActivity(Guid id, Activity outerActivity)
 {
     using (PersistenceDBAccessor accessor = new PersistenceDBAccessor(this._dbResourceAllocator, this._enableRetries))
     {
         return(WorkflowPersistenceService.RestoreFromDefaultSerializedForm(accessor.RetrieveCompletedScope(id), outerActivity));
     }
 }
 protected internal override Activity LoadWorkflowInstanceState(Guid id)
 {
     using (PersistenceDBAccessor accessor = new PersistenceDBAccessor(this._dbResourceAllocator, this._enableRetries))
     {
         WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "SqlWorkflowPersistenceService({0}):Loading instance {1}", new object[] { this._serviceInstanceId.ToString(), id.ToString() });
         return(WorkflowPersistenceService.RestoreFromDefaultSerializedForm(accessor.RetrieveInstanceState(id, this._serviceInstanceId, this.OwnershipTimeout), null));
     }
 }
        protected internal override void SaveCompletedContextActivity(Activity completedScopeActivity)
        {
            PendingWorkItem workItem = new PendingWorkItem {
                Type = PendingWorkItem.ItemType.CompletedScope,
                SerializedActivity = WorkflowPersistenceService.GetDefaultSerializedForm(completedScopeActivity),
                InstanceId         = WorkflowEnvironment.WorkflowInstanceId,
                StateId            = ((ActivityExecutionContextInfo)completedScopeActivity.GetValue(Activity.ActivityExecutionContextInfoProperty)).ContextGuid
            };

            WorkflowEnvironment.WorkBatch.Add(this, workItem);
        }
        protected internal override void SaveWorkflowInstanceState(Activity rootActivity, bool unlock)
        {
            if (rootActivity == null)
            {
                throw new ArgumentNullException("rootActivity");
            }
            WorkflowStatus  workflowStatus         = WorkflowPersistenceService.GetWorkflowStatus(rootActivity);
            bool            isBlocked              = WorkflowPersistenceService.GetIsBlocked(rootActivity);
            string          suspendOrTerminateInfo = WorkflowPersistenceService.GetSuspendOrTerminateInfo(rootActivity);
            Guid            guid     = (Guid)rootActivity.GetValue(Activity.ActivityContextGuidProperty);
            PendingWorkItem workItem = new PendingWorkItem {
                Type       = PendingWorkItem.ItemType.Instance,
                InstanceId = WorkflowEnvironment.WorkflowInstanceId
            };

            if ((workflowStatus != WorkflowStatus.Completed) && (workflowStatus != WorkflowStatus.Terminated))
            {
                workItem.SerializedActivity = WorkflowPersistenceService.GetDefaultSerializedForm(rootActivity);
            }
            else
            {
                workItem.SerializedActivity = new byte[0];
            }
            workItem.Status   = (int)workflowStatus;
            workItem.Blocked  = isBlocked ? 1 : 0;
            workItem.Info     = suspendOrTerminateInfo;
            workItem.StateId  = guid;
            workItem.Unlocked = unlock;
            TimerEventSubscription subscription = ((TimerEventSubscriptionCollection)rootActivity.GetValue(TimerEventSubscriptionCollection.TimerCollectionProperty)).Peek();

            workItem.NextTimer = (subscription == null) ? SqlDateTime.MaxValue : subscription.ExpiresAt;
            if (workItem.Info == null)
            {
                workItem.Info = "";
            }
            WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "SqlWorkflowPersistenceService({4}):Committing instance {0}, Blocked={1}, Unlocked={2}, NextTimer={3}", new object[] { guid.ToString(), workItem.Blocked, workItem.Unlocked, workItem.NextTimer.Value.ToLocalTime(), this._serviceInstanceId.ToString() });
            WorkflowEnvironment.WorkBatch.Add(this, workItem);
        }
コード例 #5
0
            public SkipUnloadOnFirstIdleWorkflowPersistenceService(WorkflowPersistenceService inner)
            {
                if (inner == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("inner");
                }

                this.inner = inner;
            }