Skip to content

Commit 2cbd297

Browse files
author
starlying
committed
4.27
1 parent 73a0137 commit 2cbd297

7 files changed

Lines changed: 65 additions & 68 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Copyright (C) 2003-2017 北京百容千域软件技术开发有限公司
1919

2020
项目正式发布的稳定版本存放在 `master` 分支,当前的开发版本存放在 `dev` 分支
2121

22-
分支 | AppVeyor | 安装包下载 | 升级包下载
23-
------ | ------ | ------ | ------
24-
master | [![Build status](https://ci.appveyor.com/api/projects/status/plx37i94y9gsqkru/branch/master?svg=true)](https://ci.appveyor.com/project/starlying/cms/branch/master) | [siteserver_install.zip](https://ci.appveyor.com/api/projects/starlying/cms/artifacts/siteserver_install.zip?branch=master) | [siteserver_upgrade.zip](https://ci.appveyor.com/api/projects/starlying/cms/artifacts/siteserver_upgrade.zip?branch=master)
25-
dev | [![Build status](https://ci.appveyor.com/api/projects/status/plx37i94y9gsqkru/branch/dev?svg=true)](https://ci.appveyor.com/project/starlying/cms/branch/dev) | [siteserver_install.zip](https://ci.appveyor.com/api/projects/starlying/cms/artifacts/siteserver_install.zip?branch=dev) | [siteserver_upgrade.zip](https://ci.appveyor.com/api/projects/starlying/cms/artifacts/siteserver_upgrade.zip?branch=dev)
22+
分支 | AppVeyor
23+
------ | ------
24+
master | [![Build status](https://ci.appveyor.com/api/projects/status/plx37i94y9gsqkru/branch/master?svg=true)](https://ci.appveyor.com/project/starlying/cms/branch/master)
25+
dev | [![Build status](https://ci.appveyor.com/api/projects/status/plx37i94y9gsqkru/branch/dev?svg=true)](https://ci.appveyor.com/project/starlying/cms/branch/dev)

appveyor.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ deploy:
5353
provider: GitHub
5454
auth_token:
5555
secure: B/TFrPxGyyTS/NKTQsf/GBLPfGI+Rz/j3e7FVLaP6yjeUDljwkfvV70C+CT34/10
56-
artifact: /.*\.zip/ # upload all NuGet packages to release assets
56+
artifact: /.*\.zip/ # upload all to release assets
5757
draft: false
5858
prerelease: false
5959
on:
60+
branch: master
6061
appveyor_repo_tag: false # deploy on tag push only

source/BaiRong.Core/Data/DataProviderBase.cs

Lines changed: 26 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,12 @@
33
using System.Collections.Generic;
44
using System.Data;
55
using System.Text;
6-
using BaiRong.Core.Data.Helper;
76
using BaiRong.Core.Model.Enumerations;
87

98
namespace BaiRong.Core.Data
109
{
1110
public class DataProviderBase
1211
{
13-
private AdoHelper _helper;
14-
15-
private AdoHelper Helper
16-
{
17-
get
18-
{
19-
if (_helper != null) return _helper;
20-
21-
if (WebConfigUtils.IsMySql)
22-
{
23-
_helper = new MySql();
24-
}
25-
else
26-
{
27-
_helper = new SqlServer();
28-
}
29-
return _helper;
30-
}
31-
}
32-
3312
protected virtual string ConnectionString => WebConfigUtils.ConnectionString;
3413

3514
protected IDbConnection GetConnection()
@@ -119,119 +98,119 @@ private static IDbDataParameter GetParameterInner(string parameterName, EDataTyp
11998

12099
protected IDataReader ExecuteReader(string commandText, params IDataParameter[] commandParameters)
121100
{
122-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteReader(ConnectionString, CommandType.Text, commandText, commandParameters) : null;
101+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteReader(ConnectionString, CommandType.Text, commandText, commandParameters) : null;
123102
}
124103

125104

126105
protected IDataReader ExecuteReader(string commandText)
127106
{
128-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteReader(ConnectionString, CommandType.Text, commandText) : null;
107+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteReader(ConnectionString, CommandType.Text, commandText) : null;
129108
}
130109

131110

132111
protected IDataReader ExecuteReader(IDbConnection conn, string commandText, params IDataParameter[] commandParameters)
133112
{
134-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteReader(conn, CommandType.Text, commandText, commandParameters) : null;
113+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteReader(conn, CommandType.Text, commandText, commandParameters) : null;
135114
}
136115

137116

138117
protected IDataReader ExecuteReader(IDbConnection conn, string commandText)
139118
{
140-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteReader(conn, CommandType.Text, commandText) : null;
119+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteReader(conn, CommandType.Text, commandText) : null;
141120
}
142121

143122

144123
protected IDataReader ExecuteReader(IDbTransaction trans, string commandText, params IDataParameter[] commandParameters)
145124
{
146-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteReader(trans, CommandType.Text, commandText, commandParameters) : null;
125+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteReader(trans, CommandType.Text, commandText, commandParameters) : null;
147126
}
148127

149128

150129
protected IDataReader ExecuteReader(IDbTransaction trans, string commandText)
151130
{
152-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteReader(trans, CommandType.Text, commandText) : null;
131+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteReader(trans, CommandType.Text, commandText) : null;
153132
}
154133

155134

156135
protected IDataReader ExecuteReader(string connectionString, string commandText)
157136
{
158-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteReader(connectionString, CommandType.Text, commandText) : null;
137+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteReader(connectionString, CommandType.Text, commandText) : null;
159138
}
160139

161140
protected IDataReader ExecuteReader(string connectionString, string commandText, params IDataParameter[] commandParameters)
162141
{
163-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteReader(connectionString, CommandType.Text, commandText, commandParameters) : null;
142+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteReader(connectionString, CommandType.Text, commandText, commandParameters) : null;
164143
}
165144

166145

167146
protected DataSet ExecuteDataset(string commandText, params IDataParameter[] commandParameters)
168147
{
169-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteDataset(ConnectionString, CommandType.Text, commandText, commandParameters) : null;
148+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteDataset(ConnectionString, CommandType.Text, commandText, commandParameters) : null;
170149
}
171150

172151

173152
protected DataSet ExecuteDataset(string commandText)
174153
{
175-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteDataset(ConnectionString, CommandType.Text, commandText) : null;
154+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteDataset(ConnectionString, CommandType.Text, commandText) : null;
176155
}
177156

178157
protected DataSet ExecuteDataset(string connectionString, string commandText)
179158
{
180-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteDataset(connectionString, CommandType.Text, commandText) : null;
159+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteDataset(connectionString, CommandType.Text, commandText) : null;
181160
}
182161

183162
protected int ExecuteNonQuery(IDbConnection conn, CommandType commandType, string commandText, params IDataParameter[] commandParameters)
184163
{
185-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteNonQuery(conn, commandType, commandText, commandParameters) : 0;
164+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteNonQuery(conn, commandType, commandText, commandParameters) : 0;
186165
}
187166

188167

189168
protected int ExecuteNonQuery(IDbConnection conn, string commandText, params IDataParameter[] commandParameters)
190169
{
191-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteNonQuery(conn, CommandType.Text, commandText, commandParameters) : 0;
170+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteNonQuery(conn, CommandType.Text, commandText, commandParameters) : 0;
192171
}
193172

194173

195174
protected int ExecuteNonQuery(IDbConnection conn, string commandText)
196175
{
197-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteNonQuery(conn, CommandType.Text, commandText) : 0;
176+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteNonQuery(conn, CommandType.Text, commandText) : 0;
198177
}
199178

200179

201180
protected int ExecuteNonQuery(IDbTransaction trans, string commandText, params IDataParameter[] commandParameters)
202181
{
203-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteNonQuery(trans, CommandType.Text, commandText, commandParameters) : 0;
182+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteNonQuery(trans, CommandType.Text, commandText, commandParameters) : 0;
204183
}
205184

206185

207186
protected int ExecuteNonQuery(IDbTransaction trans, string commandText)
208187
{
209-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteNonQuery(trans, CommandType.Text, commandText) : 0;
188+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteNonQuery(trans, CommandType.Text, commandText) : 0;
210189
}
211190

212191
protected int ExecuteNonQuery(string connectionString, string commandText, params IDataParameter[] commandParameters)
213192
{
214-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteNonQuery(connectionString, CommandType.Text, commandText, commandParameters) : 0;
193+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteNonQuery(connectionString, CommandType.Text, commandText, commandParameters) : 0;
215194
}
216195

217196

218197
protected int ExecuteNonQuery(string commandText, params IDataParameter[] commandParameters)
219198
{
220-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteNonQuery(ConnectionString, CommandType.Text, commandText, commandParameters) : 0;
199+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteNonQuery(ConnectionString, CommandType.Text, commandText, commandParameters) : 0;
221200
}
222201

223202

224203
protected int ExecuteNonQuery(string commandText)
225204
{
226-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteNonQuery(ConnectionString, CommandType.Text, commandText) : 0;
205+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteNonQuery(ConnectionString, CommandType.Text, commandText) : 0;
227206
}
228207

229208
protected int ExecuteNonQueryAndReturnId(IDbTransaction trans, string commandText, params IDataParameter[] commandParameters)
230209
{
231210
if (string.IsNullOrEmpty(commandText)) return 0;
232211

233212
var id = 0;
234-
Helper.ExecuteNonQuery(trans, CommandType.Text, commandText, commandParameters);
213+
WebConfigUtils.Helper.ExecuteNonQuery(trans, CommandType.Text, commandText, commandParameters);
235214

236215
using (var rdr = ExecuteReader(trans, "SELECT @@IDENTITY AS 'ID'"))
237216
{
@@ -259,37 +238,37 @@ protected int ExecuteNonQueryAndReturnId(IDbTransaction trans, string commandTex
259238

260239
protected object ExecuteScalar(IDbConnection conn, string commandText, params IDataParameter[] commandParameters)
261240
{
262-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteScalar(conn, CommandType.Text, commandText, commandParameters) : null;
241+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteScalar(conn, CommandType.Text, commandText, commandParameters) : null;
263242
}
264243

265244

266245
protected object ExecuteScalar(IDbConnection conn, string commandText)
267246
{
268-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteScalar(conn, CommandType.Text, commandText) : null;
247+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteScalar(conn, CommandType.Text, commandText) : null;
269248
}
270249

271250

272251
protected object ExecuteScalar(IDbTransaction trans, string commandText, params IDataParameter[] commandParameters)
273252
{
274-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteScalar(trans, CommandType.Text, commandText, commandParameters) : null;
253+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteScalar(trans, CommandType.Text, commandText, commandParameters) : null;
275254
}
276255

277256

278257
protected object ExecuteScalar(IDbTransaction trans, string commandText)
279258
{
280-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteScalar(trans, CommandType.Text, commandText) : null;
259+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteScalar(trans, CommandType.Text, commandText) : null;
281260
}
282261

283262

284263
protected object ExecuteScalar(string commandText, params IDataParameter[] commandParameters)
285264
{
286-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteScalar(ConnectionString, CommandType.Text, commandText, commandParameters) : null;
265+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteScalar(ConnectionString, CommandType.Text, commandText, commandParameters) : null;
287266
}
288267

289268

290269
protected object ExecuteScalar(string commandText)
291270
{
292-
return !string.IsNullOrEmpty(commandText) ? Helper.ExecuteScalar(ConnectionString, CommandType.Text, commandText) : null;
271+
return !string.IsNullOrEmpty(commandText) ? WebConfigUtils.Helper.ExecuteScalar(ConnectionString, CommandType.Text, commandText) : null;
293272
}
294273

295274
protected string GetString(IDataReader rdr, int i)

source/BaiRong.Core/Provider/DatabaseDao.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,9 @@ public string GetPageSqlString(string sqlString, string orderByString, int recor
512512
}
513513
}
514514

515-
public void Install(bool isMySql, StringBuilder errorBuilder)
515+
public void Install(StringBuilder errorBuilder)
516516
{
517-
var sqlPath = PathUtils.GetInstallSqlFilePath(isMySql);
517+
var sqlPath = PathUtils.GetInstallSqlFilePath(WebConfigUtils.IsMySql);
518518
BaiRongDataProvider.DatabaseDao.ExecuteSqlInFile(sqlPath, errorBuilder);
519519
BaiRongDataProvider.TableCollectionDao.CreateAllAuxiliaryTableIfNotExists();
520520
}

source/BaiRong.Core/WebConfigUtils.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.Web;
33
using System.Xml;
4+
using BaiRong.Core.Data;
5+
using BaiRong.Core.Data.Helper;
46

57
namespace BaiRong.Core
68
{
@@ -15,6 +17,25 @@ public class WebConfigUtils
1517
public static bool IsMySql { get; private set; }
1618
public static string ConnectionString { get; private set; }
1719

20+
private static AdoHelper _helper;
21+
public static AdoHelper Helper
22+
{
23+
get
24+
{
25+
if (_helper != null) return _helper;
26+
27+
if (IsMySql)
28+
{
29+
_helper = new Data.MySql();
30+
}
31+
else
32+
{
33+
_helper = new SqlServer();
34+
}
35+
return _helper;
36+
}
37+
}
38+
1839
static WebConfigUtils()
1940
{
2041
string physicalApplicationPath;
@@ -102,10 +123,11 @@ static WebConfigUtils()
102123
ConnectionString = connectionString;
103124
}
104125

105-
public void UpdateWebConfig(string configFilePath, bool isProtectData, bool isMySql, string connectionString)
126+
public static void UpdateWebConfig(bool isProtectData, bool isMySql, string connectionString)
106127
{
107-
var doc = new XmlDocument();
128+
var configFilePath = PathUtils.MapPath("~/web.config");
108129

130+
var doc = new XmlDocument();
109131
doc.Load(configFilePath);
110132
var dirty = false;
111133
var appSettings = doc.SelectSingleNode("configuration/appSettings");
@@ -171,6 +193,7 @@ public void UpdateWebConfig(string configFilePath, bool isProtectData, bool isMy
171193

172194
IsMySql = isMySql;
173195
ConnectionString = connectionString;
196+
_helper = null;
174197
}
175198
}
176199
}

source/SiteServer.BackgroundPages/PageInstaller.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ protected void btnStep3_Click(object sender, EventArgs e)
221221
else
222222
{
223223
var connectionStringWithoutDatabaseName = GetConnectionString(false);
224-
var isMySql = DdlSqlDatabaseType.SelectedValue == "MySql";
224+
var isMySql = StringUtils.EqualsIgnoreCase(DdlSqlDatabaseType.SelectedValue, "MySql");
225225
isConnectValid = BaiRongDataProvider.DatabaseDao.ConnectToServer(isMySql, connectionStringWithoutDatabaseName, out databaseNameList, out errorMessage);
226226
}
227227

@@ -347,9 +347,8 @@ private bool InstallDatabase(out string errorMessage)
347347

348348
try
349349
{
350-
var isMySql = DdlSqlDatabaseType.SelectedValue == "MySql";
351350
var errorBuilder = new StringBuilder();
352-
BaiRongDataProvider.DatabaseDao.Install(isMySql, errorBuilder);
351+
BaiRongDataProvider.DatabaseDao.Install(errorBuilder);
353352

354353
BaiRongDataProvider.ConfigDao.InitializeConfig();
355354
BaiRongDataProvider.ConfigDao.InitializeUserRole(TbAdminName.Text, TbAdminPassword.Text);
@@ -375,13 +374,8 @@ private bool UpdateWebConfig(out string errorMessage)
375374
var isMySql = StringUtils.EqualsIgnoreCase(DdlSqlDatabaseType.SelectedValue, "MySql");
376375
var connectionString = GetConnectionString(true);
377376

378-
var configFilePath = PathUtils.MapPath("~/web.config");
379-
if (FileUtils.IsFileExists(configFilePath))
380-
{
381-
var webConfigUtils = new WebConfigUtils();
382-
webConfigUtils.UpdateWebConfig(configFilePath, isProtectData, isMySql, connectionString);
383-
}
384-
377+
WebConfigUtils.UpdateWebConfig(isProtectData, isMySql, connectionString);
378+
385379
returnValue = true;
386380
}
387381
catch (Exception e)

source/SiteServer.Web/Web.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<!--<add key="DatabaseType" value="SqlServer" />
55
<add key="ConnectionString" value="server=localhost;uid=root;pwd=root;database=test2" />-->
66
<add key="IsProtectData" value="False" />
7-
<add key="DatabaseType" value="MySql" />
8-
<add key="ConnectionString" value="server=localhost;uid=root;pwd=root;database=test2" />
7+
<add key="DatabaseType" value="SqlServer" />
8+
<add key="ConnectionString" value="server=localhost;uid=root;pwd=root;database=test2" />
99
</appSettings>
1010
<system.web>
1111
<httpRuntime requestValidationMode="2.0" requestPathInvalidCharacters="" maxRequestLength="40960" executionTimeout="2000" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" enableVersionHeader="false" />

0 commit comments

Comments
 (0)