⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uddiexplorerform.cs

📁 In the previous article, we presented an approach for capturing similarity between words that was co
💻 CS
📖 第 1 页 / 共 3 页
字号:
            this.tvwSearchResults.DoubleClick += new System.EventHandler(this.tvwSearchResults_DoubleClick);
            this.tvwSearchResults.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvwSearchResults_AfterSelect);
            this.tvwSearchResults.MouseUp += new System.Windows.Forms.MouseEventHandler(this.tvwSearchResults_MouseUp);
            this.tvwSearchResults.MouseMove += new System.Windows.Forms.MouseEventHandler(this.tvwSearchResults_MouseMove);
            this.tvwSearchResults.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tvwSearchResults_MouseDown);
            this.tvwSearchResults.Click += new System.EventHandler(this.tvwSearchResults_Click);
            // 
            // contextMenuStrip1
            // 
            this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripMenuItem1});
            this.contextMenuStrip1.Name = "contextMenuStrip1";
            this.contextMenuStrip1.Size = new System.Drawing.Size(170, 26);
            this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening);
            // 
            // toolStripMenuItem1
            // 
            this.toolStripMenuItem1.Name = "toolStripMenuItem1";
            this.toolStripMenuItem1.Size = new System.Drawing.Size(169, 22);
            this.toolStripMenuItem1.Text = "Copy to clipboard";
            this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click);
            // 
            // label3
            // 
            this.label3.ForeColor = System.Drawing.Color.Blue;
            this.label3.Location = new System.Drawing.Point(13, 273);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(280, 16);
            this.label3.TabIndex = 7;
            this.label3.Text = "Search Results:";
            // 
            // imageList1
            // 
            this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
            this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
            this.imageList1.Images.SetKeyName(0, "");
            this.imageList1.Images.SetKeyName(1, "");
            this.imageList1.Images.SetKeyName(2, "");
            this.imageList1.Images.SetKeyName(3, "");
            this.imageList1.Images.SetKeyName(4, "");
            this.imageList1.Images.SetKeyName(5, "");
            this.imageList1.Images.SetKeyName(6, "");
            this.imageList1.Images.SetKeyName(7, "");
            this.imageList1.Images.SetKeyName(8, "");
            this.imageList1.Images.SetKeyName(9, "");
            this.imageList1.Images.SetKeyName(10, "");
            this.imageList1.Images.SetKeyName(11, "");
            this.imageList1.Images.SetKeyName(12, "");
            this.imageList1.Images.SetKeyName(13, "");
            this.imageList1.Images.SetKeyName(14, "");
            this.imageList1.Images.SetKeyName(15, "");
            this.imageList1.Images.SetKeyName(16, "");
            // 
            // UDDIExplorerForm
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.CancelButton = this.btnCancel;
            this.ClientSize = new System.Drawing.Size(458, 567);
            this.Controls.Add(this.groupBox2);
            this.Controls.Add(this.groupBox1);
            this.Controls.Add(this.tvwSearchResults);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.btnCancel);
            this.Controls.Add(this.btnAddSelect);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "UDDIExplorerForm";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "UDDI Explorer 1.01 ";
            this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.UDDIExplorerForm_KeyDown);
            this.Load += new System.EventHandler(this.UDDIExplorerForm_Load);
            this.groupBox2.ResumeLayout(false);
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.contextMenuStrip1.ResumeLayout(false);
            this.ResumeLayout(false);

		}
		#endregion

		static void Main() 
		{
			
			Application.Run( new UDDIExplorerForm() );
		}

		/// <summary>
		/// Pointer of TreeNodeCollection add method
		/// </summary>		 
		delegate int AddDelegate(TreeNode treeNode);		

		private void Add_SearchResultNode(TreeNode node,TreeNodeCollection  collection)
		{			
			AddDelegate addDelegate=new AddDelegate(collection.Add );		
			tvwSearchResults.Invoke(addDelegate, new object[] {node});
			
		}

		private void Invoker(object model, object data)
		{
			model.GetType().InvokeMember(    "Text",   
				BindingFlags.Default | BindingFlags.SetProperty ,    null, 
				model,    new object[]{data});
		}

		private void Get_ServiceDetail(TreeNode serviceNode )
		{						
			GetServiceDetail gsd=new GetServiceDetail();
			gsd.ServiceKeys.Add( serviceNode.Tag.ToString() );
			
			ServiceDetail sd=gsd.Send();			
			
			UDDIService s=new UDDIService ();
			s.Name=serviceNode.Text ;
			TreeNode tnInfor=new TreeNode("Registry Information", 0,0) ;
			serviceNode.Nodes.Add(tnInfor);			
			serviceNode.Nodes.Add(new TreeNode("WSDL Description") );			
			
			foreach( BusinessService service in sd.BusinessServices )
			{
				// Show service descriptions				
				TreeNode tn=new TreeNode( "Descriptions (" + service.Descriptions.Count + ")" );
				s.Descriptions =string.Empty;
				foreach( Description d in service.Descriptions )					
				{
					tn.Nodes.Add( d.Text );
					s.Descriptions=s.Descriptions + d.Text ;                    
				}
				
				tnInfor.Nodes.Add(tn) ;				
				
				// Show binding template information
				TreeNode tn1=new TreeNode();
				tn1.Text="Bindings (" + service.BindingTemplates.Count + ")";
				
				foreach( BindingTemplate bt in service.BindingTemplates )
				{
					TreeNode tn2=new TreeNode();
					foreach( Description desc in bt.Descriptions )
					{
						tn2.Text=desc.Text;
                        s.Descriptions += "\n" + desc.Text;

						if( null != bt.AccessPoint )
						{
							
							tn2.Nodes.Add( bt.AccessPoint.URLType.ToString() );
							
							string strUrl=bt.AccessPoint.Text.ToLower() ;
							strUrl=( strUrl.IndexOf ("?wsdl") != -1 || strUrl.IndexOf ("?WSDL") != -1 ? strUrl  : strUrl + "?wsdl");
							 
							tn2.Nodes[0].Nodes.Add(strUrl);
							
							//Check if this is an valid URL							
							MatchCollection mc=regexURL.Matches(bt.AccessPoint.Text);
							
							// Add a valid webservice to Result array							
							if (mc.Count >0)
							{									
								s.Url=strUrl;
								serviceNode.Tag=s;								
							};
						}

						if( 0 < bt.TModelInstanceDetail.TModelInstanceInfos.Count )
						{
							tn2.Nodes.Add( "Binding Signatures (" + bt.TModelInstanceDetail.TModelInstanceInfos.Count + ")" );
							foreach( TModelInstanceInfo tmii in bt.TModelInstanceDetail.TModelInstanceInfos )
							{
								tn2.Nodes[1].Nodes.Add( tmii.TModelKey );
							}							
						}
						if (0 < tn2.Nodes.Count )
							tn1.Nodes.Add( tn2 );
					}
				}

				if (tn1.GetNodeCount(false) > 0 ) tnInfor.Nodes.Add(tn1);									
			}
		}

		private void Explore_Business()
		{
			FindBusiness fb=new FindBusiness();
            fb.Names.Add(txtBusinessKey.Text.Trim());
            fb.FindQualifiers.Add(FindQualifier.OrAllKeys);

			try 
			{
				BusinessList bl=fb.Send();				

				if( 0 == bl.BusinessInfos.Count )
					return ;

				foreach( BusinessInfo bi in bl.BusinessInfos )
				{			
					if (bi.BusinessKey != null)
						Find_Service (bi.BusinessKey);
				}
			}
			catch( Exception e)
			{				
				MessageBox.Show(e.Message.ToString() ) ;
			}
			finally
			{
			}
			return ;
		}

        private string OrKeyWords(string query)
        {
            ServiceRanking.Tokeniser token = new Tokeniser();
            string[] toks=token.Partition(query);
            string newQuery=string.Empty;
            foreach (string s in toks)            
                newQuery += s + ";";            

            return newQuery;
        }

		
		private void Init_FindService()
		{			
			//create qualifiers
			_qualifiers=new FindQualifierCollection() ;						
			if (chkExactMatch.Checked) 
				_qualifiers.Add(FindQualifier.ExactNameMatch );
			if (chkSensitive.Checked)
                _qualifiers.Add(FindQualifier.CaseSensitiveMatch);

            string strKeyword= name.Text.Replace(" OR ", ";").Trim();
            strKeyword = name.Text.Replace(" or ", ";").Trim();
            if (chkORAllKeys.Checked)
                strKeyword = OrKeyWords(name.Text);                         

            _qualifiers.Capacity = 1000;

            _qualifiers.Add(FindQualifier.OrAllKeys);

            string delimiter = ";";
            char[] split = delimiter.ToCharArray();

            string[] strKeywords = strKeyword.Split(split);
			
            
			_keywords=new NameCollection ();
            foreach (string keyword in strKeywords)
            {
                if (keyword != string.Empty)
                    _keywords.Add(keyword);
            }

			//create Tmodels
			_tModelKeys=new StringCollection() ;

			if (txtTModelKeys.Text.Trim() != string.Empty  )
			{
				FindTModel ftm=new FindTModel();
                ftm.FindQualifiers.Add(FindQualifier.OrAllKeys);

				ftm.Name=txtTModelKeys.Text;			   
				try
				{
					TModelList tml=ftm.Send();
					if( 0 == tml.TModelInfos.Count )
						return;
					foreach( TModelInfo tmi in tml.TModelInfos )
					{
						_tModelKeys.Add(tmi.TModelKey);					
					}
				}
				catch( Exception  )
				{				
				}
				finally
				{				
				}
			}
			
		}
		
		private void Find_Service(string BusinessKey)
		{			
			FindService fs=new FindService();					
			if (BusinessKey != string.Empty)			
				fs.BusinessKey=BusinessKey;

			//enable qualifier
			fs.FindQualifiers=_qualifiers;

			//add multi-tmodels
			if (_tModelKeys.Count > 0)
				fs.TModelKeys=_tModelKeys;
			
			//multi keywords search
			if (_keywords.Count > 0 )			
				fs.Names=_keywords;
			else
                if (name.Text.Trim() != string.Empty)
                    fs.Names.Add(name.Text.Trim());

															
			
			try			
			{				
				// Perform search				
				ServiceList sl=fs.Send();								
				
				if (sl == null)
				{
					
					//MessageBox.Show (string.Empty,"UDDI Explorer", MessageBoxButtons.OK,MessageBoxIcon.Error );
					//return;

				};

				foreach( ServiceInfo si in sl.ServiceInfos )
				{	
					//action being performed					
					TreeNode tn=new TreeNode (si.Name );												
											
					//if (runFlag == false) return;
					tn.Tag=si.ServiceKey;					
					Get_ServiceDetail (tn);					
					if (tn.Tag is UDDIService) Add_SearchResultNode (tn ,tvwSearchResults.Nodes);																
					
				};


			}
			catch( Exception)
			{
				throw;				
			}

			finally
			{
			}

		}



		private void UDDISearch()
		{
			try
			{							
				// Set the URL of the UDDI Registry to search			
				btnAddSelect.Enabled=false;

				Inquire.Url=_uddiServerURL;							
				//Inquire.AuthenticationMode=AuthenticationMode.WindowsAuthentication;				
				Inquire.AuthenticationMode=AuthenticationMode.UddiAuthentication ;
				

				Init_FindService ();

				if (txtBusinessKey.Text.Trim()  != string.Empty)
					Explore_Business();
				else
					Find_Service(string.Empty);			
				if (tvwSearchResults.Nodes.Count == 0)
				{
					
					Add_SearchResultNode (new TreeNode( "No result matched the criteria"), tvwSearchResults.Nodes );
					
				}
				//else
					//tvwSearchResults.Enabled=true;

				//add this url if the search was successful
				
						
			
			} 
			catch (UddiException e)
			{
				string strErr=string.Empty;
				switch (e.Number)
				{
					case Microsoft.Uddi.UddiException.ErrorType.E_invalidKeyPassed:
						
						strErr="UDDI exception: Please check that the entered keyword is correct";
						break;
					case Microsoft.Uddi.UddiException.ErrorType.E_busy:
						strErr="UDDI exception: Server is currently busy, please try later.";
						
						break;
					default:						
						strErr="Unknown error occured: " + e.Message.ToString ();
						break;
				}				

				MessageBox.Show(strErr) ;
			}
			catch( ThreadAbortException )
			{				
				//throw e;
			}							
			catch( WebException e)
			{											
				MessageBox.Show(e.Message.ToString() ) ;			}	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -