Пример #1
0
			public void Execute(InterpretationStep step, Staff executingStaff, List<InterpretationStep> linkInterpretations, IWorkflow workflow)
			{
				// if not assigned, assign
				if (step.AssignedStaff == null)
				{
					step.Assign(executingStaff);
				}

				// put in-progress
				step.Start(executingStaff);

				// if a report has not yet been created for this step, create now
				if (step.ReportPart == null)
				{
					var report = new Report(step.Procedure);
					var reportPart = report.ActivePart;

					workflow.AddEntity(report);

					step.ReportPart = reportPart;
					step.ReportPart.Interpreter = executingStaff;
				}

				// attach linked interpretations to this report
				foreach (var interpretation in linkInterpretations)
				{
					interpretation.LinkTo(step);
				}
			}
Пример #2
0
 public static IDictionary<String, Object> Execute(IWorkflow workflow, IDictionary<String, Object> inputs)
 {
     using (var context = new Context(workflow))
     {
         foreach (var argument in workflow.Arguments)
         {
             if (((argument.Direction == Direction.In) ||
                  (argument.Direction == Direction.InOut)) &&
                 inputs.ContainsKey(argument.Name))
             {
                 context.SetValue(argument, inputs[argument.Name]);
             }
         }
         workflow.Execute(context);
         var outputs = new Dictionary<String, Object>();
         foreach (var argument in workflow.Arguments)
         {
             if ((argument.Direction == Direction.Out) ||
                 (argument.Direction == Direction.InOut))
             {
                 outputs[argument.Name] = context.GetValue(argument);
             }
         }
         return outputs;
     }
 }
Пример #3
0
 public void Run(IWorkflow workflow)
 {
     foreach (ITask I in workflow.GetTasks())
     {
         I.Execute();
     }
 }
Пример #4
0
		protected void TryAutoTerminateProcedureSteps(Procedure procedure, DateTime? time, IWorkflow workflow)
		{
			foreach (var mps in procedure.ModalityProcedureSteps)
			{
				// if the MPS is not terminated and has some MPPS
				if(!mps.IsTerminated && !mps.PerformedSteps.IsEmpty)
				{
					var allMppsDiscontinued = CollectionUtils.TrueForAll(mps.PerformedSteps,
						(PerformedProcedureStep pps) => pps.State == PerformedStepStatus.DC);
					var allMppsTerminated = CollectionUtils.TrueForAll(mps.PerformedSteps,
						(PerformedProcedureStep pps) => pps.IsTerminated);

					if (allMppsDiscontinued)
					{
						// discontinue MPS, since all MPPS are discontinued
						mps.Discontinue(time);
					}
					else if (allMppsTerminated)
					{
						// all MPPS are terminated, and at least one MPPS must be completed, so complete MPS
						mps.Complete(time);
					}
				}
			}
		}
Пример #5
0
 public void Run(IWorkflow workflow)
 {
     foreach (var activity in workflow.GetActivities())
     {
         activity.Execute();
     }
 }
Пример #6
0
 public void Setup()
 {
     if (workflow == null)
     {
         workflow = new SequentialWorkflow();
     }
     workflow.Cleanup();
 }
        public void Init()
        {
            _mocks = new MockRepository();
            _workflow = _mocks.DynamicMock<IWorkflow>();
            _rendererFactory = _mocks.DynamicMock<IWorkStepRendererFactory>();

            _httpHandler = new WorkflowHttpHandler(_workflow, _rendererFactory);
        }
Пример #8
0
 public Context(IWorkflow workflow)
 {
     Workflow = workflow;
     foreach (var argument in workflow.Arguments)
     {
         _values[argument] = new ValueStore();
     }
 }
Пример #9
0
			public void Execute(List<Patient> patientsToReconcile, IWorkflow workflow)
			{
				// reconcile all patients
				for (var i = 1; i < patientsToReconcile.Count; i++)
				{
					Reconcile(patientsToReconcile[0], patientsToReconcile[i], workflow);
				}
			}
