Event Based WebSchedule Data Provider

The NetAdvantage for ASP.NET WebSchedule controls represent a series of Web Server Controls that can be used to create a very full featured resource scheduling application.

Download the ASP.NET Sample Here.

WebSchedule consists of controls that are used to display and navigate Appointments as well as all the supporting reminder, recurrence, and Appointment editing dialog forms. Data is provided to WebSchedule via means of one of several Data Providers. Two specific data providers are included with NetAdvantage for ASP.NET: A Microsoft SQL Server data provider and an OleDB data provider. You are also given the SQL Server script to generate the Database, stored procedures and other objects as well as a Microsoft Access database file. If building an application from scratch, either of these will help you get up and running very quickly.

Many companies already have existing production systems that already contain this data and it is stored in many different kinds of back ends such as Microsoft CRM, Sybase or just about any other type of data store. Companies may also be using SQL Server, but their resource and appointment data exists in a completely different data model altogether. Can WebSchedule connect to and access this data? Absolutely!

In order for WebSchedule to access data stores other than the included Microsoft SQL Server database or the Microsoft Access file that comes with NetAdvantage for ASP.NET, you will have to create a custom data provider.

Here is a very well written KB article that clearly and completely explains how to build your own WebSchedule data provider written by Tony Lombardo. The topic walks you through the code used to create a provider that is used to access an XML file that contains appointments. Understanding this example will allow you to create your own provider.

HOWTO:Connect WebSchedule to a custom data source (Part 1)

 http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=8484

HOWTO:Connect WebSchedule to a custom data source (Part 2)

http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.Aspx?ArticleID=10013

 Event based WebSchedule Data Provider

I recently created a WebSchedule data provider that simply raises events for INSERT, SELECT, UPDATE and DELETE operations. These events expose objects that are internal to the data provider so that you, the developer can simply access the event args and easily create, read, update or delete Appointments.

Here is a simple example of an event handler that you would find on the WebForm hosting the custom event based data provider:

C#

void d_ActivityDeleting(object sender, ActivityDeletingEventArgs e)

{

string theCmdText = "DELETE FROM Activity WHERE ActivityID =?";

OleDbCommand c = this.GetCommand(theCmdText, _cn, true);

c.Parameters.Add(

 

new System.Data.OleDb.OleDbParameter(

"ActivityID",

e.DataKey));

//Execute the command and if no records have been affected, then there is a problem.

if (c.ExecuteNonQuery() == 0) Response.Write("Appointment has not been added");

this.CleanupCommand(c);

}

So as you can see, you simply take the information provided to you by the event args (in this case, the primary key of the appointment) and then you use it however you need to in order to delete the record or entity from your back end system.

Here is the event handler for updates:

C#

void d_ActivityUpdating(object sender, ActivityUpdatingEventArgs e)

{

string theCmdText = "UPDATE [Activity] ";

theCmdText += "SET";

theCmdText += " [StartDateTimeUtc]=?,";

theCmdText += " [ActivityDescription]=?,";

theCmdText += " [Subject]=?,";

theCmdText += " [AllDayEvent]=?,";

theCmdText += " [Location]=?,";

theCmdText += " [Duration]=?,";

theCmdText += " [EnableReminder]=?";

theCmdText += "WHERE ActivityID=?";

OleDbCommand c = this.GetCommand(theCmdText, _cn, true);

//Create and add command params to persist the Appointment properties.

//NOTE:

//You should add support for loading and saving the other

//Appointment properties. This example has been abbreviated

//to keep it simple.

c.Parameters.Add(

new System.Data.OleDb.OleDbParameter(

"StartDateTimeUtc",

e.Appointment.StartDateTime));

c.Parameters.Add(

new System.Data.OleDb.OleDbParameter(

"ActivityDescription",

e.Appointment.Description));

c.Parameters.Add(

new System.Data.OleDb.OleDbParameter(

"Subject",

e.Appointment.Subject));

c.Parameters.Add(

new System.Data.OleDb.OleDbParameter(

"AllDayEvent",

e.Appointment.AllDayEvent));

c.Parameters.Add(

new System.Data.OleDb.OleDbParameter(

"Location",

e.Appointment.Location));

 

if (!e.Appointment.AllDayEvent)

{

int d =

(int)e.Appointment.EndDateTime.Subtract(

e.Appointment.StartDateTime).TotalSeconds;

c.Parameters.Add(

new System.Data.OleDb.OleDbParameter(

"Duration",

d));

}

 

c.Parameters.Add(

new System.Data.OleDb.OleDbParameter(

"EnableReminder",

e.Appointment.EnableReminder));

 

c.Parameters.Add(

new System.Data.OleDb.OleDbParameter(

"ActivityID",

e.Appointment.Key));

//Execute the command and if no records have been affected, then there is a problem.

if (c.ExecuteNonQuery() == 0) Response.Write("Appointment has not been added");

this.CleanupCommand(c);

}

 In order for your Appointments to show in the WebSchedule controls, they must be periodically fetched from the back end. Doing this is simple with this data provider as you must simply handle the ActivitiesFetching event so that you can retrieve your objects from wherever data store they exist and then using a loop construct, you instantiate and populate Appointment objects and simply add them to the Appointments collection found within the event args of this event. Then, like magic, your appointments will show in the WebSchedule controls.

