Skip to content

Commit

Permalink
dao
Browse files Browse the repository at this point in the history
  • Loading branch information
starlying committed Mar 31, 2019
1 parent a7ed3e3 commit fb8ffba
Show file tree
Hide file tree
Showing 24 changed files with 391 additions and 237 deletions.
8 changes: 5 additions & 3 deletions SiteServer.BackgroundPages/Cms/PageTemplateReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void Page_Load(object sender, EventArgs e)
</a>
</td>
<td>{stlAttribute.Title}</td>
<td><a href=""https://docs.siteserver.cn/stl#/{tagName}/"" target=""_blank"" class=""{(elementName == _elementName ? "text-white" : string.Empty)}"">https://docs.siteserver.cn/stl#/{tagName}/</a></td>
<td><a href=""https://www.siteserver.cn/docs/stl/{tagName}/"" target=""_blank"" class=""{(elementName == _elementName ? "text-white" : string.Empty)}"">https://www.siteserver.cn/docs/stl/{tagName}/</a></td>
</tr>");
}

Expand Down Expand Up @@ -96,16 +96,18 @@ public void Page_Load(object sender, EventArgs e)

if (attr != null)
{
var attrUrl =
$"https://www.siteserver.cn/docs/stl/{tagName}/#{fieldName.ToLower()}-{attr.Title.ToLower()}";
attrBuilder.Append($@"
<tr>
<td>{fieldName}</td>
<td>{attr.Title}</td>
<td><a href=""https://docs.siteserver.cn/stl#/{tagName}/attributes?id={fieldName}"" target=""_blank"">https://docs.siteserver.cn/stl#/{tagName}/attributes?id={fieldName}</a></td>
<td><a href=""{attrUrl}"" target=""_blank"">{attrUrl}</a></td>
</tr>");
}
}

var helpUrl = $"https://docs.siteserver.cn/stl#/{tagName}/";
var helpUrl = $"https://www.siteserver.cn/docs/stl/{tagName}/";

var stlAttribute = (StlElementAttribute)Attribute.GetCustomAttribute(elementType, typeof(StlElementAttribute));

