| | |
| | | using MES.Service.Modes; |
| | | using MES.Service.util; |
| | | using SqlSugar; |
| | | using System.Net; |
| | | using System.Xml.Linq; |
| | | |
| | | namespace MES.Service.service.QC; |
| | |
| | | .OrderBy(a => a.BillNo, OrderByType.Desc) |
| | | .ToPageList(queryObj.PageIndex, queryObj.Limit); |
| | | |
| | | if(queryObj.Id != null) |
| | | /*if(queryObj.Id != null) |
| | | { |
| | | |
| | | |
| | |
| | | return commit; |
| | | }); |
| | | |
| | | } |
| | | }*/ |
| | | |
| | | |
| | | |
| | |
| | | |
| | | return withOracle; |
| | | } |
| | | |
| | | |
| | | |
| | | public List<string> GetFtpFileList(string ftpAddress, string username, string password, string remotePath) |
| | | { |
| | | List<string> fileList = new List<string>(); |
| | | try |
| | | { |
| | | // 构造FTP请求的URI |
| | | string requestUri = $"{ftpAddress}/{remotePath}".TrimEnd('/'); // 确保路径格式正确 |
| | | |
| | | // 创建FtpWebRequest对象 |
| | | FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(requestUri); |
| | | ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory; |
| | | ftpRequest.Credentials = new NetworkCredential(username, password); |
| | | ftpRequest.UseBinary = true; |
| | | |
| | | // 获取响应 |
| | | using (FtpWebResponse ftpResponse = (FtpWebResponse)ftpRequest.GetResponse()) |
| | | { |
| | | using (StreamReader responseReader = new StreamReader(ftpResponse.GetResponseStream())) |
| | | { |
| | | string line = responseReader.ReadLine(); |
| | | while (line != null) |
| | | { |
| | | fileList.Add(line); |
| | | line = responseReader.ReadLine(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine("获取FTP文件列表时发生错误: " + ex.Message); |
| | | |
| | | } |
| | | return fileList; |
| | | } |
| | | |
| | | |
| | | public byte[] DownloadFtpFile(string ftpAddress, string username, string password, string remotePath) |
| | | { |
| | | byte[] fileData = null; |
| | | try |
| | | { |
| | | // 构造FTP请求的URI |
| | | string requestUri = $"{ftpAddress}/{remotePath}".TrimEnd('/'); // 确保路径格式正确 |
| | | |
| | | // 创建FtpWebRequest对象 |
| | | FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(requestUri); |
| | | ftpRequest.Method = WebRequestMethods.Ftp.DownloadFile; |
| | | ftpRequest.Credentials = new NetworkCredential(username, password); |
| | | ftpRequest.UseBinary = true; |
| | | |
| | | // 获取响应 |
| | | using (FtpWebResponse ftpResponse = (FtpWebResponse)ftpRequest.GetResponse()) |
| | | { |
| | | using (Stream responseStream = ftpResponse.GetResponseStream()) |
| | | using (MemoryStream memoryStream = new MemoryStream()) |
| | | { |
| | | responseStream.CopyTo(memoryStream); |
| | | fileData = memoryStream.ToArray(); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine("下载FTP文件时发生错误: " + ex.Message); |
| | | } |
| | | return fileData; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |