From 0e5e91977629fe30b8b4bdd65f3beebc56b34ad8 Mon Sep 17 00:00:00 2001 From: Dan Dembinski Date: Thu, 7 May 2020 11:57:55 -0400 Subject: [PATCH] Should be all set to work with args being passed in now. --- orderRenamer/Program.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/orderRenamer/Program.cs b/orderRenamer/Program.cs index 9e8f5b2..8a3605b 100644 --- a/orderRenamer/Program.cs +++ b/orderRenamer/Program.cs @@ -4,23 +4,27 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; +using System.IO; namespace orderRenamer { class Program { + static string confirmation; static string client; static string jobNumber; static string path; static string ClientConfig = "\\\\aapp01\\c$\\Program Files (x86)\\AKSESS\\Storefront\\Order Delivery Service\\ClientConfig.xml"; static void Main(string[] args) { - //Console.WriteLine("test"); - client = "ADA"; - // jobNumber = "123"; + + confirmation = args[0]; + jobNumber = args[1]; + client = args[2]; + + string orderNumber = confirmation.Split('-')[3]; XmlDocument doc = new XmlDocument(); - //try { doc.Load("\\\\aapp01\\c$\\Program Files (x86)\\AKSESS\\Storefront\\Order Delivery Service\\ClientConfig.xml"); } try { doc.Load(ClientConfig); } catch (System.IO.FileNotFoundException) @@ -32,16 +36,17 @@ namespace orderRenamer for (int i = 0; i < elemList.Count; i++) { -// Console.WriteLine(elemList[i].InnerXml); if (elemList[i].InnerXml == client) { XmlNodeList elemPath = doc.GetElementsByTagName("DPCFolder"); path = elemPath[i].InnerXml; - Console.WriteLine(path); break; } } - Console.WriteLine(path); + 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()); + } } }