Reworked to use documentID instead of confirmation number. Reworked XML parsing. Added a bit more error handling.

This commit is contained in:
Dan Dembinski
2020-05-13 21:39:22 -04:00
parent 0e5e919776
commit 050bedac21

View File

@@ -22,30 +22,40 @@ namespace orderRenamer
jobNumber = args[1];
client = args[2];
string orderNumber = confirmation.Split('-')[3];
string orderNumber = confirmation.Split('-')[2];
XmlDocument doc = new XmlDocument();
try { doc.Load(ClientConfig); }
try { doc.Load(ClientConfig); }
catch (System.IO.FileNotFoundException)
{
Console.WriteLine("Can't access");
}
XmlNodeList elemList = doc.GetElementsByTagName("Name");
for (int i = 0; i < elemList.Count; i++)
XmlNodeList xnList = doc.SelectNodes("/Config/Clients/Client");
foreach (XmlNode xn in xnList)
{
if (elemList[i].InnerXml == client)
if (xn["Name"].InnerXml == client)
{
XmlNodeList elemPath = doc.GetElementsByTagName("DPCFolder");
path = elemPath[i].InnerXml;
break;
path = xn["DPCFolder"].InnerXml;
}
}
try {
string[] filename = Directory.GetFiles(path).Where(f => f.Contains(orderNumber)).ToArray();
Console.WriteLine(path);
Console.WriteLine(filename[0].Split('\\').Last());
System.IO.File.Move(filename[0], path + '\\' + jobNumber + '-' + filename[0].Split('\\').Last());
}
catch (System.IndexOutOfRangeException)
{
Console.WriteLine("File probably doesn't exist");
}
}
}