ActivitiesFetching event being handled in the WebForm:

C#

void d_ActivitiesFetching(object sender, ActivitiesFetchingEventArgs e)

{

//This is how it works:

// 1. Access your data store

// 2. Use a loop to iterate through your data and create Appointment objects

// 3. Add each of the new Appointment objects to the e.Appointments collection

// 4. That's it!

string theCmdText = @"SELECT * FROM ACTIVITY";

OleDbCommand c = this.GetCommand(theCmdText, _cn, true);

OleDbDataReader d = c.ExecuteReader();

while (d.Read())

{

Appointment a = new Appointment(this.WebScheduleInfo1);

//NOTE:

//You should add support for loading and saving the other

//Appointment properties. This example has been abbreviated

//to keep it simple.

a.DataKey = d["ActivityID"].ToString();

a.StartDateTime = new SmartDate(DateTime.Parse(d["StartDateTimeUtc"].ToString()));

a.Subject = d["Subject"].ToString();

a.Description = d["ActivityDescription"].ToString();

a.AllDayEvent = (bool)d["AllDayEvent"];

if (!a.AllDayEvent)

{

a.EndDateTime = a.StartDateTime.AddSeconds((int)d["Duration"]);

}

 

((IList)e.Appointments).Add(a);

}

this.CleanupCommand(c);

}

 Now that you have learned about several ways of creating a custom WebSchedule data provider, please feel free to modify these existing examples or create your own custom data provider. Either way, WebSchedule provides a great full featured set of controls to help you create the best resource scheduling application out there!

NetAdvantage Help Table of Contents Explanation

Hey, it's me again,

I wanted to spend some time to talk about the NetAdvantage Documentation. When we open up the help, we see this Table of Contents and it seems to overwhelm us due to its size. We have done our best to help organize all of this content in such a way that will make sense. This blog post will help to explain the philosophy behind the Table of Contents (known herein as "TOC"):

 We will use the following online help for this exercise:

http://help.infragistics.com/NetAdvantage/NET/2008.1/CLR2.0/

Once the Help loads up, observe the TOC on the left hand side of the user interface. The top level nodes consist of:

  •  Getting Started
    • This contains topics that are geared towards someone that may be using NetAdvantage for the first time. Topics include how to add the NetAdvantage tools to your toolbox, how to use the help as well as its conventions, how to get support and several other topics that are a great help to new users to the product. If you have been using NetAdvantage for some time, you can skip reading this section.
  • Windows Forms
    • This of course contains all of the topics that relate to the Windows Forms controls and components.
  • ASP.NET
    • And of course this contains the controls and components that are used for ASP.NET applications.

Wait there's more!

