internal SqlPersistenceWorkflowInstanceDescription(Guid workflowInstanceId, WorkflowStatus status, bool isBlocked, string suspendOrTerminateDescription, SqlDateTime nextTimerExpiration)
 {
     this.workflowInstanceId = workflowInstanceId;
     this.status = status;
     this.isBlocked = isBlocked;
     this.suspendOrTerminateDescription = suspendOrTerminateDescription;
     this.nextTimerExpiration = nextTimerExpiration;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 protected ContentItem()
 {
     this._id = -1;
     this._globalId = Guid.NewGuid();
     this._workflowStatus = WorkflowStatus.Draft;
     this._createdAt = DateTime.Now;
     this._modifiedAt = DateTime.Now;
     this._version = 1;
     this._syndicate = true;
     this._categories = new List<Category>();
     this._contentItemPermissions = new List<ContentItemPermission>();
     this._comments = new List<Comment>();
 }
Esempio n. 3
0
        private void Rollback(WorkflowStatus oldStatus)
        {
            this.WorkflowStatus = oldStatus;

            if (this.Scheduler != null)
                this.Scheduler.Rollback();
        }
 public async Task <List <WorkflowInstance> > GetListByStatusAsync(string definitionId = null, WorkflowStatus status = WorkflowStatus.Executing, bool includeDetails = false, CancellationToken cancellationToken = default)
 {
     return(await DbSet
            .IncludeDetails(includeDetails)
            .WhereIf(!string.IsNullOrWhiteSpace(definitionId), t => t.DefinitionId == definitionId)
            .Where(t => t.Status == status)
            .ToListAsync(cancellationToken));
 }
Esempio n. 5
0
        /// <summary>
        /// Runs the command.
        /// </summary>
        /// <param name="commandName">Name of the command.</param>
        private void RunCommand(string commandName)
        {
            FileSystemResourceProvider prov = (FileSystemResourceProvider)ResourceHandler.ResourceHandler.ResourceProvider;
            {
                //EXIT FROM DESIGN-MODE
                if (commandName == "Cancel")
                {
                    // delete temp pagedocument
                    DeleteFromTemp();
                    this.ViewState.Clear();

                    CMSContext.Current.IsDesignMode = false;

                    //back to prev page
                    if (Request.QueryString["PrevVersionId"] != null)
                    {
                        NameValueCollection vals = new NameValueCollection();

                        if (Int32.Parse(Request.QueryString["PrevVersionId"]) > 0)
                        {
                            vals.Add("VersionId", Request.QueryString["PrevVersionId"]);
                        }
                        else
                        {
                            vals.Add("VersionId", "");
                        }

                        string url = CommonHelper.FormatQueryString(CMSContext.Current.CurrentUrl, vals);

                        Response.Redirect(url);
                        //Response.Redirect("~" + CMSContext.Current.Outline + "?VersionId=" + Request.QueryString["PrevVersionId"]);
                    }
                    else
                    {
                        Response.Redirect(Request.RawUrl, true);
                    }
                }

                //ENTER DESIGN-MODE
                if (commandName == "Edit")
                {
                    //GA: delete temp pagedocument
                    DeleteFromTemp();

                    // Check if we have access to the current version, if not, the new version for a current language will
                    // need to be created for "edit" command
                    if (!PageHelper.HasLanguageVersion(CMSContext.Current.PageId, LanguageId, CMSContext.Current.VersionId))
                    {
                        // add new version
                        _CommandValue.Value = String.Format("{0},{1}", CMSContext.Current.PageId, LanguageId);
                        RunCommand("AddVersion");
                    }

                    //back to prev page
                    if (Request.QueryString["PrevVersionId"] != null)
                    {
                        NameValueCollection vals = new NameValueCollection();
                        vals.Add("PrevVersionId", Request.QueryString["PrevVersionId"]);
                        string url = CommonHelper.FormatQueryString(CMSContext.Current.CurrentUrl, vals);
                        Response.Redirect(url);
                        //Response.Redirect("~" + CMSContext.Current.Outline + "?VersionId=" + Request.QueryString["PrevVersionId"]);
                    }
                    else
                    {
                        Response.Redirect(Request.RawUrl, true);
                    }
                }

                //SAVE AS DRAFT
                if (commandName == "SaveDraft")
                {
                    if (CMSContext.Current.VersionId == -2)
                    {
                        CMSContext.Current.VersionId       = PageVersion.AddDraft(CMSContext.Current.PageId, CMSContext.Current.TemplateId, LanguageId, (Guid)ProfileContext.Current.User.ProviderUserKey);
                        PageDocument.Current.PageVersionId = CMSContext.Current.VersionId;
                        //copy resources
                        DirectoryInfo resDir = new DirectoryInfo(MapPath("~/" + prov.Archive + "/" + ProfileContext.Current.User.UserName + "/"));
                        CommonHelper.CopyDirectory(resDir.FullName, MapPath("~/" + prov.Archive + "/" + CMSContext.Current.VersionId.ToString() + "/"));
                        if (resDir.Exists)
                        {
                            resDir.Delete(true);
                        }
                    }
                    PageDocument.Current.IsModified = true;

                    using (IDataReader reader = PageVersion.GetVersionById(CMSContext.Current.VersionId))
                    {
                        if (reader.Read())
                        {
                            int  verId      = -1;
                            bool addVersion = false;
                            using (IDataReader r = PageVersion.GetVersionById(CMSContext.Current.VersionId))
                            {
                                if (r.Read())
                                {
                                    addVersion = (int)r["StatusId"] != -1;
                                    if (!addVersion)
                                    {
                                        verId = CMSContext.Current.VersionId;
                                        PageVersion.UpdatePageVersion(verId, (int)r["TemplateId"], (int)r["LangId"], -1, WorkflowStatus.DraftId, (Guid)ProfileContext.Current.User.ProviderUserKey, 1, string.Empty);
                                    }
                                }

                                r.Close();
                            }

                            if (addVersion)
                            {
                                verId = PageVersion.AddPageVersion((int)reader["PageId"], (int)reader["TemplateId"], (int)reader["LangId"], (Guid)ProfileContext.Current.User.ProviderUserKey, 1, string.Empty);
                                using (IDataReader reader2 = PageVersion.GetVersionById(verId))
                                {
                                    if (reader2.Read())
                                    {
                                        PageVersion.UpdatePageVersion(verId, (int)reader2["TemplateId"], (int)reader2["LangId"], (int)reader2["StatusId"], WorkflowStatus.DraftId, (Guid)ProfileContext.Current.User.ProviderUserKey, 1, string.Empty);
                                    }

                                    reader2.Close();
                                }

                                //copy resources
                                //todo: feature suspended, reimplement in the future
                                //CommonHelper.CopyDirectory(MapPath("~/" + prov.Archive + "/" + CMSContext.Current.VersionId.ToString() + "/"), MapPath("~/" + prov.Archive + "/" + verId.ToString() + "/"));

                                CMSContext.Current.VersionId = verId;
                            }
                        }

                        reader.Close();
                    }
                    //SAVE DRAFT TO PERSIST STORAGE
                    PageDocument.Current.Save(CMSContext.Current.VersionId, SaveMode.PersistentStorage, Guid.Empty);
                    PageDocument.Current.ResetModified();

                    //delete from temporary storage
                    DeleteFromTemp();
                    this.ViewState.Clear();

                    //SWITCH TO VIEW MODE
                    EnableViewMode();

                    RedirectToNewPage();
                }

                //PUBLISH
                if (commandName == "Publish")
                {
                    bool firstVersion = false;
                    if (CMSContext.Current.VersionId == -2)
                    {
                        firstVersion = true;
                        CMSContext.Current.VersionId       = PageVersion.AddDraft(CMSContext.Current.PageId, CMSContext.Current.TemplateId, LanguageId, (Guid)ProfileContext.Current.User.ProviderUserKey);
                        PageDocument.Current.PageVersionId = CMSContext.Current.VersionId;
                        //copy resources
                        DirectoryInfo resDir = new DirectoryInfo(MapPath("~/" + prov.Archive + "/" + ProfileContext.Current.User.UserName + "/"));
                        CommonHelper.CopyDirectory(resDir.FullName, MapPath("~/" + prov.Archive + "/" + CMSContext.Current.VersionId.ToString() + "/"));
                        if (resDir.Exists)
                        {
                            resDir.Delete(true);
                        }
                    }
                    using (IDataReader reader = PageVersion.GetVersionById(CMSContext.Current.VersionId))
                    {
                        if (reader.Read())
                        {
                            int langId = (int)reader["LangId"];
                            if (WorkflowStatus.GetNext((int)reader["StatusId"]) != -1 || (int)reader["StatusId"] == -1)
                            {
                                PageVersion.UpdatePageVersion(CMSContext.Current.VersionId, (int)reader["TemplateId"], (int)reader["LangId"], (int)reader["StatusId"], WorkflowAccess.GetMaxStatus(Roles.GetRolesForUser(), WorkflowStatus.GetLast((int)reader["StatusId"])), (Guid)ProfileContext.Current.User.ProviderUserKey, 1, string.Empty);
                            }

                            // if we publish version
                            if (WorkflowStatus.GetLast((int)reader["StatusId"]) == WorkflowAccess.GetMaxStatus(Roles.GetRolesForUser(), WorkflowStatus.GetLast((int)reader["StatusId"])))
                            {
                                //find old published and put to archive
                                using (IDataReader reader2 = PageVersion.GetVersionByStatusId((int)reader["PageId"], WorkflowStatus.GetLast((int)reader["StatusId"])))
                                {
                                    while (reader2.Read())
                                    {
                                        if ((int)reader2["LangId"] == langId)
                                        {
                                            if (CMSContext.Current.VersionId != (int)reader2["VersionId"])
                                            {
                                                PageVersion.UpdatePageVersion((int)reader2["VersionId"], (int)reader2["TemplateId"], (int)reader2["LangId"], (int)reader2["StatusId"], WorkflowStatus.GetArcStatus((int)reader2["StatusId"]), (Guid)ProfileContext.Current.User.ProviderUserKey, 2, "sent to archieve");
                                            }
                                        }
                                    }

                                    reader2.Close();
                                }
                            }
                        }
                        reader.Close();
                    }

                    //SAVE TO PERSIST STORAGE
                    PageDocument.Current.Save(CMSContext.Current.VersionId, SaveMode.PersistentStorage, Guid.Empty);
                    PageDocument.Current.ResetModified();

                    //delete from temporary storage
                    DeleteFromTemp();
                    this.ViewState.Clear();

                    //SWITCH TO VIEW MODE
                    EnableViewMode();

                    // replace VersionId in query string with a new id
                    string url = Request.RawUrl;
                    if (firstVersion)
                    {
                        // if the page has just been created and is being published, need to remove "VersionId=-2" from the queryString to load published version
                        NameValueCollection vals = new NameValueCollection();
                        vals.Add("VersionId", String.Empty);
                        url = CommonHelper.FormatQueryString(url, vals);
                    }
                    Response.Redirect(url, true);
                }

                if (commandName == "Approve")
                {
                    using (IDataReader reader = PageVersion.GetVersionById(CMSContext.Current.VersionId))
                    {
                        if (reader.Read())
                        {
                            PageVersion.UpdatePageVersion(CMSContext.Current.VersionId, (int)reader["TemplateId"], (int)reader["LangId"], (int)reader["StatusId"], WorkflowAccess.GetMaxStatus(Roles.GetRolesForUser(), WorkflowStatus.GetLast((int)reader["StatusId"])), (Guid)ProfileContext.Current.User.ProviderUserKey, 1, /*ddText.TextValue*/ "");
                            int langId = (int)reader["langId"];

                            // if we publish version
                            if (WorkflowStatus.GetLast((int)reader["StatusId"]) == WorkflowAccess.GetMaxStatus(Roles.GetRolesForUser(), WorkflowStatus.GetLast((int)reader["StatusId"])))
                            {
                                //find old publishd and put to archive
                                using (IDataReader reader2 = PageVersion.GetVersionByStatusId((int)reader["PageId"], WorkflowStatus.GetLast((int)reader["StatusId"])))
                                {
                                    while (reader2.Read())
                                    {
                                        if (langId == (int)reader2["LangId"])
                                        {
                                            if (CMSContext.Current.VersionId != (int)reader2["VersionId"])
                                            {
                                                PageVersion.UpdatePageVersion((int)reader2["VersionId"], (int)reader2["TemplateId"], (int)reader2["LangId"], (int)reader2["StatusId"], WorkflowStatus.GetArcStatus((int)reader2["StatusId"]), (Guid)ProfileContext.Current.User.ProviderUserKey, 1, "Archieved");
                                            }
                                        }
                                    }

                                    reader2.Close();
                                }
                            }
                            //PageVersion.DeletePageVersion(CMSContext.Current.VersionId);
                            //PageVersion.AddPageVerion((int)reader["PageId"], (int)reader["TemplateId"], (int)reader["LangId"], (Guid)Membership.GetUser(Page.User.Identity.Name).ProviderUserKey, 1, ddText.TextValue);
                        }

                        reader.Close();
                    }

                    Response.Redirect(Request.RawUrl, true);
                    //RedirectToNewPage();
                }

                if (commandName == "Deny")
                {
                    using (IDataReader reader = PageVersion.GetVersionById(CMSContext.Current.VersionId))
                    {
                        if (reader.Read())
                        {
                            PageVersion.UpdatePageVersion(CMSContext.Current.VersionId, (int)reader["TemplateId"], (int)reader["LangId"], (int)reader["StatusId"], WorkflowStatus.GetPrevious((int)reader["StatusId"]), (Guid)ProfileContext.Current.User.ProviderUserKey, 2, /*ddText.TextValue*/ "");
                            //PageVersion.AddPageVerion((int)reader["PageId"], (int)reader["TemplateId"], (int)reader["LangId"], (Guid)Membership.GetUser(Page.User.Identity.Name).ProviderUserKey, 1, ddText.TextValue);
                        }

                        reader.Close();
                    }
                    string url = Page.Request.Url.ToString();

                    if (!url.Contains("VersionId"))
                    {
                        NameValueCollection vals = new NameValueCollection();
                        vals.Add("VersionId", CMSContext.Current.VersionId.ToString());
                        url = CommonHelper.FormatQueryString(url, vals);
                        Response.Redirect(url);
                    }
                }

                if (commandName == "ChangeTemplate")
                {
                    // Clear cache
                    CmsCache.Clear();

                    CMSContext mcContext = CMSContext.Current;
                    using (IDataReader reader = PageVersion.GetVersionById(CMSContext.Current.VersionId))
                    {
                        if (reader.Read())
                        {
                            int pageTemplateId;

                            if (Int32.TryParse(_CommandValue.Value, out pageTemplateId))
                            {
                                PageVersion.UpdatePageVersion(CMSContext.Current.VersionId, int.Parse(_CommandValue.Value), this.LanguageId, (int)reader["StatusId"], (int)reader["StatusId"], (Guid)ProfileContext.Current.User.ProviderUserKey, 1, string.Empty);
                            }
                        }

                        reader.Close();
                    }

                    if (mcContext.VersionId == -2)
                    {
                        NameValueCollection vals = new NameValueCollection();
                        vals.Add("TemplateId", _CommandValue.Value);
                        string url = CommonHelper.FormatQueryString(Request.RawUrl, vals);
                        Response.Redirect(url, true);
                    }
                    else
                    {
                        Response.Redirect(Request.RawUrl, true);
                    }
                }

                if (commandName == "AddVersion")
                {
                    string separator      = ",";
                    int    pageId         = int.Parse(_CommandValue.Value.Split(separator.ToCharArray())[0]);
                    int    langId         = int.Parse(_CommandValue.Value.Split(separator.ToCharArray())[1]);
                    string currentCulture = "en-us";
                    using (IDataReader reader = Language.LoadLanguage(langId))
                    {
                        if (reader.Read())
                        {
                            currentCulture = (string)reader["LangName"];
                        }

                        reader.Close();
                    }

                    NameValueCollection vals = new NameValueCollection();
                    vals.Add("lang", currentCulture);
                    vals.Add("VersionId", "-2");
                    vals.Add("PrevVersionId", CMSContext.Current.VersionId.ToString());
                    string url = CommonHelper.FormatQueryString(CMSContext.Current.CurrentUrl, vals);
                    Response.Redirect(url);
                }
                return;
            }
        }
Esempio n. 6
0
    /// <summary>
    /// Asynchronously starts executing workflow.
    /// </summary>
    /// <param name="workflowType">
    /// Type object referencing the workflow.
    /// </param>
    /// <param name="parameters">
    /// Name/value list of parameters to be passed
    /// to the workflow instance.
    /// </param>
    public void BeginWorkflow(Type workflowType, Dictionary<string, object> parameters)
    {
      InitializeRuntime();

      if (!_workflowRuntime.IsStarted)
        _workflowRuntime.StartRuntime();

      // create workflow instance
      if (parameters != null)
        _instance = _workflowRuntime.CreateWorkflow(
          workflowType,
          parameters);
      else
        _instance = _workflowRuntime.CreateWorkflow(
          workflowType);

      // execute workflow
      _instance.Start();
      _status = WorkflowStatus.Executing;
    }
Esempio n. 7
0
 public void SetStatus(WorkflowStatus status, params long[] ids)
 {
     throw new NotImplementedException();
 }
Esempio n. 8
0
        public void CreateDb()
        {
            TraceEvent teDebug    = CreateEvent(TraceEventType.Debug, "Debug");
            TraceEvent teActivity = CreateEvent(TraceEventType.Activity, "Activity");
            TraceEvent teInfo     = CreateEvent(TraceEventType.Info, "Info");
            TraceEvent teError    = CreateEvent(TraceEventType.Error, "Error");

            uow.TraceEvents.Insert(teDebug);
            uow.TraceEvents.Insert(teActivity);
            uow.TraceEvents.Insert(teInfo);
            uow.TraceEvents.Insert(teError);

            WorkflowStatus wsInProgress = CreateStatus(WorkflowStatusType.InProgress, "InProgress");
            WorkflowStatus wsCompleted  = CreateStatus(WorkflowStatusType.Completed, "Completed");
            WorkflowStatus wsAborted    = CreateStatus(WorkflowStatusType.Aborted, "Aborted");
            WorkflowStatus wsTerminated = CreateStatus(WorkflowStatusType.Terminated, "Terminated");

            uow.WorkflowStatuses.Insert(wsInProgress);
            uow.WorkflowStatuses.Insert(wsCompleted);
            uow.WorkflowStatuses.Insert(wsAborted);
            uow.WorkflowStatuses.Insert(wsTerminated);

            SketchStatus skSaved        = CreateSketchStatus("Saved", "Sketch Saved");
            SketchStatus skDeployedDev  = CreateSketchStatus("DeployedDev", "Deployed to dev");
            SketchStatus skDeployedProd = CreateSketchStatus("DeployedProd", "Deployed to prod");
            SketchStatus skSentToSketch = CreateSketchStatus("SentToSketch", "Sent To Sketch");
            SketchStatus skAborted      = CreateSketchStatus("Aborted", "Abort workflow deployment");

            uow.SketchStatuses.Insert(skSaved);
            uow.SketchStatuses.Insert(skDeployedDev);
            uow.SketchStatuses.Insert(skDeployedProd);
            uow.SketchStatuses.Insert(skSentToSketch);
            uow.SketchStatuses.Insert(skAborted);

            WorkflowCode wc1 = CreateWorkflowCode("SampleWf1", "this is a sample wf code for testing (1)");

            uow.WorkflowCodes.Insert(wc1);
            WorkflowConfiguration wfc1 = CreateWorkflowConfiguration(wc1, "BasicHttpBinding_FlowTasks", "", "");

            uow.WorkflowConfigurations.Insert(wfc1);

            WorkflowCode wc2 = CreateWorkflowCode("SampleWf2", "this is a sample wf code for testing (2)");

            uow.WorkflowCodes.Insert(wc2);
            WorkflowConfiguration wfc2 = CreateWorkflowConfiguration(wc2, "BasicHttpBinding_IFlowTasksOperations2", "http://localhost/Flow.Tasks.Workflows/SampleWf2.xamlx", "BasicHttpBinding_FlowTasks");

            uow.WorkflowConfigurations.Insert(wfc2);

            WorkflowCode wc3 = CreateWorkflowCode("SampleWf3", "this is a sample wf code for testing (3)");

            uow.WorkflowCodes.Insert(wc3);
            WorkflowConfiguration wfc3 = CreateWorkflowConfiguration(wc3, "BasicHttpBinding_IFlowTasksOperations3", "http://localhost/Flow.Tasks.Workflows/SampleWf3.xamlx", "BasicHttpBinding_FlowTasks");

            uow.WorkflowConfigurations.Insert(wfc3);

            WorkflowCode wc4 = CreateWorkflowCode("SampleWf4", "this is a sample wf code for testing (4)");

            uow.WorkflowCodes.Insert(wc4);
            WorkflowConfiguration wfc4 = CreateWorkflowConfiguration(wc4, "BasicHttpBinding_IFlowTasksOperations4", "http://localhost/Flow.Tasks.Workflows/SampleWf4.xamlx", "BasicHttpBinding_FlowTasks");

            uow.WorkflowConfigurations.Insert(wfc4);

            WorkflowCode wc5 = CreateWorkflowCode("SampleWf5", "this is a sample wf code for testing (5)");

            uow.WorkflowCodes.Insert(wc5);
            WorkflowConfiguration wfc5 = CreateWorkflowConfiguration(wc5, "BasicHttpBinding_IFlowTasksOperations5", "http://localhost/Flow.Tasks.Workflows/SampleWf5.xamlx", "BasicHttpBinding_FlowTasks");

            uow.WorkflowConfigurations.Insert(wfc5);

            WorkflowCode wc6 = CreateWorkflowCode("SampleWf6", "this is a sample wf code for testing (6)");

            uow.WorkflowCodes.Insert(wc6);
            WorkflowConfiguration wfc6 = CreateWorkflowConfiguration(wc6, "BasicHttpBinding_IFlowTasksOperations6", "http://localhost/Flow.Tasks.Workflows/SampleWf6.xamlx", "BasicHttpBinding_FlowTasks");

            uow.WorkflowConfigurations.Insert(wfc6);

            WorkflowCode wc7 = CreateWorkflowCode("SampleWf7", "this is a sample wf code for testing (7)");

            uow.WorkflowCodes.Insert(wc7);
            WorkflowConfiguration wfc7 = CreateWorkflowConfiguration(wc7, "BasicHttpBinding_IFlowTasksOperations7", "http://localhost/Flow.Tasks.Workflows/SampleWf7.xamlx", "BasicHttpBinding_FlowTasks");

            uow.WorkflowConfigurations.Insert(wfc7);

            WorkflowCode wc8 = CreateWorkflowCode("SampleWf8", "this is a sample wf code for testing (8)");

            uow.WorkflowCodes.Insert(wc8);
            WorkflowConfiguration wfc8 = CreateWorkflowConfiguration(wc8, "BasicHttpBinding_IFlowTasksOperations8", "http://localhost/ServiceWorkflowsVB/SampleWf8.xamlx", "BasicHttpBinding_FlowTasks");

            uow.WorkflowConfigurations.Insert(wfc8);

            WorkflowCode wc9 = CreateWorkflowCode("SampleWf9", "this is a sample wf code for testing (9)");

            uow.WorkflowCodes.Insert(wc9);
            WorkflowConfiguration wfc9 = CreateWorkflowConfiguration(wc9, "BasicHttpBinding_IFlowTasksOperations9", "http://localhost/ServiceWorkflowsVB/SampleWf9.xamlx", "BasicHttpBinding_FlowTasks");

            uow.WorkflowConfigurations.Insert(wfc9);

            // Topic
            TopicStatus topicNew  = CreateTopicStatus("New", "New topic message");
            TopicStatus topicRead = CreateTopicStatus("Read", "Read topic message");

            uow.TopicStatuses.Insert(topicNew);
            uow.TopicStatuses.Insert(topicRead);
        }
Esempio n. 9
0
 public void UpdateStatus(WorkflowStatus status)
 {
     Status = status;
 }
 public static ISpecification <WorkflowInstance> WithStatus(this ISpecification <WorkflowInstance> specification, WorkflowStatus status) => specification.And(new WorkflowStatusSpecification(status));
 public async Task <List <WorkflowInstance> > GetListByBlockingActivityAsync(string activityType, string correlationId = null, WorkflowStatus status = WorkflowStatus.Executing, bool includeDetails = false, CancellationToken cancellationToken = default)
 {
     return(await DbSet
            .IncludeDetails(includeDetails)
            .Where(t => t.BlockingActivities.Any(t => t.ActivityType == activityType))
            .WhereIf(!string.IsNullOrWhiteSpace(correlationId), t => t.CorrelationId == correlationId)
            .OrderByDescending(t => t.CreationTime)
            .ToListAsync(cancellationToken));
 }
Esempio n. 12
0
 private async Task SendStatusUpdate(WorkflowStatus operationStatus)
 {
     await _hubContext.Clients.Group(typeof(THub).ToString()).SendAsync("UpdateStatus", operationStatus);
 }
Esempio n. 13
0
        public async Task ThenTheWorkflowInstanceWithIdShouldHaveTheStatus(string instanceId, WorkflowStatus expectedStatus)
        {
            WorkflowInstance instance = await this.GetWorkflowInstance(instanceId).ConfigureAwait(false);

            Assert.AreEqual(expectedStatus, instance.Status);
        }
Esempio n. 14
0
 public async Task <IEnumerable <WorkflowInstance> > ListByStatusAsync(
     WorkflowStatus status,
     CancellationToken cancellationToken = default)
 {
     return(Map(await _workflowInstanceService.ListByStatus(status)));
 }
        public static IQueryable <WorkflowActivity> GetAuthorized(this IRepository <WorkflowActivity> repository,
                                                                  WorkflowActivityFinderModel finder, string account, bool optimization = true)
        {
            IQueryable <WorkflowActivity> workflowActivities = repository
                                                               .Query(x => x.WorkflowAuthorizations.Any(y => y.Account.ToLower() == account.ToLower()), optimization: optimization)
                                                               .Include(x => x.DocumentUnitReferenced.Category)
                                                               .Include(x => x.DocumentUnitReferenced.Container)
                                                               .OrderBy(o => o.OrderByDescending(oo => oo.RegistrationDate))
                                                               .SelectAsQueryable();


            if (finder != null)
            {
                if (finder.IdWorkflowActivity.HasValue)
                {
                    workflowActivities = workflowActivities.Where(x => x.UniqueId == finder.IdWorkflowActivity.Value);
                }
                if (!string.IsNullOrWhiteSpace(finder.RegistrationUser))
                {
                    workflowActivities = workflowActivities.Where(x => x.RegistrationUser.Contains(finder.RegistrationUser.ToLower()));
                }
                if (finder.AuthorizeDateFrom.HasValue)
                {
                    workflowActivities = workflowActivities.Where(x => x.RegistrationDate >= finder.AuthorizeDateFrom.Value);
                }
                if (finder.AuthorizeDateTo.HasValue)
                {
                    workflowActivities = workflowActivities.Where(x => x.RegistrationDate <= finder.AuthorizeDateTo.Value);
                }
                if (!string.IsNullOrEmpty(finder.RequestorUsername))
                {
                    workflowActivities = workflowActivities.Where(x => x.WorkflowProperties.Any(y => y.Name == WorkflowPropertyHelper.DSW_PROPERTY_PROPOSER_USER && y.ValueString.Contains(finder.RequestorUsername)));
                }
                if (!string.IsNullOrEmpty(finder.RequestorRoleName))
                {
                    workflowActivities = workflowActivities.Where(x => x.DocumentUnitReferenced != null && x.DocumentUnitReferenced.Container.Name.Contains(finder.RequestorRoleName));
                }
                if (finder.Status.HasValue)
                {
                    WorkflowStatus workflowStatus = (WorkflowStatus)finder.Status.Value;
                    workflowActivities = workflowActivities.Where(x => x.WorkflowInstance.Status == workflowStatus);
                }

                if (!string.IsNullOrEmpty(finder.Note))
                {
                    workflowActivities = workflowActivities.Where(x => x.Note.Contains(finder.Note));
                }

                if (!string.IsNullOrEmpty(finder.Subject))
                {
                    workflowActivities = workflowActivities.Where(x => x.Subject.Contains(finder.Subject));
                }

                if (finder.Skip != null && finder.Top != null)
                {
                    workflowActivities = workflowActivities.Skip(finder.Skip.Value).Take(finder.Top.Value);
                }
            }

            return(workflowActivities);
        }
Esempio n. 16
0
        private void ConfigureWorkflowApplication(WorkflowApplication wfApp, Action <string> writelineListener = null)
        {
            // Configure the persistence store.
            wfApp.InstanceStore = _store;

            // Add a StringWriter to the extensions. This captures the output
            // from the WriteLine activities so we can display it in the form.
            StringWriter sw = new StringWriter();

            wfApp.Extensions.Add(sw);

            wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
            {
                var message = string.Empty;
                if (e.CompletionState == ActivityInstanceState.Faulted)
                {
                    message = string.Format(wfApp.WorkflowDefinition?.DisplayName +
                                            " Workflow Terminated. Exception: {0}\r\n{1}",
                                            e.TerminationException.GetType().FullName,
                                            GetExceptionMessage(e.TerminationException));
                    _workflowStatus = WorkflowStatus.Errored;
                }
                else if (e.CompletionState == ActivityInstanceState.Canceled)
                {
                    message         = $"Workflow {wfApp.WorkflowDefinition?.DisplayName} CANCELLED.";
                    _workflowStatus = WorkflowStatus.Cancelled;
                }
                else
                {
                    message         = $"Workflow {wfApp.WorkflowDefinition?.DisplayName} COMPLETED.";
                    _outputs        = e.Outputs; //TODO: How to use it?
                    _workflowStatus = WorkflowStatus.Completed;
                }
                LogMessages(e, sw, message, writelineListener);
                _instanceId = e.InstanceId;
                //_syncEvent.Set();
            };

            wfApp.Aborted = delegate(WorkflowApplicationAbortedEventArgs e)
            {
                var message = string.Format(wfApp.WorkflowDefinition?.DisplayName +
                                            " Workflow Aborted. Exception: {0}\r\n{1}",
                                            e.Reason.GetType().FullName,
                                            GetExceptionMessage(e.Reason));
                LogMessages(e, sw, message, writelineListener);
                _instanceId     = e.InstanceId;
                _workflowStatus = WorkflowStatus.Aborted;
                _syncEvent.Set(); //abort does not trigger unload //TODO: verify
            };

            //on exception. Then it'll hit Completed()
            wfApp.OnUnhandledException = delegate(WorkflowApplicationUnhandledExceptionEventArgs e)
            {
                var message = string.Format(wfApp.WorkflowDefinition?.DisplayName +
                                            " Unhandled Exception: {0}\r\n{1}",
                                            e.UnhandledException.GetType().FullName,
                                            GetExceptionMessage(e.UnhandledException));
                LogMessages(e, sw, message, writelineListener);
                _workflowStatus = WorkflowStatus.Errored;
                //_syncEvent.Set();
                return(UnhandledExceptionAction.Terminate);
            };

            wfApp.PersistableIdle = delegate(WorkflowApplicationIdleEventArgs e)
            {
                var message = $"Workflow {wfApp.WorkflowDefinition?.DisplayName} getting to IDLE.";
                LogMessages(e, sw, message, writelineListener, true);                        //clear messages as idle'll invoke Unloaded()
                _bookmarks      = string.Join(",", e.Bookmarks.Select(b => b.BookmarkName)); //TODO: check
                _instanceId     = e.InstanceId;
                _workflowStatus = WorkflowStatus.Persisted;
                //_syncEvent.Set();
                return(PersistableIdleAction.Unload);
            };

            //any time wf is unloaded, e.g. bookmark, completed, exception
            wfApp.Unloaded = delegate(WorkflowApplicationEventArgs e)
            {
                //_instanceId = e.InstanceId;
                //_workflowStatus = WorkflowStatus.Unloaded;
                var message = $"Workflow {wfApp.WorkflowDefinition?.DisplayName} UNLOADED.";
                LogMessages(e, sw, message, writelineListener);
                _syncEvent.Set();
            };

            string GetExceptionMessage(Exception exception)
            {
                var expMsg           = "Exception:";
                var isInnerException = false;
                var exp = exception;

                while (exp != null)
                {
                    expMsg          += $"{(isInnerException ? ". Inner Exp: " : " ")}{exp.ToString()}";
                    exp              = exp.InnerException;
                    isInnerException = true;
                }
                return(expMsg);
            }
        }
Esempio n. 17
0
 private void OnStatusUpdated(WorkflowStatus status)
 {
     StatusUpdated?.Invoke(status);
 }
        public void SendOperationStatusUpdate(WorkflowStatus status)
        {
            var hubContext = GlobalHost.ConnectionManager.GetHubContext <T>();

            hubContext.Clients.Group(GroupName).updateStatus(status);
        }
        protected void Setup()
        {
            var options = new DbContextOptionsBuilder <WorkflowDataContext>()
                          .UseInMemoryDatabase(databaseName: "workflow-tets")
                          .Options;

            var mockHttpContextAccessor = new Mock <IHttpContextAccessor>();
            var user = new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
            {
                new Claim(ClaimTypes.Name, "admin"),
                new Claim(ClaimTypes.NameIdentifier, "1"),
            }, "mock"));

            var context = new DefaultHttpContext {
                User = user
            };

            mockHttpContextAccessor.Setup(_ => _.HttpContext).Returns(context);

            Context = new WorkflowDataContext(options, mockHttpContextAccessor.Object);

            waitingApprovalStatus = new WorkflowStatus {
                Name = "Waiting Approval"
            };
            approvedStatus = new WorkflowStatus {
                Name = "Approved"
            };
            rejectedStatus = new WorkflowStatus {
                Name = "Reject"
            };

            Type = new WorkflowType {
                Name = "Workflow", IsActive = true
            };
            var approvedStep = new WorkflowApprovalStep {
                IsActive = true, WorkflowStatus = approvedStatus
            };
            var rejectedStep = new WorkflowApprovalStep {
                IsActive = true, WorkflowStatus = rejectedStatus
            };
            var firstStep = new WorkflowApprovalStep
            {
                NextStepApproved = approvedStep,
                NextStepRejected = rejectedStep,
                WorkflowStatus   = waitingApprovalStatus,
                IsActive         = true,
                IsFirstStep      = true
            };

            Type.Steps.Add(firstStep);
            Type.Steps.Add(approvedStep);
            Type.Steps.Add(rejectedStep);

            Context.WorkflowTypes.Add(Type);
            Context.SaveChanges();

            mockAuthService = new Mock <IAuthService>();
            mockAuthService.Setup(_ => _.HasRoles(It.IsAny <string>(), It.IsAny <IEnumerable <int> >())).Returns(true);

            var cache = new MemoryCache(new MemoryCacheOptions());

            workflowCache = new WorkflowCache(cache, Context);



            eventBus = new EventBus(new MockServiceProvider());
        }
