Ejemplo n.º 1
0
        public void CriarISS(int NotaID, string NovoCaminho)
        {
            Class1 db  = new Class1(true);
            var    iss = db.NotaFiscal.First(x => x.NotaFiscalId == NotaID);

            if (!File.Exists(HttpContext.Current.Server.MapPath("~/App_Data/NFSe/" + iss.NumeroRps + ".pdf")))
            {
                try
                {
                    ConsultarLoteRpsRespostaCompNfse nota = new ConsultarLoteRpsRespostaCompNfse();
                    nota = Newtonsoft.Json.JsonConvert.DeserializeObject <ConsultarLoteRpsRespostaCompNfse>(Encoding.ASCII.GetString(iss.PDF));

                    new MVX.Print.Form1().Gera(nota, iss.Observacao);
                }
                catch (Exception erro)
                {
                    MVX.Print.ConsultarLoteRpsResposta nota = new MVX.Print.ConsultarLoteRpsResposta();
                    nota = Newtonsoft.Json.JsonConvert.DeserializeObject <MVX.Print.ConsultarLoteRpsResposta>(Encoding.ASCII.GetString(iss.PDF));
                    new MVX.Print.Form1().Gera(nota, iss.Observacao);
                }
            }

            File.Copy(HttpContext.Current.Server.MapPath("~/App_Data/NFSe/" + iss.NumeroRps + ".pdf"), NovoCaminho + iss.NumeroRps + ".pdf");
        }