Let's dissect the Windows Forms TOC entry to learn more about the content that you will find. Windows Forms and ASP.NET TOC entries basically contain a similar structure so this example will work for both cases.

  • Welcome, Getting Started, Application Styling, etc
    • These first few nodes that appear directly underneath the Windows Forms TOC entry contain content that is useful to read if you are new to NetAdvantage. You can expect to find information that would help you understand the nature of our products and features. For example the Getting Started topic provides some high level information such as "hey we have these great designers ,so check them out" and "you can right click on a control to get these other cool options".
    • Reading these topics at least once before you start doing any heavy development is a good idea. Imagine if you are a new NetAdvantage customer and you started to build this really large scale application and you did not know of the existence of Quick Designers or Application Styling! Just knowing about these features ahead of time will prevent you from having to build something that already exists OR from having to do something the hard way.
  • Developer's Guide
    • The topics found under this TOC entry is where most developers will be spending their time.
    • What's New - This is the most important node for those developers that can't wait to get their hands on the NEW NetAdvantage version. I know whenever I got my hands on the latest version, I would jump to this section with hopes of reading something along the lines of "Hey, this new property setting will replace those 1000 lines of code that you wrote in your application". Most of the time, that is the case! You can also see the historical list of additions from the previous volumes by simply looking into the Revision History TOC entry.
    • The Toolset - This TOC entry contains topics that represent the different NetAdvantage assets that you get with the installation.
      • Frameworks - This TOC entry contains topics related to any NetAdvantage specific framework libraries. You can expect to find topics on the Infragistics Presentation Layer Framework as well as the Application Styling Framework. These topics discuss how these frameworks operate and how they were designed.
      • Code Libraries - This TOC entry represents any class library that is NOT a control or component. You will find the Excel and Document engines in here. Think about it, if you are building a Win or Web application, you simply use the Excel or Document classes from within your C# code (these are the libraries themselves, NOT the Excel OR document exporter which have their own components for Win and Web).
      • Assemblies - These topics represent any topic related within the scope of the assemblies themselves. Expect to find an extensive list of the controls and their dependent assemblies, a list of the resource keys and their corresponding strings (e.g. The WinGrid has several strings within its rendered surface that cannot really be accessed through property settings. These strings can only be accessed through the Resource Customizer which is discussed in the Assembly Resource Strings TOC entry.)
      • Controls and Components (Bingo!) This is indeed where most developers will be spending their time. This is where you look for WinGrid, WinChart and the rest of your favorite controls and components. WinGridExcelExporter is also in here because it is indeed a component that exists in the Toolbox and you can drag it onto your Form's component tray.
        • WinGrid (or any other control)
          • Understanding WinGrid - I recommend that any developer new to the control should read this. This is where you learn all about what this control does, how it does it and WHY you may want to use this.
          • Getting Started - Think of this as your Hello World app with the control.
          • Using WinGrid - This TOC entry contains lots of child topics that when read will result in a developer that is well versed in the use of the control. Think of these topics as tutorials that step you through typical use case scenarios. These topics should definitely be read so that you can essentially get practice on how to accomplish certain tasks with the control.
          • API Overview - This TOC entry simply jumps you across the Help system directly to the API documentation (Explained in more detail below)

You have just been taken through a tour of the upper portion of the NetAdvantage Help. This is what we like to call the "Developer's Guide". This is a compilation of conceptual, code and walk through topics that are designed to speak to the developer directly with the intention of getting the developer up to speed in the most efficient and painless manner. The "API" documentation on the other hand is accessible through the "API Overview" TOC entry as described above OR it can be accessed directly under the Windows Forms TOC entry. The API Documentation is essentially the Intellisense tooltips that show whenever you are accessing the control properties, methods and or enums. The Documentation team here at Infragistics compiles this information along with an entire database of code snippets and then merges it together to create API documentation that has relevant code snippets to help with understanding the use of a member.

 Now that you have been given a tour of the NetAdvantage Help System I encourage you all to review the Docs whenever you can. The docs can teach you alot about the controls and ensure that you are taking advantage of all these features and functionalities. Trust me, in the past, after building an application, I would go through the Help and say "Hey! I had to build that! I didnt know the product could do that intrinsically!"

Embed Any Control In WinGrid Col Header Using IUIElementCreationFilter

Here is a sample that I put together a while back when someone asked me about embedding "Any Control I Want" into the Column Headers of the Infragistics WinGrid.

 Ultra Panel Grid

 

I started to explain how to think about the control that you want to place in the Header and then try to build it through the use of the Presentation Layer Framework (Known here at Infragistics as PLF) and while losing him after the term "EditorWithComboDropDownButtonUIElement", I thought to myself "Hey, why not make a sample that makes it easy for anyone to add any Control to the Headers of WinGrid?". After thinking of a way to do this in a semi-elegant way, I came up with the idea of using a Creation Filter (aka: IUIElementCreationFilter) which is a class that implements an Infragistics Interface that allows code to be written to interact with the various "UI Elements" that are being created and put together to ultimately form the WinGrid. You can test the types of UIElements that are being rendered in this class and then you can cancel their creation, modify them or even create and instantiate other UIElements and add them as Children of the current UIElement. This allows you to basically take whatever UIElements are available as part of the Infragistics Library and essentially throw them wherever you want. In other words, the WinGrid does not have a property setting that allows you to have check boxes in the column headers. To implement this, you would use a Creation Filter.

