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.

168 lines
4.9 KiB

  1. using System;
  2. using System.Data;
  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.Diagnostics;
  11. namespace UDDI.Web
  12. {
  13. public class ServiceControl : UddiControl
  14. {
  15. protected BusinessServiceCollection services;
  16. private BusinessServiceCollection bindableServices;
  17. private BusinessServiceCollection bindableServiceProjections;
  18. protected BusinessEntity parent;
  19. protected bool frames;
  20. protected string parentKey;
  21. protected DataGrid grid;
  22. protected DataGrid projectionsGrid;
  23. public void Initialize( BusinessServiceCollection services, string parentKey )
  24. {
  25. this.services = services;
  26. this.parentKey = parentKey;
  27. this.parent = null;
  28. InitializeBindableData();
  29. grid.Columns[ 0 ].Visible = false;
  30. grid.Columns[ 1 ].Visible = false;
  31. grid.Columns[ 2 ].Visible = true;
  32. grid.ShowFooter = false;
  33. projectionsGrid.Columns[ 0 ].Visible = false;
  34. projectionsGrid.Columns[ 1 ].Visible = false;
  35. projectionsGrid.Columns[ 2 ].Visible = true;
  36. }
  37. public void Initialize( BusinessServiceCollection services, BusinessEntity parent )
  38. {
  39. this.services = services;
  40. this.parent = parent;
  41. this.parentKey = parent.BusinessKey;
  42. InitializeBindableData();
  43. grid.Columns[ 0 ].Visible = true;
  44. grid.Columns[ 1 ].Visible = true;
  45. grid.Columns[ 2 ].Visible = false;
  46. grid.ShowFooter = true;
  47. projectionsGrid.Columns[ 0 ].Visible = true;
  48. projectionsGrid.Columns[ 1 ].Visible = true;
  49. projectionsGrid.Columns[ 2 ].Visible = false;
  50. }
  51. private void InitializeBindableData( )
  52. {
  53. //
  54. // Fix to filter out service projections
  55. //
  56. bindableServices = new BusinessServiceCollection();
  57. bindableServiceProjections = new BusinessServiceCollection();
  58. foreach( BusinessService s in services )
  59. {
  60. if( s.BusinessKey!=parentKey )
  61. {
  62. bindableServiceProjections.Add( s );
  63. }
  64. else
  65. {
  66. bindableServices.Add( s );
  67. }
  68. }
  69. }
  70. protected void Page_Load( object sender, EventArgs e )
  71. {
  72. frames = ( "true" == Request[ "frames" ] );
  73. PopulateDataGrid();
  74. }
  75. void PopulateDataGrid()
  76. {
  77. projectionsGrid.DataSource = bindableServiceProjections;
  78. projectionsGrid.DataBind();
  79. grid.DataSource = bindableServices;
  80. // commented for service projection fix.
  81. //grid.DataSource = services;
  82. grid.DataBind();
  83. }
  84. protected void ServiceProjection_View( object sender, DataGridCommandEventArgs e )
  85. {
  86. string key = bindableServiceProjections[ e.Item.ItemIndex ].ServiceKey;
  87. string root = ((Request.ApplicationPath=="/")?"":Request.ApplicationPath );
  88. if( frames )
  89. {
  90. string explkey = "sp:" + bindableServiceProjections[ e.Item.ItemIndex ].BusinessKey + ":" + key;
  91. Response.Write(
  92. ClientScripts.ReloadExplorerAndViewPanes( root+"/details/servicedetail.aspx?projectionContext=edit&frames=true&projectionKey="+parentKey+"&key=" + key, explkey ) );
  93. Response.End();
  94. }
  95. else
  96. {
  97. Response.Redirect( "editservice.aspx?frames=false&key=" + key );
  98. Response.End();
  99. }
  100. }
  101. protected void Service_Edit( object sender, DataGridCommandEventArgs e )
  102. {
  103. string key = bindableServices[ e.Item.ItemIndex ].ServiceKey;
  104. if( frames )
  105. {
  106. Response.Write(
  107. ClientScripts.ReloadExplorerAndViewPanes( "editservice.aspx?frames=true&key=" + key, key ) );
  108. Response.End();
  109. }
  110. else
  111. {
  112. Response.Redirect( "editservice.aspx?frames=false&key=" + key );
  113. Response.End();
  114. }
  115. }
  116. protected void Service_Delete( object sender, DataGridCommandEventArgs e )
  117. {
  118. string name = bindableServices[ e.Item.ItemIndex ].Names[ 0 ].Value;
  119. string key = bindableServices[ e.Item.ItemIndex ].ServiceKey;
  120. //
  121. // The user has not yet confirmed the delete operation, so display
  122. // a confirmation dialog.
  123. //
  124. string message = String.Format(
  125. Localization.GetString( "TEXT_DELETE_CONFIRMATION" ),
  126. name );
  127. Page.RegisterStartupScript(
  128. "Confirm",
  129. ClientScripts.Confirm(
  130. message,
  131. "editservice.aspx?frames=" + ( frames ? "true" : "false" ) + "&key=" + key + "&mode=delete&confirm=true&tab=1" ) );
  132. }
  133. protected void Service_Add( object sender, EventArgs e )
  134. {
  135. Response.Redirect( "editservice.aspx?frames=" + ( frames ? "true" : "false" ) + "&key=" + parent.BusinessKey + "&mode=add" );
  136. }
  137. }
  138. }