Skip to content

Commit

Permalink
ekun008
Browse files Browse the repository at this point in the history
  • Loading branch information
siteserverekun committed Jun 15, 2017
1 parent e5c639b commit 879aebf
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 16 deletions.
39 changes: 39 additions & 0 deletions source/SiteServer.CMS/Core/Create/CreateTaskManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public interface ICreateTaskManager

CreateTaskInfo GetLastPendingTask();

List<CreateTaskInfo> GetLastPendingTasks(int topNum);

void RemovePendingAndAddSuccessLog(CreateTaskInfo taskInfo, string timeSpan);

void RemovePendingAndAddFailureLog(CreateTaskInfo taskInfo, Exception ex);
Expand Down Expand Up @@ -119,6 +121,38 @@ public CreateTaskInfo GetLastPendingTask()
return null;
}

public List<CreateTaskInfo> GetLastPendingTasks(int topNum)
{
List<CreateTaskInfo> list = null;

foreach (var entry in PendingTaskDict)
{
var pendingTasks = entry.Value;
if (pendingTasks.Count > 0)
{
list = new List<CreateTaskInfo>();
if (pendingTasks.Count >= topNum)
{
while (topNum > 0)
{
list.Add(pendingTasks[pendingTasks.Count - topNum]);
topNum--;
}
}
else
{
foreach (var taskInfo in pendingTasks)
{
list.Add(taskInfo);
}
}

return list;
}
}
return list;
}

public void RemovePendingAndAddSuccessLog(CreateTaskInfo taskInfo, string timeSpan)
{
var pendingTasks = GetPendingTasks(taskInfo.PublishmentSystemID);
Expand Down Expand Up @@ -230,6 +264,11 @@ public CreateTaskInfo GetLastPendingTask()
return DataProvider.CreateTaskDao.GetLastPendingTask();
}

public List<CreateTaskInfo> GetLastPendingTasks(int topNum)
{
return DataProvider.CreateTaskDao.GetLastPendingTasks(topNum);
}

public void RemovePendingAndAddSuccessLog(CreateTaskInfo taskInfo, string timeSpan)
{
DataProvider.CreateTaskDao.Delete(taskInfo.ID);
Expand Down
24 changes: 24 additions & 0 deletions source/SiteServer.CMS/Provider/CreateTaskDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,30 @@ public CreateTaskInfo GetLastPendingTask()
return info;
}

/// <summary>
/// Ò»´Î»ñÈ¡¶à¸öÈÎÎñ
/// </summary>
/// <param name="topNum"></param>
/// <returns></returns>
public List<CreateTaskInfo> GetLastPendingTasks(int topNum)
{
List<CreateTaskInfo> list = null;

var sqlString = SqlUtils.GetTopSqlString("siteserver_CreateTask", "ID, CreateType, PublishmentSystemID, ChannelID, ContentID, TemplateID", "ORDER BY ID", topNum);

using (var rdr = ExecuteReader(sqlString))
{
while (rdr.Read())
{
var i = 0;
var info = new CreateTaskInfo(GetInt(rdr, i++), ECreateTypeUtils.GetEnumType(GetString(rdr, i++)), GetInt(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i++), GetInt(rdr, i));
list.Add(info);
}
rdr.Close();
}
return list;
}

public bool IsPendingTask()
{
var retval = false;
Expand Down
80 changes: 67 additions & 13 deletions source/SiteServer.CMS/StlParser/FileSystemObject.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using BaiRong.Core;
using BaiRong.Core.Model.Attributes;
Expand Down Expand Up @@ -171,22 +173,34 @@ public void CreateChannel(int nodeId)

StlUtility.ParseStl(PublishmentSystemInfo, pageInfo, contextInfo, contentBuilder, filePath, false);

for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
{
var thePageInfo = new PageInfo(pageInfo.PageNodeId, pageInfo.PageContentId, pageInfo.PublishmentSystemInfo, pageInfo.TemplateInfo, null);
var pageHtml = pageContentsElementParser.Parse(totalNum, currentPageIndex, pageCount, true);
var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml));
//for (var currentPageIndex = 0; currentPageIndex < pageCount; currentPageIndex++)
//{
// var thePageInfo = new PageInfo(pageInfo.PageNodeId, pageInfo.PageContentId, pageInfo.PublishmentSystemInfo, pageInfo.TemplateInfo, null);
// var pageHtml = pageContentsElementParser.Parse(totalNum, currentPageIndex, pageCount, true);
// var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml));

StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageNodeId, currentPageIndex, pageCount, totalNum);
// StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageNodeId, currentPageIndex, pageCount, totalNum);

filePath = PathUtility.GetChannelPageFilePath(PublishmentSystemInfo, thePageInfo.PageNodeId, currentPageIndex);
thePageInfo.AddLastPageScript(pageInfo);
// filePath = PathUtility.GetChannelPageFilePath(PublishmentSystemInfo, thePageInfo.PageNodeId, currentPageIndex);
// thePageInfo.AddLastPageScript(pageInfo);

GenerateFile(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder);
// GenerateFile(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder);

// thePageInfo.ClearLastPageScript(pageInfo);
// pageInfo.ClearLastPageScript();
//}

