using System; using System.Collections.Generic; using System.Text; using System.Net; using System.IO; namespace EseguiMotorePrometeia { //EseguiMotorePrometeia.exe serverPrometeia portaServerPrometeia pathInput pathOnput tipoTracciato hp alfa //EseguiMotorePrometeia.exe vmcolpra 9875 D:\BatchSEI\C6\input\input.txt D:\BatchSEI\C6\output\output 13 63 99 class EseguiMotorePrometeia { static int Main(string[] args) { try { string serverPrometeia = args[0]; string portaServerPrometeia = args[1]; string pathInput = args[2]; string pathOnput = args[3]; string tipoTracciato = args[4]; string hp = args[5]; string alfa = args[6]; StringBuilder xml = new StringBuilder(); xml.Append(""); xml.Append(""); xml.Append("riskengine.perform"); xml.Append(""); xml.Append(""); xml.Append(""); xml.Append(""); xml.Append(""); xml.Append("C6"); xml.Append(""); xml.Append("" + pathInput + ""); xml.Append("" + pathOnput + ""); xml.Append("" + tipoTracciato + ""); xml.Append("" + hp + ""); xml.Append("" + alfa + ""); xml.Append(""); xml.Append(""); xml.Append("]]>"); xml.Append(""); xml.Append(""); xml.Append(""); xml.Append(""); xml.Append(""); HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create("http://" + serverPrometeia + ":" + portaServerPrometeia); webrequest.KeepAlive = false; webrequest.Method = "POST"; webrequest.ContentType = "text/xml"; webrequest.AllowAutoRedirect = false; webrequest.Timeout = int.MaxValue; BuildReqStream(ref webrequest, xml.ToString()); HttpWebResponse webresponse = (HttpWebResponse)webrequest.GetResponse(); Encoding enc = System.Text.Encoding.GetEncoding(1252); StreamReader loResponseStream = new StreamReader(webresponse.GetResponseStream(), enc); string Response = loResponseStream.ReadToEnd(); loResponseStream.Close(); webresponse.Close(); if (Response.ToLower().Contains("exception")) { throw new Exception("Esegui Motore Prometeia ha generato un errore: " + Response); } return 0; } catch (Exception ex) { Console.WriteLine(ex.Message); return 1; } } private static void BuildReqStream(ref HttpWebRequest webrequest, string xml) { byte[] bytes = Encoding.ASCII.GetBytes(xml); webrequest.ContentLength = bytes.Length; Stream oStreamOut = webrequest.GetRequestStream(); oStreamOut.Write(bytes, 0, bytes.Length); oStreamOut.Close(); } } }