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];
|
jobNumber = args[1];
|
||||||
client = args[2];
|
client = args[2];
|
||||||
|
|
||||||
string orderNumber = confirmation.Split('-')[3];
|
string orderNumber = confirmation.Split('-')[2];
|
||||||
|
|
||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
try { doc.Load(ClientConfig); }
|
|
||||||
|
|
||||||
|
try { doc.Load(ClientConfig); }
|
||||||
catch (System.IO.FileNotFoundException)
|
catch (System.IO.FileNotFoundException)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Can't access");
|
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 = xn["DPCFolder"].InnerXml;
|
||||||
path = elemPath[i].InnerXml;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string[] filename = Directory.GetFiles(path).Where(f => f.Contains(orderNumber)).ToArray();
|
|
||||||
Console.WriteLine(filename[0].Split('\\').Last());
|
try {
|
||||||
System.IO.File.Move(filename[0], path + '\\' + jobNumber + '-' + filename[0].Split('\\').Last());
|
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