Пример #10
0
        public STR_MSG Redirect(STR_MSG oMsg)
        {
            if (oMsg.token == "Pharmacien")
            {
                // services pharmaciens
            }
            else if (oMsg.token == "Fournisseur")
            {
                // services Fournisseurs
            }
            else if (oMsg.token == "Preparateur")
            {
                // services préparateur
            }
            else
            {

            }

            // SERVICES GÉNÉRAUX

            // Connexion à la BDD
            if ((oMsg.Invoke == "Connexion") && (oMsg.App_Name == "PharmaProject_v1"))
            {
                //// vérification des droits
                this.work = new CL_WF_VerificationDroits();
                this.oMsg = work.exec(oMsg);

                // Si la vérification est OK
                if ((string)this.oMsg.Data[0] == oMsg.token)
                {
                    this.work = new CL_WF_Connect();
                    this.oMsg = work.exec(oMsg);
                }
                else if ((string)this.oMsg.Data[0] == "Utilisateur Inexistant")
                {
                    this.oMsg = CL_MESSAGE_Factory.msg_factory("", null, "Utilisateur Inexistant", "", "", true, "");
                }

                else
                {
                    this.oMsg = CL_MESSAGE_Factory.msg_factory("", null, "Mauvais droits", "", "", true, "");
                }

            }

            else if ((oMsg.Invoke == "CreerUtilisateur") && (oMsg.App_Name == "PharmaProject_v1"))
            {

                this.work = new CL_WF_CreerUtilisateur();
                this.oMsg = work.exec(oMsg);

            }

            return this.oMsg;
        }
 public void ShouldExecuteAfterSuccessfulFunction()
 {
     _workflow = Workflow<Colour>.Definition()
         .Do(s =>
                 {
                     s.Name = "blue";
                     return s;
                 })
         .Do<DoubleSpace>(If.Successfull(Step.Previous));
 }
Пример #12
0
 public void Given()
 {
     var branchPoint = Declare.Step();
     wf = new Workflow<IObject>()
         .Do(x => x.Feedback("beginning"), If.IsTrue(() => counter < 1, branchPoint))
         .Do(x => x.Feedback("middle"))
         .Do(x => x.Feedback("end"), defineAs: branchPoint);
     mock = new Mock<IObject>();
     mock.Setup(x => x.Feedback(It.IsAny<string>())).Returns(mock.Object);
 }
 public void Given()
 {
     _taskList = new TaskList<string>();
     _container = new DefaultKernel();
     ServiceLocator<string>.SetInstance(_container);
     _container.Register(Component.For<TaskList<string>>().Instance(_taskList));
     _container.Register(Component.For<SequentialBuilder<string>>().Instance(new SequentialBuilder<string>(_taskList)));
     _container.Register(Component.For<WorkflowEngine<string>>().Instance(new WorkflowEngine<string>()));
     _workflow = new Workflow<string>();
     _function = new Func<bool>(RedOrangeYellow);
 }
        public static async Task InvokeAsync(IWorkflow workflow)
        {
            workflow = new Workflow();
            workflow.Add(new CallWebService(1));
            workflow.Add(new CallWebService(2));
            workflow.Add(new CallWebService(3));
            workflow.Add(new CallWebService(4));
            workflow.Add(new CallWebService(5));

            var engine = new WorkflowEngine();
            await engine.RunAsync(workflow);
        }
        public static void Invoke(IWorkflow workflow)
        {
            workflow = new Workflow();
            workflow.Add(new CallWebService(1));
            workflow.Add(new CallWebService(2));
            workflow.Add(new CallWebService(3));
            workflow.Add(new CallWebService(4));
            workflow.Add(new CallWebService(5));

            var engine = new WorkflowEngine();
            engine.Run(workflow);
        }
