Click here to Skip to main content
15,886,258 members
Articles / Web Development / Apache

The platform-independent code with Mono: Client-server application sample

Rate me:
Please Sign up or sign in to vote.
4.80/5 (23 votes)
24 Mar 2010CPOL10 min read 73.4K   798   59  
This article shows how we can develop the platform-independent software with Mono usage
//------------------------------------------------------------------------------
// <auto-generated>
//     Этот код создан программой.
//     Исполняемая версия:2.0.50727.3053
//
//     Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
//     повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Generic;

using NHibernate;
using NHibernate.Criterion;

using InfoCenter.Persistence;
using InfoCenter.Persistence.Core;
using InfoCenter.Persistence.Entities;

namespace InfoCenter.WebConsole
{
	public partial class Default : System.Web.UI.Page
	{
		IRepository<Computer> computers;
		IRepository<Process> processes;
		
		protected override void OnLoad (EventArgs e)
		{
			ISessionFactory sessionFactory = Initializer.GetSessionFactory(false);
            computers = new Repository<Computer>(sessionFactory);
            processes = new Repository<Process>(sessionFactory);
			
			DetachedCriteria criteria = DetachedCriteria.For<Computer>()
                .Add(NHibernate.Criterion.Expression.Like("Name","%")); 
						
			IList<Computer> list = new List<Computer>();
			foreach(Computer item in computers.FindAll(criteria))
				list.Add(item);
			
			computersList.DataSource = list;
			computersList.DataBind();
			
			base.OnLoad (e);
		}
		
		protected void ComputersList_ItemCommand(object source, DataListCommandEventArgs e)
		{
			string compName = e.CommandArgument.ToString();
			lblCurrentComp.Text = String.Format(@"<b>Processes on computer '{0}':</b>",compName);
			
			DetachedCriteria criteria = DetachedCriteria.For<Process>().CreateAlias("Host","c")
                .Add(NHibernate.Criterion.Expression.Eq("c.Name",compName));
			
			IList<Process> list = new List<Process>();
			foreach(Process item in processes.FindAll(criteria))
				list.Add(item);

			processesGrid.DataSource = list;
			processesGrid.DataBind();			
		}	

	}
}

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Nokia
Germany Germany
Interested in design/development of framework functionality using the best patterns and practices.

Comments and Discussions