Esempio n. 20
0
        public async Task <IEnumerable <WorkflowInstance> > ListByStatusAsync(string definitionId, WorkflowStatus status,
                                                                              CancellationToken cancellationToken = default)
        {
            var documents = await cosmosDbStoreHelper.ListAsync(q =>
            {
                return(q.Where(c => c.DefinitionId == definitionId && c.Status == status)
                       .OrderByDescending(x => x.CreatedAt));
            }, cancellationToken);

            return(Map(documents));
        }
Esempio n. 21
0
 public async Task PurgeWorkflows(WorkflowStatus status, DateTime olderThan)
 {
     await DeleteWorkflowInstances(status, olderThan);
 }
Esempio n. 22
0
    /// <summary>
    /// Binds my work.
    /// </summary>
    private void BindMyWork()
    {
        //don't load "my work" subnodes if permissions not allocated
        if (!ProfileContext.Current.CheckPermission("content:admin:workflow:mng:view"))
        {
            return;
        }

        List <JsonTreeNode> nodes = new List <JsonTreeNode>();

        DataTable dtPV = PageVersion.GetWorkVersionByUserId(Page.User.Identity.Name);

        if (dtPV != null && dtPV.Rows.Count > 0)
        {
            DataView dv = dtPV.DefaultView;

            //APPLY FILTER
            int defaultWorkflowId = -1;
            using (IDataReader reader = Workflow.LoadDefault())
            {
                if (reader.Read())
                {
                    defaultWorkflowId = (int)reader["WorkflowId"];
                }
                reader.Close();
            }

            int PublishId = WorkflowStatus.GetLastByWorkflowId(defaultWorkflowId);
            int DraftId   = WorkflowStatus.DraftId;

            dv.RowFilter = String.Format("StateId = 1 AND StatusId NOT IN (-1, {0}, {1})", PublishId, DraftId);
            if (dv.Count > 0)
            {
                nodes.Add(JsonTreeNode.CreateNode(String.Format("{0} <b>({1})</b>", Resources.Admin.ForApprove, dv.Count), ModuleName, "Approve-List", "filter=approve", true));
            }
            else
            {
                nodes.Add(JsonTreeNode.CreateNode(Resources.Admin.ForApprove, ModuleName, "Approve-List", "approve", true));
            }

            dv.RowFilter = String.Format("StateId = 2 AND StatusId NOT IN (-1, {0})", PublishId);
            if (dv.Count > 0)
            {
                nodes.Add(JsonTreeNode.CreateNode(String.Format("{0} <b>({1})</b>", Resources.Admin.Rollbacked, dv.Count), ModuleName, "Reject-List", "filter=reject", true));
            }
            else
            {
                nodes.Add(JsonTreeNode.CreateNode(Resources.Admin.Rollbacked, ModuleName, "Reject-List", "filter=reject", true));
            }

            dv.RowFilter = String.Format("StateId = 1 AND StatusId = {0}", DraftId);
            if (dv.Count > 0)
            {
                nodes.Add(JsonTreeNode.CreateNode(String.Format("{0} <b>({1})</b>", Resources.Admin.Drafts, dv.Count), ModuleName, "Draft-List", "filter=draft", true));
            }
            else
            {
                nodes.Add(JsonTreeNode.CreateNode(Resources.Admin.Drafts, ModuleName, "Draft-List", "filter=draft", true));
            }
        }

        WriteArray(nodes);
    }