Moving on to this particular example, the Creation filter is used to basically create and instantiate a standard Windows Forms Panel control per WinGrid Column Header. These Panels will then be positioned directly over each Column Header UIElement. This information is all provided in the event arguments within the methods of the Creation Filter. The Creation Filter is also called upon whenever the end user interacts with the WinGrid, therefore when headers are resized, moved or interacted with, the UIElement rectangles will change, and the Panels will follow along with them without any problems. In the end, you will never know that the Panels are just hovering over the Headers.

Now that we understand this far, I neatly subclassed the WinGrid to incorporate this Creation Filter along with an Event that fires during the initialization of each Panel. This event is used by the Developer to dynamically create any control, wire up control events and then place it into the Panel. You can also determine which Header the Panel belongs to through the Event Args. This results in a WinGrid that you can basically put whatever Control (or controls) into the Column Headers.

Please check out the code and comments of this example. You may need to use the Infragistics Project Upgrade Utility on this before you try to build it as it was made with 2007 Volume 1.

Download Sample 

 Enjoy!

Tom

A cool KB article on creating Excel files

Did you know that there are Classes defined in Infragistics.Excel that can be used manually to generate Microsoft Excel files? It wasn't until I ran into a situation where I needed to create a complex Excel file (that represented a view of data based on a customer's mock up) that I realized that we can create an Excel file from scratch using the Infragistics.Excel classes.

Check out this KB article and it will show you the basics on how this is done:

HOWTO:Use Infragistics.Excel objects to manually create Excel files

The best benefit of doing it this way is that you do NOT need to have Excel installed on the machine generating these files and you also do NOT need to make any references to Interop assemblies and use unmanaged code. our Excel files are created from scratch, using managed code so please check this out.

New KB Article: Upgrading Apps to use Application Styling

Application Styling, a new and powerful framework added to the NetAdvantage Windows Forms elements allows you to separate the task of building the application and styling the application. This Knowledge Base article walks you through a simple series of steps designed to instruct you how to upgrade a NetAdvantage Windows Forms equipped application to use the latest 2006 Volume 2 version and then to set it up to load an Infragistics Style Library (*.isl) which contains the resources and settings that will give your application a complete makeover.

Check it out here:

HOWTO:Upgrading an existing application to use Infragistics App Styling

Application Startup Templates

Many times we start off a new project from scratch. We then piece together the components that are needed from various libraries, snippets and projects. To avoid this, we can basically start off from a baseline solution that we may have built to include functionality for performing basic tasks (loading forms, saving preferences, user validation, printing, exporting data, etc). It is from this perspective that I present to you an application template that was built with this in mind. This Knowledge base article presents to you the "MDI Application Template" which is both available in C# and VB.NET. Quite a few features (Infragistics specific) have been used throughout to make a nice, scalable startup application. You can simply expand upon what is there, following the patterns to load more forms, export data, create reports, etc. Check them out and let me know what you think:

HOWTO:MDI Application Quick Start Templates with Infragistics controls

 

New Knowledge Base Articles

I have been out on the road doing client visits, training, consulting and presentations. I have had the chance to write some KB articles based on some things that would help everyone out there. Feel free to enjoy these and if there are any topics you would like to see posted on our KB, please feel free to let me know.

These articles are for .NET 2.0 as they relate to CAB and the last article relates to the Background Worker Component.

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

HOWTO:NetAdvantage CAB Extensibility Kit: Achieve complex layouts with UltraDock Workspace

http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=9842

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

HOWTO:NetAdvantage CAB Extensibility Kit: Loading and saving Dock Layouts with UltraDockWorkspace

http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=9844

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

HOWTO:NetAdvantage CAB Extensibility Kit: Workspace Name Property

http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=9848

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

HOWTO:Using the Background Worker component with the WinGrid to get data asynchronously

http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=9838

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

 

 

Sample Application Preview

I have started working on a cool sample application that will be titled "Northwind CRM". This application will be based on the Infragistics Windows Forms elements and it will be used to demonstrate how to make a professional user interface that ties into an ADO.NET powered data model. The "Back End" code will basically contain classes dedicated to getting and updating the various data entities, as well as classes dedicated to raising application-wide events (ex: the Customers have changed, the Orders have changed...). Other features will be scoped as the requirements are further defined.

By all means, feel free to download what I have created so far using the following link:

http://download.infragistics.com/users/TomP/NorthwindCRM.zip

Evangelism Updates

Now that we have released 5.3, the dust is settling. All of us have participated in hard work on samples, code, and quality assurance to ensure that a solid product was delivered. Now that the new volume has been released, we can move on to the other projects that have been scheduled. I will keep you updated on the new and exciting things that I will be working on as they come along.