public ActionResult Overview()
        {
            var model = new OverviewViewModel
            {
                ExampleFileSelector = new ExampleFileSelector
                {
                    ID          = "exampleFileSelector",
                    InitialFile = "Default.pdf"
                }
            };

            var inputDocument = model.ExampleFileSelector.SelectedFile;
            var fileInfo      = new FileInfo(inputDocument);
            var inputFormat   = DocumentFormatInfo.Get(inputDocument);

            model.InputFormat = inputFormat != null ? inputFormat.Description : "(not supported)";

            PopulatePossibleOutputFormats(inputDocument, model);

            model.ConvertHandlerUrl = ExamplesConfiguration.GetDynamicDownloadUrl(
                ConvertHandlerName,
                new NameValueCollection
            {
                { "inputDocument", ExamplesConfiguration.ProtectString(inputDocument) },
                { "version", fileInfo.LastWriteTimeUtc.Ticks + "-" + fileInfo.Length }
            });

            return(View(model));
        }
        public static void ConvertHandler(IHttpContext context)
        {
            DocumentConverterResult result;

            try
            {
                var inputDocument  = new BackSlashPath(ExamplesConfiguration.UnprotectString(context.Request["inputDocument"]));
                var outputFormat   = (DocumentFormat)Enum.Parse(typeof(DocumentFormat), context.Request["outputFormat"]);
                var fileName       = inputDocument.FileNameWithoutExtension + "." + DocumentFormatInfo.Get(outputFormat).DefaultExtension;
                var outputPath     = ConvertedPath.Append(context.Session.Id).Append(fileName);
                var outputDocument = outputPath.Append(fileName);

                if (Directory.Exists(outputPath))
                {
                    Directory.Delete(outputPath, true);
                }
                Directory.CreateDirectory(outputPath);
                result = DocumentUltimate.DocumentConverter.Convert(inputDocument, outputDocument, outputFormat);
            }
            catch (Exception exception)
            {
                context.Response.Output.Write("<span style=\"color: red; font-weight: bold\">Conversion failed</span><br/>");
                context.Response.Output.Write(exception.Message);
                return;
            }

            context.Response.Output.Write("<span style=\"color: green; font-weight: bold\">Conversion successful</span>");
            context.Response.Output.Write("<br/>Conversion time: " + result.ElapsedTime);
            context.Response.Output.Write("<br/>Output files:");

            if (result.OutputFiles.Length > 1)
            {
                context.Response.Output.Write(" - " + GetZipDownloadLink(new FileInfo(result.OutputFiles[0]).Directory));
            }

            context.Response.Output.Write("<br/><ol>");
            foreach (var outputFile in result.OutputFiles)
            {
                if (outputFile.EndsWith("\\"))
                {
                    var directoryInfo = new DirectoryInfo(outputFile);
                    context.Response.Output.Write(string.Format(
                                                      "<br/><li><b>{0}\\</b> - {1}</li>",
                                                      directoryInfo.Name,
                                                      GetZipDownloadLink(directoryInfo))
                                                  );
                }
                else
                {
                    var fileInfo = new FileInfo(outputFile);
                    context.Response.Output.Write(string.Format(
                                                      "<br/><li><b>{0}</b> ({1} bytes) - {2}</li>",
                                                      fileInfo.Name,
                                                      fileInfo.Length,
                                                      GetDownloadLink(fileInfo))
                                                  );
                }
            }
            context.Response.Output.Write("<br/></ol>");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            exampleExplorer.VersionTitle = "v" + VideoUltimateConfiguration.AssemblyInfo.FileVersion;

            exampleExplorer.Examples = new ExampleBase[]
            {
                new Example
                {
                    Title           = "Overview",
                    Url             = "Overview.aspx",
                    SourceFiles     = new[] { "Overview.aspx", "Overview.aspx.cs" },
                    DescriptionFile = "Descriptions/Overview.html"
                },
                new Example
                {
                    Title           = "Reading video frames",
                    Url             = "Reading.aspx",
                    SourceFiles     = new[] { "Reading.aspx", "Reading.aspx.cs" },
                    DescriptionFile = "Descriptions/Reading.html"
                }
            };

            exampleExplorer.ExampleProjectName = "ASP.NET Web Forms (C#)";
            exampleExplorer.ExampleProjects    = ExamplesConfiguration.LoadExampleProjects(Server.MapPath("~/App_Data/ExampleProjects.json"));
        }
        public static void ZipDownloadHandler(IHttpContext context)
        {
            var path = new BackSlashPath(ExamplesConfiguration.UnprotectString(context.Request["path"])).RemoveTrailingSlash();

            var fileResponse = new FileResponse(context, 0);

            fileResponse.Transmit((targetStream) =>
            {
                QuickZip.Zip(targetStream, Directory.EnumerateFileSystemEntries(path));
            }, path.FileName + ".zip", 0);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            PopulateInputFormats();
            PopulateOutputFormats();

            ResultHandlerUrl = ExamplesConfiguration.GetDynamicDownloadUrl(
                ResultHandlerName,
                new NameValueCollection
            {
                { "version", DateTime.UtcNow.Ticks.ToString() }
            });
        }
 private static string GetZipDownloadLink(DirectoryInfo directoryInfo)
 {
     return(string.Format(
                "<a href=\"{0}\">Download as Zip</a>",
                ExamplesConfiguration.GetDynamicDownloadUrl(
                    ZipDownloadHandlerName,
                    new NameValueCollection
     {
         { "path", ExamplesConfiguration.ProtectString(directoryInfo.FullName) },
         { "version", directoryInfo.LastWriteTimeUtc.Ticks.ToString() },
     })));
 }