Esempio n. 23
0
        protected override void Seed(FlowTasksEntities context)
        {
            TraceEvent teDebug    = CreateEvent(TraceEventType.Debug, "Debug");
            TraceEvent teActivity = CreateEvent(TraceEventType.Activity, "Activity");
            TraceEvent teInfo     = CreateEvent(TraceEventType.Info, "Info");
            TraceEvent teError    = CreateEvent(TraceEventType.Error, "Error");

            context.TraceEvents.AddOrUpdate(
                te => te.Type,
                teDebug,
                teActivity,
                teError,
                teInfo
                );

            WorkflowStatus wsInProgress = CreateStatus(WorkflowStatusType.InProgress, "InProgress");
            WorkflowStatus wsCompleted  = CreateStatus(WorkflowStatusType.Completed, "Completed");
            WorkflowStatus wsAborted    = CreateStatus(WorkflowStatusType.Aborted, "Aborted");
            WorkflowStatus wsTerminated = CreateStatus(WorkflowStatusType.Terminated, "Terminated");

            context.WorkflowStatuses.AddOrUpdate(
                ws => ws.Status,
                wsCompleted,
                wsAborted,
                wsInProgress,
                wsTerminated
                );

            SketchStatus skSaved        = CreateSketchStatus("Saved", "Sketch Saved");
            SketchStatus skDeployedDev  = CreateSketchStatus("DeployedDev", "Deployed to dev");
            SketchStatus skDeployedProd = CreateSketchStatus("DeployedProd", "Deployed to prod");
            SketchStatus skSentToSketch = CreateSketchStatus("SentToSketch", "Sent To Sketch");
            SketchStatus skAborted      = CreateSketchStatus("Aborted", "Abort workflow deployment");

            context.SketchStatuses.AddOrUpdate(
                sk => sk.Status,
                skAborted,
                skDeployedDev,
                skDeployedProd,
                skSaved,
                skSentToSketch
                );

            WorkflowCode wc1       = CreateWorkflowCode("SampleWf1", "this is a sample wf code for testing (1)");
            WorkflowCode wc2       = CreateWorkflowCode("SampleWf2", "this is a sample wf code for testing (2)");
            WorkflowCode wc3       = CreateWorkflowCode("SampleWf3", "this is a sample wf code for testing (3)");
            WorkflowCode wc4       = CreateWorkflowCode("SampleWf4", "this is a sample wf code for testing (4)");
            WorkflowCode wc4a      = CreateWorkflowCode("SampleWf4a", "this is a sample wf code for testing (4a)");
            WorkflowCode wc5       = CreateWorkflowCode("SampleWf5", "this is a sample wf code for testing (5)");
            WorkflowCode wc6       = CreateWorkflowCode("SampleWf6", "this is a sample wf code for testing (6)");
            WorkflowCode wc7       = CreateWorkflowCode("SampleWf7", "this is a sample wf code for testing (7)");
            WorkflowCode wc8       = CreateWorkflowCode("SampleWf8", "this is a sample wf code for testing (8)");
            WorkflowCode wc9       = CreateWorkflowCode("SampleWf9", "this is a sample wf code for testing (9)");
            WorkflowCode wcSketch  = CreateWorkflowCode("SketchWf", "Sketch workflow code");
            WorkflowCode wcHoliday = CreateWorkflowCode("HolidayWf", "Holiday workflow code");

            context.WorkflowCodes.AddOrUpdate(
                wc => wc.Code,
                wc1, wc2, wc3, wc4, wc4a, wc5, wc6, wc7, wc8, wc9, wcSketch, wcHoliday);

            WorkflowConfiguration wfc1       = CreateWorkflowConfiguration(wc1, "", "", "BasicHttpBinding_FlowTasks");
            WorkflowConfiguration wfc2       = CreateWorkflowConfiguration(wc2, "BasicHttpBinding_IFlowTasksOperations2", "http://localhost/Flow.Tasks.Workflows/SampleWf2.xamlx", "BasicHttpBinding_FlowTasks");
            WorkflowConfiguration wfc3       = CreateWorkflowConfiguration(wc3, "BasicHttpBinding_IFlowTasksOperations3", "http://localhost/Flow.Tasks.Workflows/SampleWf3.xamlx", "BasicHttpBinding_FlowTasks");
            WorkflowConfiguration wfc4       = CreateWorkflowConfiguration(wc4, "BasicHttpBinding_IFlowTasksOperations4", "http://localhost/Flow.Tasks.Workflows/SampleWf4.xamlx", "BasicHttpBinding_FlowTasks");
            WorkflowConfiguration wfc4a      = CreateWorkflowConfiguration(wc4a, "BasicHttpBinding_IFlowTasksOperations4a", "http://localhost/Flow.Tasks.Workflows/SampleWf4a.xamlx", "BasicHttpBinding_FlowTasks");
            WorkflowConfiguration wfc5       = CreateWorkflowConfiguration(wc5, "BasicHttpBinding_IFlowTasksOperations5", "http://localhost/Flow.Tasks.Workflows/SampleWf5.xamlx", "BasicHttpBinding_FlowTasks");
            WorkflowConfiguration wfc6       = CreateWorkflowConfiguration(wc6, "BasicHttpBinding_IFlowTasksOperations6", "http://localhost/Flow.Tasks.Workflows/SampleWf6.xamlx", "BasicHttpBinding_FlowTasks");
            WorkflowConfiguration wfc7       = CreateWorkflowConfiguration(wc7, "BasicHttpBinding_IFlowTasksOperations7", "http://localhost/Flow.Tasks.Workflows/SampleWf7.xamlx", "BasicHttpBinding_FlowTasks");
            WorkflowConfiguration wfc8       = CreateWorkflowConfiguration(wc8, "BasicHttpBinding_IFlowTasksOperations8", "http://localhost/ServiceWorkflowsVB/SampleWf8.xamlx", "BasicHttpBinding_FlowTasks");
            WorkflowConfiguration wfc9       = CreateWorkflowConfiguration(wc9, "BasicHttpBinding_IFlowTasksOperations9", "http://localhost/ServiceWorkflowsVB/SampleWf9.xamlx", "BasicHttpBinding_FlowTasks");
            WorkflowConfiguration wfcSketch  = CreateWorkflowConfiguration(wcSketch, "", "http://localhost/Flow.Tasks.Workflows/SketchWf.xamlx", "BasicHttpBinding_FlowTasks");
            WorkflowConfiguration wfcHoliday = CreateWorkflowConfiguration(wcHoliday, "", "http://localhost/Flow.Tasks.Workflows/HolidayWf.xamlx", "BasicHttpBinding_FlowTasks");

            context.WorkflowConfigurations.AddOrUpdate(
                wfc => wfc.ServiceUrl,
                wfc1, wfc2, wfc3, wfc4, wfc4a, wfc5, wfc6, wfc7, wfc8, wfc9, wfcSketch, wfcHoliday);

            // Topic
            TopicStatus topicNew  = CreateTopicStatus("New", "New topic message");
            TopicStatus topicRead = CreateTopicStatus("Read", "Read topic message");

            context.TopicStatuses.AddOrUpdate(
                t => t.Status,
                topicNew,
                topicRead
                );

            // Holiday
            HolidayType pubType   = CreateHolidayType("Public", "Public holiday");
            HolidayType anualType = CreateHolidayType("Annual", "Annual leave");
            HolidayType sickType  = CreateHolidayType("Sick", "Sick leave");

            context.HolidayTypes.AddOrUpdate(
                h => h.Type,
                pubType, anualType, sickType
                );

            Holiday h2014 = CreateHoliday(pubType, 2014, HolidayStatus.A.ToString(), "01/01/2014,27/01/2014,25/04/2014,09/06/2014,06/10/2014,25/12/2014,26/12/2014");
            Holiday h2015 = CreateHoliday(pubType, 2015, HolidayStatus.A.ToString(), "01/01/2015,26/01/2015,25/04/2015,08/06/2015,05/10/2015,25/12/2015,28/12/2015");
            Holiday h2016 = CreateHoliday(pubType, 2016, HolidayStatus.A.ToString(), "01/01/2016,26/01/2016,25/04/2016,13/06/2016,03/10/2016,26/12/2016,27/12/2016");

            context.Holidays.AddOrUpdate(
                h => h.Year,
                h2014, h2015, h2016
                );

            // Sketch properties
            var sketchUrl  = CreateProperty("SketchWorkflowUrl", "http://localhost/Flow.Tasks.Workflows/");
            var sketchPath = CreateProperty("SketchWorkflowPath", @"C:\Dev\Codeplex\FlowTasks\src\Workflows\ServiceWorkflows\");

            context.Properties.AddOrUpdate(
                p => p.Name,
                sketchUrl, sketchPath
                );

            var sketchWfpUrl  = CreateWorkflowProperty(sketchUrl, wcSketch);
            var sketchWfpPath = CreateWorkflowProperty(sketchPath, wcSketch);

            context.WorkflowProperties.AddOrUpdate(
                p => new { p.WorkflowCodeId, p.WorkflowPropertyId },
                sketchWfpUrl, sketchWfpPath
                );


            context.Database.ExecuteSqlCommand(REMOVE_PROC);
            context.Database.ExecuteSqlCommand(REPORT_TASK_TIME_PROC);
            context.Database.ExecuteSqlCommand(REPORT_USER_TASK_COUNT_PROC);
            context.Database.ExecuteSqlCommand(REPORT_USER_TASKS_PROC);
            context.Database.ExecuteSqlCommand(REPORT_WORKFLOW_TIME_PROC);
            context.Database.ExecuteSqlCommand(TOPIC_SEARCH_FUNC);
        }
Esempio n. 24
0
 private WorkflowDefinition CreateWorkflowDefinition(WorkflowCode workflowCode, WorkflowStatus workflowStatus)
 {
     return(new WorkflowDefinition
     {
         WorkflowOid = Guid.NewGuid(),
         WorkflowCode = workflowCode,
         StartedOn = DateTime.Now,
         WorkflowStatus = workflowStatus
     });
 }
 public WorkflowStatusSpecification(WorkflowStatus workflowStatus) => WorkflowStatus = workflowStatus;
Esempio n. 26
0
        /// <summary>
        /// Loads the published version context.
        /// </summary>
        /// <param name="loadDefaults">if set to <c>true</c> [load defaults].</param>
        private void LoadPublishedVersionContext(bool loadDefaults)
        {
            //GET PUBLISHED VERSION
            int statusId = WorkflowStatus.GetLast();

            string cacheKey = CmsCache.CreateCacheKey("page-published", CMSContext.Current.PageId.ToString(), statusId.ToString(), loadDefaults.ToString(), Thread.CurrentThread.CurrentCulture.Name);

            // check cache first
            object cachedObject = CmsCache.Get(cacheKey);

            int[] versionArray = null;

            if (cachedObject != null)
            {
                versionArray = (int[])cachedObject;
            }

            // Load the object
            if (versionArray == null)
            {
                lock (CmsCache.GetLock(cacheKey))
                {
                    cachedObject = CmsCache.Get(cacheKey);
                    if (cachedObject != null)
                    {
                        versionArray = (int[])cachedObject;
                    }
                    else
                    {
                        //using (IDataReader reader = PageVersion.GetByLangIdAndStatusId(CMSContext.Current.PageId, LanguageId, statusId))
                        using (IDataReader reader = PageVersion.GetVersionByStatusId(CMSContext.Current.PageId, statusId))
                        {
                            while (reader.Read())
                            {
                                // Load first language that we encounter, possibly should be the default language
                                if (CMSContext.Current.VersionId == -1 && loadDefaults)
                                {
                                    versionArray = new int[] { (int)reader["VersionId"], (int)reader["TemplateId"] };
                                }

                                if ((int)reader["LangId"] == LanguageId)
                                {
                                    versionArray = new int[] { (int)reader["VersionId"], (int)reader["TemplateId"] };
                                    break;
                                }
                            }

                            reader.Close();
                        }

                        CmsCache.Insert(cacheKey, versionArray, CmsConfiguration.Instance.Cache.PageDocumentTimeout);
                    }
                }
            }

            // Populate info from version array
            if (versionArray != null)
            {
                CMSContext.Current.VersionId  = versionArray[0];
                CMSContext.Current.TemplateId = versionArray[1];
            }
        }
Esempio n. 27
0
 public static StatusFilter Equals(WorkflowStatus value) => new StatusFilter()
 {
     Value = value.ToString()
 };
Esempio n. 28
0
    /// <summary>
    /// Initializes the workflow runtime.
    /// </summary>
    public void InitializeRuntime()
    {
      if (_workflowRuntime != null)
        return;

      _waitHandle = new ManualResetEvent(false);

      // initialize workflow runtime
      _workflowRuntime = new WorkflowRuntime();
      _workflowRuntime.WorkflowCompleted +=
        delegate(object sender, WorkflowCompletedEventArgs e)
        {
          _status = WorkflowStatus.Completed;
          _waitHandle.Set();
        };
      _workflowRuntime.WorkflowTerminated +=
        delegate(object sender, WorkflowTerminatedEventArgs e)
        {
          _status = WorkflowStatus.Terminated;
          _workflowError = e.Exception;
          _waitHandle.Set();
        };
      _workflowRuntime.WorkflowSuspended +=
        delegate(object sender, WorkflowSuspendedEventArgs e)
        {
          _status = WorkflowStatus.Suspended;
          _waitHandle.Set();
        };
      _workflowRuntime.WorkflowAborted +=
        delegate(object sender, WorkflowEventArgs e)
        {
          _status = WorkflowStatus.Aborted;
          _waitHandle.Set();
        };
      _workflowRuntime.WorkflowIdled +=
        delegate(object sender, WorkflowEventArgs e)
        {
          _status = WorkflowStatus.Idled;
          _waitHandle.Set();
        };
    }
 protected virtual void OnStatusUpdated(WorkflowStatus status)
 {
     StatusUpdated?.Invoke(status);
 }
Esempio n. 30
0
    /// <summary>
    /// Resumes asynchronous execution of
    /// the current workflow.
    /// </summary>
    public void BeginResumeWorkflow()
    {
      InitializeRuntime();

      if (!_workflowRuntime.IsStarted)
        _workflowRuntime.StartRuntime();

      // execute workflow
      _instance.Resume();
      _status = WorkflowStatus.Executing;
    }
Esempio n. 31
0
 internal void UpdateWorkflowStatus(string user, WorkflowStatus status)
 {
     UpdateWorkflowStatus(user, (int)status);
 }
Esempio n. 32
0
 public void WorkflowStatus_Not_In_Set_Returns_True(object[] data, WorkflowStatus status, bool result)
 {
     Assert.Equal(result, status.NotIn(data));
 }
Esempio n. 33
0
        private void CreateVersion(DynamicContent entity, string changeComment, VersionManager versionManager, WorkflowStatus status)
        {
            entity.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, status.ToString());

            var change = versionManager.CreateVersion(entity, status == WorkflowStatus.Published);

            if (changeComment != null)
            {
                change.Comment = changeComment;
            }
        }
Esempio n. 34
0
        protected virtual void UpdateWorkflowStatus(WorkflowStatus status, string message)
        {
            var statusActor = Context.ActorOf(Props.Create(typeof(WorkflowStatusActor)));

            statusActor.Tell(new UpdateStatusMesssage { Status = status, Message = message }, Self);
        }
Esempio n. 35
0
 protected void OperationStatusUpdated(WorkflowStatus operationStatus)
 {
     SendStatusUpdate(operationStatus).GetAwaiter().GetResult();
 }