RISE to Bloome Software
Log In    
Home
RISE
Collapse RISERISE
Overview
Product feature list
Expand RISE Visual ModelingRISE Visual Modeling
How to get started
Expand Information ModelingInformation Modeling
Expand Interface ModelingInterface Modeling
Expand Code generatorsCode generators
Collapse Application DevelopmentApplication Development
Expand CustomizationCustomization
Philosophy of RISE
Expand User CommunityUser Community
Marshal
Download
 
 
r2bsoftware.se r2bsoftware.se
 
 
 
Click to hide navigation tree
Developing a ASP.NET Web Application
In this example we show how to build a ASP.NET application in c# for a RISE information solution. We assume that you are fairly accustomed to Visual Studio and ASP.NET programming so we'll focus on the RISE parts. Our example is a task list application called ToDo for tracking and distributing tasks.
 
Sample solution
You may choose to follow this example by downloading the Visual Studio sample solution. The project contains our web application and the folders App_Code and Model. In the Model folder we've placed the RISE model file and an SQL Server database script generated using RISE. The App_Code folder contains the server parts, persistent classes, needed to access the model. These too are generated using RISE. Note that this project includes the model server parts as source code (todo.DB.IAttachment.cs and todo.DB.ITask.cs) rather than calling external web services. Read more about generating your application server.
 
 
 
Prerequisited for running sample application:
  1. Create a SQL Server database, named ToDo, and run the todo.sql script in the database to setup the database model.
  2. If the SQL Server isn't on your local machine (or you used another database name) modify the connection string found in Web.config of the project.
  
The ToDo model
Using RISE a ToDo information system has been modelled. The core object in the model is the Task entity. Tasks can be categorized, using the Category entity, and each task may have a list files stored in the Attachment entity. We provide the model with one view for each list that we intend to display - in reality these we're added when designing the user interface, i.e. one view per task list. Finally, we publish our model using the interface ITask and IAttachment. We're ITask is the main interface and IAttachment is used solely for file up and downloading.
 
 
Building our ASP.NET web application
Now it's time to build our web application. We design it as a plain page containing a few lists; my open tasks, all open tasks and complete tasks. We also add a function for creating a new task. Each of the task list are spreadsheets listing tasks and providing a way to open the task to view further details and/or change task information.
 
Step 1. Create a web application project
Select File | New | Project in the menu of Visual Studio. This will display the New Project dialog. Select project type Web and the project template ASP.NET Web Application and give your application a suitable name, in this case Todo, and click OK.
 
 
Step 2. Add server components
In our Todo sample - since we have another sample running web services and since this is a server side application - we choose to include the model server parts (classes running ODBC) directly into the project. The classes are placed in the App_Code folder in the project.
 
Step 3. Create the user interface
The user interface consist of a number of fairly alike pages each displaying a list of task. We drag a Grid View web control on to each page and provides it with the columns of interest. Since navigation works the same way we build a little custom user control for it and drags that one on to each page as well.
 
 
Step 4. Write the code behind
Finally, we tie everything together by implenting the code behind for each of our pages. Here we just provide some limited snippets of code to display the principles. For more code look in the Todo sample project.
 
In the below sample code we create a DataTable and populates it with task information returned from the MyOpenTasks method of the ITask interface. We then bind the DataTable to the Grid View web control (_GridView1) to display the data on the page. Note that the ITask is class in the project to access to class, without providing the full namespace, we've added a using directive in the beginning of the code behind file. The ITask classes requires a database connection string. We retrieve the connection string from the Web.config file.
using todo.DB.ITask;
 
// other code goes here

DataTable dt = new DataTable("MyOpenTasks");
dt.Columns.Add(new DataColumn("DetailsLink", typeof(string)));
dt.Columns.Add(new DataColumn("CategoryLabel", typeof(string)));
dt.Columns.Add(new DataColumn("Title", typeof(string)));
dt.Columns.Add(new DataColumn("AttendedToDate", typeof(string)));
dt.Columns.Add(new DataColumn("AttendedToBy", typeof(string)));
dt.Columns.Add(new DataColumn("Deadline", typeof(string)));
dt.Columns.Add(new DataColumn("Priority", typeof(string)));
dt.Columns.Add(new DataColumn("State", typeof(string)));
dt.Columns.Add(new DataColumn("Private", typeof(bool)));
ITask iTask = new ITask(System.Configuration.ConfigurationManager.AppSettings["ToDo"]);
foreach (returnMyOpenTasks task in iTask.MyOpenTasks(1024, _userName))
{
DataRow dr = dt.NewRow();
dr["DetailsLink"] = "<a href=\"TaskDetails.aspx?ID=" + task.ID.ToString() + "\">Open</a>";
dr["CategoryLabel"] = task.CategoryLabel ?? string.Empty;
dr["Title"] = task.Title ?? string.Empty;
dr["AttendedToDate"] = (task.AttendedToDate != null ? task.AttendedToDate.Value.Date.ToShortDateString() : string.Empty);
dr["AttendedToBy"] = task.AttendedToBy ?? string.Empty;
dr["Deadline"] = (task.Deadline != null ? task.Deadline.Value.Date.ToShortDateString() : string.Empty);
dr["Priority"] = task.Priority ?? string.Empty;
dr["State"] = task.State ?? string.Empty;
dr["Private"] = task.Private;
dt.Rows.Add(dr);
}
_GridView1.DataSource = dt;
_GridView1.DataBind();
 
The Todo application also supports uploading of documents to tasks. The below sample code shows how to use a RISE generated interface to store a file. First we create an instance of the IAttachment class for providing us with the needed file management functionality. Then we call the method NewAttachment to create an attachment and, finally, using UploadAttachmentFile we store the actual file content. The object FileUpload1 is FileUpload web control. Since the upload control provides us with the file a single block there's no need to use RISE abilities to send the file in chunks, we just pass all of it directly to the database.
if (FileUpload1.HasFile)
{
IAttachment iFile = new IAttachment(System.Configuration.ConfigurationManager.AppSettings["ToDo"]);
int attachmentID = iFile.NewAttachment(FileUpload1.FileName, _userName, id, FileUpload1.PostedFile.ContentType);
iFile.UploadAttachmentFile(null, true, attachmentID, FileUpload1.FileBytes);
}