Пример #16
0
        public Context(IWorkflow workflow, IVariableScope variableScope)
            : this(workflow)
        {
            if (variableScope == null)
                return;

            foreach (var variable in variableScope.Variables)
            {
                Variables.Add(variable);
                _values[variable] = new ValueStore();
            }
        }
 //        Returns all none-final states based on a specific template of a specific workflow
 public static IEnumerable<WorkflowState> GetNonFinalStatesByTemplate(IWorkflow workflow, string templateName)
 {
     using (new SecurityModel.SecurityDisabler())
     {
         Database masterDb = Factory.GetDatabase(DbName);
         var allStates = workflow.GetStates();
         return
             allStates.Where(
                 s => !s.FinalState &&
                      string.Equals(masterDb.GetItem(new ID(s.StateID)).TemplateName, templateName,
                                    StringComparison.InvariantCultureIgnoreCase));
     }
 }
Пример #18
0
 public static String Save(IWorkflow workflow)
 {
     var output = new StringWriter();
     using (var writer = XmlWriter.Create(output, new XmlWriterSettings { Indent = true }))
     {
         var xamlSchemaContext = new CustomXamlSchemaContext();
         using (var xamlWriter = new XamlXmlWriter(writer, xamlSchemaContext))
         {
             XamlServices.Save(xamlWriter, workflow);
         }
     }
     return output.ToString();
 }
Пример #19
0
        public void TerminateWorkflow(IApplicationContext ctx, IWorkflow wf, bool rollback = false)
        {
            if (rollback)
                ctx.Dal.CancelChanges();
            else
                ctx.Dal.SaveChanges();

            Workflow lastWorkflow = _workflowStack.Pop();
            lastWorkflow.Stop(ctx);

            if (_workflowStack.Count == 0)
                throw new Exception("Application terminated");
        }
Пример #20
0
			/// <summary>
			/// Reconciles the specified patient to this patient
			/// </summary>
			/// <param name="thisPatient"></param>
			/// <param name="otherPatient"></param>
			/// <param name="workflow"></param>
			private static void Reconcile(Patient thisPatient, Patient otherPatient, IWorkflow workflow)
			{
				if (PatientIdentifierConflictsFound(thisPatient, otherPatient))
					throw new PatientReconciliationException("assigning authority conflict - cannot reconcile");

				// copy the collection to iterate
				var otherProfiles = new List<PatientProfile>(otherPatient.Profiles);
				foreach (var profile in otherProfiles)
				{
					thisPatient.AddProfile(profile);
				}

				// copy the collection to iterate
				var otherNotes = new List<PatientNote>(otherPatient.Notes);
				foreach (var note in otherNotes)
				{
					thisPatient.AddNote(note);
				}

				// copy the collection to iterate
				var otherAttachments = new List<PatientAttachment>(otherPatient.Attachments);
				foreach (var attachment in otherAttachments)
				{
					otherPatient.Attachments.Remove(attachment);
					thisPatient.Attachments.Add(attachment);
				}

				// copy the collection to iterate
				var otherAllergies = new List<Allergy>(otherPatient.Allergies);
				foreach (var allergy in otherAllergies)
				{
					otherPatient.Allergies.Remove(allergy);
					thisPatient.Allergies.Add(allergy);
				}

				var visitCriteria = new VisitSearchCriteria();
				visitCriteria.Patient.EqualTo(otherPatient);
				var otherVisits = workflow.GetBroker<IVisitBroker>().Find(visitCriteria);
				foreach (var visit in otherVisits)
				{
					visit.Patient = thisPatient;
				}

				var orderCriteria = new OrderSearchCriteria();
				orderCriteria.Patient.EqualTo(otherPatient);
				var otherOrders = workflow.GetBroker<IOrderBroker>().Find(orderCriteria);
				foreach (var order in otherOrders)
				{
					order.Patient = thisPatient;
				}
			}
