Esempio n. 1
0
        private void ExecuteAction(WorkFlow.WorkFlow SourceWorkflow, WorkFlow.WorkFlow TargetWorkflow)
        {
            try
            {
                if ((this.CurrentObject as XPBaseObject).Fit(this.CurrentObject.Session.ParseCriteria(SourceWorkflow.SourceCriterion)))
                {
                    if (SourceWorkflow.SourceObject == TargetWorkflow.TargetObject)
                    {
                        ActionUpdate(this.CurrentObject, TargetWorkflow);
                        ActionTracking(SourceWorkflow, string.Concat(TargetWorkflow.TargetObject.Name, string.Empty, TargetWorkflow.FullDescription, " executed"));
                    }
                    else
                    {
                        foreach (PropertyInfo propertyInfo in this.CurrentObject.GetType().GetProperties())
                        {
                            IterateProperties(propertyInfo, TargetWorkflow);
                        }

                        ActionTracking(SourceWorkflow, string.Concat(TargetWorkflow.TargetObject.Name, string.Empty, TargetWorkflow.FullDescription, " executed"));
                    }
                }
            }
            catch (Exception ex)
            {
                ActionTracking(SourceWorkflow, string.Concat(TargetWorkflow.TargetObject.Name, ex.ToString(), TargetWorkflow.FullDescription, " executed"));
                throw ex;
            }
        }
Esempio n. 2
0
 private void IterateProperties(PropertyInfo PropertyInfo, WorkFlow.WorkFlow WorkFlow)
 {
     if (PropertyInfo.PropertyType == WorkFlow.SourceObject)
     {
         ActionUpdate(PropertyInfo.GetValue(WorkFlow), WorkFlow);
     }
 }
