Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

346 lines
12 KiB

  1. using System;
  2. using System.Web;
  3. using System.Web.UI;
  4. using System.Web.UI.WebControls;
  5. using UDDI;
  6. using UDDI.API;
  7. using UDDI.API.Business;
  8. using UDDI.API.Service;
  9. using UDDI.API.ServiceType;
  10. using UDDI.API.Binding;
  11. namespace UDDI.Web
  12. {
  13. public enum BreadCrumbType
  14. {
  15. Edit = 0,
  16. Details = 1,
  17. Search = 1,
  18. Administer = 2
  19. }
  20. public class BreadCrumbControl : UserControl
  21. {
  22. protected string root = "";
  23. protected bool frames;
  24. protected PlaceHolder section;
  25. protected PlaceHolder navigate;
  26. protected BreadCrumbType type;
  27. protected override void OnInit( EventArgs e )
  28. {
  29. if( "/" != Request.ApplicationPath )
  30. root = Request.ApplicationPath;
  31. frames = ( 0 == String.Compare( "true", Request[ "frames" ], true ) );
  32. }
  33. public void Initialize( BreadCrumbType type, EntityType entityType, string key )
  34. {
  35. Initialize( type,entityType,key,null );
  36. }
  37. public void Initialize( BreadCrumbType type, EntityType entityType, string key, string projectionkey )
  38. {
  39. this.type = type;
  40. switch( entityType )
  41. {
  42. case EntityType.BusinessEntity:
  43. AddBusinessBlurb( key, false );
  44. break;
  45. case EntityType.BusinessService:
  46. if( null!=projectionkey )
  47. {
  48. AddServiceProjectionBlurb( key,projectionkey, false );
  49. }
  50. else
  51. {
  52. AddServiceBlurb( key, false );
  53. }
  54. break;
  55. case EntityType.BindingTemplate:
  56. AddBindingBlurb( key, false );
  57. break;
  58. case EntityType.TModel:
  59. AddTModelBlurb( key, false );
  60. break;
  61. default:
  62. break;
  63. }
  64. }
  65. public void Initialize( BreadCrumbType type, EntityType entityType, string key, int index )
  66. {
  67. this.type = type;
  68. switch( entityType )
  69. {
  70. case EntityType.Contact:
  71. AddContactBlurb( key, index, false );
  72. break;
  73. case EntityType.TModelInstanceInfo:
  74. AddInstanceInfoBlurb( key, index, false );
  75. break;
  76. default:
  77. break;
  78. }
  79. }
  80. public void AddBlurb( string text, string url, string imageFilename, string tooltip, bool crumb )
  81. {
  82. if( crumb )
  83. {
  84. if( navigate.Controls.Count > 0 )
  85. navigate.Controls.Add( new LiteralControl( " | " ) );
  86. HyperLink link = new HyperLink();
  87. link.NavigateUrl = url;
  88. link.Text = HttpUtility.HtmlEncode( text );
  89. link.CssClass = "breadcrumb";
  90. link.ToolTip = tooltip;
  91. navigate.Controls.Add( link );
  92. }
  93. else
  94. {
  95. if( null != imageFilename )
  96. {
  97. Image image = new Image();
  98. image.ImageUrl = root + "/images/" + imageFilename;
  99. if( frames )
  100. image.ImageAlign = ImageAlign.AbsMiddle;
  101. else
  102. image.ImageAlign = ImageAlign.Bottom;
  103. section.Controls.Add( image );
  104. section.Controls.Add( new LiteralControl( " " ) );
  105. }
  106. Label label = new Label();
  107. label.Text = HttpUtility.HtmlEncode( text );
  108. label.CssClass = "section";
  109. label.ToolTip = tooltip;
  110. section.Controls.Add( label );
  111. }
  112. }
  113. public void AddContainerBlurb( bool chained )
  114. {
  115. string text;
  116. string tooltip;
  117. string url = root;
  118. if( BreadCrumbType.Edit == type )
  119. {
  120. text = Localization.GetString( "HEADING_MY_ENTRIES" );
  121. tooltip = text;
  122. url = root + "/edit/edit.aspx?refreshExplorer=&frames=" + frames.ToString().ToLower();
  123. }
  124. else
  125. {
  126. if( frames )
  127. return;
  128. if( chained )
  129. {
  130. text = Localization.GetString( "HEADING_SEARCH_RESULTS" );
  131. url += "/search/results.aspx";
  132. }
  133. else
  134. {
  135. text = Localization.GetString( "HEADING_SEARCH_CRITERIA" );
  136. url += "/search/search.aspx";
  137. }
  138. tooltip = text;
  139. url += "?search=" + Request[ "search" ] + "&frames=" + frames.ToString().ToLower();
  140. }
  141. if( chained )
  142. AddBlurb( text, url, null, tooltip, true );
  143. else
  144. AddBlurb( text, null, null, tooltip, false );
  145. }
  146. public void AddBusinessBlurb( string businessKey, bool chained )
  147. {
  148. BusinessInfo businessInfo = new BusinessInfo( businessKey );
  149. businessInfo.Get( false );
  150. string text = businessInfo.Names[ 0 ].Value;
  151. string tooltip = Localization.GetString( "HEADING_BUSINESS" );
  152. string url = root;
  153. if( BreadCrumbType.Edit == type )
  154. url += "/edit/editbusiness.aspx?refreshExplorer=&key=";
  155. else
  156. url += "/details/businessdetail.aspx?search=" + Request[ "search" ] + "&key=";
  157. url += businessKey + "&frames=" + frames.ToString().ToLower();
  158. AddContainerBlurb( true );
  159. if( chained )
  160. AddBlurb( text, url, null, tooltip, true );
  161. else
  162. AddBlurb( text, null, "business.gif", tooltip, false );
  163. }
  164. public void AddServiceBlurb( string serviceKey, bool chained )
  165. {
  166. ServiceInfo serviceInfo = new ServiceInfo();
  167. serviceInfo.ServiceKey = serviceKey;
  168. serviceInfo.Get();
  169. string text = serviceInfo.Names[ 0 ].Value;
  170. string tooltip = Localization.GetString( "HEADING_SERVICE" );
  171. string url = root;
  172. if( BreadCrumbType.Edit == type )
  173. url += "/edit/editservice.aspx?refreshExplorer=&key=";
  174. else
  175. url += "/details/servicedetail.aspx?search=" + Request[ "search" ] + "&key=";
  176. url += serviceKey + "&frames=" + frames.ToString().ToLower();
  177. AddBusinessBlurb( serviceInfo.BusinessKey, true );
  178. if( chained )
  179. AddBlurb( text, url, null, tooltip, true );
  180. else
  181. AddBlurb( text, null, "service.gif", tooltip, false );
  182. }
  183. public void AddServiceProjectionBlurb( string serviceKey, string parentKey, bool chained )
  184. {
  185. ServiceInfo serviceInfo = new ServiceInfo();
  186. serviceInfo.ServiceKey = serviceKey;
  187. serviceInfo.Get();
  188. string text = serviceInfo.Names[ 0 ].Value;
  189. string tooltip = Localization.GetString( "HEADING_SERVICE" );
  190. string url = root;
  191. if( BreadCrumbType.Edit == type )
  192. url += "/edit/editservice.aspx?refreshExplorer=&key=";
  193. else
  194. url += "/details/servicedetail.aspx?search=" + Request[ "search" ] + "&key=";
  195. url += serviceKey + "&frames=" + frames.ToString().ToLower();
  196. AddBusinessBlurb( parentKey, true );
  197. if( chained )
  198. AddBlurb( text, url, null, tooltip, true );
  199. else
  200. AddBlurb( text, null, "service_projection.gif", tooltip, false );
  201. }
  202. public void AddBindingBlurb( string bindingKey, bool chained )
  203. {
  204. BindingTemplate binding = new BindingTemplate( bindingKey );
  205. binding.Get();
  206. string text = ( null != binding.AccessPoint ? binding.AccessPoint.Value : Localization.GetString( "HEADING_BINDING" ) );
  207. string tooltip = Localization.GetString( "HEADING_BINDING" );
  208. string url = root;
  209. if( BreadCrumbType.Edit == type )
  210. url += "/edit/editbinding.aspx?refreshExplorer=&key=";
  211. else
  212. url += "/details/bindingdetail.aspx?search=" + Request[ "search" ] + "&key=";
  213. url += bindingKey + "&frames=" + frames.ToString().ToLower();
  214. AddServiceBlurb( binding.ServiceKey, true );
  215. if( chained )
  216. AddBlurb( text, url, null, tooltip, true );
  217. else
  218. AddBlurb( text, null, "binding.gif", tooltip, false );
  219. }
  220. public void AddInstanceInfoBlurb( string bindingKey, int index, bool chained )
  221. {
  222. TModelInstanceInfoCollection infos = new TModelInstanceInfoCollection();
  223. infos.Get( bindingKey );
  224. string text = Lookup.TModelName( infos[ index ].TModelKey );
  225. string tooltip = Localization.GetString( "HEADING_INSTANCE_INFO" );
  226. string url = root;
  227. if( BreadCrumbType.Edit == type )
  228. url += "/edit/editinstanceinfo.aspx?key=";
  229. else
  230. url += "/details/instanceinfodetail.aspx?search=" + Request[ "search" ] + "&key=";
  231. url += bindingKey + "&index=" + index + "&frames=" + frames.ToString().ToLower();
  232. AddBindingBlurb( bindingKey, true );
  233. if( chained )
  234. AddBlurb( text, url, null, tooltip, true );
  235. else
  236. AddBlurb( text, null, "instance.gif", tooltip, false );
  237. }
  238. public void AddContactBlurb( string businessKey, int index, bool chained )
  239. {
  240. ContactCollection contacts = new ContactCollection();
  241. contacts.Get( businessKey );
  242. string text = contacts[ index ].PersonName;
  243. string tooltip = Localization.GetString( "HEADING_CONTACT" );
  244. string url = root;
  245. if( BreadCrumbType.Edit == type )
  246. url += "/edit/editcontact.aspx?key=";
  247. else
  248. url += "/details/contactdetail.aspx?search=" + Request[ "search" ] + "&key=";
  249. url += businessKey + "&index=" + index + "&frames=" + frames.ToString().ToLower();
  250. AddBusinessBlurb( businessKey, true );
  251. if( chained )
  252. AddBlurb( text, url, null, tooltip, true );
  253. else
  254. AddBlurb( text, null, "contact.gif", tooltip, false );
  255. }
  256. public void AddTModelBlurb( string tModelKey, bool chained )
  257. {
  258. TModelInfo tModelInfo = new TModelInfo( tModelKey );
  259. tModelInfo.Get();
  260. string text = tModelInfo.Name;
  261. string tooltip = Localization.GetString( "HEADING_TMODEL" );
  262. string url = root;
  263. if( BreadCrumbType.Edit == type )
  264. url += "/edit/editmodel.aspx?key=";
  265. else
  266. url += "/details/modeldetail.aspx?search=" + Request[ "search" ] + "&key=";
  267. url += tModelKey + "&frames=" + frames.ToString().ToLower();
  268. AddContainerBlurb( true );
  269. if( chained )
  270. AddBlurb( text, url, null, tooltip, true );
  271. else
  272. AddBlurb( text, null, "tmodel.gif", tooltip, false );
  273. }
  274. }
  275. }