using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Microsoft.Uddi;
using Microsoft.Uddi.Api;
using Microsoft.Uddi.Business;
using Microsoft.Uddi.Service;
using Microsoft.Uddi.Binding;
using Microsoft.Uddi.ServiceType;

namespace UDDI_Browser
{
	/// <summary>
	/// Summary description for business2.
	/// </summary>
	public class business2 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label Label_Introduction;
		protected System.Web.UI.WebControls.Image Image1;
		protected System.Web.UI.WebControls.Label Label2;
	
		public business2()
		{
			Page.Init += new System.EventHandler(Page_Init);
		}

		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
			Inquire.Url = Session["host"].ToString();
			
			GetBusinessDetail gbusinessDetails = new GetBusinessDetail();
			gbusinessDetails.BusinessKeys.Add(Request.Params["BusinessKey"]);
			BusinessDetail businessDetails = gbusinessDetails.Send();
			
			Label2.Text += "<br> <b><u>Company Information</u></b><br><br>";
			Label2.Text += businessDetails.BusinessEntities[0].Name +  "<br>";
			foreach (Description d in businessDetails.BusinessEntities[0].Descriptions)  Label2.Text += d.Text + "<br>";
			Label2.Text += "<br>";
			foreach (Contact c in businessDetails.BusinessEntities[0].Contacts ) 
			{
				Label2.Text += c.PersonName + "<br>"; 
				foreach (Address a in c.Addresses) 
				{
					foreach (string al in a.AddressLines) Label2.Text += al + "<br>"; 
				}
				Label2.Text += "<br>";
				foreach (Phone phone in c.Phones) Label2.Text +=  "Phone: " + phone.Text  + "<br>";
				foreach (Email email in c.Emails) Label2.Text +=  "Email: " + email.Text + "<br>";
							
			}
			foreach (DiscoveryUrl du in businessDetails.BusinessEntities[0].DiscoveryUrls) Label2.Text += "<a href='" + du.Text + "'>Discovery URL</a><br>";
			Label2.Text += "<br>";
			Label2.Text += "<br> <b><u>Business Service Information</u></b><br><br>";
			
			foreach (BusinessService bs in businessDetails.BusinessEntities[0].BusinessServices) 
			{
				
				Label2.Text += "<b><i>Service Name: -  " + bs.Name + "</i></b><BR>";
				foreach (Description d in bs.Descriptions )  Label2.Text += d.Text + "<br>";

				Label2.Text += "<br><i>Binding Templates: -  " + bs.Name + "</i><BR>";
				foreach (BindingTemplate bt in bs.BindingTemplates)
				{
					Label2.Text += "<blockquote>";
					
					Label2.Text += "AccessPoint: " + "<a href='" + bt.AccessPoint.Text + "'>" + bt.AccessPoint.Text + "</a><BR>";
					foreach (Description d in bt.Descriptions)  
					{
						Label2.Text += "Description : " + d.Text + "<br>";
					}

					if (bt.TModelInstanceDetail.TModelInstanceInfos.Count > 0)
					{
						Label2.Text += "tModels : <br>";
						foreach (TModelInstanceInfo tmi in bt.TModelInstanceDetail.TModelInstanceInfos)  
						{
							Label2.Text += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='tModel.aspx?tModelKey="  + tmi.TModelKey + "'>" + tmi.TModelKey + "</a>&nbsp;&nbsp;&nbsp;(<a href='" + tmi.InstanceDetail.OverviewDoc.OverviewURL +  "'>Overview Url</a>) <br>";
						}
					}

					Label2.Text += "</blockquote>";
				
				}
				Label2.Text += "</p>";
			}
		}

		private void Page_Init(object sender, EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
		}

		#region Web Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
	}
}