Exemplo n.º 1
0
        public PreviewResult PreviewChanges(string workflowId, [Required, FromBody] WorkflowModel model)
        {
            var id = PrimaryKey.Parse(workflowId, typeof(WorkflowEntity));
            var wf = Database.Retrieve <WorkflowEntity>(id);

            return(WorkflowLogic.PreviewChanges(wf, model));
        }
Exemplo n.º 2
0
        static public Guid OpenExportProcess(Guid tenantId, ShippingExportDC dc)
        {
            if (GetExportProcessbyContractId(dc.Id) != null)
            {
                return(Guid.Empty);
            }
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("TenantId", tenantId);
            parameters.Add("ObjectId", dc.Id);
            parameters.Add("Number", dc.Number);
            string textUpn = AuthenticationLogic.GetUpnByUserId((Guid)dc.Creator);

            parameters.Add("Creator", textUpn);

            WorkflowDefinition workflowDef = WorkflowLogic.GetWorkflowDefinition(tenantId, (int)ProcessTypes.ShippingExport);

            parameters.Add("InternalWorkflowType", (int)ProcessTypes.ShippingExport);
            System.Xml.XmlReader xomlReader  = System.Xml.XmlReader.Create(new StringReader(workflowDef.Xoml));
            System.Xml.XmlReader rulesReader = string.IsNullOrEmpty(workflowDef.Rules)?null:System.Xml.XmlReader.Create(new StringReader(workflowDef.Rules));

            WorkflowInstance workflowInstance = Runtime.CreateWorkflow(xomlReader, rulesReader, parameters);

            workflowInstance.Start();
            RunWorkflowInScheduler(workflowInstance.InstanceId);
            return(workflowInstance.InstanceId);
        }
Exemplo n.º 3
0
#pragma warning restore CS8618 // Non-nullable field is uninitialized.
    public bool IsStartCurrentUser()
    {
        if (Workflow.HasExpired())
        {
            return(false);
        }

        if (Workflow.MainEntityStrategies.Count == 0)
        {
            return(false);
        }

        var act = Events.Values.Where(a => a.Type == WorkflowEventType.Start);

        return(act.Any(a =>
        {
            if (a.Lane.ActorsEval != null)
            {
                var actors = a.Lane.ActorsEval.Algorithm.GetActors(null !, new WorkflowTransitionContext(null, null, null));

                return actors.Any(a => WorkflowLogic.IsUserActor(UserEntity.Current, a));
            }

            return a.Lane.Actors.Any(a => WorkflowLogic.IsUserActor(UserEntity.Current, a));
        }));
    }