thePageInfo.ClearLastPageScript(pageInfo);
pageInfo.ClearLastPageScript();
for (int i = 1; i <= pageCount; i = i + 3)
{
var list = new List<int>();
list.Add(i);
if (i <= pageCount - 1)
list.Add(i + 1);
if (i <= pageCount - 2)
list.Add(i + 2);
Parallel.ForEach(list, currentPageIndex => PageContentsDetail(filePath, pageInfo, stlLabelList, pageContentsElementParser, contentBuilder, stlElementTranslated, totalNum, pageCount, currentPageIndex));
}

}
//如果标签中存在<stl:pageChannels>
else if (StlParserUtility.IsStlElementExists(StlPageChannels.ElementName, stlLabelList))
Expand Down Expand Up @@ -267,16 +281,56 @@ public void CreateChannel(int nodeId)
}
}

/// <summary>
/// 处理栏目列表页分页标签PageContents
/// </summary>
/// <param name="filePath"></param>
/// <param name="pageInfo"></param>
/// <param name="stlLabelList"></param>
/// <param name="pageContentsElementParser"></param>
/// <param name="contentBuilder"></param>
/// <param name="stlElementTranslated"></param>
/// <param name="totalNum"></param>
/// <param name="pageCount"></param>
private void PageContentsDetail(string filePath, PageInfo pageInfo,List<string> stlLabelList, StlPageContents pageContentsElementParser, StringBuilder contentBuilder, string stlElementTranslated,int totalNum,int pageCount, int currentPageIndex)
{
var thePageInfo = new PageInfo(pageInfo.PageNodeId, pageInfo.PageContentId, pageInfo.PublishmentSystemInfo, pageInfo.TemplateInfo, null);
var pageHtml = pageContentsElementParser.Parse(totalNum, currentPageIndex, pageCount, true);
var pagedBuilder = new StringBuilder(contentBuilder.ToString().Replace(stlElementTranslated, pageHtml));

StlParserManager.ReplacePageElementsInChannelPage(pagedBuilder, thePageInfo, stlLabelList, thePageInfo.PageNodeId, currentPageIndex, pageCount, totalNum);

filePath = PathUtility.GetChannelPageFilePath(PublishmentSystemInfo, thePageInfo.PageNodeId, currentPageIndex);
thePageInfo.AddLastPageScript(pageInfo);

GenerateFile(filePath, pageInfo.TemplateInfo.Charset, pagedBuilder);

thePageInfo.ClearLastPageScript(pageInfo);
pageInfo.ClearLastPageScript();
}

public void CreateContents(int nodeId)
{
var nodeInfo = NodeManager.GetNodeInfo(PublishmentSystemId, nodeId);
var tableStyle = NodeManager.GetTableStyle(PublishmentSystemInfo, nodeInfo);
var tableName = NodeManager.GetTableName(PublishmentSystemInfo, nodeInfo);
var orderByString = ETaxisTypeUtils.GetContentOrderByString(ETaxisType.OrderByTaxisDesc);
var contentIdList = DataProvider.ContentDao.GetContentIdListChecked(tableName, nodeId, orderByString);
foreach (var contentId in contentIdList)

//foreach (var contentId in contentIdList)
//{
// CreateContent(tableStyle, tableName, nodeId, contentId);

//}
for (int i = 0; i < contentIdList.Count; i = i + 3)
{
CreateContent(tableStyle, tableName, nodeId, contentId);
var list = new List<int>();
list.Add(contentIdList[i]);
if (i < contentIdList.Count - 1)
list.Add(contentIdList[i + 1]);
if (i < contentIdList.Count - 2)
list.Add(contentIdList[i + 2]);
Parallel.ForEach(list, contentId => CreateContent(tableStyle, tableName, nodeId, contentId));
}
}

Expand Down
5 changes: 4 additions & 1 deletion source/SiteServer.Web/CreateHub.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using BaiRong.Core;
using SiteServer.CMS.Model;
using Microsoft.AspNet.SignalR;
using SiteServer.CMS.Core;
using SiteServer.CMS.Core.Create;
Expand Down Expand Up @@ -42,7 +45,7 @@ public void Execute()
Clients.Client(Context.ConnectionId).next(true);
}
}
}
}

public void GetTasks(int publishmentSystemId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,8 @@ CREATE CLUSTERED INDEX IX_siteserver_Comment_PSID ON siteserver_Comment(Publishm
GO

CREATE INDEX IX_siteserver_Comment_ContentID ON siteserver_Comment(ContentID)
GO

ALTER TABLE siteserver_PublishmentSystem ADD
PublishmentSystemType varchar(50) NULL
GO
2 changes: 1 addition & 1 deletion source/SiteServer.Web/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<add key="IsProtectData" value="False" />
<add key="DatabaseType" value="SqlServer" />
<add key="ConnectionString" value="server=(local);uid=sa;pwd=ekun008;database=cms5.0" />
<add key="ConnectionString" value="server=(local);uid=sa;pwd=ekun008;database=tmwcm" />
</appSettings>
<system.web>
<httpRuntime targetFramework="4.5" requestValidationMode="2.0" requestPathInvalidCharacters="" maxRequestLength="40960" executionTimeout="2000" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" enableVersionHeader="false" />
Expand Down
4 changes: 3 additions & 1 deletion source/siteserver/ExecutionManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using BaiRong.Core;
using SiteServer.CMS.Core;
using SiteServer.CMS.Core.Create;
Expand Down Expand Up @@ -47,7 +49,7 @@ public static bool ExecutePendingCreate()
}

return false;
}
}

public static bool ExecuteTask()
{
Expand Down

0 comments on commit 879aebf

Please sign in to comment.