public void Main() { string[] dwFiles = new string[4] { "A1.gz", "A2.gz", "A3.gz", "A4.gz" }; string[] XMLFiles = new string[4] { "A1.xml", "A2.xml", "a3.xml", "a4.xml" }; string[] XMLFiles1 = new string[4] { "lco1.xml", "lco2.xml", "lco3.xml", "lco4.xml" }; g.ChangeState(true); g.WriteLog("STEP", "START"); g.WriteLog("STEP", "dw"); dowload down = new dowload(); if (!down.DownloadFiles(dwFiles)) { return; } g.WriteLog("STEP", "unzip"); UnZip zip = new UnZip(); if (!zip.unzipFiles(dwFiles)) { return; } g.WriteLog("STEP", "clean"); ExecuteCMD cleaningXML = new ExecuteCMD(); if (!cleaningXML.CleaningFiles(XMLFiles, XMLFiles1)) { return; } g.WriteLog("STEP", "xmlwrite"); foreach (string fPath in XMLFiles1) { if (!LoadXML2List(fPath)) { return; } if (!CreaXML(g.DirPath + "final.txt")) { return; } } //if(!ExecuteSP()) return; if (!spExecute("spExecuteBULK")) { return; } g.WriteLog("STEP", "DONE"); }
bool ExecuteCommand(string _Command) { try { ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " + @_Command); procStartInfo.RedirectStandardOutput = true; procStartInfo.UseShellExecute = false; procStartInfo.CreateNoWindow = false; Process proc = new Process(); proc.StartInfo = procStartInfo; proc.Start(); string result = proc.StandardOutput.ReadToEnd(); return(true); } catch (Exception e) { g.WriteLog("ERROR", "Exec Command " + e.Message); } g.ChangeState(false); return(false); }
public bool DownloadFiles(string[] nombres) { string _url = @"http://www.gestionix.com/Zip/"; using (WebClient ClienteWeb = new WebClient()) { try { for (int i = 0; i < nombres.Length; i++) { ClienteWeb.Proxy = null; ClienteWeb.DownloadFile(_url + nombres[i], lc.DirPath + nombres[i]); } return(true); } catch (Exception ex) { lc.WriteLog("ERROR", "Download " + ex.Message); } } lc.ChangeState(false); return(false); }
public bool unzipFiles(string[] nombres) { for (int i = 0; i < nombres.Length; i++) { try { FileInfo archivo = new FileInfo(g.DirPath + nombres[i]); FileStream ArchivoOriginal = archivo.OpenRead(); string NombreArchivo = archivo.FullName; string NuevoNombre = NombreArchivo.Remove(NombreArchivo.Length - archivo.Extension.Length); FileStream ArchivoDescomprimido = File.Create(NuevoNombre + ".xml"); GZipStream Descomprimir = new GZipStream(ArchivoOriginal, CompressionMode.Decompress); Descomprimir.CopyTo(ArchivoDescomprimido); } catch (Exception e) { g.WriteLog("ERROR", "Unzip " + e.Message); g.ChangeState(false); return(false); } } return(true); }