#234 merging an existing xml to the site xml
This commit is contained in:
parent
940dfb34a6
commit
b8031a5e7f
@ -8,8 +8,8 @@
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"GoogleAnalyticsCode": "",
|
||||
"APIRoot": "https://ganjgah.ir",
|
||||
"GlobalAPIRoot": "https://ganjgah.ir",
|
||||
"APIRoot": "http://localhost:3439",
|
||||
"GlobalAPIRoot": "http://localhost:3439",
|
||||
"SiteUrl": "http://localhost:33081",
|
||||
"ReadOnlyMode": "False"
|
||||
}
|
||||
|
||||
@ -12161,6 +12161,14 @@
|
||||
<param name="List"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:ganjoor.GDBListProcessor.RetrieveListFromFile(System.String,System.String@)">
|
||||
<summary>
|
||||
دریافت یک فایل xml و تبدیل آن به لیستی از GDBInfoها
|
||||
</summary>
|
||||
<param name="fileName"></param>
|
||||
<param name="Exception"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:ganjoor.PoemAudio">
|
||||
<summary>
|
||||
اطلاعات فایل صوتی شعر
|
||||
|
||||
@ -49,6 +49,20 @@ namespace RMuseum.Services.Implementation
|
||||
string outDir = Configuration.GetSection("Ganjoor")["GDBStorage"];
|
||||
string imgDir = Configuration.GetSection("Ganjoor")["GDBStorageImageSource"];
|
||||
string xmlFile = Configuration.GetSection("Ganjoor")["GDBListXMLFile"];
|
||||
string preExisitingListXMLFile = Configuration.GetSection("Ganjoor")["GDBPreExisitingListXMLFile"];
|
||||
List<GDBInfo> programList = new List<GDBInfo>();
|
||||
if (!string.IsNullOrEmpty(preExisitingListXMLFile))
|
||||
{
|
||||
if (File.Exists(preExisitingListXMLFile))
|
||||
{
|
||||
programList = GDBListProcessor.RetrieveListFromFile(preExisitingListXMLFile, out string exception);
|
||||
if (programList == null)
|
||||
{
|
||||
await jobProgressServiceEF.UpdateJob(job.Id, 100, "GDBListProcessor.RetrieveListFromFile", false, exception);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var poets = await context.GanjoorPoets.AsNoTracking().ToListAsync();
|
||||
|
||||
@ -131,7 +145,13 @@ namespace RMuseum.Services.Implementation
|
||||
if (File.Exists(xmlFile))
|
||||
File.Delete(xmlFile);
|
||||
|
||||
GDBListProcessor.Save(xmlFile, "مجموعههای متناظر شاعران سایت", "", "", lstFiles);
|
||||
if(programList.Count > 0)
|
||||
{
|
||||
lstFiles.AddRange(programList);
|
||||
}
|
||||
|
||||
|
||||
GDBListProcessor.Save(xmlFile, "مجموعههای قابل دریافت از گنجور", "", "", lstFiles);
|
||||
|
||||
await jobProgressServiceEF.UpdateJob(job.Id, 100, "", true);
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
|
||||
namespace ganjoor
|
||||
{
|
||||
@ -106,6 +107,83 @@ namespace ganjoor
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// دریافت یک فایل xml و تبدیل آن به لیستی از GDBInfoها
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="Exception"></param>
|
||||
/// <returns></returns>
|
||||
public static List<GDBInfo> RetrieveListFromFile(string fileName, out string Exception)
|
||||
{
|
||||
List<GDBInfo> lstGDBs = new List<GDBInfo>();
|
||||
try
|
||||
{
|
||||
using (StreamReader reader = File.OpenText(fileName))
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.LoadXml(reader.ReadToEnd());
|
||||
|
||||
XmlNodeList gdbNodes = doc.GetElementsByTagName("gdb");
|
||||
foreach (XmlNode gdbNode in gdbNodes)
|
||||
{
|
||||
GDBInfo gdbInfo = new GDBInfo();
|
||||
foreach (XmlNode Node in gdbNode.ChildNodes)
|
||||
{
|
||||
switch (Node.Name)
|
||||
{
|
||||
case "CatName":
|
||||
gdbInfo.CatName = Node.InnerText;
|
||||
break;
|
||||
case "PoetID":
|
||||
gdbInfo.PoetID = Convert.ToInt32(Node.InnerText);
|
||||
break;
|
||||
case "CatID":
|
||||
gdbInfo.CatID = Convert.ToInt32(Node.InnerText);
|
||||
break;
|
||||
case "DownloadUrl":
|
||||
gdbInfo.DownloadUrl = Node.InnerText;
|
||||
break;
|
||||
case "BlogUrl":
|
||||
gdbInfo.BlogUrl = Node.InnerText;
|
||||
break;
|
||||
case "FileExt":
|
||||
gdbInfo.FileExt = Node.InnerText;
|
||||
break;
|
||||
case "ImageUrl":
|
||||
gdbInfo.ImageUrl = Node.InnerText;
|
||||
break;
|
||||
case "FileSizeInByte":
|
||||
gdbInfo.FileSizeInByte = Convert.ToInt32(Node.InnerText);
|
||||
break;
|
||||
case "LowestPoemID":
|
||||
gdbInfo.LowestPoemID = Convert.ToInt32(Node.InnerText);
|
||||
break;
|
||||
case "PubDate":
|
||||
{
|
||||
string[] dateParts = Node.InnerText.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
int Year = Convert.ToInt32(dateParts[0]);
|
||||
int Month = Convert.ToInt32(dateParts[1]);
|
||||
int Day = Convert.ToInt32(dateParts[2]);
|
||||
gdbInfo.PubDate = new DateTime(Year, Month, Day);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
lstGDBs.Add(gdbInfo);
|
||||
}
|
||||
|
||||
}
|
||||
Exception = string.Empty;
|
||||
return lstGDBs;
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
Exception = exp.Message;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +77,8 @@
|
||||
"SitemapLocation": "C:\\inetpub\\ganjoor\\wwwroot\\sitemap.xml",
|
||||
"GDBStorage": "D:\\My Documents\\My Web Design\\ganjoor\\www\\i\\android\\sgdb",
|
||||
"GDBStorageImageSource": "D:\\My Documents\\My Web Design\\ganjoor\\www\\i\\android\\img",
|
||||
"GDBListXMLFile": "D:\\My Documents\\My Web Design\\ganjoor\\www\\i\\android\\sitepoets.xml"
|
||||
"GDBListXMLFile": "D:\\My Documents\\My Web Design\\ganjoor\\www\\i\\android\\sitepoets.xml",
|
||||
"GDBPreExisitingListXMLFile": "D:\\My Documents\\My Web Design\\ganjoor\\www\\i\\android\\programpoets.xml"
|
||||
},
|
||||
"WebServiceUrl": "http://localhost:3439",
|
||||
"ReadOnlyMode": "False",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user