Ejemplo n.º 7
0
        public static void Start()
        {
            var kernel = new StandardKernel(new NinjectSettings());

            kernel.Unbind <ModelValidatorProvider>();

            kernel.RegisterDryv();

            kernel.Bind <IOptions <Options2> >().ToMethod(_ => ExamplesConfiguration.CreateOptionsFromCookie <Options2>()).InRequestScope();
            kernel.Bind <IOptions <Options3> >().ToMethod(_ => ExamplesConfiguration.CreateOptionsFromCookie <Options3>()).InRequestScope();

            DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel));
        }
Ejemplo n.º 8
0
        public static void Start()
        {
            var container = new UnityContainer();

            FilterProviders.Providers.Remove(FilterProviders.Providers.OfType <FilterAttributeFilterProvider>().First());
            FilterProviders.Providers.Add(new UnityFilterAttributeFilterProvider(container));

            container.RegisterDryv();

            container.RegisterType <IOptions <Options2> >(new InjectionFactory(_ => ExamplesConfiguration.CreateOptionsFromCookie <Options2>()));
            container.RegisterType <IOptions <Options3> >(new InjectionFactory(_ => ExamplesConfiguration.CreateOptionsFromCookie <Options3>()));

            DependencyResolver.SetResolver(new UnityDependencyResolver(container));
        }
        public ActionResult Possible()
        {
            var model = new PossibleViewModel();

            PopulateInputFormats(model);
            PopulateOutputFormats(model);

            model.ResultHandlerUrl = ExamplesConfiguration.GetDynamicDownloadUrl(
                ResultHandlerName,
                new NameValueCollection
            {
                { "version", DateTime.UtcNow.Ticks.ToString() }
            });

            return(View(model));
        }
Ejemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var videoPath         = exampleFileSelector.SelectedFile;
            var fileInfo          = new FileInfo(videoPath);
            var thumbnailCacheKey = new FileCacheKey(new FileCacheSourceKey(fileInfo.Name, fileInfo.Length, fileInfo.LastWriteTimeUtc), "jpg");
            var cacheItem         = ThumbnailCache.GetOrAdd(
                thumbnailCacheKey,
                thumbnailStream => GetAndSaveThumbnail(videoPath, thumbnailStream)
                );

            ThumbnailUrl = ExamplesConfiguration.GetDownloadUrl(
                Hosting.ResolvePhysicalPath(ThumbnailCachePath.Append(cacheItem.RelativeName)),
                thumbnailCacheKey.FullValue
                );

            VideoInfo = GetVideoInfo(videoPath);
        }
