forked from siteserver/cms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPagesMainController.cs
More file actions
62 lines (57 loc) · 1.93 KB
/
PagesMainController.cs
File metadata and controls
62 lines (57 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Threading.Tasks;
using System.Web.Http;
using SiteServer.CMS.Core.Create;
using SiteServer.CMS.Plugin.Impl;
using SiteServer.CMS.StlParser;
using SiteServer.Utils;
namespace SiteServer.API.Controllers.Pages
{
[RoutePrefix("pages/main")]
public class PagesMainController : ApiController
{
private const string Route = "";
[HttpGet, Route(Route)]
public async Task<IHttpActionResult> Get()
{
try
{
var request = new RequestImpl();
if (!request.IsAdminLoggin)
{
return Unauthorized();
}
var count = CreateTaskManager.PendingTaskCount;
var pendingTask = CreateTaskManager.GetFirstPendingTask();
if (pendingTask != null)
{
try
{
var start = DateTime.Now;
await FileSystemObjectAsync.ExecuteAsync(pendingTask.SiteId, pendingTask.CreateType,
pendingTask.ChannelId,
pendingTask.ContentId, pendingTask.FileTemplateId, pendingTask.SpecialId);
var timeSpan = DateUtils.GetRelatedDateTimeString(start);
CreateTaskManager.AddSuccessLog(pendingTask, timeSpan);
}
catch (Exception ex)
{
CreateTaskManager.AddFailureLog(pendingTask, ex);
}
finally
{
CreateTaskManager.RemovePendingTask(pendingTask);
}
}
return Ok(new
{
Value = count
});
}
catch (Exception ex)
{
return InternalServerError(ex);
}
}
}
}