forked from siteserver/cms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImportObject.cs
More file actions
666 lines (565 loc) · 27.9 KB
/
ImportObject.cs
File metadata and controls
666 lines (565 loc) · 27.9 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using Atom.Core;
using BaiRong.Core;
using BaiRong.Core.IO;
using BaiRong.Core.Model.Enumerations;
using SiteServer.CMS.Core;
using SiteServer.CMS.Core.Office;
using SiteServer.CMS.ImportExport.Components;
using SiteServer.CMS.Model;
using SiteServer.CMS.Model.Enumerations;
using SiteServer.CMS.StlParser;
namespace SiteServer.CMS.ImportExport
{
public class ImportObject
{
public FileSystemObject Fso;
public ImportObject(int publishmentSystemId)
{
Fso = new FileSystemObject(publishmentSystemId);
}
//获取保存辅助表名称对应集合数据库缓存键
private string GetTableNameNameValueCollectionDbCacheKey()
{
return "SiteServer.CMS.Core.ImportObject.TableNameNameValueCollection_" + Fso.PublishmentSystemId;
}
public NameValueCollection GetTableNameCache()
{
NameValueCollection nameValueCollection = null;
var cacheValue = DbCacheManager.GetValue(GetTableNameNameValueCollectionDbCacheKey());
if (!string.IsNullOrEmpty(cacheValue))
{
nameValueCollection = TranslateUtils.ToNameValueCollection(cacheValue);
}
return nameValueCollection;
}
public void SaveTableNameCache(NameValueCollection nameValueCollection)
{
if (nameValueCollection != null && nameValueCollection.Count > 0)
{
var cacheKey = GetTableNameNameValueCollectionDbCacheKey();
var cacheValue = TranslateUtils.NameValueCollectionToString(nameValueCollection);
DbCacheManager.RemoveAndInsert(cacheKey, cacheValue);
}
}
public void RemoveDbCache()
{
var cacheKey = GetTableNameNameValueCollectionDbCacheKey();
DbCacheManager.GetValueAndRemove(cacheKey);
}
public void ImportFiles(string siteTemplatePath, bool isOverride)
{
//if (this.FSO.IsHeadquarters)
//{
// string[] filePaths = DirectoryUtils.GetFilePaths(siteTemplatePath);
// foreach (string filePath in filePaths)
// {
// string fileName = PathUtils.GetFileName(filePath);
// if (!PathUtility.IsSystemFile(fileName))
// {
// string destFilePath = PathUtils.Combine(FSO.PublishmentSystemPath, fileName);
// FileUtils.MoveFile(filePath, destFilePath, isOverride);
// }
// }
// ArrayList publishmentSystemDirArrayList = DataProvider.PublishmentSystemDAO.GetLowerPublishmentSystemDirArrayListThatNotIsHeadquarters();
// string[] directoryPaths = DirectoryUtils.GetDirectoryPaths(siteTemplatePath);
// foreach (string subDirectoryPath in directoryPaths)
// {
// string directoryName = PathUtils.GetDirectoryName(subDirectoryPath);
// if (!PathUtility.IsSystemDirectory(directoryName) && !publishmentSystemDirArrayList.Contains(directoryName.ToLower()))
// {
// string destDirectoryPath = PathUtils.Combine(FSO.PublishmentSystemPath, directoryName);
// DirectoryUtils.MoveDirectory(subDirectoryPath, destDirectoryPath, isOverride);
// }
// }
//}
//else
//{
// DirectoryUtils.MoveDirectory(siteTemplatePath, FSO.PublishmentSystemPath, isOverride);
//}
//string siteTemplateMetadataPath = PathUtils.Combine(FSO.PublishmentSystemPath, DirectoryUtility.SiteTemplates.SiteTemplateMetadata);
//DirectoryUtils.DeleteDirectoryIfExists(siteTemplateMetadataPath);
DirectoryUtility.ImportPublishmentSystemFiles(Fso.PublishmentSystemInfo, siteTemplatePath, isOverride);
}
public void ImportSiteContent(string siteContentDirectoryPath, string filePath, bool isImportContents)
{
var siteContentIe = new SiteContentIe(Fso.PublishmentSystemInfo, siteContentDirectoryPath);
siteContentIe.ImportChannelsAndContents(filePath, isImportContents, false, 0);
}
/// <summary>
/// 从指定的地址导入网站模板至站点中
/// </summary>
public void ImportTemplates(string filePath, bool overwrite, string administratorName)
{
var templateIe = new TemplateIe(Fso.PublishmentSystemId, filePath);
templateIe.ImportTemplates(overwrite, administratorName);
}
/// <summary>
/// 从指定的地址导入网站菜单显示方式至站点中
/// </summary>
/// <param name="filePath">指定的导入地址</param>
/// <param name="overwrite">是否覆盖原有菜单显示方式</param>
public void ImportMenuDisplay(string filePath, bool overwrite)
{
var menuDisplayIe = new MenuDisplayIe(Fso.PublishmentSystemId, filePath);
menuDisplayIe.ImportMenuDisplay(overwrite);
}
public void ImportTagStyle(string filePath, bool overwrite)
{
var tagStyleIe = new TagStyleIe(Fso.PublishmentSystemId, filePath);
tagStyleIe.ImportTagStyle(overwrite);
}
/// <summary>
/// 从指定的地址导入固定广告至站点中
/// </summary>
/// <param name="filePath">指定的导入地址</param>
/// <param name="overwrite">是否覆盖原有固定广告</param>
public void ImportAd(string filePath, bool overwrite)
{
var adIe = new AdvIe(Fso.PublishmentSystemId, filePath);
adIe.ImportAd(overwrite);
}
/// <summary>
/// 从指定的地址导入搜索引擎站点中
/// </summary>
/// <param name="filePath">指定的导入地址</param>
/// <param name="overwrite">是否覆盖原有搜索引擎</param>
public void ImportSeo(string filePath, bool overwrite)
{
var seoIe = new SeoIe(Fso.PublishmentSystemId, filePath);
seoIe.ImportSeo(overwrite);
}
/// <summary>
/// 从指定的地址导入自定义模板语言站点中
/// </summary>
/// <param name="filePath">指定的导入地址</param>
/// <param name="overwrite">是否覆盖原有自定义模板语言</param>
public void ImportStlTag(string filePath, bool overwrite)
{
var stlTagIe = new StlTagIe(Fso.PublishmentSystemId, filePath);
stlTagIe.ImportStlTag(overwrite);
}
/// <summary>
/// 从指定的地址导入采集规则至站点中
/// </summary>
/// <param name="filePath">指定的导入地址</param>
/// <param name="overwrite">是否覆盖原有菜单显示方式</param>
public void ImportGatherRule(string filePath, bool overwrite)
{
var gatherRuleIe = new GatherRuleIe(Fso.PublishmentSystemId, filePath);
gatherRuleIe.ImportGatherRule(overwrite);
}
public void ImportInput(string inputDirectoryPath, bool overwrite)
{
if (DirectoryUtils.IsDirectoryExists(inputDirectoryPath))
{
var inputIe = new InputIe(Fso.PublishmentSystemId, inputDirectoryPath);
inputIe.ImportInput(overwrite);
}
}
public void ImportInputByZipFile(string zipFilePath, bool overwrite)
{
var directoryPath = PathUtils.GetTemporaryFilesPath("Input");
DirectoryUtils.DeleteDirectoryIfExists(directoryPath);
DirectoryUtils.CreateDirectoryIfNotExists(directoryPath);
ZipUtils.UnpackFiles(zipFilePath, directoryPath);
var inputIe = new InputIe(Fso.PublishmentSystemId, directoryPath);
inputIe.ImportInput(overwrite);
}
public void ImportRelatedFieldByZipFile(string zipFilePath, bool overwrite)
{
var directoryPath = PathUtils.GetTemporaryFilesPath("RelatedField");
DirectoryUtils.DeleteDirectoryIfExists(directoryPath);
DirectoryUtils.CreateDirectoryIfNotExists(directoryPath);
ZipUtils.UnpackFiles(zipFilePath, directoryPath);
var relatedFieldIe = new RelatedFieldIe(Fso.PublishmentSystemId, directoryPath);
relatedFieldIe.ImportRelatedField(overwrite);
}
public void ImportAuxiliaryTables(string tableDirectoryPath, bool isUseTables)
{
NameValueCollection nameValueCollection = null;
if (DirectoryUtils.IsDirectoryExists(tableDirectoryPath))
{
var tableIe = new AuxiliaryTableIe(tableDirectoryPath);
nameValueCollection = tableIe.ImportAuxiliaryTables(Fso.PublishmentSystemId, isUseTables);
}
SaveTableNameCache(nameValueCollection);
}
public void ImportTableStyles(string tableDirectoryPath)
{
if (DirectoryUtils.IsDirectoryExists(tableDirectoryPath))
{
var tableStyleIe = new TableStyleIe(tableDirectoryPath);
tableStyleIe.ImportTableStyles(Fso.PublishmentSystemId);
}
}
public static void ImportTableStyleByZipFile(ETableStyle tableStyle, string tableName, int nodeId, string zipFilePath)
{
var styleDirectoryPath = PathUtils.GetTemporaryFilesPath("TableStyle");
DirectoryUtils.DeleteDirectoryIfExists(styleDirectoryPath);
DirectoryUtils.CreateDirectoryIfNotExists(styleDirectoryPath);
ZipUtils.UnpackFiles(zipFilePath, styleDirectoryPath);
TableStyleIe.SingleImportTableStyle(tableStyle, tableName, styleDirectoryPath, nodeId);
}
public void ImportConfiguration(string configurationFilePath)
{
var configIe = new ConfigurationIe(Fso.PublishmentSystemId, configurationFilePath);
configIe.Import();
}
public void ImportChannelsAndContentsByZipFile(int parentId, string zipFilePath, bool isOverride)
{
var siteContentDirectoryPath = PathUtils.GetTemporaryFilesPath(EBackupTypeUtils.GetValue(EBackupType.ChannelsAndContents));
DirectoryUtils.DeleteDirectoryIfExists(siteContentDirectoryPath);
DirectoryUtils.CreateDirectoryIfNotExists(siteContentDirectoryPath);
ZipUtils.UnpackFiles(zipFilePath, siteContentDirectoryPath);
ImportChannelsAndContentsFromZip(parentId, siteContentDirectoryPath, isOverride);
DataProvider.NodeDao.UpdateContentNum(Fso.PublishmentSystemInfo);
string filePath = PathUtils.Combine(siteContentDirectoryPath, BackupUtility.UploadFolderName, BackupUtility.UploadFileName);
var UploadFolderPath = PathUtils.Combine(siteContentDirectoryPath, BackupUtility.UploadFolderName);
var UploadFilePath = PathUtils.Combine(UploadFolderPath, BackupUtility.UploadFileName);
if (!FileUtils.IsFileExists(UploadFilePath))
{
return;
}
var feed = AtomFeed.Load(FileUtils.GetFileStreamReadOnly(UploadFilePath));
if (feed != null)
{
AtomEntry entry = feed.Entries[0];
string imageUploadDirectoryPath = AtomUtility.GetDcElementContent(entry.AdditionalElements, "ImageUploadDirectoryName");
if(imageUploadDirectoryPath != null)
{
DirectoryUtils.MoveDirectory(PathUtils.Combine(siteContentDirectoryPath, imageUploadDirectoryPath), PathUtils.Combine(Fso.PublishmentSystemPath, Fso.PublishmentSystemInfo.Additional.ImageUploadDirectoryName), isOverride);
}
string videoUploadDirectoryPath = AtomUtility.GetDcElementContent(entry.AdditionalElements, "VideoUploadDirectoryName");
if (videoUploadDirectoryPath != null)
{
DirectoryUtils.MoveDirectory(PathUtils.Combine(siteContentDirectoryPath, videoUploadDirectoryPath), PathUtils.Combine(Fso.PublishmentSystemPath, Fso.PublishmentSystemInfo.Additional.VideoUploadDirectoryName), isOverride);
}
string fileUploadDirectoryPath = AtomUtility.GetDcElementContent(entry.AdditionalElements, "FileUploadDirectoryName");
if (fileUploadDirectoryPath != null)
{
DirectoryUtils.MoveDirectory(PathUtils.Combine(siteContentDirectoryPath, fileUploadDirectoryPath), PathUtils.Combine(Fso.PublishmentSystemPath, Fso.PublishmentSystemInfo.Additional.FileUploadDirectoryName), isOverride);
}
}
}
public void ImportChannelsAndContentsFromZip(int parentId, string siteContentDirectoryPath, bool isOverride)
{
var filePathArrayList = GetSiteContentFilePathArrayList(siteContentDirectoryPath);
var siteContentIe = new SiteContentIe(Fso.PublishmentSystemInfo, siteContentDirectoryPath);
Hashtable levelHashtable = null;
foreach (string filePath in filePathArrayList)
{
var firstIndex = filePath.LastIndexOf(PathUtils.SeparatorChar) + 1;
var lastIndex = filePath.LastIndexOf(".", StringComparison.Ordinal);
var orderString = filePath.Substring(firstIndex, lastIndex - firstIndex);
var level = StringUtils.GetCount("_", orderString);
if (levelHashtable == null)
{
levelHashtable = new Hashtable
{
[level] = parentId
};
}
var insertNodeId = siteContentIe.ImportChannelsAndContents(filePath, true, isOverride, (int)levelHashtable[level]);
levelHashtable[level + 1] = insertNodeId;
}
}
public void ImportChannelsAndContents(int parentId, string siteContentDirectoryPath, bool isOverride)
{
var filePathArrayList = GetSiteContentFilePathArrayList(siteContentDirectoryPath);
var siteContentIe = new SiteContentIe(Fso.PublishmentSystemInfo, siteContentDirectoryPath);
var parentOrderString = "none";
//int parentID = 0;
foreach (string filePath in filePathArrayList)
{
var firstIndex = filePath.LastIndexOf(PathUtils.SeparatorChar) + 1;
var lastIndex = filePath.LastIndexOf(".", StringComparison.Ordinal);
var orderString = filePath.Substring(firstIndex, lastIndex - firstIndex);
if (StringUtils.StartsWithIgnoreCase(orderString, parentOrderString))
{
parentId = siteContentIe.ImportChannelsAndContents(filePath, true, isOverride, parentId);
parentOrderString = orderString;
}
else
{
siteContentIe.ImportChannelsAndContents(filePath, true, isOverride, parentId);
}
}
}
public void ImportContentsByZipFile(NodeInfo nodeInfo, string zipFilePath, bool isOverride, int importStart, int importCount, bool isChecked, int checkedLevel)
{
var siteContentDirectoryPath = PathUtils.GetTemporaryFilesPath("contents");
DirectoryUtils.DeleteDirectoryIfExists(siteContentDirectoryPath);
DirectoryUtils.CreateDirectoryIfNotExists(siteContentDirectoryPath);
ZipUtils.UnpackFiles(zipFilePath, siteContentDirectoryPath);
var tableName = NodeManager.GetTableName(Fso.PublishmentSystemInfo, nodeInfo);
var taxis = BaiRongDataProvider.ContentDao.GetMaxTaxis(tableName, nodeInfo.NodeId, false);
ImportContents(nodeInfo, siteContentDirectoryPath, isOverride, taxis, importStart, importCount, isChecked, checkedLevel);
DataProvider.NodeDao.UpdateContentNum(Fso.PublishmentSystemInfo);
}
public void ImportContentsByAccessFile(int nodeId, string excelFilePath, bool isOverride, int importStart, int importCount, bool isChecked, int checkedLevel)
{
var nodeInfo = NodeManager.GetNodeInfo(Fso.PublishmentSystemId, nodeId);
var contentInfoArrayList = AccessObject.GetContentsByAccessFile(excelFilePath, Fso.PublishmentSystemInfo, nodeInfo);
if (importStart > 1 || importCount > 0)
{
var theArrayList = new ArrayList();
if (importStart == 0)
{
importStart = 1;
}
if (importCount == 0)
{
importCount = contentInfoArrayList.Count;
}
var firstIndex = contentInfoArrayList.Count - importStart - importCount + 1;
if (firstIndex <= 0)
{
firstIndex = 0;
}
var addCount = 0;
for (var i = 0; i < contentInfoArrayList.Count; i++)
{
if (addCount >= importCount) break;
if (i >= firstIndex)
{
theArrayList.Add(contentInfoArrayList[i]);
addCount++;
}
}
contentInfoArrayList = theArrayList;
}
var tableName = NodeManager.GetTableName(Fso.PublishmentSystemInfo, nodeInfo);
foreach (BackgroundContentInfo contentInfo in contentInfoArrayList)
{
contentInfo.IsChecked = isChecked;
contentInfo.CheckedLevel = checkedLevel;
//contentInfo.ID = DataProvider.ContentDAO.Insert(tableName, this.FSO.PublishmentSystemInfo, contentInfo);
if (isOverride)
{
var existsIDs = DataProvider.ContentDao.GetIdListBySameTitleInOneNode(tableName, contentInfo.NodeId, contentInfo.Title);
if (existsIDs.Count > 0)
{
foreach (int id in existsIDs)
{
contentInfo.Id = id;
DataProvider.ContentDao.Update(tableName, Fso.PublishmentSystemInfo, contentInfo);
}
}
else
{
contentInfo.Id = DataProvider.ContentDao.Insert(tableName, Fso.PublishmentSystemInfo, contentInfo);
}
}
else
{
contentInfo.Id = DataProvider.ContentDao.Insert(tableName, Fso.PublishmentSystemInfo, contentInfo);
}
}
}
public void ImportContentsByCsvFile(int nodeId, string csvFilePath, bool isOverride, int importStart, int importCount, bool isChecked, int checkedLevel)
{
var nodeInfo = NodeManager.GetNodeInfo(Fso.PublishmentSystemId, nodeId);
var contentInfoList = ExcelObject.GetContentsByCsvFile(csvFilePath, Fso.PublishmentSystemInfo, nodeInfo);
contentInfoList.Reverse();
if (importStart > 1 || importCount > 0)
{
var theList = new List<BackgroundContentInfo>();
if (importStart == 0)
{
importStart = 1;
}
if (importCount == 0)
{
importCount = contentInfoList.Count;
}
var firstIndex = contentInfoList.Count - importStart - importCount + 1;
if (firstIndex <= 0)
{
firstIndex = 0;
}
var addCount = 0;
for (var i = 0; i < contentInfoList.Count; i++)
{
if (addCount >= importCount) break;
if (i >= firstIndex)
{
theList.Add(contentInfoList[i]);
addCount++;
}
}
contentInfoList = theList;
}
var tableName = NodeManager.GetTableName(Fso.PublishmentSystemInfo, nodeInfo);
foreach (var contentInfo in contentInfoList)
{
contentInfo.IsChecked = isChecked;
contentInfo.CheckedLevel = checkedLevel;
if (isOverride)
{
var existsIDs = DataProvider.ContentDao.GetIdListBySameTitleInOneNode(tableName, contentInfo.NodeId, contentInfo.Title);
if (existsIDs.Count > 0)
{
foreach (int id in existsIDs)
{
contentInfo.Id = id;
DataProvider.ContentDao.Update(tableName, Fso.PublishmentSystemInfo, contentInfo);
}
}
else
{
contentInfo.Id = DataProvider.ContentDao.Insert(tableName, Fso.PublishmentSystemInfo, contentInfo);
}
}
else
{
contentInfo.Id = DataProvider.ContentDao.Insert(tableName, Fso.PublishmentSystemInfo, contentInfo);
}
//this.FSO.AddContentToWaitingCreate(contentInfo.NodeID, contentID);
}
}
public void ImportContentsByTxtZipFile(int nodeId, string zipFilePath, bool isOverride, int importStart, int importCount, bool isChecked, int checkedLevel)
{
var directoryPath = PathUtils.GetTemporaryFilesPath("contents");
DirectoryUtils.DeleteDirectoryIfExists(directoryPath);
DirectoryUtils.CreateDirectoryIfNotExists(directoryPath);
ZipUtils.UnpackFiles(zipFilePath, directoryPath);
var nodeInfo = NodeManager.GetNodeInfo(Fso.PublishmentSystemId, nodeId);
var contentInfoArrayList = TxtObject.GetContentsByTxtFile(directoryPath, Fso.PublishmentSystemInfo, nodeInfo);
if (importStart > 1 || importCount > 0)
{
var theArrayList = new ArrayList();
if (importStart == 0)
{
importStart = 1;
}
if (importCount == 0)
{
importCount = contentInfoArrayList.Count;
}
var firstIndex = contentInfoArrayList.Count - importStart - importCount + 1;
if (firstIndex <= 0)
{
firstIndex = 0;
}
var addCount = 0;
for (var i = 0; i < contentInfoArrayList.Count; i++)
{
if (addCount >= importCount) break;
if (i >= firstIndex)
{
theArrayList.Add(contentInfoArrayList[i]);
addCount++;
}
}
contentInfoArrayList = theArrayList;
}
var tableName = NodeManager.GetTableName(Fso.PublishmentSystemInfo, nodeInfo);
foreach (BackgroundContentInfo contentInfo in contentInfoArrayList)
{
contentInfo.IsChecked = isChecked;
contentInfo.CheckedLevel = checkedLevel;
//int contentID = DataProvider.ContentDAO.Insert(tableName, this.FSO.PublishmentSystemInfo, contentInfo);
if (isOverride)
{
var existsIDs = DataProvider.ContentDao.GetIdListBySameTitleInOneNode(tableName, contentInfo.NodeId, contentInfo.Title);
if (existsIDs.Count > 0)
{
foreach (int id in existsIDs)
{
contentInfo.Id = id;
DataProvider.ContentDao.Update(tableName, Fso.PublishmentSystemInfo, contentInfo);
}
}
else
{
contentInfo.Id = DataProvider.ContentDao.Insert(tableName, Fso.PublishmentSystemInfo, contentInfo);
}
}
else
{
contentInfo.Id = DataProvider.ContentDao.Insert(tableName, Fso.PublishmentSystemInfo, contentInfo);
}
//this.FSO.AddContentToWaitingCreate(contentInfo.NodeID, contentID);
}
}
public void ImportContents(NodeInfo nodeInfo, string siteContentDirectoryPath, bool isOverride, int taxis, int importStart, int importCount, bool isChecked, int checkedLevel)
{
var filePath = PathUtils.Combine(siteContentDirectoryPath, "contents.xml");
var siteContentIe = new SiteContentIe(Fso.PublishmentSystemInfo, siteContentDirectoryPath);
siteContentIe.ImportContents(filePath, isOverride, nodeInfo, taxis, importStart, importCount, isChecked, checkedLevel);
FileUtils.DeleteFileIfExists(filePath);
DirectoryUtils.MoveDirectory(siteContentDirectoryPath, Fso.PublishmentSystemPath, isOverride);
}
public void ImportInputContentsByCsvFile(InputInfo inputInfo, string excelFilePath, int importStart, int importCount, bool isChecked)
{
var contentInfoList = ExcelObject.GetInputContentsByCsvFile(excelFilePath, Fso.PublishmentSystemInfo, inputInfo);
contentInfoList.Reverse();
if (importStart > 1 || importCount > 0)
{
var theList = new List<InputContentInfo>();
if (importStart == 0)
{
importStart = 1;
}
if (importCount == 0)
{
importCount = contentInfoList.Count;
}
var firstIndex = contentInfoList.Count - importStart - importCount + 1;
if (firstIndex <= 0)
{
firstIndex = 0;
}
var addCount = 0;
for (var i = 0; i < contentInfoList.Count; i++)
{
if (addCount >= importCount) break;
if (i >= firstIndex)
{
theList.Add(contentInfoList[i]);
addCount++;
}
}
contentInfoList = theList;
}
foreach (var contentInfo in contentInfoList)
{
contentInfo.IsChecked = isChecked;
DataProvider.InputContentDao.Insert(contentInfo);
}
}
public static ArrayList GetSiteContentFilePathArrayList(string siteContentDirectoryPath)
{
var filePaths = DirectoryUtils.GetFilePaths(siteContentDirectoryPath);
var filePathSortedList = new SortedList();
foreach (var filePath in filePaths)
{
var keyBuilder = new StringBuilder();
var fileName = PathUtils.GetFileName(filePath).ToLower().Replace(".xml", "");
var nums = fileName.Split('_');
foreach (var numStr in nums)
{
var count = 7 - numStr.Length;
if (count > 0)
{
for (var i = 0; i < count; i++)
{
keyBuilder.Append("0");
}
}
keyBuilder.Append(numStr);
keyBuilder.Append("_");
}
if (keyBuilder.Length > 0) keyBuilder.Remove(keyBuilder.Length - 1, 1);
filePathSortedList.Add(keyBuilder.ToString(), filePath);
}
var filePathArrayList = new ArrayList(filePathSortedList.Values);
return filePathArrayList;
}
}
}