public ActionResult ArquivoInterfaceFolhaPagamento(string CodigoFolha, string CodigoLojaAlternate, string CodigoClienteADP, string NumeroProcessoFolha)
        {
            InterfaceFolhaPagamentoViewModel itpVM = new InterfaceFolhaPagamentoViewModel();

            try
            {
                string xmlStream;

                List<FolhaPagamento> fp = _produtoAppService.InterfaceFolhaPagamento(CodigoFolha, CodigoLojaAlternate, CodigoClienteADP, NumeroProcessoFolha).ToList();

                StringWriter sw = new StringWriter();

                sw.WriteLine("\"Cod de Folha\";\"Cod da Empresa\";\"Matricula\";\"Cod do cliente\";\"Processo de folha\";\"Valor do lancamento\"");

                foreach (var line in fp)
                {
                    sw.WriteLine(string.Format("\"{0}\";\"{1}\";\"{2}\";\"{3}\";\"{4}\";\"{5}\"",
                                               line.COD_FOLHA,
                                               line.COD_EMPRESA,
                                               line.MATRICULA,
                                               line.COD_CLIENTE,
                                               line.PROCESSO_FOLHA,
                                               line.VALOR_LANCAMENTO));
                }

                xmlStream = sw.ToString();

                return new ExcelResult
                {
                    FileName = string.Format("InterfaceFolhaPagamento-{0}.csv", DateTime.Now.ToString("yyyyMMdd-HHmmss")),
                    XMLStream = xmlStream
                };

            }
            catch (RetryLimitExceededException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("", "Erro ao gerar arquivo. Tente novamente ou, se o problema persistir, entre em contato com o suporte.");
            }

            return View(itpVM);
        }
        // GET: /Interface/InterfaceFolhaPagamentoIndex
        public ActionResult InterfaceFolhaPagamentoIndex()
        {
            #region populaobjetos

            string codigoFolha = _configuracaoAppService.Find(t => t.DESC_CHAVE == "InterfaceFolhaPagamentoCodigoFolhaPagamento").FirstOrDefault().DESC_VALOR.Trim();

            string codigoClienteADP = _configuracaoAppService.Find(t => t.DESC_CHAVE == "InterfaceFolhaPagamentoCodigoClienteADP").FirstOrDefault().DESC_VALOR.Trim();

            var empresas = _empresaAppService.AllConcatCodigoEmpresaLegado();
            IEnumerable<SelectListItem> empresasSelectListItem = new SelectList(empresas, "CodigoEmpresaAlternate", "NomeEmpresa");
            ViewBag.CodigoEmpresaAlternate = new SelectList(empresas, "CodigoEmpresaAlternate", "NomeEmpresa");

            var lojas = _lojaAppService.Find(t => t.CodigoLojaAlternate.Trim() != "-2" && t.CodigoLojaAlternate.Trim() != "-1"); ;
            IEnumerable<SelectListItem> lojasSelectListItem = new SelectList(lojas, "CodigoLojaAlternate", "NomeLoja");
            ViewBag.CODIGOLOJAALTERNATE = new SelectList(lojas, "CodigoLojaAlternate", "NomeLoja");

            #endregion populaobjetos

            InterfaceFolhaPagamentoViewModel ifpVM = new InterfaceFolhaPagamentoViewModel(codigoFolha, codigoClienteADP, empresasSelectListItem, lojasSelectListItem);

            return View(ifpVM);
        }