Expand Down
2 changes: 2 additions & 0 deletions SiteServer.CMS/Core/DirectoryUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public static void ChangeSiteDir(string parentPsPath, string oldPsDir, string ne

public static void DeleteSiteFiles(SiteInfo siteInfo)
{
if (siteInfo == null) return;

var sitePath = PathUtility.GetSitePath(siteInfo);

if (siteInfo.IsRoot)
Expand Down
10 changes: 4 additions & 6 deletions SiteServer.CMS/Core/InputParserUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,9 @@ public static string GetVideoHtml(SiteInfo siteInfo, string videoUrl, NameValueC

public static string GetFileHtmlWithCount(SiteInfo siteInfo, int channelId, int contentId, string fileUrl, NameValueCollection attributes, string innerHtml, bool isStlEntity, bool isLower, bool isUpper)
{
var retVal = string.Empty;
if (siteInfo == null) return retVal;
if (string.IsNullOrEmpty(fileUrl)) return retVal;
if (siteInfo == null || string.IsNullOrEmpty(fileUrl)) return string.Empty;

string retVal;
if (isStlEntity)
{
retVal = ApiRouteActionsDownload.GetUrl(ApiManager.ApiUrl, siteInfo.Id, channelId, contentId,
Expand Down Expand Up @@ -356,10 +355,9 @@ public static string GetFileHtmlWithCount(SiteInfo siteInfo, int channelId, int

public static string GetFileHtmlWithoutCount(SiteInfo siteInfo, string fileUrl, NameValueCollection attributes, string innerHtml, bool isStlEntity, bool isLower, bool isUpper)
{
var retVal = string.Empty;
if (siteInfo == null) return retVal;
if (string.IsNullOrEmpty(fileUrl)) return retVal;
if (siteInfo == null || string.IsNullOrEmpty(fileUrl)) return string.Empty;

string retVal;
if (isStlEntity)
{
retVal = ApiRouteActionsDownload.GetUrl(ApiManager.ApiUrl, siteInfo.Id, fileUrl);
Expand Down
5 changes: 3 additions & 2 deletions SiteServer.CMS/Plugin/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ public static SortedList<string, PluginInstance> GetPluginSortedList()

public static void LoadPlugins(string applicationPhysicalPath)
{
WebConfigUtils.Load(applicationPhysicalPath);
_pluginInfoListRunnable = PluginInfoListRunnable;
WebConfigUtils.Load(applicationPhysicalPath, PathUtils.Combine(applicationPhysicalPath, WebConfigUtils.WebConfigFileName));

Context.Initialize(new EnvironmentImpl(WebConfigUtils.DatabaseType, WebConfigUtils.ConnectionString, WebConfigUtils.AdminDirectory, WebConfigUtils.PhysicalApplicationPath), new ApiCollectionImpl
{
Expand All @@ -200,6 +199,8 @@ public static void LoadPlugins(string applicationPhysicalPath)
UserApi = UserApi.Instance,
UtilsApi = UtilsApi.Instance
});

_pluginInfoListRunnable = PluginInfoListRunnable;
}

public static void ClearCache()
Expand Down
3 changes: 1 addition & 2 deletions SiteServer.CMS/Provider/AdministratorDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ public class AdministratorDao : DataProviderBase
new TableColumn
{
AttributeName = nameof(AdministratorInfoDatabase.SiteIdCollection),
DataType = DataType.VarChar,
DataLength = 50
DataType = DataType.Text
},
new TableColumn
{
Expand Down
58 changes: 47 additions & 11 deletions SiteServer.CMS/Provider/DatabaseDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -655,19 +655,43 @@ public void AlterPluginTable(string pluginId, string tableName, List<TableColumn
var columnNameList = TableColumnManager.GetTableColumnNameList(tableName);
foreach (var tableColumn in tableColumns)
{
if (StringUtils.ContainsIgnoreCase(columnNameList, tableColumn.AttributeName)) continue;

var columnSqlString = SqlUtils.GetColumnSqlString(tableColumn);
var sqlString = SqlUtils.GetAddColumnsSqlString(tableName, columnSqlString);

try
if (StringUtils.ContainsIgnoreCase(columnNameList, tableColumn.AttributeName))
{
DataProvider.DatabaseDao.ExecuteSql(sqlString);
isAltered = true;
var databaseColumn = TableColumnManager.GetTableColumnInfo(tableName, tableColumn.AttributeName);
if (databaseColumn != null && !tableColumn.IsIdentity)
{
if (databaseColumn.DataType != tableColumn.DataType ||
(databaseColumn.DataType == DataType.VarChar && tableColumn.DataType == DataType.VarChar && databaseColumn.DataLength != tableColumn.DataLength))
{
var sqlString = SqlUtils.GetModifyColumnsSqlString(tableName, tableColumn.AttributeName,
SqlUtils.GetColumnTypeString(tableColumn));

try
{
DataProvider.DatabaseDao.ExecuteSql(sqlString);
isAltered = true;
}
catch (Exception ex)
{
LogUtils.AddErrorLog(pluginId, ex, sqlString);
}
}
}
}
catch (Exception ex)
else
{
LogUtils.AddErrorLog(pluginId, ex, sqlString);
var columnSqlString = SqlUtils.GetColumnSqlString(tableColumn);
var sqlString = SqlUtils.GetAddColumnsSqlString(tableName, columnSqlString);

try
{
DataProvider.DatabaseDao.ExecuteSql(sqlString);
isAltered = true;
}
catch (Exception ex)
{
LogUtils.AddErrorLog(pluginId, ex, sqlString);
}
}
}

Expand Down Expand Up @@ -831,7 +855,19 @@ public void AlterSystemTable(string tableName, List<TableColumn> tableColumns, L
var columnNameList = TableColumnManager.GetTableColumnNameList(tableName);
foreach (var tableColumn in tableColumns)
{
if (!StringUtils.ContainsIgnoreCase(columnNameList, tableColumn.AttributeName))
if (StringUtils.ContainsIgnoreCase(columnNameList, tableColumn.AttributeName))
{
var databaseColumn = TableColumnManager.GetTableColumnInfo(tableName, tableColumn.AttributeName);
if (databaseColumn != null && !tableColumn.IsIdentity)
{
if (tableColumn.DataType != databaseColumn.DataType ||
tableColumn.DataType == databaseColumn.DataType && tableColumn.DataLength > databaseColumn.DataLength)
{
list.Add(SqlUtils.GetModifyColumnsSqlString(tableName, tableColumn.AttributeName, SqlUtils.GetColumnTypeString(tableColumn)));
}
}
}
else
{
list.Add(SqlUtils.GetAddColumnsSqlString(tableName, SqlUtils.GetColumnSqlString(tableColumn)));
}
Expand Down
74 changes: 53 additions & 21 deletions SiteServer.CMS/StlParser/FileSystemObjectAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,46 +82,41 @@ private static async Task CreateChannelAsync(int siteId, int channelId)
var contentBuilder = new StringBuilder(TemplateManager.GetTemplateContent(siteInfo, templateInfo));

var stlLabelList = StlParserUtility.GetStlLabelList(contentBuilder.ToString());
var stlPageContentElement = string.Empty;
foreach (var label in stlLabelList)
{
if (!StlParserUtility.IsStlChannelElement(label, ChannelAttribute.PageContent)) continue;
stlPageContentElement = label;
break;
}

//如果标签中存在<stl:channel type="PageContent"></stl:channel>
if (!string.IsNullOrEmpty(stlPageContentElement)) //内容存在
if (StlParserUtility.IsStlChannelElementWithTypePageContent(stlLabelList)) //内容存在
{
var innerBuilder = new StringBuilder(stlPageContentElement);
var stlElement = StlParserUtility.GetStlChannelElementWithTypePageContent(stlLabelList);
var stlElementTranslated = StlParserManager.StlEncrypt(stlElement);
contentBuilder.Replace(stlElement, stlElementTranslated);

var innerBuilder = new StringBuilder(stlElement);
StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
var contentAttributeHtml = innerBuilder.ToString();
var pageCount =
StringUtils.GetCount(ContentUtility.PagePlaceHolder, contentAttributeHtml) + 1; //一共需要的页数
var pageContentHtml = innerBuilder.ToString();
var pageCount = StringUtils.GetCount(ContentUtility.PagePlaceHolder, pageContentHtml) + 1; //一共需要的页数

pageInfo.AddPageBodyCodeIfNotExists(PageInfo.Const.Jquery);
Parser.Parse(pageInfo, contextInfo, contentBuilder, filePath, false);

for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
{
var thePageInfo = pageInfo.Clone();
var index = contentAttributeHtml.IndexOf(ContentUtility.PagePlaceHolder, StringComparison.Ordinal);
var length = index == -1 ? contentAttributeHtml.Length : index;
var pagedContentAttributeHtml = contentAttributeHtml.Substring(0, length);
var pagedBuilder = new StringBuilder(contentBuilder.ToString()
.Replace(stlPageContentElement, pagedContentAttributeHtml));

var index = pageContentHtml.IndexOf(ContentUtility.PagePlaceHolder, StringComparison.Ordinal);
var length = index == -1 ? pageContentHtml.Length : index;

var pageHtml = pageContentHtml.Substring(0, length);
var pagedBuilder =
new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml));
StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList,
thePageInfo.PageChannelId, currentPageIndex, pageCount, 0);

filePath = PathUtility.GetChannelPageFilePath(siteInfo, thePageInfo.PageChannelId,
currentPageIndex);

await GenerateFileAsync(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder);

if (index != -1)
{
contentAttributeHtml =
contentAttributeHtml.Substring(length + ContentUtility.PagePlaceHolder.Length);
pageContentHtml = pageContentHtml.Substring(length + ContentUtility.PagePlaceHolder.Length);
}
}
}
Expand Down Expand Up @@ -293,6 +288,43 @@ private static async Task CreateContentAsync(SiteInfo siteInfo, ChannelInfo chan
}
}
}
//如果标签中存在<stl:channel type="PageContent"></stl:channel>
else if (StlParserUtility.IsStlChannelElementWithTypePageContent(stlLabelList)) //内容存在
{
var stlElement = StlParserUtility.GetStlChannelElementWithTypePageContent(stlLabelList);
var stlElementTranslated = StlParserManager.StlEncrypt(stlElement);
contentBuilder.Replace(stlElement, stlElementTranslated);

var innerBuilder = new StringBuilder(stlElement);
StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo);
var pageContentHtml = innerBuilder.ToString();
var pageCount = StringUtils.GetCount(ContentUtility.PagePlaceHolder, pageContentHtml) + 1; //一共需要的页数

Parser.Parse(pageInfo, contextInfo, contentBuilder, filePath, false);

for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
{
var thePageInfo = pageInfo.Clone();

var index = pageContentHtml.IndexOf(ContentUtility.PagePlaceHolder, StringComparison.Ordinal);
var length = index == -1 ? pageContentHtml.Length : index;

var pageHtml = pageContentHtml.Substring(0, length);
var pagedBuilder =
new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml));
StlParserManager.ReplacePageElementsInContentPage(pagedBuilder, thePageInfo, stlLabelList,
channelInfo.Id, contentId, currentPageIndex, pageCount);

filePath = PathUtility.GetContentPageFilePath(siteInfo, thePageInfo.PageChannelId, contentInfo,
currentPageIndex);
await GenerateFileAsync(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder);

if (index != -1)
{
pageContentHtml = pageContentHtml.Substring(length + ContentUtility.PagePlaceHolder.Length);
}
}
}
//如果标签中存在<stl:pageContents>
else if (StlParserUtility.IsStlElementExists(StlPageContents.ElementName, stlLabelList))
{
Expand Down
39 changes: 20 additions & 19 deletions SiteServer.CMS/StlParser/Model/StlListBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ public class StlListBase
[StlAttribute(Title = "从首页向下的栏目级别")]
public const string TopLevel = nameof(TopLevel);

[StlAttribute(Title = "内容范围")]
[StlAttribute(Title = "范围")]
public const string Scope = nameof(Scope);

[StlAttribute(Title = "指定显示的栏目组")]
[StlAttribute(Title = "指定栏目组")]
public const string GroupChannel = nameof(GroupChannel);

[StlAttribute(Title = "指定不显示的栏目组")]
[StlAttribute(Title = "排除栏目组")]
public const string GroupChannelNot = nameof(GroupChannelNot);

[StlAttribute(Title = "指定显示的内容组")]
[StlAttribute(Title = "指定内容组")]
public const string GroupContent = nameof(GroupContent);

[StlAttribute(Title = "指定不显示的内容组")]
[StlAttribute(Title = "排除内容组")]
public const string GroupContentNot = nameof(GroupContentNot);

[StlAttribute(Title = "指定标签")]
Expand All @@ -47,13 +47,14 @@ public class StlListBase
[StlAttribute(Title = "仅显示醒目内容")]
public const string IsColor = nameof(IsColor);

[StlAttribute(Title = "显示内容数目")]
[StlAttribute(Title = "显示信息总数")]
public const string TotalNum = nameof(TotalNum);

[StlAttribute(Title = "从第几条信息开始显示")]
public const string StartNum = nameof(StartNum);

[StlAttribute(Title = "排序")] public const string Order = nameof(Order);
[StlAttribute(Title = "排序")]
public const string Order = nameof(Order);

[StlAttribute(Title = "仅显示图片内容")]
public const string IsImage = nameof(IsImage);
Expand All @@ -67,40 +68,40 @@ public class StlListBase
[StlAttribute(Title = "显示相关内容列表")]
public const string IsRelatedContents = nameof(IsRelatedContents);

[StlAttribute(Title = "获取内容列表的条件判断")]
[StlAttribute(Title = "条件判断")]
public const string Where = nameof(Where);

[StlAttribute(Title = "布局")]
public const string Layout = nameof(Layout);

[StlAttribute(Title = "列数")]
public const string Columns = nameof(Columns);

[StlAttribute(Title = "方向")]
public const string Direction = nameof(Direction);

[StlAttribute(Title = "指定列表布局方式")]
public const string Height = nameof(Height);

[StlAttribute(Title = "整体高度")]
public const string Width = nameof(Width);
public const string Height = nameof(Height);

[StlAttribute(Title = "整体宽度")]
public const string Align = nameof(Align);
public const string Width = nameof(Width);

[StlAttribute(Title = "整体对齐")]
public const string ItemHeight = nameof(ItemHeight);
public const string Align = nameof(Align);

[StlAttribute(Title = "项高度")]
public const string ItemWidth = nameof(ItemWidth);
public const string ItemHeight = nameof(ItemHeight);

[StlAttribute(Title = "项宽度")]
public const string ItemAlign = nameof(ItemAlign);
public const string ItemWidth = nameof(ItemWidth);

[StlAttribute(Title = "项水平对齐")]
public const string ItemVerticalAlign = nameof(ItemVerticalAlign);
public const string ItemAlign = nameof(ItemAlign);

[StlAttribute(Title = "项垂直对齐")]
public const string ItemClass = nameof(ItemClass);
public const string ItemVerticalAlign = nameof(ItemVerticalAlign);

[StlAttribute(Title = "项Css类")]
public const string Layout = nameof(Layout);
public const string ItemClass = nameof(ItemClass);
}
}
Loading

0 comments on commit fb8ffba

Please sign in to comment.