void tFtp_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { ConfigHandler conf = ConfigHandler.instance; FTPclient ftp = new FTPclient(conf.ftpHost, conf.ftpUserName, conf.ftpUserPassword); DirectoryInfo di = new DirectoryInfo(ConfigHandler.instance.tempfolder); foreach (FileInfo f in di.GetFiles()) { if (f.Length > ConfigHandler.instance.maximmiumValue) { string fileName = String.Concat(ftp.CurrentDirectory, "/", f.Name); bool res = ftp.Upload(f, fileName); if (res) { f.Delete(); } } } string stmtFullPath = String.Concat(ftp.CurrentDirectory, conf.stmtFile); if (ftp.FtpFileExists(stmtFullPath)) { string downPath = Path.Combine(conf.tempfolder, conf.stmtFile); ftp.Download(stmtFullPath, downPath, true); ftp.FtpDelete(stmtFullPath); //Bussiness Method ProcessStmtFile(downPath); } }
void LoadImage(WPF.UCs.ImgBox pImage, string mylocalImage, string imgPath) { try { if (File.Exists(mylocalImage) && !m_blnForced2GetImagesFromFTP) { pImage.fullName = mylocalImage; pImage.LoadIMg(); pImage.Tag = mylocalImage; return; } if (!string.IsNullOrEmpty(imgPath)) { if (!PropertyLib._FTPProperties.IamLocal || m_blnForced2GetImagesFromFTP) { FtpClient.CurrentDirectory = string.Format("{0}{1}", _FtpClientCurrentDirectory, objChitiet.IdChitietchidinh.ToString()); if (FtpClient.FtpFileExists(FtpClient.CurrentDirectory + imgPath)) { string sPath1 = string.Format(@"{0}\{1}\{2}", _baseDirectory, objChitiet.IdChitietchidinh.ToString(), imgPath); Utility.CreateFolder(sPath1); FtpClient.Download(imgPath, sPath1, true); pImage.fullName = sPath1; pImage.LoadIMg(); pImage.Tag = sPath1; } else { pImage.fullName = path + @"\Path\noimage.jpg"; pImage.LoadIMg(); pImage.Tag = ""; } } else//Ảnh trên chính máy tính này { pImage.fullName = imgPath; pImage.LoadIMg(); pImage.Tag = imgPath; } } } catch { } finally { if (pImage._img.Source == null) { pImage.fullName = path + @"\Path\noimage.jpg"; pImage.LoadIMg(); pImage.Tag = ""; } } }