Exemplo n.º 1
0
        public HttpResponseMessage Print()
        {
            HttpResponseMessage response = new HttpResponseMessage();

            try
            {
                String outputFolderPath = _environment.ContentRootPath + "\\Outputs\\";
                String outputFilePath   = outputFolderPath + FileNameGenerator.getName(6) + _config.GetValue <String>("IoFileType");

                var newsString = Request.Form["newspaper"];

                var newspaper = JsonConvert.DeserializeObject <Newspaper>(newsString);

                if (!Directory.Exists(outputFolderPath))
                {
                    Directory.CreateDirectory(outputFolderPath);
                }

                _streamWriter.setPath(outputFilePath);
                newspaper.printNewspaper(_streamWriter);

                response.StatusCode = HttpStatusCode.OK;
            }
            catch (Exception e)
            {
                response.StatusCode = HttpStatusCode.InternalServerError;
            }
            return(response);
        }