Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
455
Databinding to WinGanttView is not working
posted

Hi,

I am trying to populate the UltraGanttView and I'm not getting information to bind correctly.  Basically, I'm using a DataSet named VendorRepo with two DataTables called theVendors and theTasks.  The DataSet is updated by a message received by a socket listener on a separate thread.  I suspect the problem could lie in either 1) I'm not binding the data correctly because I've missed some setup assumptions from the documentation, or 2) maybe the separate update thread is triggering a data change event on the wrong thread?  I'd like to rule out any problems with the first issue with this post.

I'm posting a printout of my dataset, the code for the dataset, and then the form load event.

Here is a print out of the data when I run the code, which looks like I expect it to.  No exceptions are thrown at all, but nothing shows up in the task list or in the timeline:

Number of vendors captured is: 1

--------------------------------------------

Vendors DataTable Contents: Record 0

VendorGuid: 00000000-0000-0000-0000-000000000000

VendorID: FF:00:00:01

VendorName: ACME Vending

VendorstartTime: 1/1/0001 12:00:00 AM

 

Number of Transactions captured is: 2

--------------------------------------------

Transactions DataTable Contents, Record :0

TransactionGuid: 00000000-0000-0000-0000-000000000000

VendorID: FF:00:00:01

TransactionName: ACME Vending

TransactionstartTime: 11/10/2010 2:44:10 PM

TransactionDuration: 00:20:00

ParentTransactionGuid:

TransactionPercentComplete:

--------------------------------------------

Transactions DataTable Contents, Record :1

TransactionGuid: 5d877ea2-cec2-4172-962a-b0c763c505a9

VendorID: FF:00:00:01

TransactionName: Deliver to (Lat,Lon):  0 , 0

TransactionstartTime: 11/10/2010 2:44:10 PM

TransactionDuration: 01:01:01

ParentTransactionGuid: 00000000-0000-0000-0000-000000000000

TransactionPercentComplete: 25

_______________________________________________________________________

This is what the repository code looks like:

using System;

using System.Data;

using System.Collections.Generic;

using GanttChart.DataAccess;

 

namespace GanttChart.Model

{

   public class VendorRepository

   {

      private ServerTerminal serverTerminal;

      private DataSet VendorRepo;

      private DataTable theVendors;

      private DataTable theTransactions;

      private List<string> vendorList = new List<string>();

 

      private static readonly VendorRepository instance;

      public static VendorRepository Instance

      {

         get { return instance; }

      }

      static VendorRepository()

      {

         instance = new VendorRepository();

      }

 

      private VendorRepository()

      {

         InitializeRepos();

         serverTerminal = new ServerTerminal();

         serverTerminal.StartListen(2535);

      }

      public void InitializeRepos()

      {

         VendorRepo = new DataSet();

 

         theVendors = VendorRepo.Tables.Add("Vendors");

         theVendors.Columns.Add("VendorGuid");

         theVendors.Columns.Add("VendorID");

         theVendors.Columns.Add("VendorName");

         theVendors.Columns.Add("VendorstartTime", typeof(DateTime));

        

         //set the primary key to the VendorID Column

         DataColumn[] keys = new DataColumn[1];

         keys[0] = theVendors.Columns["VendorID"];

         theVendors.PrimaryKey = keys;

 

         theTransactions = VendorRepo.Tables.Add("Transactions");

         theTransactions.Columns.Add("TransactionGuid");

         theTransactions.Columns.Add("VendorID");

         theTransactions.Columns.Add("TransactionName");

         theTransactions.Columns.Add("TransactionstartTime", typeof(DateTime));

         theTransactions.Columns.Add("TransactionDuration", typeof(TimeSpan));

         theTransactions.Columns.Add("ParentTransactionGuid");

         theTransactions.Columns.Add("TransactionPercentComplete");

         theTransactions.Columns.Add("AllProperties", typeof(Byte[]));

 

         DataColumn[] TransactionsKey = new DataColumn[1];

         TransactionsKey[0] = theTransactions.Columns["TransactionGuid"];

         theTransactions.PrimaryKey = TransactionsKey;

 

         System.Data.DataRelation relOrdDet;

         System.Data.DataColumn colMaster;

         System.Data.DataColumn colDetail;

         colMaster = VendorRepo.Tables["Vendors"].Columns["VendorID"];

         colDetail = VendorRepo.Tables["Transactions"].Columns["VendorID"];

         relOrdDet = new System.Data.DataRelation("RelOrdDet", colMaster, colDetail);

         VendorRepo.Relations.Add(relOrdDet);

      }

 