Exemplo n.º 4
0
        public static void Register()
        {
            new Execute(WorkflowOperation.Save)
            {
                CanBeNew      = true,
                CanBeModified = true,
                Execute       = (e, args) =>
                {
                    if (e.MainEntityStrategies.Contains(WorkflowMainEntityStrategy.CreateNew))
                    {
                        var type = e.MainEntityType.ToType();
                        if (CaseActivityLogic.Options.TryGetC(type)?.Constructor == null)
                        {
                            throw new ApplicationException(WorkflowMessage._0NotAllowedFor1NoConstructorHasBeenDefinedInWithWorkflow.NiceToString(WorkflowMainEntityStrategy.CreateNew.NiceToString(), type.NiceName()));
                        }
                    }

                    WorkflowLogic.ApplyDocument(e, args.TryGetArgC <WorkflowModel>(), args.TryGetArgC <WorkflowReplacementModel>(), args.TryGetArgC <List <WorkflowIssue> >() ?? new List <WorkflowIssue>());
                    DynamicCode.OnInvalidated?.Invoke();
                }
            }.Register();

            new ConstructFrom <WorkflowEntity>(WorkflowOperation.Clone)
            {
                Construct = (w, args) =>
                {
                    WorkflowBuilder wb = new WorkflowBuilder(w);

                    var result = wb.Clone();

                    return(result);
                }
            }.Register();

            new Delete(WorkflowOperation.Delete)
            {
                CanDelete = w =>
                {
                    var usedWorkflows = Database.Query <CaseEntity>()
                                        .Where(c => c.Workflow.Is(w) && c.ParentCase != null)
                                        .Select(c => c.ParentCase !.Entity.Workflow.ToLite())
                                        .Distinct()
                                        .ToList();

                    if (usedWorkflows.Any())
                    {
                        return(WorkflowMessage.WorkflowUsedIn0ForDecompositionOrCallWorkflow.NiceToString(usedWorkflows.ToString(", ")));
                    }

                    return(null);
                },

                Delete = (w, _) =>
                {
                    var wb = new WorkflowBuilder(w);
                    wb.Delete();
                    DynamicCode.OnInvalidated?.Invoke();
                }
            }.Register();
Exemplo n.º 5
0
 public byte[] GetWorkflowGraphic(Guid processId)
 {
     if (!RequestContext.Current.IsAuthenticated)
     {
         throw new InvalidOperationException("Insufficient privilege!");
     }
     return(WorkflowLogic.GetWorkflowGraphic(processId));
 }
Exemplo n.º 6
0
        public WorkflowModel GetWorkflowModel(string workflowId)
        {
            var id  = PrimaryKey.Parse(workflowId, typeof(WorkflowEntity));
            var wf  = Database.Retrieve <WorkflowEntity>(id);
            var res = WorkflowLogic.GetWorkflowModel(wf);

            return(res);
        }
Exemplo n.º 7
0
 public byte[] GetWorkflowDefinitionGraphic(int workflowType)
 {
     if (RequestContext.Current.TenantId == Guid.Empty)
     {
         throw new ArgumentNullException("tenantId");
     }
     return(WorkflowLogic.GetWorkflowDefinitionGraphic(RequestContext.Current.TenantId, workflowType));
 }
Exemplo n.º 8
0
        public WorkflowModelAndIssues GetWorkflowModel(string workflowId)
        {
            var id    = PrimaryKey.Parse(workflowId, typeof(WorkflowEntity));
            var wf    = Database.Retrieve <WorkflowEntity>(id);
            var model = WorkflowLogic.GetWorkflowModel(wf);
            var wb    = new WorkflowBuilder(wf);
            List <WorkflowIssue> issues = new List <WorkflowIssue>();

            wb.ValidateGraph(issues);
            return(new WorkflowModelAndIssues(model, issues));
        }
Exemplo n.º 9
0
 public byte[] GetWorkflowDefinitionGraphic(int workflowType)
 {
     if (RequestContext.Current.TenantId == Guid.Empty)
     {
         throw new ArgumentNullException("tenantId");
     }
     if (!RequestContext.Current.IsAuthenticated)
     {
         throw new InvalidOperationException("Insufficient privilege!");
     }
     return(WorkflowLogic.GetWorkflowDefinitionGraphic(RequestContext.Current.TenantId, workflowType));
 }
Exemplo n.º 10
0
 public void UpdateWorkflowDefinition(int workflowType, string xoml, string rules)
 {
     if (RequestContext.Current.TenantId == Guid.Empty)
     {
         throw new ArgumentNullException("tenantId");
     }
     if (string.IsNullOrEmpty(xoml))
     {
         throw new ArgumentNullException("xoml");
     }
     WorkflowLogic.UpdateWorkflowDefinition(RequestContext.Current.TenantId, workflowType, xoml, rules);
 }
Exemplo n.º 11
0
 public void UpdateWorkflowDefinition(int workflowType, string xoml, string rules)
 {
     if (RequestContext.Current.TenantId == Guid.Empty)
     {
         throw new ArgumentNullException("tenantId");
     }
     if (string.IsNullOrEmpty(xoml))
     {
         throw new ArgumentNullException("xoml");
     }
     if (!RequestContext.Current.IsAuthenticated)
     {
         throw new InvalidOperationException("Insufficient privilege!");
     }
     WorkflowLogic.UpdateWorkflowDefinition(RequestContext.Current.TenantId, workflowType, xoml, rules);
 }
Exemplo n.º 12
0
 public List <WorkflowEntity> Starts()
 {
     return(WorkflowLogic.GetAllowedStarts());
 }
Exemplo n.º 13
0
        public List <Lite <IWorkflowNodeEntity> > FindNode([Required, FromBody] WorkflowFindNodeRequest request)
        {
            var workflow = Lite.Create <WorkflowEntity>(request.workflowId);

            return(WorkflowLogic.AutocompleteNodes(workflow, request.subString, request.count, request.excludes));
        }
Exemplo n.º 14
0
 public static void Start(SchemaBuilder sb, Func <WorkflowConfigurationEmbedded> getConfiguration)
 {
     WorkflowLogic.Start(sb, getConfiguration);
     CaseActivityLogic.Start(sb);
     WorkflowEventTaskLogic.Start(sb);
 }
Exemplo n.º 15
0
 public byte[] GetWorkflowGraphic(Guid processId)
 {
     return(WorkflowLogic.GetWorkflowGraphic(processId));
 }