64 lines
1.7 KiB
C#
64 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
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)
|
|
{
|
|
|
|
confirmation = args[0];
|
|
jobNumber = args[1];
|
|
|
|
string orderNumber = confirmation.Split('-')[2];
|
|
client = confirmation.Split('-')[1];
|
|
|
|
XmlDocument doc = new XmlDocument();
|
|
|
|
try { doc.Load(ClientConfig); }
|
|
catch (System.IO.FileNotFoundException)
|
|
{
|
|
Console.WriteLine("Can't access");
|
|
|
|
}
|
|
|
|
|
|
XmlNodeList xnList = doc.SelectNodes("/Config/Clients/Client");
|
|
foreach (XmlNode xn in xnList)
|
|
{
|
|
if (xn["Name"].InnerXml == client)
|
|
{
|
|
path = xn["DPCFolder"].InnerXml;
|
|
}
|
|
}
|
|
|
|
try {
|
|
string[] filename = Directory.GetFiles(path).Where(f => f.Contains(orderNumber)).ToArray();
|
|
|
|
Console.WriteLine(client);
|
|
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");
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|