|
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using System.Data;
namespace MVWorkflow
{
public sealed partial class Workflow1: SequentialWorkflowActivity
{
public Workflow1()
{
InitializeComponent();
}
private string _driver = String.Empty;
public string DriverName
{
get { return _driver; }
set { _driver = value; }
}
private void GenerateMVData(object sender, EventArgs e)
{
// Create a blank DataSet to pass back
DataSet ds = new DataSet();
// Pull (create) the vehicle information for the
// assigned driver
ds.Tables.Add(GenerateVehicleTable(DriverName));
// Pull (create) the vehicle information for the
// assigned driver
ds.Tables.Add(GenerateViolationTable(DriverName));
// Assign the DataSet we just created as the host data
mvDataUpdate1.mvData = ds;
}
private DataTable GenerateVehicleTable(string driverName)
{
// Create the empty table
DataTable dt = new DataTable("Vehicles");
// Add the columns for plate number, make, model, and color
// (all strings).
dt.Columns.Add(new DataColumn("Plate",typeof(string)));
dt.Columns.Add(new DataColumn("Make",typeof(string)));
dt.Columns.Add(new DataColumn("Model",typeof(string)));
dt.Columns.Add(new DataColumn("Color",typeof(string)));
// Now add the actual data, based on the driver. Normally
// this would be a database or service call of some type,
// but we're just simulating pulling data here. We know
// we have only three drivers...
if (driverName == "Marc Faeber")
{
// Add a vehicle
DataRow row = dt.NewRow();
dt.Rows.Add(row);
row["Plate"] = "2FAST4U";
row["Make"] = "Chevrolet";
row["Model"] = "Corvette";
row["Color"] = "Arrest Me Red";
row = dt.NewRow();
dt.Rows.Add(row);
row["Plate"] = "VIPER1";
row["Make"] = "Dodge";
row["Model"] = "Viper";
row["Color"] = "Midnight Black";
} // if
else if (driverName == "Tracy Tallman")
{
// Add a vehicle
DataRow row = dt.NewRow();
dt.Rows.Add(row);
row["Plate"] = "28ADX55";
row["Make"] = "Buick";
row["Model"] = "LeSabre";
row["Color"] = "Polo White";
} // else if
else if (driverName == "Darrell Meisner")
{
// Add a vehicle
DataRow row = dt.NewRow();
dt.Rows.Add(row);
row["Plate"] = "42NBR31";
row["Make"] = "Ford";
row["Model"] = "Windstar";
row["Color"] = "Does it matter?";
} // else if
return dt;
}
private DataTable GenerateViolationTable(string driverName)
{
// Create the empty table
DataTable dt = new DataTable("Violations");
// Add the columns for citation ID, plate number, violation,
// and date (all strings but date, which is a date).
dt.Columns.Add(new DataColumn("ID", typeof(string)));
dt.Columns.Add(new DataColumn("Plate", typeof(string)));
dt.Columns.Add(new DataColumn("Violation", typeof(string)));
dt.Columns.Add(new DataColumn("Date", typeof(DateTime)));
// Now add the actual data, based on the driver. Normally
// this would be a database or service call of some type,
// but we're just simulating pulling data here. We know
// we have only three drivers...
if (driverName == "Marc Faeber")
{
// Add a violation
DataRow row = dt.NewRow();
dt.Rows.Add(row);
row["ID"] = "24175641";
row["Plate"] = "2FAST4U";
row["Violation"] = "Speeding, 55MPH in a 25MPH zone";
row["Date"] = new DateTime(2006, 5, 21);
row = dt.NewRow();
dt.Rows.Add(row);
row["ID"] = "38573319";
row["Plate"] = "2FAST4U";
row["Violation"] = "Speeding, 85MPH in a 65MPH zone";
row["Date"] = new DateTime(2006, 11, 6);
row = dt.NewRow();
dt.Rows.Add(row);
row["ID"] = "67112487";
row["Plate"] = "VIPER1";
row["Violation"] = "Ran red light";
row["Date"] = new DateTime(2007, 2, 12);
} // if
else if (driverName == "Tracy Tallman")
{
// You're kidding, right? In a LeSabre?
} // else if
else if (driverName == "Darrell Meisner")
{
// Add a violation
DataRow row = dt.NewRow();
dt.Rows.Add(row);
row["ID"] = "43564217";
row["Plate"] = "42NBR31";
row["Violation"] = "Illegal Parking";
row["Date"] = new DateTime(2006, 10, 3);
} // else if
return dt;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.