Ejemplo n.º 1
0
        // GET: /Interface/InterfaceTransferPricingIndex
        public ActionResult InterfaceTransferPricingIndex()
        {
            InterfaceTransferPricingViewModel itpVM = new InterfaceTransferPricingViewModel();

            return View(itpVM);
        }
Ejemplo n.º 2
0
        public ActionResult ArquivoInterfaceTransferPricing(string DT_INI, string DT_FIM)
        {
            InterfaceTransferPricingViewModel itpVM = new InterfaceTransferPricingViewModel();

            try
            {
                string xmlStream;

                List<TransferPricing> tp = _produtoAppService.InterfaceTransferPricing(Convert.ToDateTime(DT_INI), Convert.ToDateTime(DT_FIM)).ToList();

                StringWriter sw = new StringWriter();

                sw.WriteLine("\"COD_PRODUTO\";\"NEGOCIO\";\"MES\";\"VLR_DOLAR\";\"VLR_REAL\";\"COD_EMPRESA\"");

                foreach (var line in tp)
                {
                    sw.WriteLine(string.Format("\"{0}\";\"{1}\";\"{2}\";\"{3}\";\"{4}\";\"{5}\"",
                                               line.COD_PRODUTO,
                                               line.NEGOCIO,
                                               line.MES.ToString("dd/MM/yy"),
                                               line.VLR_DOLAR,
                                               line.VLR_REAL,
                                               line.COD_EMPRESA));
                }

                xmlStream = sw.ToString();

                return new ExcelResult
                {
                    FileName = string.Format("InterfaceTransferPricing-{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);
        }