Reworked to use documentID instead of confirmation number. Reworked XML parsing. Added a bit more error handling.
This commit is contained in:
@@ -22,31 +22,41 @@ 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;
|
||||
}
|
||||
}
|
||||
string[] filename = Directory.GetFiles(path).Where(f => f.Contains(orderNumber)).ToArray();
|
||||
Console.WriteLine(filename[0].Split('\\').Last());
|
||||
System.IO.File.Move(filename[0], path + '\\' + jobNumber + '-' + filename[0].Split('\\').Last());
|
||||
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user