public ActionResult Thumbnail(string id) { using (var db = new FileDB(pathDB, FileAccess.Read)) { var info = db.Search(Guid.Parse(id)); if (!info.MimeType.StartsWith("image", StringComparison.InvariantCultureIgnoreCase)) { return(File(Server.MapPath("~/Content/no-picture.jpg"), "image/jpg")); } using (MemoryStream output = new MemoryStream()) { db.Read(info.ID, output); Image image = Image.FromStream(output); Image thumbnailImage = image.GetThumbnailImage(64, 64, new Image.GetThumbnailImageAbort(delegate { return(true); }), IntPtr.Zero); using (MemoryStream imageStream = new MemoryStream()) { thumbnailImage.Save(imageStream, System.Drawing.Imaging.ImageFormat.Png); return(File(imageStream.ToArray(), "image/png")); } } } }
static void Main(string[] args) { var qlikViewFiles = QlikViewObjectFactory.Create(@"C:\Users\Wiko\Documents\visual studio 2010\Projects\ConsoleApplication1\Knorr.Tests\TestFiles\"); var db = new FileDB <QlikViewFile>(@"C:\Temp\"); var dbNodes = new FileDB <Node>(@"C:\Temp\"); var dbEdges = new FileDB <Edge>(@"C:\Temp\"); db.DeleteAll(); dbNodes.DeleteAll(); dbEdges.DeleteAll(); var nodes = NodeFactory.CreateNodes(qlikViewFiles); foreach (var node in nodes) { dbNodes.Create(node); } var edges = NodeFactory.CreateEdges(qlikViewFiles); foreach (var edge in edges) { dbEdges.Create(edge); } foreach (var qlikViewFile in qlikViewFiles) { db.Create(qlikViewFile); } var qlikviewObjects = db.Read(); foreach (var qlikviewObject in qlikviewObjects) { Console.WriteLine("Filename " + qlikviewObject.FileInfo.FullName); foreach (var source in qlikviewObject.Script.Sources) { Console.WriteLine(" Source " + source); } foreach (var target in qlikviewObject.Script.Targets) { Console.WriteLine(" Target " + target); } } Console.Read(); }
static void Test3() { string dbFileName = @"d:\\WImageTest\\testdb3.dat"; #if DEBUG if (File.Exists(dbFileName)) { File.Delete(dbFileName); } #endif using (var db = new FileDB(dbFileName, FileAccess.ReadWrite)) { byte[] docStream = TestGenLqDocStream(); //save using (var dataStream = new MemoryStream(docStream)) { db.Store(dbFileName, dataStream); db.Flush(); } } //test read file //and generate liquid document using (var db = new FileDB(dbFileName, FileAccess.ReadWrite)) { EntryInfo[] prevFiles = db.ListFiles(); //test read file using (MemoryStream ms = new MemoryStream()) { db.Read(prevFiles[0].ID, ms); ms.Position = 0; //convert data to document var docDeser = new LiquidDocumentDeserializer(); var reader = new BinaryReader(ms); docDeser.SetBinaryReader(reader); docDeser.ReadDocument(); LiquidDoc result = docDeser.Result; ms.Close(); } } }
public ActionResult Download(string id) { // Using a classic way to download a file, insted of FileContentResult mode. // Optimize for big files (download on demand) using (var db = new FileDB(pathDB, FileAccess.Read)) { var info = db.Search(Guid.Parse(id)); Response.Buffer = false; Response.BufferOutput = false; Response.ContentType = info.MimeType; Response.AppendHeader("Content-Length", info.FileLength.ToString()); Response.AppendHeader("content-disposition", "attachment; filename=" + info.FileName); db.Read(info.ID, Response.OutputStream); return(new EmptyResult()); } }
static void Main(string[] args) { var qlikViewFiles = QlikViewObjectFactory.Create(@"C:\Users\Wiko\Documents\visual studio 2010\Projects\ConsoleApplication1\Knorr.Tests\TestFiles\"); var db = new FileDB<QlikViewFile>(@"C:\Temp\"); var dbNodes = new FileDB<Node>(@"C:\Temp\"); var dbEdges = new FileDB<Edge>(@"C:\Temp\"); db.DeleteAll(); dbNodes.DeleteAll(); dbEdges.DeleteAll(); var nodes = NodeFactory.CreateNodes(qlikViewFiles); foreach (var node in nodes) dbNodes.Create(node); var edges = NodeFactory.CreateEdges(qlikViewFiles); foreach (var edge in edges) dbEdges.Create(edge); foreach (var qlikViewFile in qlikViewFiles) db.Create(qlikViewFile); var qlikviewObjects = db.Read(); foreach (var qlikviewObject in qlikviewObjects) { Console.WriteLine("Filename " + qlikviewObject.FileInfo.FullName); foreach (var source in qlikviewObject.Script.Sources) { Console.WriteLine(" Source " + source); } foreach (var target in qlikviewObject.Script.Targets) { Console.WriteLine(" Target " + target); } } Console.Read(); }