Пример #21
0
        public void ZeroWorkflows_Start_LogsNoWorkflows()
        {
            var logger = new MockLogger();
            var engine = new WorkflowEngine(logger);

            var workflows = new IWorkflow[]{};
            engine.Start(workflows);

            IEnumerable<string> expectedLogResult = new string[]
            {
                "Starting all workflows...",
                "Finished all workflows."
            };
            IEnumerable<string> actualLogResult = logger.GetLogContents();

            Assert.IsTrue(expectedLogResult.SequenceEqual(actualLogResult));
        }
        public void Run(IWorkflow workflow)
        {
            foreach (IActivity activity in workflow.GetActivities())
            {
                try
                {
                    activity.Execute();
                }
                catch (Exception ex)
                {
                    // Log to event log...
                    // Terminate and throw exception while saving state.
                    Console.WriteLine("Error was found: " + ex);                    
                }

            }
        }
        public void Given()
        {
            var branchPoint = Declare.Step();
            w = new Workflow<IObject>()
                .Do(x => x.Feedback("branch point"), branchPoint)
                .Do(x => x.Feedback("first point"), If.IsTrue(() => tracker < 2, branchPoint))
                .Do(x => x.Feedback("second point"), If.IsTrue(() => tracker < 1, branchPoint))
                ;

            mock = new Mock<IObject>();
            mock.Setup(x => x.Feedback(It.IsAny<string>())).Returns(mock.Object);
            // This setup is to avoid infinite loops in the test data
            int timer = 0;
            mock.Setup(x => x.Feedback("branch point")).Callback(() =>
            {
                if (++timer == 2)
                    tracker = 0;
            }).Returns(mock.Object);
        }
        //        Returns all items in a specific state of a specific workflow
        public static IEnumerable<Item> GetItemsInState(IWorkflow workflow, string stateId)
        {
            using (new SecurityModel.SecurityDisabler())
            {
                Database masterDb = Factory.GetDatabase(DbName);
                List<Item> itemsInSate = new List<Item>();

                var itemsDataUri = workflow.GetItems(stateId);
                foreach (var uri in itemsDataUri)
                {
                    var item = masterDb.GetItem(uri);
                    if (item != null)
                    {
                        itemsInSate.Add(item);
                    }
                }

                return itemsInSate;
            }
        }
 public ItemWorkflowModel(Item i)
 {
     if (i != null)
     {
         _contextItem = i;
         _database = i.Database;
         if (_database != null)
         {
             _workflowProvider = _database.WorkflowProvider;
             if (_workflowProvider != null)
             {
                 _workflow = _workflowProvider.GetWorkflow(ContextItem);
                 if (_workflow != null)
                 {
                     _workflowState = _workflow.GetState(ContextItem);
                 }
             }
         }
     }
 }
Пример #26
0
        private static ITaskResult<Nothing> ExecuteWorkflow(
            IWorkflow workflow,
            Identities tasks,
            ILogRenderer logRenderer,
            IDirectory workDirectory)
        {
            var executer = new SubflowTask<Nothing>(
                workflow,
                tasks);

            var context = new TaskContext(
                new ParallelExecutionStrategy(),
                logRenderer,
                workDirectory,
                new DefaultEnvironment(),
                new CompositeInterceptor(
                    new LoggingInterceptor()));

            return executer.Execute(context);
        }
        protected virtual IEnumerable<Item> GetItems(IWorkflow workflow)
        {
            Assert.ArgumentNotNull(workflow, "workflow");

            List<Item> items = new List<Item>();
            DataUri[] uris = workflow.GetItems(WorkflowStateId);
            {
                foreach (DataUri uri in uris)
                {
                    if (items.Count >= MaxItems.Value)
                    {
                        break;
                    }
                    Item item = Database.Items[uri];
                    if ((((item != null) && item.Access.CanRead()) && (item.Access.CanReadLanguage() && item.Access.CanWriteLanguage())) && ((Sitecore.Context.IsAdministrator || item.Locking.CanLock()) || item.Locking.HasLock()))
                    {
                        items.Add(item);
                    }
                }
            }
            return items;
        }