Ejemplo n.º 2
0
        public string ArquivoCriaDeStringOrga(List <CenarioArquivo> lst)
        {
            string novocaminho = string.Empty;

            novocaminho = HttpContext.Current.Server.MapPath("~/App_Data/Documentos/");
            if (Directory.Exists(novocaminho))
            {
                Directory.Delete(novocaminho, true);
            }
            Class1 db = new Class1(true);

            Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/App_Data/Documentos/"));
            foreach (var item in lst)
            {
                try
                {
                    if (item.tipoArquivo == "Demonstrativo")
                    {
                        File.Copy(HttpContext.Current.Server.MapPath("~/App_Data/Demostrativos/Demonstrativo" + item.RemessaLote + ".pdf"), novocaminho + "Demonstrativo" + item.RemessaLote + ".pdf");
                    }
                    if (item.tipoArquivo == "BL")
                    {
                        var Boleto = db.Boleto.First(x => x.NumeroDocumento == item.NumeroDocumento);

                        string valor = String.Format("{0:C}", new Utils.Calculos().CalculoPorcentagem(0.033, (double)item.Valor));
                        new MVX.Print.Boleto().Gera(Boleto, valor);
                        File.Copy(HttpContext.Current.Server.MapPath("~/App_Data/BoletosPDF/" + item.NumeroDocumento + ".pdf"), novocaminho + item.NumeroDocumento + ".pdf");
                    }
                    if (item.tipoArquivo == "DEBITO")
                    {
                        if (!File.Exists(HttpContext.Current.Server.MapPath("~/App_Data/Debito/" + item.NumeroDocumento + ".pdf")))
                        {
                            CriaArquivo(item.CenarioArquivoId);
                        }


                        File.Copy(HttpContext.Current.Server.MapPath("~/App_Data/Debito/" + item.NumeroDocumento + ".pdf"), novocaminho + item.NumeroDocumento + ".pdf");
                    }
                    if (item.tipoArquivo == "ISS")
                    {
                        if (!File.Exists(HttpContext.Current.Server.MapPath("~/App_Data/NFSe/" + item.NumeroDocumento + ".pdf")))
                        {
                            try
                            {
                                ConsultarLoteRpsRespostaCompNfse nota = new ConsultarLoteRpsRespostaCompNfse();
                                nota = Newtonsoft.Json.JsonConvert.DeserializeObject <ConsultarLoteRpsRespostaCompNfse>(Encoding.ASCII.GetString(item.CorpoDocumento));

                                new MVX.Print.Form1().Gera(nota, item.Observacao);
                            }
                            catch (Exception erro)
                            {
                                MVX.Print.ConsultarLoteRpsResposta nota = new MVX.Print.ConsultarLoteRpsResposta();
                                nota = Newtonsoft.Json.JsonConvert.DeserializeObject <MVX.Print.ConsultarLoteRpsResposta>(Encoding.ASCII.GetString(item.CorpoDocumento));
                                new MVX.Print.Form1().Gera(nota, item.Observacao);
                            }
                        }

                        File.Copy(HttpContext.Current.Server.MapPath("~/App_Data/NFSe/" + item.NumeroDocumento + ".pdf"), novocaminho + item.NumeroDocumento + ".pdf");
                    }
                    if (item.tipoArquivo == "ICMS_FORMULARIO")
                    {
                        string AArq = HttpContext.Current.Server.MapPath("~/App_Data/ICMSELE/ICMS" + item.NumeroDocumento + ".doc");
                        if (File.Exists(AArq))
                        {
                            File.Delete(AArq);
                        }
                        if (!File.Exists(AArq))
                        {
                            EnviarLoteRpsEnvioLoteRpsRps nota = new EnviarLoteRpsEnvioLoteRpsRps();
                            nota = Newtonsoft.Json.JsonConvert.DeserializeObject <EnviarLoteRpsEnvioLoteRpsRps>(Encoding.ASCII.GetString(item.CorpoDocumento));
                            string valor = String.Format("{0:C}", new Utils.Calculos().CalculoPorcentagem(32, (double)item.Valor));

                            string cliente     = item.cnpjCpf.Replace("CNPJ:", "").Replace("CPF:", "").Replace(" ", "").Replace("-", "").Replace(".", "").Replace("/", "");
                            var    _Cliente    = db.cliente.First(x => x.CpfCnpj == cliente);
                            var    Contrato    = db.Contrato.First(x => x.ClienteId == _Cliente.ClienteId);
                            string dias        = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month).ToString();
                            string Vvencimento = string.Empty;
                            if (Contrato._MapaFaturamento.First().MesParcelas == 2)
                            {
                                dias = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.AddMonths(1).Month).ToString();
                                var Data = DateTime.Now.AddMonths(1);
                                Vvencimento = "01" + "/" + Data.ToString("MM/yyyy") + " - " + dias + "/" + Data.ToString("MM/yyyy");
                                new MVX.Print.Icms().Gera(nota, item.NumeroDocumento, item.Observacao, valor, item.Vencimento.ToString() + "/" + Data.ToString("MM/yyyy"), Vvencimento);
                            }
                            if (Contrato._MapaFaturamento.First().MesParcelas == 1)
                            {
                                dias = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month).ToString();
                                var Data = DateTime.Now;
                                Vvencimento = "01" + "/" + Data.ToString("MM/yyyy") + " - " + dias + "/" + Data.ToString("MM/yyyy");
                                new MVX.Print.Icms().Gera(nota, item.NumeroDocumento, item.Observacao, valor, item.Vencimento.ToString() + "/" + Data.ToString("MM/yyyy"), Vvencimento);
                            }
                        }

                        File.Copy(HttpContext.Current.Server.MapPath("~/App_Data/ICMSELE/ICMS" + item.NumeroDocumento + ".doc"), novocaminho + item.NumeroDocumento + ".doc");
                    }
                }
                catch
                {
                }
            }
            List <string> lstStr = new List <string>();

            string[] arquivos = Directory.GetFiles(novocaminho);
            foreach (var item in arquivos)
            {
                lstStr.Add(item);
            }
            ZIP.AddListCompress(lstStr, Path.Combine(novocaminho, "Arquivos.zip"));
            return(Path.Combine(novocaminho, "Arquivos.zip"));
        }