Esempio n. 1
0
        public void DllTest()
        {
            Assembly  a        = Assembly.LoadFrom(@"F:\Prog\gnutella2\bin\Debug\gnutella2.dll");
            Type      type     = a.GetType("ActionInnocence.P2PScan.ProtocolPlugin");
            IProtocol protocol = (IProtocol)Activator.CreateInstance(type, new string[] { @"F:\Prog\gnutella2\bin\Debug\", "192.168.1.38" });

            protocol.NewResult += new SearchResultHandler(protocol_NewResult);
            protocol.Connect();
            Thread.Sleep(1000 * 2);
            Keyword           w    = new Keyword("gnutella2", "madonna");
            KeywordCollection coll = new KeywordCollection();

            coll.Add(w);
            protocol.SearchKeyword(new SearchTransaction("1", coll, 1, null));
            System.Threading.Thread.Sleep(1000 * 30);
            protocol.Disconnect();
        }
Esempio n. 2
0
        /// <summary>
        ///     Connect with remote host
        /// </summary>
        /// <param name="obj"></param>
        private void Connect(PasswordBox obj)
        {
            if (!IsConnected)
            {
                try
                {
                    if (ProtocolMode.Equals("SFTP"))
                    {
                        _protocol = new Sftp();
                    }
                    if (ProtocolMode.Equals("FTP"))
                    {
                        _protocol = new Ftp();
                    }
                    if (ProtocolMode.Equals("FTPS"))
                    {
                        _protocol = new Ftps();
                    }

                    IsConnected = _protocol.Connect(Server, Port, User, obj.Password);
                    RemotePath  = _protocol.WorkingDirectory();

                    if (IsConnected)
                    {
                        RemoteItems = new ObservableCollection <ProtocolItem>(_protocol.ListDirectory(RemotePath));
                    }
                }
                catch (Exception)
                {
                    // We need some data
                }
            }
            else
            {
                IsConnected = !_protocol.Disconnect();
                _protocol   = null;
                RemotePath  = null;
                RemoteItems.Clear();
                Tasks.Clear();
            }
        }
Esempio n. 3
0
 /// <summary>
 ///     断开设备
 /// </summary>
 /// <returns>设备是否断开成功</returns>
 public bool Disconnect()
 {
     return(ProtocolWrapper.Disconnect());
 }