      public Guid UpdateVendor(VendorData Vendor)

      {

         Guid id;

         DataRow row = theVendors.Rows.Find(Vendor.vehId);

         if (row == null)

         {

            // need to insert row

            id = new Guid();

            theVendors.Rows.Add(new Object[] { id, Vendor.vehId, Vendor.name, Vendor.startTime });

         }

         else

         {

            // need to update row

            string idstring = row["VendorGuid"].ToString();

            id = new Guid(idstring);

         }

         return id;

      }

 

      public void UpdateTransaction(TransactionData transaction)

      {

         DataRow row = theTransactions.Rows.Find(transaction.parentGuid);

         if (row == null)

         {

            // need to insert row

            Guid id = new Guid(transaction.parentGuid);

            theTransactions.Rows.Add(new Object[] { id, transaction.VendorID, transaction.vendorName, DateTime.Now, TimeSpan.FromMinutes(20), null, null });

         }

         else

         {

            // need to update row

         }

 

         // Add transaction as a child of the vendor summary transaction

         theTransactions.Rows.Add(new Object[] { Guid.NewGuid(), transaction.VendorID, transaction.name, DateTime.Now, transaction.duration, new Guid(transaction.parentGuid), transaction.transactionPercentageComplete });

        

      }

 

_____________________________________________________________________

and here is what the form load event looks like:

private void BindingGanttView_Load(object sender, EventArgs e)

{

   transactionRepo = this.SetupData();

 this.ultraCalendarInfo1.DataBindingsForTransactions.BindingContextControl = this;          this.ultraCalendarInfo1.DataBindingsForProjects.BindingContextControl = this;            this.ultraCalendarInfo1.DataBindingsForProjects.SetDataBinding(transactionRepo.GetVendorRepository(), "Vendors");   this.ultraCalendarInfo1.DataBindingsForTransactions.SetDataBinding(transactionRepo.GetVendorRepository(), "Transactions");

    this.ultraCalendarInfo1.DataBindingsForProjects.IdMember = "VendorGuid";

    this.ultraCalendarInfo1.DataBindingsForProjects.KeyMember = "VendorID";

    this.ultraCalendarInfo1.DataBindingsForProjects.NameMember = "VendorName";

    this.ultraCalendarInfo1.DataBindingsForProjects.StartDateMember = "VendorstartTime";

 

            //  Set the DataBinding members for Transactions

       this.ultraCalendarInfo1.DataBindingsForTransactions.NameMember = "TransactionName";       this.ultraCalendarInfo1.DataBindingsForTransactions.DurationMember = "TransactionDuration";          this.ultraCalendarInfo1.DataBindingsForTransactions.StartDateTimeMember = "TransactionstartTime";          this.ultraCalendarInfo1.DataBindingsForTransactions.IdMember = "TransactionGuid";      this.ultraCalendarInfo1.DataBindingsForTransactions.ProjectKeyMember = "VendorID";

this.ultraCalendarInfo1.DataBindingsForTransactions.ParentTransactionIdMember = "ParentTransactionGuid";

this.ultraCalendarInfo1.DataBindingsForTransactions.PercentCompleteMember = "TransactionPercentComplete";

this.ultraCalendarInfo1. DataBindingsForTransactions.AllPropertiesMember = "AllProperties";

this.ultraGanttView1.CalendarInfo = this.ultraCalendarInfo1;

this.ultraGanttView1.Project = this.ultraGanttView1.CalendarInfo.Projects[0];

 

 

Can anyone confirm that the databindings are setup correctly?  If so, is there anything I can do debugging wise to gain more insight about why the control does not display the data?  Something like the WPF trick of using a converter to examine a breakpoint? 

Thanks!

Michele

Parents Reply Children
No Data