Fire up your applications with Jetfire

DVD Tracking


DVD Tracking is a great demonstration of the ease of programming with Jetfire. Everyone has a collection of one sort that they are asked to share. Often we lend one of our precious items to someone and then forget who has it. It’s gone! DVD Tracking allows you to define a simple workflow for tracking items in your collection. It also allows you to build up a database of your collection for quickly searching through it.
View the code

The Code


The DVD Inventory namespace has two workflows in it – DVD and DVDInventory.

DVD workflow


The DVD workflow is a reflection of the actual DVD. It contains information about the DVD, e.g. title, description (director, actors, etc), the DVD states that are being tracked, timestamps and who the DVD is loaned to.
The DVD states include:
  • DVD At Home: The DVD is in your collection. There is a timestamp for when the DVD was returned to your collection.
  • DVD On Loan: The DVD is on loan to the person shown in the On Loan To field and was loaned at the On Loan To timestamp.
  • DVD Lost: Someone lost the DVD. There is a timestamp for when the loss was recorded.
  • DVD Dead: The DVD is broken or will never be seen again.

DVD Inventory workflow


The DVDInventory workflow is used to create the DVD collection. (The demo is a ‘session’ demo, which means that the demo data is only valid for the lifetime of your session. You create, delete and modify data during the lifetime of your session.)
Normally, the DVD’s are added one at a time or through a bulk upload of an XML file.

Command Methods


Commands are added to the workflow and take the form shown in Figure 1. Note the following:   
  • The Borrow command method is only accessible in the DVD At Home state.
  • The Borrow command method is private, i.e. it is not ‘seen’ by the application (The OnLoanTo property actually calls this method.)
  • The ‘enterstate’ keyword is used to move the DVD into the DVD On Loan state.
  • The ‘ResetDateTimes’ method is called.
  • The ‘loanedOnDateTime’ property is set.

private void Borrow() : states(DVDAtHome)
{
enterstate this.DVDOnLoan();      
this.ResetDateTimes();   
this.loanedOnDateTime = DateTime.Now;   
}

Figure 1: Command Method

Properties


Figure 2 show the OnLoanTo Property of the DVD workflow. Note the following:
  • The OnLoanProperty is only accessible in the DVD At Home and DVD On Loan states.
  • The property setter sets the local variable and calls a method based on the presence/absence of a name in the onLoanTo field.

public string OnLoanTo : states(DVDAtHome, DVDOnLoan)
{
get { return this.onLoanTo;      }    
set
{   
   this.onLoanTo = value;   
   if (value.Length == 0)   
   {   this.Return();   }   
   else   
   {   this.Borrow();   }   
}   
}

Figure 2: Property
The DVDInventory workflow has a number of interesting programming features. These include:
  • Multi-language string initialization
  • Class Instantiation

Multi-Language Strings



this.Subject = "DVD Inventory";
this.Subject.Set("DFD Infentury", "sw-ch");

Figure 3: Setting Multi-language strings
Jetfire strings are by definition Multi-language strings. Figure 3: Setting Multi-language strings shows how to assign the ‘normal’ value to a string and how to assign a language-specific string, e.g. sw-ch (Swedish-chef) to a string.

Class Instantiation



Tag tagAction = new Tag();

Figure 4: Class Instantiation
Figure 4: Class Instantiation shows how to create a new object. Once the object is created, it is used within the application.