// D V D I N V E N T O R Y W O R K F L O W //=================================================================================== // DVDInventory.txt //=================================================================================== // Copyright (C) 2007 TrackerRealm Corporation // This file is part of Jetfire. http://jetfire.ca // // Jetfire is open software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License. // // Jetfire is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along with Jetfire. If not, see http://www.gnu.org/licenses. // REMOVAL OF THIS NOTICE IS VIOLATION OF THE COPYRIGHT. //=================================================================================== // namespace JetfireApps { public workflow DVD { string onLoanTo; DateTime loanedOnDateTime; DateTime returnedOnDateTime; DateTime lostDateTime; string instructions; List tags; // Constructor public DVD() { enterstate this.DVDAtHome(); this.onLoanTo = ""; this.tags = new List(); this.instructions = "Enter the name of the person who borrowed the DVD; Remove the name of the borrower when the DVD is returned"; this.instructions.Set("Enter zee neme-a ooff zee persun vhu burrooed zee DFD; Remufe-a zee neme-a ooff zee burrooer vhee zee DFD is retoorned", "sw-CH"); } public DVD(string subject) { this.Subject = subject; enterstate this.DVDAtHome(); this.onLoanTo = ""; this.tags = new List(); this.instructions = "Enter the name of the person who borrowed the DVD; Remove the name of the borrower when the DVD is returned"; this.instructions.Set("Enter zee neme-a ooff zee persun vhu burrooed zee DFD; Remufe-a zee neme-a ooff zee burrooer vhee zee DFD is retoorned", "sw-CH"); } // S T A T E M E T H O D S // State Transition Command Comment // New -> DVDAtHome - The workflow enters the DVDAtHome state when instantiated // DVDAtHome -> DVDOnLoan Borrow Someone borrows the DVD // DVDOnLoan -> DVDAtHome Return Someone returns the DVD // DVDAtHome -> DVDLost Lost Owner 'misplaces' the DVD // DVDOnLoan -> DVDLost Lost Borrowed LOST the DVD // DVDAtHome -> DVDDead Broke Something BAD happened // DVDOnLoan -> DVDDead Broke Something BAD happened public DVDAtHome() { } public DVDOnLoan() { } public DVDLost() { } public DVDDead() { } // C O M M A N D S private void Borrow() { this.ResetDateTimes(); this.loanedOnDateTime = DateTime.Now; enterstate this.DVDOnLoan(); } private void Return() { this.ResetDateTimes(); this.returnedOnDateTime = DateTime.Now; enterstate this.DVDAtHome(); } public void Lost() : states(DVDAtHome, DVDOnLoan) { this.lostDateTime = DateTime.Now; enterstate DVDLost(); } public void Found() : states(DVDLost) { this.lostDateTime = DateTime.NoDateOrTime; if (this.onLoanTo.Length == 0) { this.Return(); } if (this.onLoanTo.Length > 0) { this.Borrow(); } } public void Broke() : states(DVDAtHome, DVDOnLoan) { enterstate DVDDead(); } private void ResetDateTimes() { this.returnedOnDateTime = DateTime.NoDateOrTime; this.loanedOnDateTime = DateTime.NoDateOrTime; this.lostDateTime = DateTime.NoDateOrTime; } // P R O P E R T I E S public string OnLoanTo : states(DVDAtHome, DVDOnLoan) { get { return this.onLoanTo; } set { this.onLoanTo = value; if (this.onLoanTo.Length == 0) { this.Return(); } if (this.onLoanTo.Length > 0) { this.Borrow(); } } } public DateTime LoanedOnDateTime { get { return this.loanedOnDateTime; } } public DateTime ReturnedOnDateTime { get { return this.returnedOnDateTime; } } public DateTime LostDateTime { get { return this.lostDateTime; } } public string Instructions { get { return this.instructions; } } public List Tags { get { return this.tags; } } } }