Пример #28
0
		public ModalityPerformedProcedureStep Execute(IList<ModalityProcedureStep> modalitySteps, DateTime? startTime, Staff technologist, IWorkflow workflow)
		{
			if (modalitySteps.Count == 0)
				throw new WorkflowException("At least one procedure step is required.");

			// validate that each mps being started is being performed on the same modality
			if (!CollectionUtils.TrueForAll(modalitySteps, step => step.Modality.Equals(modalitySteps[0].Modality)))
			{
				throw new WorkflowException("Procedure steps cannot be started together because they are not on the same modality.");
			}

			// create an mpps
			var mpps = new ModalityPerformedProcedureStep(technologist, startTime);
			workflow.AddEntity(mpps);

			foreach (var mps in modalitySteps)
			{
				mps.Start(technologist, startTime);
				mps.AddPerformedStep(mpps);

				//note: this feature was disabled by request (see #2138) - they want to enforce explicit check-in
				//AutoCheckIn(mps.Procedure, startTime);
			}

			// Create Documentation Step for each RP that has an MPS started by this service call
			foreach (var step in modalitySteps)
			{
				if (step.Procedure.DocumentationProcedureStep == null)
				{
					ProcedureStep docStep = new DocumentationProcedureStep(step.Procedure);
					docStep.Start(technologist, startTime);
					workflow.AddEntity(docStep);
				}
			}

			return mpps;
		}
Пример #29
0
 public static ExecutionGraph Graph(this IWorkflow workflow)
 {
     return(new ExecutionGraph(ComponentNode.BuildNodes(workflow.Activities)));
 }
 private SequentialWorkflowActivity(IWorkflow workflow, MethodBase method, SequentialWorkflowActivity previous, Func <object, object> binding)
     : this(workflow, method, previous)
 {
     Binding = binding;
 }
Пример #31
0
 public InitializationResult(IWorkflow workflow)
 {
     Workflow = workflow;
     _isSuccess = true;
 }
Пример #32
0
 internal override WorkflowAction Interpret(IWorkflow workflow)
 {
     return(workflow.OnTimerCancelled(this));
 }
Пример #33
0
 public TransitionContext(IWorkflow instance)
 {
     Instance   = instance;
     _variables = new Dictionary <string, WorkflowVariableBase>();
     _errors    = new List <string>();
 }
 public static IEnumerable <IPlace> StartPlaces(this IWorkflow workflow)
 {
     return(workflow.Places.Where(p => p.Classification == NodeClassification.Start));
 }
