/// <summary> /// Default constructor. /// </summary> /// <param name="ftpRootDir">Ftp root dir for this server.</param> /// <param name="ip">IP address on which to listen.</param> /// <param name="port">Port on which to listen.</param> public ls_FTP_Server(string ftpRootDir, string ip, int port) { m_FtpRoot = ftpRootDir; m_pServer = new LumiSoft.Net.FTP.Server.FTP_Server(); this.m_pServer.CommandIdleTimeOut = 5000; this.m_pServer.LogCommands = false; this.m_pServer.MaxBadCommands = 30; this.m_pServer.SessionIdleTimeOut = 8000; this.m_pServer.Port = port; this.m_pServer.IpAddress = ip; this.m_pServer.CreateDir += new LumiSoft.Net.FTP.Server.FileSysEntryEventHandler(this.OnCreateDir); this.m_pServer.StoreFile += new LumiSoft.Net.FTP.Server.FileSysEntryEventHandler(this.OnStoreFile); this.m_pServer.DeleteDir += new LumiSoft.Net.FTP.Server.FileSysEntryEventHandler(this.OnDeleteDir); this.m_pServer.SysError += new LumiSoft.Net.ErrorEventHandler(this.OnSysError); this.m_pServer.DirExists += new LumiSoft.Net.FTP.Server.FileSysEntryEventHandler(this.OnDirExists); this.m_pServer.FileExists += new LumiSoft.Net.FTP.Server.FileSysEntryEventHandler(this.OnFileExists); this.m_pServer.RenameDirFile += new LumiSoft.Net.FTP.Server.FileSysEntryEventHandler(this.OnRenameDirFile); this.m_pServer.DeleteFile += new LumiSoft.Net.FTP.Server.FileSysEntryEventHandler(this.OnDeleteFile); this.m_pServer.ValidateIPAddress += new LumiSoft.Net.ValidateIPHandler(this.OnValidateIP); this.m_pServer.GetFile += new LumiSoft.Net.FTP.Server.FileSysEntryEventHandler(this.OnGetFile); this.m_pServer.GetDirInfo += new LumiSoft.Net.FTP.Server.FileSysEntryEventHandler(this.OnGetDirInfo); this.m_pServer.AuthUser += new LumiSoft.Net.FTP.Server.AuthUserEventHandler(this.OnAuthUser); this.m_pServer.SessionLog += m_pServer_SessionLog; m_pServer.Enabled = true; m_pServer.LogCommands = true; }
/// <summary> /// Stops server and does clean up. /// </summary> public void EndServer() { if (this.m_pServer != null) { this.m_pServer.Enabled = false; this.m_pServer = null; } }
public void Load_file_without_dir() { FTP_Server server = null; try { server = new FTP_Server(); var port = new Random().Next(10000, 20000); server.BindInfo = new[] { new BindInfo(BindInfoProtocol.TCP, IPAddress.Loopback, port), }; server.StartServer(); var testProduct = new TestProduct("Тестовый продукт"); session.Save(testProduct); var product = session.Load <Product>(testProduct.Id); var line = new DocumentLine { ProductEntity = product, SerialNumber = "012011", }; var source = new KatrenSource(); var certificateSource = new CertificateSource(); certificateSource.SourceClassName = source.GetType().Name; session.Save(certificateSource); var sourceCatalog = new CertificateSourceCatalog { CertificateSource = certificateSource, SerialNumber = line.SerialNumber, CatalogProduct = product.CatalogProduct, SupplierCode = "34266440", SupplierProducerCode = "13483667", OriginFilePath = KatrenSource.ToOriginFileName(0x1B9EFC8), }; session.Save(sourceCatalog); certificateSource.LookupUrl = String.Format("ftp://127.0.0.1:{0}/", port); source.GetFilesFromSource(new CertificateTask(certificateSource, line), new List <CertificateFile>()); } finally { if (server != null) { server.Dispose(); } } }