private void SaveHtmlContent(string htmlFileName, string configuration)
        {
            XslCompiledTransform xsl = new XslCompiledTransform();

            using (XmlReader xmlReader = this._preprocessManager.PreprocessXslString(
                       configuration.Replace("$JS_FOLDER$", GetFileCommand.GetWebPath()))
                   )
            {
                xsl.Load(xmlReader);
            }

            try
            {
                XsltArgumentList list    = new XsltArgumentList();
                XmlDocument      xmlData = this._dataProvider.XmlDocument;

                using (MemoryStream stream = new MemoryStream())
                {
                    XmlNode docEmenent = null;

                    if (xmlData != null)
                    {
                        docEmenent = xmlData.DocumentElement;
                    }
                    else
                    {
                        docEmenent = new XmlDocument();
                    }

                    //
                    // #248 - fix memory leaks during XML files processing
                    //
                    // XmlReader reader = new XmlNodeReader(docEmenent);
                    // xsl.Transform(reader, list, stream);
                    using (XmlReader reader = new XmlNodeReader(docEmenent))
                    {
                        xsl.Transform(reader, list, stream);
                    }

                    stream.Position = 0;

                    this._preprocessManager.DbFs.WriteStream(htmlFileName, stream);
                }
            }
            catch (PathTooLongException ex)
            {
                log.ErrorFormat("PathTooLongException:htmlFileName:{0};Exception:{1}",
                                htmlFileName,
                                ex
                                );

                throw;
            }
        }
Ejemplo n.º 2
0
        public void GetFileFromDfsResponse_Can_Get_Output()
        {
            //Arrange
            var getFileFromDfsResponse = new GetFileFromDfsResponse();
            var commandContext         = TestCommandHelpers.GenerateCliResponseCommandContext(_testScheduler);
            var getFileFromDfsCommand  = new GetFileCommand(null, commandContext, Substitute.For <ILogger>());

            //Act
            TestCommandHelpers.GenerateResponse(commandContext, getFileFromDfsResponse);

            _testScheduler.Start();

            //Assert
            commandContext.UserOutput.Received(1).WriteLine(getFileFromDfsResponse.ToJsonString());
        }
Ejemplo n.º 3
0
        public MediaController(BusinessFactory business, GetFileCommand getFileCommand)
            : base(business)
        {
            _getFileCommand = getFileCommand;
            var mimeNames = new Dictionary <string, string>();

            mimeNames.Add(".mp3", "audio/mpeg"); // List all supported media types;
            mimeNames.Add(".mp4", "video/mp4");
            mimeNames.Add(".ogg", "application/ogg");
            mimeNames.Add(".ogv", "video/ogg");
            mimeNames.Add(".oga", "audio/ogg");
            mimeNames.Add(".wav", "audio/x-wav");
            mimeNames.Add(".webm", "video/webm");

            MimeNames = new ReadOnlyDictionary <string, string>(mimeNames);

            InvalidFileNameChars = Array.AsReadOnly(Path.GetInvalidFileNameChars());
        }
Ejemplo n.º 4
0
        private async Task <IActionResult> GetImageAsync(GetFileCommand _getFileCommand, string siteId, string id, string key,
                                                         string propertyName = null)
        {
            var fileInfo = new GetFileInput
            {
                SiteId       = siteId,
                Id           = id,
                Key          = key,
                PropertyName = propertyName,
                UserId       = StatController.GetUserId(User)
            };
            var result = await
                         Business.InvokeAsync <GetFileCommand, GetFileInput, CommandResult <GetFileResult> >(
                _getFileCommand, fileInfo).ConfigureAwait(false);

            if (result.IsSuccess)
            {
                return(File(result.Data.Stream, result.Data.ContentType));
            }

            return(NotFound());
            //return new HttpResponseMessage(HttpStatusCode.NotFound);
        }
Ejemplo n.º 5
0
 public async Task <IActionResult> Get([FromServices] GetFileCommand _getFileCommand, string siteId, string id, string propertyName, string key, string filename)
 {
     return(await GetImageAsync(_getFileCommand, siteId, id, key, propertyName).ConfigureAwait(false));
 }