Пример #35
0
        /// <summary>
        /// Configure a 'Foreach' step.
        /// </summary>
        /// <typeparam name="U"></typeparam>
        /// <param name="itemExtractor">Function that will be dynamicaly resolved and list items.</param>
        /// <param name="workflow">Workflow that will be run for each item listed.</param>
        /// <returns></returns>
        public IWorkflow <T> Foreach <U>(Func <T, IEnumerable <U> > itemExtractor, IWorkflow <Tuple <U, T> > workflow)
        {
            _Actions.Add(new ForWorkflowAction <U, T>(itemExtractor, workflow));

            return(this);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ManualTestingController"/> class
 /// </summary>
 /// <param name="httpContextAccessor">the http context accessor service</param>
 /// <param name="profile">the profile service</param>
 /// <param name="register">the register service</param>
 /// <param name="authorization">the authorization service</param>
 /// <param name="testdata">the testdata service</param>
 /// <param name="serviceRepositorySettings">the service repository settings</param>
 /// <param name="generalSettings">the general settings</param>
 /// <param name="giteaApi">the gitea api</param>
 /// <param name="workflow">the workflow</param>
 public ManualTestingController(IHttpContextAccessor httpContextAccessor, IProfile profile, IRegister register, IAuthorization authorization, ITestdata testdata, IOptions <ServiceRepositorySettings> serviceRepositorySettings, IOptions <GeneralSettings> generalSettings, IGitea giteaApi, IWorkflow workflow)
 {
     _httpContextAccessor       = httpContextAccessor;
     _register                  = register;
     _profile                   = profile;
     _userHelper                = new UserHelper(_profile, _register);
     _authorization             = authorization;
     _testdata                  = testdata;
     _serviceRepositorySettings = serviceRepositorySettings.Value;
     _generalSettings           = generalSettings.Value;
     _giteaApi                  = giteaApi;
     _workflow                  = workflow;
 }
Пример #37
0
 public DashboardPageViewModel(IWorkflow workflow, IRegionManager regionManager, IDialogService dialogService) : base(workflow, regionManager, dialogService)
 {
     CreateSectionCommand = new DelegateCommand(DoCreateSection);
     ViewSectionCommand   = new DelegateCommand <object>(DoViewSection);
 }
Пример #38
0
 internal override WorkflowAction Interpret(IWorkflow workflow)
 {
     return(workflow.WorkflowAction(this));
 }
Пример #39
0
 public virtual bool IsAllowed(IWorkflow <TIdentifier> workflow)
 {
     return(Evaluate(null));
 }
Пример #40
0
        /// <summary>
        /// Run a step depending the condition.
        /// </summary>
        /// <param name="condition">Condition to run the action.</param>
        /// <param name="actionsIfTrue">Actions that must be run if condition is true</param>
        /// <param name="actionsIfFalse">Actions that must be run if condition is false</param>
        /// <returns></returns>
        public IWorkflow <T> If(Func <T, bool> condition, IWorkflow <T> actionsIfTrue, IWorkflow <T> actionsIfFalse)
        {
            _Actions.Add(new IfWorkflowAction <T>(condition, actionsIfTrue, actionsIfFalse));

            return(this);
        }
Пример #41
0
 public ActivityWorker(IWorkflow workflow, IAmazonSimpleWorkflow swfClient, IStorageManager storeManager) : this(workflow, swfClient)
 {
     _storeClient = storeManager;
 }
Пример #42
0
        private void ActivityDesigner_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                if (RobotInstance.instance == null)
                {
                    throw new ArgumentException("RobotInstance.instance");
                }
                if (RobotInstance.instance.Projects == null)
                {
                    throw new ArgumentException("RobotInstance.instance.Projects");
                }
                if (RobotInstance.instance.Projects.Count() == 0)
                {
                    throw new ArgumentException("RobotInstance.instance.Projects.Count == 0");
                }
                var       result   = new List <Workflow>();
                var       designer = RobotInstance.instance.Window.Designer;
                var       workflow = ModelItem.GetValue <string>("workflow");
                IWorkflow selected = null;
                if (!string.IsNullOrEmpty(workflow))
                {
                    var workflow2 = workflow.Replace("\\", "/");
                    if (workflow != workflow2)
                    {
                        ModelItem.SetValueInArg("workflow", workflow2);
                    }
                }
                foreach (var w in RobotInstance.instance.Workflows)
                {
                    if (designer != null && designer.Workflow != null)
                    {
                        if (designer.Workflow._id != w._id || w._id == null)
                        {
                            result.Add(w as Workflow);
                        }
                        if (w._id == workflow)
                        {
                            selected = w;
                        }
                        if (w.RelativeFilename == workflow)
                        {
                            selected = w;
                        }
                        // if (w.ProjectAndName == workflow) selected = w;
                    }
                    else
                    {
                        result.Add(w as Workflow);
                    }
                }
                if (selected != null && selected.ProjectAndName != workflow)
                {
                    ModelItem.SetValueInArg("workflow", selected.ProjectAndName);
                }
                // result = result.OrderBy(x => x.name).OrderBy(x => x.Project.name).ToList();
                result = result.OrderBy(x => x.name).OrderBy(x => x.projectid).ToList();
                if (!string.IsNullOrEmpty(workflow))
                {
                    var exists = result.Where(x => x.RelativeFilename == workflow || x.ProjectAndName == workflow).ToList();
                }

                foreach (var w in result)
                {
                    workflows.Add(w);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
        }
 public AdvancedBranchingExpression(StatefulWorkflow <T> workflow,
                                    Func <T, IDictionary <string, object>, bool> condition, IWorkflow <T> current, StatefulBuilder <T> builder,
                                    ITransitionRule <T> transitionRule)
     : base(workflow, current, builder, transitionRule)
 {
     _condition = condition;
 }
Пример #44
0
 public void Execute(Procedure rp, Staff checkInStaff, DateTime?checkInTime, IWorkflow workflow)
 {
     rp.CheckIn(checkInStaff, checkInTime);
 }
 public void Given()
 {
     _workflow = Workflow <string> .Definition() as IWorkflow <string>;
 }
Пример #46
0
            /// <summary>
            /// Reconciles the specified patient to this patient
            /// </summary>
            /// <param name="thisPatient"></param>
            /// <param name="otherPatient"></param>
            /// <param name="workflow"></param>
            private static void Reconcile(Patient thisPatient, Patient otherPatient, IWorkflow workflow)
            {
                if (PatientIdentifierConflictsFound(thisPatient, otherPatient))
                {
                    throw new PatientReconciliationException("assigning authority conflict - cannot reconcile");
                }

                // copy the collection to iterate
                var otherProfiles = new List <PatientProfile>(otherPatient.Profiles);

                foreach (var profile in otherProfiles)
                {
                    thisPatient.AddProfile(profile);
                }

                // copy the collection to iterate
                var otherNotes = new List <PatientNote>(otherPatient.Notes);

                foreach (var note in otherNotes)
                {
                    thisPatient.AddNote(note);
                }

                // copy the collection to iterate
                var otherAttachments = new List <PatientAttachment>(otherPatient.Attachments);

                foreach (var attachment in otherAttachments)
                {
                    otherPatient.Attachments.Remove(attachment);
                    thisPatient.Attachments.Add(attachment);
                }

                // copy the collection to iterate
                var otherAllergies = new List <Allergy>(otherPatient.Allergies);

                foreach (var allergy in otherAllergies)
                {
                    otherPatient.Allergies.Remove(allergy);
                    thisPatient.Allergies.Add(allergy);
                }

                var visitCriteria = new VisitSearchCriteria();

                visitCriteria.Patient.EqualTo(otherPatient);
                var otherVisits = workflow.GetBroker <IVisitBroker>().Find(visitCriteria);

                foreach (var visit in otherVisits)
                {
                    visit.Patient = thisPatient;
                }

                var orderCriteria = new OrderSearchCriteria();

                orderCriteria.Patient.EqualTo(otherPatient);
                var otherOrders = workflow.GetBroker <IOrderBroker>().Find(orderCriteria);

                foreach (var order in otherOrders)
                {
                    order.Patient = thisPatient;
                }
            }
 public static IEnumerable <IPlace> EndPlaces(this IWorkflow workflow)
 {
     return(workflow.Places.Where(p => p.Classification.HasFlag(NodeClassification.Exit)));
 }
Пример #48
0
 protected WorkflowItem(Identity identity, IWorkflow workflow)
 {
     Identity  = identity;
     _workflow = workflow;
 }
        public void Process(WorkflowPipelineArgs args)
        {
            Item      workflowItem = args.DataItem;
            IWorkflow itemwf       = this.master.WorkflowProvider.GetWorkflow(workflowItem);

            // Only run on project workflow
            if (itemwf.WorkflowID != Data.ProjectWorkflow.ToString())
            {
                return;
            }

            // Find other items that are in the same project
            var items = master.SelectItems("fast:/sitecore/content//*[@Project = '" + workflowItem.Fields[Data.ProjectFieldId].Value + "']");

            // Get the project defintion
            var projectDefinition = master.GetItem(workflowItem.Fields[Data.ProjectFieldId].Value);

            if (projectDefinition == null)
            {
                return;
            }
            DateField projectReleaseDate = projectDefinition.Fields[Data.ProjectDetailsReleaseDate];

            // If there are no other items in the project, and it's after the project release date, continue the workflow.
            if (items == null && projectReleaseDate.DateTime < DateTime.Now)
            {
                // no other items using this so, send back
                RevertItemsWorkflowToOrigional(workflowItem);
                AutoPublish(args);
            }
            else
            {
                foreach (var item in items)
                {
                    // is the item in the same project
                    if (item.Fields[Data.ProjectFieldId].Value == workflowItem.Fields[Data.ProjectFieldId].Value)
                    {
                        // is it not in the waiting state
                        if (item.Fields["__Workflow state"].Value != Data.ProjectWorkflowReadytoGoLiveState.ToString())
                        {
                            if (item.ID != workflowItem.ID) // ignore if same item
                            {
                                AllItemsReady = false;
                                break;
                            }
                        }
                    }
                }

                if (AllItemsReady && projectReleaseDate.DateTime < DateTime.Now)
                {
                    foreach (var item in items)
                    {
                        // is the item in the same project
                        if (item.Fields[Data.ProjectFieldId].Value == workflowItem.Fields[Data.ProjectFieldId].Value)
                        {
                            RevertItemsWorkflowToOrigional(item);
                        }
                    }

                    AutoPublish(args);
                }
            }
        }
Пример #50
0
 public WorkflowActionItem(Func <IWorkflowItem, WorkflowAction> workflowActionFunc, IWorkflow workflow)
     : base(RandomIdentity(), workflow)
 {
     _workflowActionFunc = workflowActionFunc;
     _whenFunc           = _ => true;
 }
Пример #51
0
 ///<summary>
 /// Removes the workflow.
 /// </summary>
 /// <param name="Workflow">The workflow.</param>
 /// <returns>True if it is removed, false otherwise</returns>
 public bool RemoveWorkflow(IWorkflow Workflow)
 {
     return(Workflows.Remove(Workflow.Name));
 }
Пример #52
0
 public ElsaOptionsBuilder AddWorkflow(IWorkflow workflow)
 {
     Services.AddSingleton(workflow);
     ElsaOptions.WorkflowFactory.Add(workflow.GetType(), workflow);
     return(this);
 }
Пример #53
0
        public async Task <RunWorkflowResult> BuildAndResumeWorkflowAsync(IWorkflow workflow, WorkflowInstance workflowInstance, string?activityId = default, object?input = default, CancellationToken cancellationToken = default)
        {
            var workflowBlueprint = _workflowBuilderFactory().Build(workflow);

            return(await _workflowRunner.RunWorkflowAsync(workflowBlueprint, workflowInstance, activityId, input, cancellationToken));
        }
 ///
 public void Initialize(IWorkflow workflow)
 {
     State.Initialize(workflow);
 }
Пример #55
0
 internal override WorkflowAction Interpret(IWorkflow workflow)
 {
     return(workflow.OnWorkflowStarted(this));
 }
Пример #56
0
        /// <summary>
        /// Run a step and block while the condition is true.
        /// </summary>
        /// <param name="workflow">Workflow that must be run</param>
        /// <param name="condition">Condition to run the action.</param>
        /// <returns></returns>
        public IWorkflow <T> While(Func <T, bool> condition, IWorkflow <T> workflow)
        {
            _Actions.Add(new WhileWorkflowAction <T>(condition, workflow));

            return(this);
        }
Пример #57
0
 public WorkflowInvoker(IWorkflow <T> workflow)
 {
     _workflow = workflow;
 }
 public ParseWorkflowTests(WriterSinkFixture _)
 {
     fileSystem    = new TestFileSystem();
     parseWorkflow = new ParseWorkflow(fileSystem);
 }
Пример #59
0
 public void Given()
 {
     _result = string.Empty;
     _workflow = Workflow<string>.Definition()
         .Do((x) => x += "AB");
 }
Пример #60
0
 public bool IsAllowed(IWorkflow <TIdentifier> workflow)
 {
     return(_conditions.Any(c => c.IsAllowed(workflow)));
 }