forked from siteserver/cms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskCreate.cs
More file actions
79 lines (71 loc) · 3.49 KB
/
TaskCreate.cs
File metadata and controls
79 lines (71 loc) · 3.49 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System.Collections.Generic;
using BaiRong.Core;
using SiteServer.CMS.Core;
using SiteServer.CMS.Core.Create;
using SiteServer.CMS.Model;
using SiteServer.CMS.Model.Enumerations;
namespace siteserver
{
public class TaskCreate
{
public static bool Execute(TaskInfo taskInfo)
{
var taskCreateInfo = new TaskCreateInfo(taskInfo.ServiceParameters);
if (string.IsNullOrEmpty(taskCreateInfo.CreateTypes)) return true;
var guid = StringUtils.GetShortGuid();
var createTypeArrayList = TranslateUtils.StringCollectionToStringList(taskCreateInfo.CreateTypes);
var createChannel = createTypeArrayList.Contains(ECreateTypeUtils.GetValue(ECreateType.Channel));
var createContent = createTypeArrayList.Contains(ECreateTypeUtils.GetValue(ECreateType.Content));
var createFile = createTypeArrayList.Contains(ECreateTypeUtils.GetValue(ECreateType.File));
if (taskInfo.PublishmentSystemID != 0)
{
var nodeIdList = taskCreateInfo.IsCreateAll ? DataProvider.NodeDao.GetNodeIdListByPublishmentSystemId(taskInfo.PublishmentSystemID) : TranslateUtils.StringCollectionToIntList(taskCreateInfo.ChannelIDCollection);
Create(createChannel, createContent, createFile, taskInfo, taskInfo.PublishmentSystemID, nodeIdList, guid);
}
else
{
var publishmentSystemIdList = taskCreateInfo.IsCreateAll ? PublishmentSystemManager.GetPublishmentSystemIdList() : TranslateUtils.StringCollectionToIntList(taskCreateInfo.ChannelIDCollection);
foreach (var publishmentSystemId in publishmentSystemIdList)
{
var nodeIdList = DataProvider.NodeDao.GetNodeIdListByPublishmentSystemId(publishmentSystemId);
Create(createChannel, createContent, createFile, taskInfo, publishmentSystemId, nodeIdList, guid);
}
}
return true;
}
private static void Create(bool createChannel, bool createContent, bool createFile, TaskInfo taskInfo, int publishmentSystemId, List<int> nodeIdList, string guid)
{
var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(publishmentSystemId);
if (publishmentSystemInfo == null) return;
if (nodeIdList != null && nodeIdList.Count > 0)
{
if (createChannel)
{
foreach (var nodeId in nodeIdList)
{
CreateManager.CreateChannel(publishmentSystemId, nodeId, guid);
}
}
if (createContent)
{
foreach (var nodeId in nodeIdList)
{
CreateManager.CreateAllContent(publishmentSystemId, nodeId, guid);
}
}
}
if (createFile)
{
var templateIdList = DataProvider.TemplateDao.GetTemplateIdListByType(publishmentSystemId, ETemplateType.FileTemplate);
foreach (var templateId in templateIdList)
{
CreateManager.CreateFile(publishmentSystemId, templateId, guid);
}
}
if (taskInfo.ServiceType == EServiceType.Create && taskInfo.FrequencyType == EFrequencyType.OnlyOnce)
{
DataProvider.TaskDao.Delete(taskInfo.TaskID);
}
}
}
}