Ejemplo n.º 11
0
        public static void Start()
        {
            var builder = new ContainerBuilder();

            builder.RegisterControllers(typeof(MvcApplication).Assembly);
            builder.RegisterModelBinders(typeof(MvcApplication).Assembly);
            builder.RegisterModelBinderProvider();

            builder.RegisterDryv();

            builder.Register(_ => ExamplesConfiguration.CreateOptionsFromCookie <Options2>());
            builder.Register(_ => ExamplesConfiguration.CreateOptionsFromCookie <Options3>());

            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
Ejemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var videoPath = exampleFileSelector.SelectedFile;
            var fileInfo  = new FileInfo(videoPath);

            FrameDownloaderUrl = ExamplesConfiguration.GetDynamicDownloadUrl(
                FrameDownloaderHandlerName,
                new NameValueCollection
            {
                { "videoPath", ExamplesConfiguration.ProtectString(videoPath) },
                { "version", fileInfo.LastWriteTimeUtc.Ticks + "-" + fileInfo.Length },
                { "frameTime", "0" }
            });

            var duration = GetDuration(videoPath);

            TotalSeconds = ((int)duration.TotalSeconds).ToString(CultureInfo.InvariantCulture);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var inputDocument = exampleFileSelector.SelectedFile;
            var fileInfo      = new FileInfo(inputDocument);

            var inputFormat = DocumentFormatInfo.Get(inputDocument);

            InputFormat = inputFormat != null ? inputFormat.Description : "(not supported)";

            PopulatePossibleOutputFormats(inputDocument);

            ConvertHandlerUrl = ExamplesConfiguration.GetDynamicDownloadUrl(
                ConvertHandlerName,
                new NameValueCollection
            {
                { "inputDocument", ExamplesConfiguration.ProtectString(inputDocument) },
                { "version", fileInfo.LastWriteTimeUtc.Ticks + "-" + fileInfo.Length }
            });
        }
Ejemplo n.º 14
0
        public static void DownloadVideoFrame(IHttpContext context)
        {
            var videoPath = ExamplesConfiguration.UnprotectString(context.Request["videoPath"]);
            var frameTime = int.Parse(context.Request["frameTime"]);

            using (var bitmap = GetFrame(videoPath, frameTime))
                using (var stream = new MemoryStream())
                {
                    bitmap.Save(stream, ImageFormat.Jpeg);
                    stream.Position = 0;

                    var fileResponse = new FileResponse(context);
                    fileResponse.Transmit(
                        stream,
                        "frame.jpg",
                        File.GetLastWriteTimeUtc(videoPath),
                        stream.Length,
                        neverExpires: true);
                }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            exampleExplorer.VersionTitle = "v" + DocumentUltimateConfiguration.AssemblyInfo.FileVersion;

            exampleExplorer.Examples = new ExampleBase[]
            {
                new ExampleFolder
                {
                    Title    = "Document Viewer",
                    Children = new ExampleBase[]
                    {
                        new Example
                        {
                            Title           = "Overview",
                            Url             = "DocumentViewer/Overview.aspx",
                            SourceFiles     = new[] { "DocumentViewer/Overview.aspx", "DocumentViewer/Overview.aspx.cs" },
                            DescriptionFile = "Descriptions/DocumentViewer/Overview.html"
                        },
                        new Example
                        {
                            Title           = "Copy protection (DRM)",
                            Url             = "DocumentViewer/Protection.aspx",
                            SourceFiles     = new[] { "DocumentViewer/Protection.aspx", "DocumentViewer/Protection.aspx.cs" },
                            DescriptionFile = "Descriptions/DocumentViewer/Protection.html"
                        },
                        new Example
                        {
                            Title           = "Auto searching and highlighting keywords",
                            Url             = "DocumentViewer/Highlight.aspx",
                            SourceFiles     = new[] { "DocumentViewer/Highlight.aspx", "DocumentViewer/Highlight.aspx.cs" },
                            DescriptionFile = "Descriptions/DocumentViewer/Highlight.html"
                        },
                        new Example
                        {
                            Title           = "Watermarking pages",
                            Url             = "DocumentViewer/Watermark.aspx",
                            SourceFiles     = new[] { "DocumentViewer/Watermark.aspx", "DocumentViewer/Watermark.aspx.cs" },
                            DescriptionFile = "Descriptions/DocumentViewer/Watermark.html"
                        },
                        new Example
                        {
                            Title           = "Using with a stream",
                            Url             = "DocumentViewer/Stream.aspx",
                            SourceFiles     = new[] { "DocumentViewer/Stream.aspx", "DocumentViewer/Stream.aspx.cs" },
                            DescriptionFile = "Descriptions/DocumentViewer/Stream.html"
                        },
                        new Example
                        {
                            Title           = "Client-side events",
                            Url             = "DocumentViewer/ClientEvents.aspx",
                            SourceFiles     = new[] { "DocumentViewer/ClientEvents.aspx", "DocumentViewer/ClientEvents.aspx.cs" },
                            DescriptionFile = "Descriptions/DocumentViewer/ClientEvents.html"
                        }
                    }
                },
                new ExampleFolder
                {
                    Title    = "Document Converter",
                    Children = new ExampleBase[]
                    {
                        new Example
                        {
                            Title           = "Overview",
                            Url             = "DocumentConverter/Overview.aspx",
                            SourceFiles     = new[] { "DocumentConverter/Overview.aspx", "DocumentConverter/Overview.aspx.cs" },
                            DescriptionFile = "Descriptions/DocumentConverter/Overview.html"
                        },
                        new Example
                        {
                            Title           = "Possible conversions",
                            Url             = "DocumentConverter/Possible.aspx",
                            SourceFiles     = new[] { "DocumentConverter/Possible.aspx", "DocumentConverter/Possible.aspx.cs" },
                            DescriptionFile = "Descriptions/DocumentConverter/Possible.html"
                        }
                    }
                }
            };

            exampleExplorer.ExampleProjectName = "ASP.NET Web Forms (C#)";
            exampleExplorer.ExampleProjects    = ExamplesConfiguration.LoadExampleProjects("~/App_Data/ExampleProjects.json");
        }
