📄 upgrade.cs
字号:
}
}
}
catch (SqlException)
{
this.dataBaseVersion = "99.99.99.99";
}
connection.Close();
connection.Dispose();
}
catch (SqlException)
{
this.dataBaseVersion = "9.9.9.9";
}
string str3 = WebConfigurationManager.AppSettings["Version"];
if (str3 == "0.9.8.0")
{
this.dataBaseVersion = "0.9.8.0";
}
string productVersion = ProductVersion;
if (string.Compare(this.dataBaseVersion, productVersion) >= 0)
{
base.Response.Redirect("~/");
}
}
private void RCToRelease()
{
base.Response.Write(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss:fff") + " - 更新RC版本数据<br/>");
base.Response.Flush();
string connectionString = WebConfigurationManager.ConnectionStrings["Connection String"].ConnectionString;
foreach (ModelInfo info in ModelManager.ContentModelList(ModelShowType.None))
{
bool flag = false;
bool flag2 = false;
bool flag3 = false;
int orderId = 0;
string str2 = "";
string str3 = "";
IList<FieldInfo> fieldListByModelId = ModelManager.GetFieldListByModelId(info.ModelId);
foreach (FieldInfo info2 in fieldListByModelId)
{
if ((info2.FieldLevel == 0) && (info2.Id == "defaultpicurl"))
{
flag2 = true;
}
if (((info2.FieldType == FieldType.ContentType) && (info2.Id == "content")) && (info2.Settings[2] == "DefaultPicUrl"))
{
flag = true;
flag3 = true;
str2 = "DefaultPicUrl";
str3 = "UploadFiles";
orderId = info2.OrderId;
}
if ((info2.FieldType == FieldType.PictureType) && (info2.Id == "softpicurl"))
{
flag = true;
str2 = "softpicurl";
str3 = "";
orderId = info2.OrderId;
}
if ((info2.FieldType == FieldType.MultiplePhotoType) && (info2.Id == "photourl"))
{
if ((DataConverter.CBool(info2.Settings[2]) && !string.IsNullOrEmpty(info2.Settings[3])) && (string.Compare(info2.Settings[3], "photothumb", true) == 0))
{
flag = true;
str2 = "photothumb";
str3 = "";
}
orderId = info2.OrderId;
}
if (info2.FieldType == FieldType.ContentType)
{
if ((info2.Settings.Count == 6) || (info2.Settings.Count == 11))
{
Collection<string> settings = new Collection<string>();
settings.Add(info2.Settings[0]);
settings.Add(info2.Settings[1]);
settings.Add("jpg|gif|jpeg|png|bmp");
settings.Add("swf|fla|wmv|mp3|rm|rmvb|avi");
settings.Add("txt|doc|rar|zip");
settings.Add("false");
settings.Add("false");
info2.CopyToSettings(settings);
}
try
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand command = new SqlCommand();
connection.Open();
command.Connection = connection;
command.CommandText = "SELECT * FROM [" + info.TableName + "]";
command.CommandType = CommandType.Text;
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
using (SqlConnection connection2 = new SqlConnection(connectionString))
{
connection2.Open();
SqlCommand command2 = connection2.CreateCommand();
command2.CommandText = "UPDATE [" + info.TableName + "] SET [" + info2.Id + "] = @Value WHERE ID=" + reader["ID"].ToString();
command2.Parameters.Add(new SqlParameter("@Value", DataSecurity.HtmlDecode(reader[info2.Id].ToString())));
command2.ExecuteNonQuery();
connection2.Close();
continue;
}
}
}
connection.Close();
}
continue;
}
catch
{
continue;
}
}
}
if (flag)
{
string str4 = "";
if (string.IsNullOrEmpty(str3))
{
base.Response.Write(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss:fff") + " - 正在复制" + info.TableName + "表" + str2 + "字段数据到PE_CommonModel表中<br/>");
base.Response.Flush();
str4 = "\r\nDECLARE @DefaultPicUrl nvarchar(255)\r\nDECLARE @GeneralID int\r\n--定义游标\r\nDECLARE cur_DefaultPicUrl CURSOR\r\nFor SELECT " + str2 + ",ID FROM " + info.TableName + "\r\nOpen cur_DefaultPicUrl\r\n --移动或提取列值\r\n Fetch From cur_DefaultPicUrl into @DefaultPicUrl,@GeneralID\r\n --利用循环处理游标中的列值\r\n While @@Fetch_Status=0\r\n Begin\r\n\t UPDATE PE_CommonModel SET DefaultPicUrl=@DefaultPicUrl WHERE GeneralID=@GeneralID\r\n Fetch From cur_DefaultPicUrl into @DefaultPicUrl,@GeneralID\r\n End\r\n--关闭/释放游标\r\nCLOSE cur_DefaultPicUrl\r\nDEALLOCATE cur_DefaultPicUrl\r\n";
}
else
{
base.Response.Write(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss:fff") + " - 正在复制" + info.TableName + "表" + str2 + "字段数据和" + str3 + "字段数据到PE_CommonModel表中<br/>");
base.Response.Flush();
str4 = "\r\nDECLARE @DefaultPicUrl nvarchar(255)\r\nDECLARE @UploadFiles nvarchar(4000)\r\nDECLARE @GeneralID int\r\n--定义游标\r\nDECLARE cur_DefaultPicUrl CURSOR\r\nFor SELECT " + str2 + "," + str3 + ",ID FROM " + info.TableName + "\r\nOpen cur_DefaultPicUrl\r\n --移动或提取列值\r\n Fetch From cur_DefaultPicUrl into @DefaultPicUrl,@UploadFiles,@GeneralID\r\n --利用循环处理游标中的列值\r\n While @@Fetch_Status=0\r\n Begin\r\n\t UPDATE PE_CommonModel SET DefaultPicUrl=@DefaultPicUrl,UploadFiles=@UploadFiles WHERE GeneralID=@GeneralID\r\n Fetch From cur_DefaultPicUrl into @DefaultPicUrl,@UploadFiles,@GeneralID\r\n End\r\n--关闭/释放游标\r\nCLOSE cur_DefaultPicUrl\r\nDEALLOCATE cur_DefaultPicUrl\r\n";
}
SqlConnection connection3 = new SqlConnection(connectionString);
SqlCommand command3 = new SqlCommand();
connection3.Open();
command3.Connection = connection3;
command3.CommandText = str4;
command3.ExecuteNonQuery();
connection3.Close();
connection3.Dispose();
try
{
if ((str2 == "DefaultPicUrl") && (str3 == "UploadFiles"))
{
string str5 = "/*\r\n此脚本由 Visual Studio 在 2008/2/27 上的 11:13 处创建。\r\n请在 SiteFactory RC版 上运行此脚本,使其与 SiteFactory正式版 相同。\r\n请在运行此脚本之前备份目标数据库。\r\n*/\r\nSET NUMERIC_ROUNDABORT OFF\r\nSET ANSI_PADDING ON\r\nSET ANSI_WARNINGS ON\r\nSET CONCAT_NULL_YIELDS_NULL ON\r\nSET ARITHABORT ON\r\nSET QUOTED_IDENTIFIER ON\r\nSET ANSI_NULLS ON\r\nIF EXISTS (SELECT * FROM tempdb..sysobjects WHERE id=OBJECT_ID('tempdb..#tmpErrors')) DROP TABLE #tmpErrors\r\nCREATE TABLE #tmpErrors (Error int)\r\nSET XACT_ABORT ON\r\nSET TRANSACTION ISOLATION LEVEL READ COMMITTED\r\nBEGIN TRANSACTION\r\nPRINT N'正在改变 [dbo].[" + info.TableName + "]'\r\nALTER TABLE [dbo].[" + info.TableName + "] DROP\r\nCOLUMN [DefaultPicUrl],\r\nCOLUMN [UploadFiles]\r\nIF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION\r\nIF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END\r\nIF EXISTS (SELECT * FROM #tmpErrors) ROLLBACK TRANSACTION\r\nIF @@TRANCOUNT>0 BEGIN\r\nPRINT '数据库更新成功。'\r\nCOMMIT TRANSACTION\r\nEND\r\nELSE PRINT '数据库更新失败。'\r\nDROP TABLE #tmpErrors\r\n";
SqlConnection connection4 = new SqlConnection(connectionString);
SqlCommand command4 = new SqlCommand();
connection4.Open();
command4.Connection = connection4;
command4.CommandText = str5;
command4.ExecuteNonQuery();
connection4.Close();
connection4.Dispose();
}
}
catch
{
}
}
if (!flag2)
{
FieldInfo item = new FieldInfo();
item.Id = "DefaultPicUrl";
item.FieldName = "DefaultPicUrl";
item.FieldLevel = 0;
item.FieldType = FieldType.PictureType;
item.FieldAlias = "首页图片";
item.OrderId = orderId;
Collection<string> collection2 = new Collection<string>();
collection2.Add("30");
collection2.Add("1024");
collection2.Add("jpg|gif|bmp");
collection2.Add("0");
collection2.Add("0");
collection2.Add("0");
if (flag3)
{
collection2.Add("False");
collection2.Add("True");
}
else
{
collection2.Add("True");
collection2.Add("False");
}
item.CopyToSettings(collection2);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -