public void TestUploadedSongs() { try { List <int> songIds = new List <int>(); IEnumerable <String> uploadedSongs = FtpManager.List(); foreach (String uploadedSong in uploadedSongs) { String songIdString = uploadedSong.Substring(5); songIdString = songIdString.Remove(songIdString.IndexOf(".")); int songId = Convert.ToInt32(songIdString); songIds.Add(songId); } var dataContext = new MusicEntities1(); var songs = from row in dataContext.SONG where (row.UPLOADED == true) select row; foreach (SONG song in songs) { if (!songIds.Contains(song.ID)) { Console.WriteLine(song.TITLE); song.UPLOADED = false; } } dataContext.SaveChanges(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); throw; } }
void InValidFingerPrintShouldFail() { string nodeId = "4816d758dd37833a3a5551001dac8a5fa737a342"; PayloadSigner signer = new PayloadSigner(nodeId, new FileKeyStore("./")); signer.Init(); List <string> telemetryToSend = new List <string>(); telemetryToSend.Add("abc 1"); telemetryToSend.Add("abc 2"); telemetryToSend.Add("abc 3"); TelemetryPacket pkt = new TelemetryPacket { NodeId = nodeId, Payload = telemetryToSend, Signature = signer.SignPayload(string.Join(string.Empty, telemetryToSend)) }; string jsonPayload = JsonConvert.SerializeObject(pkt); FtpManager fm = new FtpManager(_userName, _password, _ftpHost, _ftpPort, "38:32:36:8e:ad:ac:8c:31:57:b4:80:ba:2d:e4:88:9d", "/upload/dropzone/"); string fileName = string.Format("{0}-{1}.json", nodeId, DateTime.UtcNow.ToString("yyyy-MM-dd_HH:mm:ss")); //Assert.True(!fm.transferData(jsonPayload, fileName)); }
private void Watch() { if (!Directory.Exists(currentUser.Path)) { Directory.CreateDirectory(currentUser.Path); } relatiavePath = client.GetUserDir(); ftpManager = new FtpManager(client.GetFtpHost(), client.GetFtpUser(), client.GetFtpPassword()); ftpManager.CreateDirectory($@"UserDirectories{client.GetPath(currentUser)}"); var url = "UserDirectories/28"; ftpManager.DownloadFtpDirectory(url, Properties.Settings.Default.PutBoxDirectory); watcher = new FileSystemWatcher { IncludeSubdirectories = true, Path = currentUser.Path, NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName, Filter = "*.*", EnableRaisingEvents = true }; watcher.Renamed += OnRenamed; watcher.Created += OnCreated; watcher.Deleted += OnDeleted; }
private void UploadEngineFiles() { List <CopyInformation> engineFiles = CopyBuiltEnginesToReleaseFolder.CopyInformationList; for (int i = 0; i < engineFiles.Count; i++) { string localFile = engineFiles[i].DestinationFile; string engineName = FileManager.RemovePath(FileManager.GetDirectory(localFile)); string debugOrRelease = null; if (engineName.ToLower() == "debug/" || engineName.ToLower() == "release/") { debugOrRelease = engineName; engineName = FileManager.RemovePath(FileManager.GetDirectory(FileManager.GetDirectory(localFile))); } string fileName = engineName + debugOrRelease + FileManager.RemovePath(localFile); string destination = _ftpFolder + "SingleDlls/" + fileName; FtpManager.UploadFile( localFile, "ftp://flatredball.com", "frbadmin", p, destination, false); Results.WriteMessage(engineFiles[i].DestinationFile + " uploaded to " + destination); } }
private void ProcessFiles() { var ftpManager = new FtpManager(_ftpSetting.FtpUri, null, false, true); var regex = FileNameRegex; foreach (var fileName in ftpManager.GetFiles()) { if (!regex.IsMatch(fileName)) { continue; } using (var stream = ftpManager.Download(Path.GetFileName(fileName))) { using (var streamReader = new StreamReader(stream)) { try { var engine = new FileHelperEngine(typeof(DatColPurchaseOrder)); var listofPickTickets = engine.ReadStream(streamReader) as DatColPurchaseOrder[]; ProcessFile(listofPickTickets); _archiveService.CopyToArchive(ftpManager.BaseUri.AbsoluteUri, SaveTo.PurchaseOrderDirectory, fileName); ftpManager.Delete(fileName); } catch (Exception) { _log.AuditError(string.Format("Failed to process the Purchase order file. File name: '{0}'", fileName)); } } } } }
private void UploadImages() { new System.Threading.Thread(() => { Console.WriteLine("Intro========== " + imageCaptions.Count); FtpManager ftpManger = new FtpManager(); ListingManager listingManager = new ListingManager(); ftpManger.OnProgressChange += ftpManger_OnProgressChange; Hashing hashing = new Hashing(); List <string> urls = new List <string>(); List <string> links = new List <string>(); numberOfImages = localFilePaths.Count(); foreach (string localFile in localFilePaths) { numberToUpload++; string fileHash = hashing.HashFile(localFile); string extension = System.IO.Path.GetExtension(localFile); urls.Add(webDir + fileHash + extension); links.Add(linkDir + fileHash + extension); } for (int i = 0; i < numberOfImages; i++) { LoadImage(localFilePaths[i]); Console.WriteLine("Pregame========== " + imageCaptions.Count); UpdateProgress(numberToUpload, i + 1); ftpManger.UploadFile(localFilePaths[i], urls[i]); listingManager.AddListingImage(propertyID, links[i], imageCaptions[i]); } CloseForm(); }).Start(); }
private void PublishFile(ConnectorRelation connector, string fileUrl, string fileName) { switch ((FtpTypeEnum)connector.FtpType.Value) { case FtpTypeEnum.Customer: var ftp = new FtpManager(connector.FtpAddress, string.Empty, connector.Username, connector.FtpPass, false, connector.FtpType.HasValue ? (FtpConnectionTypeEnum)connector.FtpType.Value == FtpConnectionTypeEnum.Passive : false, log); fileName = String.Format("{0}_{1}", DateTime.Now.ToString("yyyyMMddhhmmss"), fileName); using (var wc = new System.Net.WebClient()) { using (var stream = new MemoryStream(wc.DownloadData(fileUrl))) { ftp.Upload(stream, fileName); } } break; case FtpTypeEnum.Xtract: var xtractPath = Path.Combine(_config.AppSettings.Settings["XtractFtpPath"].Value, connector.CustomerID); DownloadFile(fileUrl, xtractPath, fileName); break; } }
protected override void SyncProducts() { DataTable content = null; try { FtpManager productDownloader = new FtpManager( Config.AppSettings.Settings["AmacomUrl"].Value, Config.AppSettings.Settings["ProductPath"].Value, Config.AppSettings.Settings["Username"].Value, Config.AppSettings.Settings["Password"].Value, false, true, log); var clientID = Config.AppSettings.Settings["ClientID"].Value; var filename = clientID + ".csv"; using (var file = productDownloader.OpenFile(filename)) { content = CreateDataTable(file.Data, false, ';'); } if (content != null) { log.AuditInfo(string.Format("Start: {0}", DateTime.Now)); Parseproducts(content); log.AuditInfo(string.Format("Done: {0}", DateTime.Now)); } } catch (Exception ex) { log.AuditFatal("Unable to retreive file from ftp"); } }
protected override void SyncProducts() { try { log.AuditInfo("Start Tech Data import"); var stopWatch = Stopwatch.StartNew(); FtpManager downloader = new FtpManager(GetConfiguration().AppSettings.Settings["TechDataFtpSite"].Value, string.Empty, GetConfiguration().AppSettings.Settings["TechDataFtpUserName"].Value, GetConfiguration().AppSettings.Settings["TechDataFtpPass"].Value, false, false, log); using (var file = downloader.OpenFile("prices.zip")) { using (ZipProcessor zipUtil = new ZipProcessor(file.Data)) { var zipEligible = (from z in zipUtil where z.FileName == "00136699.txt" select z); foreach (var zippedFile in zipEligible) { using (CsvParser parser = new CsvParser(zippedFile.Data, ColumnDefinitions, true)) { ProcessCsv(parser); } } } } log.AuditSuccess(string.Format("Total import process finished in: {0}", stopWatch.Elapsed), "Tech Data Import"); } catch (Exception e) { log.AuditFatal("Tech data import failed", e, "Tech Data Import"); } }
protected override void Process() { var config = GetConfiguration().AppSettings.Settings; try { var ftp = new FtpManager(config["LenmarImageFtpUrl"].Value, "mycom/Images/" + config["LenmarImageFtpFolder"].Value + "/", config["LenmarImageUser"].Value, config["LenmarImagePassword"].Value, false, true, log); using (var unit = GetUnitOfWork()) { foreach (var file in ftp) { try { ProcessImageFile(file, unit); file.Data.Dispose(); unit.Save(); } catch (Exception ex) { log.AuditError("Error processing image", ex); } } } log.AuditComplete("Finished full Lenmar image import", "Lenmar Image Import"); } catch (Exception ex) { log.AuditError("Error import Lenmar Images", ex); } }
private void ButtonBackupServer_Click(object sender, RoutedEventArgs e) { if (ListServers.SelectedItem == null) { return; } var server = ListServers.SelectedItem as Server; var files = FtpManager.DownloadWorldFiles(server); var backups = DataManager.BackupFtpFiles(server, files); // replace backups in memory App.Backups.Clear(); foreach (var b in backups) { App.Backups.Add(b); } // save files to backup location BackupDataManager.SaveData(backups); // associate the backups and servers with one another from the new backup App.AssociateCollections(); return; }
private void populateRemoteWorlds() { try { Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; var files = FtpManager.ListFiles(Server.ConnectionInfo, Server.BackupSettings.WorldDirectory); var worldNames = new List <string>(); foreach (FtpFileInfo file in files) { if (file.Extension == ".db") { worldNames.Add(file.Name); } } Server.BackupSettings.SelectedWorlds = worldNames; } catch (FtpException e) { MessageBox.Show("Unable to connect to remote server to populate the selected server list:\r\n" + e.Message, "Check your FTP Settings!", MessageBoxButton.OK, MessageBoxImage.Error); } finally { Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow; } }
public int DispatchOrders(Dictionary <Concentrator.Objects.Models.Orders.Order, List <OrderLine> > orderLines, Vendor vendor, IAuditLogAdapter log, IUnitOfWork work) { try { XDocument order = new AlphaOrderExporter().GetOrder(orderLines, vendor); var msgID = orderLines.FirstOrDefault().Value.FirstOrDefault().OrderLineID; FtpManager manager = new FtpManager(vendor.VendorSettings.GetValueByKey("AlphaFtpUrl", string.Empty), string.Empty, vendor.VendorSettings.GetValueByKey("AlphaUserName", string.Empty), vendor.VendorSettings.GetValueByKey("AlphaPassword", string.Empty), false, false, log); using (Stream s = new MemoryStream()) { XmlDocument doc = new XmlDocument(); doc.LoadXml(order.ToString()); doc.Save(s); string fileName = vendor.VendorSettings.GetValueByKey("AlphaCustomerNumber", string.Empty) + "-" + "ORDER" + "-" + msgID + ".xml"; manager.Upload(s, vendor.VendorSettings.GetValueByKey("AlphaRemoteOrderDirectory", string.Empty) + @"/WS-D" + fileName); LogOrder(doc, vendor.VendorID, fileName, log); } return(msgID); } catch (Exception e) { throw new Exception("Alpha dispatching failed", e); } }
protected override void Process() { #region Ftp connection var config = GetConfiguration().AppSettings.Settings; var ftpFile1 = new FtpManager(config["VSNFtpUrl"].Value, "pub4/ExportSupplierNames.xml", config["VSNUser"].Value, config["VSNPassword"].Value, false, true, log).FirstOrDefault(); var ftpFile2 = new FtpManager(config["VSNFtpUrl"].Value, "pub4/ExportSupplier.xml", config["VSNUser"].Value, config["VSNPassword"].Value, false, true, log).FirstOrDefault(); var vendorID = int.Parse(config["VendorID"].Value); #endregion //ExportStock.xml //ExportSupplier.xml //ExportSupplierNames.xml #region Data process using (var unit = GetUnitOfWork()) { List <FtpManager.RemoteFile> files = new List <FtpManager.RemoteFile>(); files.Add(ftpFile2); files.Add(ftpFile1); ProcessFile(files, unit, vendorID); unit.Save(); } log.AuditComplete("Finished VSN SupplierNames Import Plugin", "VSN SupplierNames Import Plugin"); #endregion }
private void ReadStockFile() { var ftpManager = new FtpManager(_ftpSetting.FtpUri, null, false, true); var regex = FileNameRegex; foreach (var fileName in ftpManager.GetFiles()) { if (!regex.IsMatch(fileName)) { continue; } using (var stream = ftpManager.Download(Path.GetFileName(fileName))) { using (var streamReader = new StreamReader(stream)) { var engine = new FileHelperEngine(typeof(DatColStock)); var listOfVendorStock = engine.ReadStream(streamReader) as DatColStock[]; ProcessStock(listOfVendorStock); try { ftpManager.Upload(stream, Path.Combine("History", fileName)); } catch (Exception e) { } } } _archiveService.CopyToArchive(ftpManager.BaseUri.AbsoluteUri, SaveTo.StockDirectory, fileName); ftpManager.Delete(fileName); } }
protected override void Process() { #region Ftp connection var config = GetConfiguration().AppSettings.Settings; var ftp = new FtpManager(config["VSNFtpUrl"].Value, "pub4/", config["VSNUser"].Value, config["VSNPassword"].Value, false, false, log); vendorID = int.Parse(config["VendorID"].Value); #endregion //ExportStock.xml //ExportSupplier.xml //ExportSupplierNames.xml #region Data process using (var unit = GetUnitOfWork()) { using (var prodFile = ftp.OpenFile("ExportStock.xml")) { ProcessFile(prodFile, unit); unit.Save(); } } log.AuditComplete("Finished VSN Stock import Plugin", "VSN Stock import Plugin"); #endregion }
protected override void Process() { var config = GetConfiguration().AppSettings.Settings; var ftp = new FtpManager(config["VSNFtpUrl"].Value, "pub3/", config["VSNUser"].Value, config["VSNPassword"].Value, false, true, log); using (var unit = GetUnitOfWork()) { using (var synFile = ftp.OpenFile("XMLExportSynopsis.zip")) { using (var zipProc = new ZipProcessor(synFile.Data)) { foreach (var file in zipProc) { using (file) { using (DataSet ds = new DataSet()) { ds.ReadXml(file.Data); ProcessSynopsisTable(ds.Tables[0], unit); } } } } } } log.AuditComplete("Finished full VSN synopsis import", "VSN Synopsis Import"); }
public void GetAvailableDispatchAdvices(Vendor vendor, IAuditLogAdapter log, string logPath, IUnitOfWork unit) { try { FtpManager AcknowledgementManager = new FtpManager(vendor.VendorSettings.GetValueByKey("VSNFtpUrl", string.Empty), "orderresponse/", vendor.VendorSettings.GetValueByKey("VSNUser", string.Empty), vendor.VendorSettings.GetValueByKey("VSNPassword", string.Empty), false, false, log); ProcessNotifications(AcknowledgementManager, OrderResponseTypes.Acknowledgement, log, vendor, logPath, unit); } catch (Exception ex) { log.AuditWarning("Acknowledment VSN failed", ex); } try { FtpManager ShipmentNotificationManager = new FtpManager(vendor.VendorSettings.GetValueByKey("VSNFtpUrl", string.Empty), "pakbonnen/", vendor.VendorSettings.GetValueByKey("VSNUser", string.Empty), vendor.VendorSettings.GetValueByKey("VSNPassword", string.Empty), false, false, log); ProcessNotifications(ShipmentNotificationManager, OrderResponseTypes.ShipmentNotification, log, vendor, logPath, unit); } catch (Exception ex) { log.Warn("Shipment Notification VSN failed", ex); } try { FtpManager InvoiceNotificationManager = new FtpManager(vendor.VendorSettings.GetValueByKey("VSNFtpUrl", string.Empty), vendor.VendorSettings.GetValueByKey("InvoicePath", string.Empty) + "/", vendor.VendorSettings.GetValueByKey("VSNUser", string.Empty), vendor.VendorSettings.GetValueByKey("VSNPassword", string.Empty), false, false, log); ProcessInvoiceNotifications(InvoiceNotificationManager, OrderResponseTypes.InvoiceNotification, log, vendor, logPath, unit); } catch (Exception ex) { log.AuditWarning("Invoice Notification VSN failed", ex); } try { FtpManager CancelNotificationManager = new FtpManager(vendor.VendorSettings.GetValueByKey("VSNFtpUrl", string.Empty), "cancellations/", vendor.VendorSettings.GetValueByKey("VSNUser", string.Empty), vendor.VendorSettings.GetValueByKey("VSNPassword", string.Empty), false, false, log); ProcessNotifications(CancelNotificationManager, OrderResponseTypes.CancelNotification, log, vendor, logPath, unit); } catch (Exception ex) { log.AuditWarning("Cancel Notification VSN failed", ex); } }
//private const int UnMappedID = -1; protected override void SyncProducts() { var config = GetConfiguration(); FtpManager downloader = new FtpManager( config.AppSettings.Settings["AlphaFtpUrl"].Value, config.AppSettings.Settings["AlphaStockPath"].Value, config.AppSettings.Settings["AlphaUserName"].Value, config.AppSettings.Settings["AlphaPassword"].Value, false, true, log);//new FtpDownloader("test/"); log.AuditInfo("Starting stock import process"); using (var unit = GetUnitOfWork()) { // log.DebugFormat("Found {0} files for Alpha process", downloader.Count()); foreach (var file in downloader) { if (!Running) { break; } log.InfoFormat("Processing file: {0}", file.FileName); XDocument doc = null; using (file) { try { using (var reader = XmlReader.Create(file.Data)) { reader.MoveToContent(); doc = XDocument.Load(reader); if (ProcessXML(doc, unit.Scope)) { log.InfoFormat("Succesfully processed file: {0}", file.FileName); downloader.Delete(file.FileName); } else { log.InfoFormat("Failed to process file: {0}", file.FileName); downloader.MarkAsError(file.FileName); } } } catch (Exception ex) { log.AuditError(String.Format("Failed to load xml for file: {0}", file.FileName), ex); downloader.MarkAsError(file.FileName); continue; } } } unit.Save(); } }
public void ListSongs() { IEnumerable <String> songs = FtpManager.List(); foreach (String song in songs) { testContextInstance.WriteLine(song); } }
public RealTimeTelemetryManagerTests() { PayloadSigner sig = new PayloadSigner( "4816d758dd37833a3a5551001dac8a5fa737a342", new FileKeyStore("./")); string pubkey = sig.GenerateKeys(); _ftpMgr = new FtpManager("foo", "pass", "127.0.0.1", 2222, "78:72:96:8e:ad:ac:8c:31:57:b4:80:ba:2d:e4:88:9d", "/upload/dropzone/"); }
public int DispatchOrders(Dictionary <Concentrator.Objects.Models.Orders.Order, List <OrderLine> > orderLines, Vendor vendor, IAuditLogAdapter log, IUnitOfWork unit) { try { var orderDoc = new XDocument(new XDeclaration("1.0", "UTF-8", "yes"), new XElement("SalesOrders", from o in orderLines select new XElement("SalesOrder", new XElement("CustomerCode", vendor.VendorSettings.GetValueByKey("VSNUser", string.Empty)), new XElement("Reference", o.Key.OrderID), new XElement("DeliveryDate", DateTime.Now.ToString("dd-MM-yyyy")), new XElement("DeliveryAddress", new XElement("AddressName", o.Key.ShippedToCustomer.CustomerName), new XElement("Street", o.Key.ShippedToCustomer.CustomerAddressLine1), new XElement("HouseNumber", o.Key.ShippedToCustomer.HouseNumber), new XElement("ZipCode", o.Key.ShippedToCustomer.PostCode.Length < 7 ? o.Key.ShippedToCustomer.PostCode.Substring(0, 4) + " " + o.Key.ShippedToCustomer.PostCode.Substring(4, 2).ToUpper() : o.Key.ShippedToCustomer.PostCode.ToUpper()), new XElement("City", o.Key.ShippedToCustomer.City), new XElement("CountryCode", o.Key.ShippedToCustomer.Country)), from ol in o.Value let vendorAss = VendorUtility.GetMatchedVendorAssortment(unit.Scope.Repository <VendorAssortment>(), vendor.VendorID, ol.ProductID.Value) let purchaseLine = ol.OrderResponseLines.Where(x => x.OrderLineID == ol.OrderLineID && x.OrderResponse.ResponseType == OrderResponseTypes.PurchaseAcknowledgement.ToString()).FirstOrDefault() select new XElement("SalesOrderLine", new XElement("ProductCode", vendorAss.CustomItemNumber), new XElement("Quantity", ol.GetDispatchQuantity()), new XElement("Reference", ol.OrderLineID + "/" + ol.Order.WebSiteOrderNumber)//(purchaseLine != null ? purchaseLine.VendorItemNumber : vendorAss.ProductID.ToString())) ) ) ) ); var ftp = new FtpManager(vendor.VendorSettings.GetValueByKey("VSNFtpUrl", string.Empty), "orders/", vendor.VendorSettings.GetValueByKey("VSNUser", string.Empty), vendor.VendorSettings.GetValueByKey("VSNPassword", string.Empty), false, false, log); var fileName = String.Format("{0}.xml", DateTime.Now.ToString("yyyyMMddhhmmss")); using (var inStream = new MemoryStream()) { using (XmlWriter writer = XmlWriter.Create(inStream)) { orderDoc.WriteTo(writer); writer.Flush(); } ftp.Upload(inStream, fileName); } LogOrder(orderDoc, vendor.VendorID, fileName, log); return(-1); } catch (Exception e) { throw new Exception("VSN dispatching failed", e); } }
public LogSync() { _seatId = AppConfigReader.ReadCfg("SeatId"); _ftpIP = AppConfigReader.ReadCfg("FtpIp"); _ftpPort = AppConfigReader.ReadCfg("FtpPort"); _ftpUserName = AppConfigReader.ReadCfg("FtpUserName"); _ftpPassWord = AppConfigReader.ReadCfg("FtpPassWord"); _logSavePath = AppConfigReader.ReadCfg("LogSavePath"); _curFtpServices = new FtpManager(); _curFtpServices.FtpUpDown(_ftpIP, _ftpUserName, _ftpPassWord); }
private void UploadFrbdkFiles() { string localFile = ZipFrbdk.DestinationFile; string fileName = FileManager.RemovePath(localFile); string destination = _ftpFolder + fileName; FtpManager.UploadFile( localFile, "ftp://flatredball.com", "frbadmin", p, destination, false); Results.WriteMessage(localFile + " uploaded to " + destination); }
private void ReadCustomerInformation() { _ftpSetting.Path = _vendorSettingRepo.GetVendorSetting(SapphVendorID, CustomerInformationDirectorySettingKey); var ftpManager = new FtpManager(_ftpSetting.FtpUri, null, false, usePassive: true); var regex = FileNameRegex; foreach (var fileName in ftpManager.GetFiles()) { if (!regex.IsMatch(fileName)) { continue; } try { _log.Info(string.Format("Processing file: {0}", fileName)); using (var stream = ftpManager.Download(Path.GetFileName(fileName))) { using (var excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream)) { excelReader.IsFirstRowAsColumnNames = true; var result = excelReader.AsDataSet(); var dt = result.Tables[0]; var customerInformationList = ( from ci in dt.AsEnumerable() select new DatColCustomerInformation { CustomerNumber = ci.Field <string>(ColumnCustomerNumber), SupplierName = ci.Field <string>(ColumnSupplierName), SupplierAdress = ci.Field <string>(ColumnSupplierAdress), ExpeditionCity = ci.Field <string>(ColumnExpeditionCity), ExpeditionPc = ci.Field <string>(ColumnExpeditionZip), ExpeditionCountry = ci.Field <string>(ColumnExpeditionCountry) }) .ToList(); UploadCustomerInformationToTnt(customerInformationList); } } _archiveService.CopyToArchive(ftpManager.BaseUri.AbsoluteUri, SaveTo.CustomerInformationDirectory, fileName); ftpManager.Delete(Path.GetFileName(fileName)); } catch (Exception e) { _log.Info(string.Format("Failed to process file {0}. Error: {1}", fileName, e.Message)); } } }
private FtpManager GetFtpManager(SaveTo saveTo) { var ftpSetting = new FtpSetting { FtpAddress = _vendorSettingRepo.GetVendorSetting(SapphVendorID, FtpAddressSettingKey), FtpUsername = _vendorSettingRepo.GetVendorSetting(SapphVendorID, FtpUsernameSettingKey), FtpPassword = _vendorSettingRepo.GetVendorSetting(SapphVendorID, FtpPasswordSettingKey), Path = GetDirectory(saveTo) }; var ftpManager = new FtpManager(ftpSetting.FtpUri, null, false, true); return(ftpManager); }
void InvalidArgumentShouldNotCreateInstance(string userName, string password, string sftpHost, int port, string fingerPrint, string workingDir) { FtpManager mgr = null; PayloadSigner signer = new PayloadSigner("4816d758dd37833a3a5551001dac8a5fa737a342", new FileKeyStore("./")); signer.Init(); Assert.Throws <ArgumentException>(() => { mgr = new FtpManager(userName, password, sftpHost, port, fingerPrint, workingDir); }); Assert.Null(mgr); }
private async void DirectorySearchDialog_Shown(object sender, EventArgs e) { Text = string.Format(Text, ProjectName, Program.VersionString); _ftp = new FtpManager(Host, Port, null, Username, Password, null, UsePassiveMode, FtpAssemblyPath, Protocol, NetworkVersion); var node = new TreeNode("Server", 0, 0); serverDataTreeView.Nodes.Add(node); await LoadListAsync("/", node); node.Expand(); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Loaded(object sender, RoutedEventArgs e) { //获取称点编码 _curClientCode = XpathHelper.GetValue(_sysConfigFile, _curClientCode); this.notifyIcon = new NotifyIcon(); //this.notifyIcon.BalloonTipText = "文件同步程序"; //设置程序启动时显示的文本 //this.notifyIcon.Text = "文件同步程序";//最小化到托盘时,鼠标点击时显示的文本 this.notifyIcon.BalloonTipText = ""; //设置程序启动时显示的文本 this.notifyIcon.Text = ""; //最小化到托盘时,鼠标点击时显示的文本 this.notifyIcon.Icon = Properties.Resources.FileSync; this.notifyIcon.Visible = true; //退出菜单项 System.Windows.Forms.MenuItem exit = new System.Windows.Forms.MenuItem("退出"); exit.Click += new EventHandler(Quit); //关联托盘控件 System.Windows.Forms.MenuItem[] childen = new System.Windows.Forms.MenuItem[] { exit }; notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu(childen); // notifyIcon.MouseDoubleClick += OnNotifyIconDoubleClick; //this.notifyIcon.ShowBalloonTip(1000); log.Info("注册托盘图标完成"); //读取照片配置 ConfigReader rf = new ConfigReader(_sysConfigFile); _curPhotoConfig = ConfigReader.ReadPhotoConfig(); log.Info("读取配置文件完成"); _curFtpServices = new FtpManager(); _curFtpServices.FtpUpDown(_curPhotoConfig.FtpIp, _curPhotoConfig.FtpUserName, _curPhotoConfig.FtpPassWord); log.Info("初始化文件服务器完成"); //定时器相关 curUploadTimer = new DispatcherTimer(); curUploadTimer.Interval = new TimeSpan(0, 1, 0); //一分钟检测一次 curUploadTimer.Tick += curUploadJpgTimer_Tick; curUploadTimer.Start(); ShowUpLoadInfo("开始文件同步"); WindowState = System.Windows.WindowState.Minimized; wsl = WindowState; // this.Visibility = System.Windows.Visibility.Hidden; this.Hide(); }
protected virtual void LoadDocuments(string sourceUri) { var ftpManager = new FtpManager(sourceUri, Log, usePassive: true); var regex = FileNameRegex; foreach (var fileName in ftpManager.GetFiles()) { if (regex.IsMatch(fileName)) { using (var stream = ftpManager.Download(fileName)) { Documents[fileName] = XDocument.Load(stream); } } } }
/// <summary> /// Execute Ftp /// </summary> /// <param name="input">list of files </param> /// <returns>list of response message</returns> public List<string> Run(List<string> files) { List<string> responses = new List<string>(); if (d != null) { Db.intelliScraperProjectFtpSetting ftpInfo = (from x in Factory.Instance.i.Project.FtpSetting where x.id == d.ftpId select x).FirstOrDefault(); if (ftpInfo != null) { FtpManager f = new FtpManager(ftpInfo.ftpServerString, ftpInfo.authenticate, ftpInfo.user, ftpInfo.pass,ftpInfo.domain); foreach (string file in files) responses.Add(f.upload(file)); } return responses; } return responses; }