温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:风讯dotNETCMSv1.0免安装版源码
当前文件:
FooSunCMS/Foosun.CMS/Database.cs[4K,2009-6-12 11:42:42],打开代码结构图
FooSunCMS/Foosun.CMS/Database.cs[4K,2009-6-12 11:42:42],打开代码结构图1//=========================================================== 2
//== (c)2007 Foosun Inc. by dotNETCMS 1.0 == 3
//== Forum:bbs.foosun.net == 4
//== website:www.foosun.net == 5
//== Address:NO.109 HuiMin ST.,Chengdu ,China == 6
//== TEL:86-28-85098980/66026180 == 7
//== qq:655071,MSN:ikoolls@gmail.com == 8
//== Code By Xi.deng == 9
//=========================================================== 10
using System; 11
using System.Collections.Generic; 12
using System.Text; 13
using Foosun.DALFactory; 14
using Foosun.CMS; 15
using Foosun.Model; 16
using System.IO; 17
using System.Data; 18
19
namespace Foosun.CMS 20
{ 21
public class Database 22
{ 23
private IDatabase data; 24
public Database() 25
{ 26
data = DataAccess.CreateDatabase(); 27
} 28
29
public DataTable ExecuteSql(string sqlText) 30
{ 31
DataTable dt = data.ExecuteSql(sqlText); 32
return dt; 33
34
} 35
36
public int backSqlData(int type, string backpath) 37
{ 38
return data.backSqlData(type, backpath); 39
} 40
41
public int DbBak(string sourcePath, string desPath) 42
{ 43
int result = 0; 44
if (File.Exists(sourcePath)) 45
{ 46
try 47
{ 48
FileInfo Fso = new FileInfo(sourcePath); //实例化FSO对象 49
Fso.CopyTo(desPath); //备份数据库到指定目录 50
result = 1; 51
52
} 53
catch 54
{ 55
result = 2; 56
} 57
} 58
else 59
{ 60
result = 3; 61
} 62
return result; 63
} 64
65
public int DbRar(string rarSourcePath, string rarTempPath, string rarStr_S, string rarStr_T) 66
{ 67
int result = 0; 68
if (File.Exists(rarSourcePath)) //判断数据库文件是否存在 69
{ 70
JRO.JetEngine Jet = new JRO.JetEngineClass(); //实例化JET引掣 71
if (File.Exists(rarTempPath)) 72
{ 73
try 74
{ 75
File.Delete(rarTempPath); 76
} 77
catch 78
{ 79
result = 1; //删除存在的数据库文件失败 80
} 81
} 82
Jet.CompactDatabase(rarStr_S, rarStr_T); //压缩数据库 83
try 84
{ 85
File.Delete(rarSourcePath); //删除源数据库 86
File.Move(rarTempPath, rarSourcePath); //移动新文件到指定地方并且指定文件名 87
File.Delete(rarTempPath); //删除临时数据库文件 88
result = 3; //压缩数据库成功! 89
} 90
catch (Exception e) 91
{ 92
result = 2; 93
throw e; 94
//操作失败 95
} 96
} 97
else 98
{ 99
result = 4; //数据库不存在! 100
} 101
return result; 102
} 103
104
public int DelBakDb(string bakPath) 105
{ 106
int result = 0; 107
FileInfo Fso = new FileInfo(bakPath); //实例化FSO对象 108
try 109
{ 110
Fso.Delete(); //删除此文件 111
} 112
catch //容错处理,提取IO异常 113
{ 114
result = 2; //失败 115
} 116
result = 1; //成功 117
return result; 118
} 119
120
public void Replace(string oldTxt, string newTxt, string Table, string FieldName) 121
{ 122
data.Replace(oldTxt, newTxt, Table, FieldName); 123
} 124
} 125
126
} 127






}
}