BusinessProcessRun Method

Runs the BusinessProcess


Namespace: Firefly.Box
Assembly: Firefly.Box (in Firefly.Box.dll) Version: debug-master-v:33791
public long Run()

Return Value



When the business process is run, the following actions occur:
  • The Load event is executed
  • The values of the filter defined in the Where property are fixed
  • The Start event is executed
  • The data will be loaded from the database
  • Row Level Loop(*):
    • The Row will be loaded from the database
    • The Relations and Columns will evaluate according to the loaded row values
    • The EnterRow event will be executed
    • The LeaveRow event will be executed
    • The SavingRow event will be executed if there was any change in the row, as indicated by the RowChanged property, or for new and deleted rows. For more information see SavingRow event
    • The Row will be saved to the database
  • The End event is executed

This sequence can be broken, using the Exit(ExitTiming, FuncBoolean) method.

(*)Row Level Loop - The BusinessProcess will perform the Row Level Loop for each row of the entity that was set to the From property, that matches the filter set in the Where property.
When no entity was set to the From property, or when the Activity property is set to Insert, the row iteration will be performed infinitely until the Exit(ExitTiming, FuncBoolean) method will force it to end.


The event flow of a BusinessProcess
This example is in the form of Unit Tests. It references the NUnit framework. This framework can be downloaded from For more information about unit testing visit:
This example is based on test data. The code for the entities included in this test data can be found in the documentation of Entity
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Firefly.Box;
using Firefly.Box.Testing;

namespace TestFirefly.Box.Documentation
    public class BusinessProcessEventFlow
        public void Demo()
            var jobs = new Pubs.Jobs();

            var bp = new BusinessProcess
                             From = jobs

            string result = "";
            bp.Load += () => result += "Load\n";
            bp.Start += () => result += "Start\n";
            bp.EnterRow += () => result += "EnterRow for job #" + jobs.Id + "\n";
            bp.LeaveRow += () =>
                    result += "LeaveRow for job #" + jobs.Id + "\n";
                    if (jobs.Id==3)
                        jobs.Description.Value += "xx";//to demonstrate a changed row
            bp.SavingRow += cancelEventArgs => result += "SavingRow for job #" + jobs.Id + "\n";
            bp.End += () => result += "End\n";
            result.ShouldBe("Load\n" +
                            "Start\n" +
                            "EnterRow for job # 1\n" +
                            "LeaveRow for job # 1\n" +
                            "EnterRow for job # 2\n" +
                            "LeaveRow for job # 2\n" +
                            "EnterRow for job # 3\n" +
                            "LeaveRow for job # 3\n" +
                            "SavingRow for job # 3\n" +//Because the row was changed
                            "EnterRow for job # 4\n" +
                            "LeaveRow for job # 4\n" +
                            "EnterRow for job # 5\n" +
                            "LeaveRow for job # 5\n" +

See Also