BusinessProcessLoad Event

Occurs when the BusinessProcess is executed, before the Start event and before the database query is constructed. Raised once for each Run method.

Definition

Namespace: Firefly.Box
Assembly: Firefly.Box (in Firefly.Box.dll) Version: debug-master-v:33791
C#
public event Action Load

Value

Action

Remarks

See the Run method for the complete event flow.

Example

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 www.NUnit.org. For more information about unit testing visit: www.NUnit.org.
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
C#
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Firefly.Box;
using Firefly.Box.Testing;

namespace TestFirefly.Box.Documentation
{
    [TestFixture]
    public class BusinessProcessEventFlow
    {
        [Test]
        public void Demo()
        {
            var jobs = new Pubs.Jobs();
            jobs.InitializeWithTestData();

            var bp = new BusinessProcess
                         {
                             From = jobs
                         };
            bp.Where.Add(jobs.Id.IsLessOrEqualTo(5));

            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)
                    {
                        bp.RowChanged.ShouldBe(false);
                        jobs.Description.Value += "xx";//to demonstrate a changed row
                        bp.RowChanged.ShouldBe(true);
                    }
                };
            bp.SavingRow += cancelEventArgs => result += "SavingRow for job #" + jobs.Id + "\n";
            bp.End += () => result += "End\n";
            bp.Run();
            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" +
                            "End\n"
                            );
        }
    }
}

See Also