Ejemplo n.º 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            exampleExplorer.VersionTitle = "v" + FileUltimateConfiguration.AssemblyInfo.FileVersion;

            exampleExplorer.Examples = new ExampleBase[]
            {
                new ExampleFolder
                {
                    Title    = "FileManager",
                    Children = new ExampleBase[]
                    {
                        new Example
                        {
                            Title           = "Overview",
                            Url             = "FileManager/Overview.aspx",
                            SourceFiles     = new[] { "FileManager/Overview.aspx", "FileManager/Overview.aspx.cs" },
                            DescriptionFile = "Descriptions/FileManager/Overview.html"
                        },
                        new Example
                        {
                            Title           = "Setting properties programmatically",
                            Url             = "FileManager/Programmatic.aspx",
                            SourceFiles     = new[] { "FileManager/Programmatic.aspx", "FileManager/Programmatic.aspx.cs" },
                            DescriptionFile = "Descriptions/FileManager/Programmatic.html"
                        },
                        new Example
                        {
                            Title           = "Displaying control on demand",
                            Url             = "FileManager/Display.aspx",
                            SourceFiles     = new[] { "FileManager/Display.aspx", "FileManager/Display.aspx.cs" },
                            DescriptionFile = "Descriptions/FileManager/Display.html"
                        },
                        new Example
                        {
                            Title           = "Server-side events",
                            Url             = "FileManager/ServerEvents.aspx",
                            SourceFiles     = new[] { "FileManager/ServerEvents.aspx", "FileManager/ServerEvents.aspx.cs" },
                            DescriptionFile = "Descriptions/FileManager/ServerEvents.html"
                        },
                        new Example
                        {
                            Title           = "Client-side events",
                            Url             = "FileManager/ClientEvents.aspx",
                            SourceFiles     = new[] { "FileManager/ClientEvents.aspx", "FileManager/ClientEvents.aspx.cs" },
                            DescriptionFile = "Descriptions/FileManager/ClientEvents.html"
                        },
                        new Example
                        {
                            Title           = "Dynamic folder and permissions",
                            Url             = "FileManager/Dynamic.aspx",
                            SourceFiles     = new[] { "FileManager/Dynamic.aspx", "FileManager/Dynamic.aspx.cs" },
                            DescriptionFile = "Descriptions/FileManager/Dynamic.html"
                        },
                        new Example
                        {
                            Title           = "File/Folder chooser",
                            Url             = "FileManager/Chooser.aspx",
                            SourceFiles     = new[] { "FileManager/Chooser.aspx", "FileManager/Chooser.aspx.cs" },
                            DescriptionFile = "Descriptions/FileManager/Chooser.html"
                        }
                    }
                }
            };

            exampleExplorer.ExampleProjectName = "ASP.NET Web Forms (C#)";
            exampleExplorer.ExampleProjects    = ExamplesConfiguration.LoadExampleProjects("~/App_Data/ExampleProjects.json");
        }
 private static string GetDownloadLink(FileInfo fileInfo)
 {
     return(string.Format(
                "<a href=\"{0}\">Download</a>",
                ExamplesConfiguration.GetDownloadUrl(fileInfo.FullName, fileInfo.LastWriteTimeUtc.Ticks.ToString())));
 }