-
Notifications
You must be signed in to change notification settings - Fork 0
/
IFile.cs
96 lines (89 loc) · 2.63 KB
/
IFile.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using HR.Utility;
using SRDMS.FTPClient.Bussiness;
using HR.Data;
namespace CHXQ.XMManager
{
public interface IFile
{
int ID { get; }
string Name { get; }
string Path { get; }
void Delete();
void DownloadFile(string SavePath);
}
public abstract class FileClass : IFile
{
protected int m_ID;
protected string m_Name;
protected string m_Path;
public int ID { get { return m_ID; } }
public string Path { get { return m_Path; } }
public string Name { get { return m_Name; } }
public abstract void Delete();
public FileClass(int ID) {
m_ID = ID;
}
public override string ToString()
{
return m_Name;
}
public virtual void DownloadFile(string SavePath)
{
IFtpClient pFtpClient = SysDBConfig.GetInstance().GetFtpClient("CHXQ");
pFtpClient.Connect();
try
{
pFtpClient.DownloadFile(SavePath, this.Path);
}
catch (Exception ex)
{
throw ex;
}
finally
{
pFtpClient.Close();
}
}
}
public class FtpFile : FileClass
{
public FtpFile(int ID):base(ID)
{
string sql = string.Format("select Name,Path from up_files where ID={0}", ID);
DataTable pTable = SysDBConfig.GetInstance().GetOleDataBase("OrclConn").ExecuteQuery(sql).Tables[0];
if (pTable.Rows.Count > 0)
{
m_Name = pTable.Rows[0]["Name"].ToString();
m_Path = pTable.Rows[0]["Path"].ToString();
m_ID = ID;
}
}
public override void Delete()
{
IFtpClient pFtpClient = SysDBConfig.GetInstance().GetFtpClient("CHXQ");
pFtpClient.Connect();
try
{
pFtpClient.DeleteFile(this.Path);
string sql = string.Format("delete from up_files where ID={0}", this.m_ID);
IDataBase OrclDataBase = HR.Utility.SysDBConfig.GetInstance().GetOleDataBase("OrclConn");
OrclDataBase.OpenConnection();
OrclDataBase.ExecuteNonQuery(sql);
OrclDataBase.CloseConnection();
}
catch (Exception ex)
{
throw ex;
}
finally
{
pFtpClient.Close();
}
}
}
}