public static string CreateTXT(RPS_Input rps) { var rpsFile = new StringBuilder(); //header rpsFile.AppendLine(string.Format("{0}{1}", rps.nome, rps.cnpj)); foreach (var nota in rps.notas) { rpsFile.AppendLine(string.Format("{0}{1}", nota.numero, nota.valor)); } return(rpsFile.ToString()); }
static void Main(string[] args) { //Retorno API var rpsApiString = File.ReadAllText(@"C:\Temp\input\rsp_retorno_api.json"); RPS_Input rpsApi = Newtonsoft.Json.JsonConvert.DeserializeObject <RPS_Input>(rpsApiString); //Retorno API //formatando dados Header(rpsApi); Detail(rpsApi.notas); //transformar em texto var arqFinalString = CreateTXT(rpsApi); //salvar arquivo File.WriteAllText(@"C:\Temp\output\rps_output_malaco.txt", arqFinalString); }
public static void Header(RPS_Input rps) { rps.cnpj = string.Format("999.999.999", rps.cnpj); }