67 lines
2.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Data;
using System.IO;
using System.Net;
using System.Threading;
using Consulenza.Web;
using Consulenza.Web.ConsulenzaUnicaWS;
using Consulenza.WebTemplateModeler.Entity;
using System.IO;
using System.Diagnostics;
namespace ReportGeneratorConsoleApp
{
class Program
{
private static string reportsPath = @"C:\Users\suchowie\Desktop\desktop\unica\report generator\reports";
static void Main(string[] args)
{
var reportManager = new ReportManager();
reportManager.Timeout = 60000 * 10; //10 minuti
string line = string.Empty;
// s7
//var template = new Consulenza.Web.ConsulenzaUnicaWS.Template { IdModello = -1, Nome = "patryk7 " };
//var imagePdf = reportManager.CreaReport("012057", "DNDMCL54A11L551Z", "", "F", 127235, template, new Consulenza.Web.ConsulenzaUnicaWS.Parametro[0]);
//File.WriteAllBytes(@"C:\Users\suchowie\Desktop\report generator\reports\" + "report" + template.Nome + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".pdf", imagePdf);
string[] words = null;
while (true)
{
try
{
Console.WriteLine("put data or press enter to generate previosly loaded doc");
line = Console.ReadLine();
if (line != "")
{
words = line.Split(',');
}
int idModello = int.Parse(words[0]);
string templateName = words[1];
string codiceAgente = words[2];
string codiceFiscale = words[3];
string rete = words[4];
long chiave = long.Parse(words[5]);
var template = new Consulenza.Web.ConsulenzaUnicaWS.Template { IdModello = idModello, Nome = templateName };
var imagePdf = reportManager.CreaReport(codiceAgente, codiceFiscale, "", rete, chiave, template, new Consulenza.Web.ConsulenzaUnicaWS.Parametro[0]);
string path = reportsPath + "\\" + "report" + template.Nome + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".pdf";
File.WriteAllBytes(path, imagePdf);
Process.Start(path);
Console.WriteLine("{0}: file generated", DateTime.Now.ToString());
}
catch (Exception ex)
{
Console.WriteLine("exception occured + {0}", ex.Message);
Console.ReadKey();
}
}
}
}
}