Transaction System

The Transaction System is behind-the-scenes, in that users will likely not know they are interacting with it, though it is used to keep track of the changes they make on their layouts.

How to View – User Point Of View

In the core implementation of YourOtherMind, the transaction system is viewed from the header bar by pressing the INFO button. This shows the list of all transactions that have involved this layout. This is a screenshot of a simple transaction list.
simple info

This is the core transaction list:

  • Add Layout
  • Delete Layout (user technically cannot see it, but it exists in case a global view of all transactions is ever added)
  • Status Changed – i.e., project has moved from planning stage to writing stage

But AddIns are able to add transactions too. The Submission AddIn, for example, uses the transaction system to record where users try to sell stories, whereas the Worklog AddIn uses it to track the amount of time users spend on a project. This screenshot shows this in action.
simple info2

How to Work with the Status Change Transaction

The Status Change transaction has a couple built in behaviors, that may be confusing.
Generally when status changes (i.e., from Writing to Complete, this table list_status being defined on the System Layout) a transaction occurs. But if the keyword Retired is found a Retired Transaction is recorded instead of the generic Status Change Transaction. Likewise, if the keyword Complete is discovered a Finished Transaction is recorded.

These are separate to draw attention to these two major state changes.

What a transaction is

A transaction is a row in a database. There are several predefined fields that developers are free to to use to store whatever information they want. These fields are:

static public ColumnConstant DATE = new ColumnConstant("date",1,"datetime",1);

static public ColumnConstant TYPE = new ColumnConstant("type", 2, "TEXT", 2);

static public ColumnConstant DATA1_LAYOUTGUID = new ColumnConstant("data1", 3, "TEXT", 3);
static public ColumnConstant DATA2 = new ColumnConstant("data2", 4, "TEXT", 4);
static public ColumnConstant DATA3 = new ColumnConstant("data3", 5, "INTEGER", 5);
static public ColumnConstant DATA4 = new ColumnConstant("data4", 6, "INTEGER", 6);

static public ColumnConstant MONEY1 = new ColumnConstant("money1", 7, "float", 7);
static public ColumnConstant MONEY2 = new ColumnConstant("money2", 8, "float", 8);

static public ColumnConstant DATE2 = new ColumnConstant("date2",9,"datetime",9);
static public ColumnConstant NOTES = new ColumnConstant("notes", 10, "TEXT", 10);
static public ColumnConstant DATA5 = new ColumnConstant("data5", 11, "TEXT", 11);
static public ColumnConstant DATA6 = new ColumnConstant("data6", 12, "TEXT", 12);
static public ColumnConstant DATA7 = new ColumnConstant("data7", 13, "TEXT", 13);
static public ColumnConstant DATA8 = new ColumnConstant("data8", 14, "TEXT", 14);
static public ColumnConstant DATA9 = new ColumnConstant("data9", 15, "TEXT", 15);
static public ColumnConstant TYPE_OF_OBJECT = new ColumnConstant("typeofobject", 16, "TEXT", 16);
static public ColumnConstant DATA10 = new ColumnConstant("data10", 17, "TEXT", 17);

So there is a variety of data types to work with.
All transactions appear on the Information List, when viewed by the user.

How to add a Transaction

Adding a transaction is fairly easy if all you need to do is allow the user to add it (as happens with the Proofread Addin; users are able to mark when they have proofread a text).
To do this, you derive class from TransactionBase, as in the following example:

using System;
using CoreUtilities;

namespace Transactions
{
public class TransactionDeleteLayout : TransactionBase
{
public TransactionDeleteLayout (DateTime date, string LayoutGuid) : base()
{
RowData[TransactionsTable.TYPE.Index] = TransactionsTable.T_DELETED.ToString ();
RowData[TransactionsTable.DATE.Index] = date;
RowData[TransactionsTable.DATA1_LAYOUTGUID.Index] = LayoutGuid;
}
public TransactionDeleteLayout(object[] items): base(items)
{
// all children need this form of the constructor
}

public override string Display {
get {
return Loc.Instance.GetStringFmt("Layout {0} Deleted on {1}", RowData[TransactionsTable.DATA1_LAYOUTGUID.Index].ToString (),DateAsFriendlyString());
}
}
}
}

Notice that overriding the method Display is how the developer chooses to display the text shown to the user.

NOTE: When working with Transactions inside of an AddIn (doing more than just adding them as transaction) there are issues. When I have time I’m going to dig into the system more and examine why but that’s why three transactions that should belong in their AddIns, are currently required to be part of the main code base.

Post to Twitter Post to Plurk Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to StumbleUpon