Esempio n. 3
0
        private void ExecuteWorkFlow(WorkFlow.WorkFlow SourceWorkflow)
        {
            try
            {
                ICollection <WorkFlow.WorkFlow> childExecutionActions = XpoHelper.GetObjects <WorkFlow.WorkFlow>(new BinaryOperator("Action", WorkFlowAction.ExecuteAction) & new BinaryOperator("ParentItem", SourceWorkflow) & new BinaryOperator("Status", WorkFlowStatus.Enabled));

                foreach (WorkFlow.WorkFlow workFlow in childExecutionActions)
                {
                    ExecuteAction(SourceWorkflow, workFlow);
                }
            }catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
        private void ActionTracking(WorkFlow.WorkFlow WorkFlow, string Description)
        {
            using (UnitOfWork unitOfWork = new UnitOfWork(WorkFlow.Session.DataLayer))
            {
                WorkFlow.WorkFlow workFlow = unitOfWork.FindObject <WorkFlow.WorkFlow>(CriteriaOperator.Parse("Oid ==?", WorkFlow.Oid));

                WorkFlowDesignTracking workFlowTracking = new WorkFlowDesignTracking(unitOfWork)
                {
                    WorkFlow    = workFlow,
                    Description = Description
                };

                unitOfWork.CommitTransaction();
            }
        }
Esempio n. 5
0
        private void ActionUpdate(object value, WorkFlow.WorkFlow WorkFlow)
        {
            Dictionary <string, object> criteriaValues;

            using (UnitOfWork unitOfWork = new UnitOfWork(this.CurrentObject.Session.DataLayer))
            {
                object            secondObject = unitOfWork.FindObject(value.GetType(), CriteriaOperator.Parse("Oid ==?", (value as BaseObject).Oid));
                WorkFlow.WorkFlow workFlow     = unitOfWork.FindObject <WorkFlow.WorkFlow>(CriteriaOperator.Parse("Oid ==?", WorkFlow.Oid));

                criteriaValues = Extract(unitOfWork.ParseCriteria(workFlow.TargetCriterion));

                foreach (KeyValuePair <string, object> criteriaValue in criteriaValues)
                {
                    ActionUpdateProperty(criteriaValue, secondObject);
                }

                unitOfWork.CommitTransaction();
            }
        }
Esempio n. 6
0
        public override IResult Parse(object source)
        {
            WorkFlowManagerWebPart workflowManagerWebPart = source as WorkFlowManagerWebPart;

            if (null == workflowManagerWebPart)
            {
                throw new ArgumentException("source is not a WorkFlowManagerWebPart");
            }

            IConfiguration configuration = workflowManagerWebPart.Configuration;

            if (null == configuration)
            {
                throw new ArgumentException("source does not have a configuration");
            }

            WebPartManager Manager = WebPartManager.GetCurrentWebPartManager(workflowManagerWebPart.Page);

            if (configuration.Sections.ContainsKey("flows"))
            {
                WorkFlow.WorkFlow flow = new WorkFlow.WorkFlow();
                flow.Monitor = workflowManagerWebPart.Monitor;
                flow.Title   = "screen flow";
                IConfigurationSection flowsSection = configuration.GetConfigurationSectionReference("flows");
                foreach (IConfigurationElement flowElement in flowsSection.Elements.Values)
                {
                    Job job = new Job();
                    job.Monitor = workflowManagerWebPart.Monitor;
                    job.Title   = flowElement.ConfigKey;
                    if (flowElement.Elements.ContainsKey("conditions"))
                    {
                        foreach (IConfigurationElement conditionElement in flowElement.Elements["conditions"].Elements.Values)
                        {
                            if (flowElement.Elements["conditions"].Attributes.ContainsKey("type"))
                            {
                                ReflectionServices.SetValue(job.Conditions, "Type", flowElement.Elements["conditions"].GetAttributeReference("type").Value.ToString());
                            }
                            if (conditionElement.Attributes.ContainsKey("waitfor") && !("waitfor" == conditionElement.GetAttributeReference("type").Value.ToString()))
                            {
                                throw new InvalidOperationException("Unknown condition type " + conditionElement.GetAttributeReference("type").Value.ToString());
                            }

                            WaitForCondition condition = new WaitForCondition();
                            condition.Monitor = workflowManagerWebPart.Monitor;
                            if (conditionElement.Attributes.ContainsKey("milestone"))
                            {
                                condition.Milestone = conditionElement.GetAttributeReference("milestone").Value.ToString();
                            }
                            if (conditionElement.Attributes.ContainsKey("sender"))
                            {
                                condition.Chronicler = (ReflectionServices.FindControlEx(conditionElement.GetAttributeReference("sender").Value.ToString(), Manager) as IChronicler);
                            }
                            condition.Target = job;
                            job.Conditions.Add(condition);
                            if (conditionElement.Elements.ContainsKey("expression"))
                            {
                                IConfigurationElement expressionElement = conditionElement.GetElementReference("expression");
                                IExpression           expression        = workflowManagerWebPart.ExpressionsManager.Token(expressionElement.GetAttributeReference("type").Value.ToString()) as IExpression;
                                if (null != expression)
                                {
                                    expression.Make(expressionElement, workflowManagerWebPart.ExpressionsManager);
                                    condition.Expression = expression;
                                }
                            }
                        }
                    }

                    if (flowElement.Elements.ContainsKey("transits"))
                    {
                        foreach (IConfigurationElement transitElement in flowElement.GetElementReference("transits").Elements.Values)
                        {
                            if (transitElement.Attributes.ContainsKey("key"))
                            {
                                Transit transit = new Transit();
                                transit.Monitor = workflowManagerWebPart.Monitor;
                                transit.Title   = transitElement.ConfigKey;
                                transit.Key     = transitElement.GetAttributeReference("key").Value.ToString();
                                transit.Storage = workflowManagerWebPart.StatePersistence;
                                if (transitElement.Elements.ContainsKey("expression"))
                                {
                                    IConfigurationElement expressionElement = transitElement.GetElementReference("expression");
                                    IExpression           expression        = workflowManagerWebPart.ExpressionsManager.Token(expressionElement.GetAttributeReference("type").Value.ToString()) as IExpression;
                                    if (null == expression)
                                    {
                                        throw new InvalidOperationException("Token is not an IExpression");
                                    }
                                    expression.Make(expressionElement, workflowManagerWebPart.ExpressionsManager);
                                    transit.Expression = expression;
                                }
                                if (transitElement.Elements.ContainsKey("source"))
                                {
                                    transit.Source = this.CreateTransitPoint(Manager, transitElement.GetElementReference("source"), workflowManagerWebPart.ExpressionsManager);
                                }
                                if (transitElement.Elements.ContainsKey("destination"))
                                {
                                    transit.Destination = this.CreateTransitPoint(Manager, transitElement.GetElementReference("destination"), workflowManagerWebPart.ExpressionsManager);
                                }
                                if (transitElement.Attributes.ContainsKey("persistent"))
                                {
                                    transit.IsPersistent = bool.Parse(transitElement.GetAttributeReference("persistent").Value.ToString());
                                }

                                job.Transits.Add(transit);
                            }
                        }
                    }
                    flow.Jobs.Add(job);
                }
                workflowManagerWebPart.WorkFlows.Add(flow);
            }
            return(null);
        }
        public override IResult Parse(object source)
        {
            WorkFlowManagerWebPart workflowManagerWebPart = source as WorkFlowManagerWebPart;
            if (null == workflowManagerWebPart) throw new ArgumentException("source is not a WorkFlowManagerWebPart");

            IConfiguration configuration = workflowManagerWebPart.Configuration;
            if (null == configuration) throw new ArgumentException("source does not have a configuration");

            WebPartManager Manager = WebPartManager.GetCurrentWebPartManager(workflowManagerWebPart.Page);
            if (configuration.Sections.ContainsKey("flows"))
            {
                WorkFlow.WorkFlow flow = new WorkFlow.WorkFlow();
                flow.Monitor = workflowManagerWebPart.Monitor;
                flow.Title = "screen flow";
                IConfigurationSection flowsSection = configuration.GetConfigurationSectionReference("flows");
                foreach (IConfigurationElement flowElement in flowsSection.Elements.Values)
                {
                    Job job = new Job();
                    job.Monitor = workflowManagerWebPart.Monitor;
                    job.Title = flowElement.ConfigKey;
                    if (flowElement.Elements.ContainsKey("conditions"))
                    {
                        foreach (IConfigurationElement conditionElement in flowElement.Elements["conditions"].Elements.Values)
                        {
                            if (flowElement.Elements["conditions"].Attributes.ContainsKey("type"))
                                ReflectionServices.SetValue(job.Conditions, "Type", flowElement.Elements["conditions"].GetAttributeReference("type").Value.ToString());
                            if (conditionElement.Attributes.ContainsKey("waitfor") && !("waitfor" == conditionElement.GetAttributeReference("type").Value.ToString()))
                                throw new InvalidOperationException("Unknown condition type " + conditionElement.GetAttributeReference("type").Value.ToString());

                            WaitForCondition condition = new WaitForCondition();
                            condition.Monitor = workflowManagerWebPart.Monitor;
                            if (conditionElement.Attributes.ContainsKey("milestone"))
                                condition.Milestone = conditionElement.GetAttributeReference("milestone").Value.ToString();
                            if (conditionElement.Attributes.ContainsKey("sender"))
                                condition.Chronicler = (ReflectionServices.FindControlEx(conditionElement.GetAttributeReference("sender").Value.ToString(), Manager) as IChronicler);
                            condition.Target = job;
                            job.Conditions.Add(condition);
                            if (conditionElement.Elements.ContainsKey("expression"))
                            {
                                IConfigurationElement expressionElement = conditionElement.GetElementReference("expression");
                                IExpression expression = workflowManagerWebPart.ExpressionsManager.Token(expressionElement.GetAttributeReference("type").Value.ToString()) as IExpression;
                                if (null != expression)
                                {
                                    expression.Make(expressionElement, workflowManagerWebPart.ExpressionsManager);
                                    condition.Expression = expression;
                                }
                            }
                        }
                    }

                    if (flowElement.Elements.ContainsKey("transits"))
                    {
                        foreach (IConfigurationElement transitElement in flowElement.GetElementReference("transits").Elements.Values)
                        {
                            if (transitElement.Attributes.ContainsKey("key"))
                            {
                                Transit transit = new Transit();
                                transit.Monitor = workflowManagerWebPart.Monitor;
                                transit.Title = transitElement.ConfigKey;
                                transit.Key = transitElement.GetAttributeReference("key").Value.ToString();
                                transit.Storage = workflowManagerWebPart.StatePersistence;
                                if (transitElement.Elements.ContainsKey("expression"))
                                {
                                    IConfigurationElement expressionElement = transitElement.GetElementReference("expression");
                                    IExpression expression = workflowManagerWebPart.ExpressionsManager.Token(expressionElement.GetAttributeReference("type").Value.ToString()) as IExpression;
                                    if (null == expression) throw new InvalidOperationException("Token is not an IExpression");
                                    expression.Make(expressionElement, workflowManagerWebPart.ExpressionsManager);
                                    transit.Expression = expression;
                                }
                                if (transitElement.Elements.ContainsKey("source"))
                                    transit.Source = this.CreateTransitPoint(Manager, transitElement.GetElementReference("source"), workflowManagerWebPart.ExpressionsManager);
                                if (transitElement.Elements.ContainsKey("destination"))
                                    transit.Destination = this.CreateTransitPoint(Manager, transitElement.GetElementReference("destination"), workflowManagerWebPart.ExpressionsManager);
                                if (transitElement.Attributes.ContainsKey("persistent"))
                                    transit.IsPersistent = bool.Parse(transitElement.GetAttributeReference("persistent").Value.ToString());

                                job.Transits.Add(transit);
                            }
                        }
                    }
                    flow.Jobs.Add(job);
                }
                workflowManagerWebPart.WorkFlows.Add(flow);
            }
            return null;
        }