private static bool ImportContentFile(IServerSession session, string assetFile, ContentAssetType type) { Console.Write("Analyzing {0} file \"{1}\"...", type, assetFile); AssetInfo imageInfo = MediaAnalyzer.AnalyzeAssetFile(assetFile); if (!string.IsNullOrEmpty(imageInfo.ErrorMessage)) { Console.WriteLine("failed: {0}", imageInfo.ErrorMessage); return(false); } else { Console.WriteLine("success"); } string thumbnailFile = Path.Combine(Path.GetTempPath(), new Oid().ToString() + ".jpg"); File.WriteAllBytes(thumbnailFile, imageInfo.ThumbnailImageBytes); try { IContent content = session.ModelFactory.CreateContent(); content.DurationInMilliseconds = 5000; content.Format = ContentFormat.Landscape; content.Name = type.ToString() + " Content"; content.ResolutionX = imageInfo.Width.Value; content.ResolutionY = imageInfo.Height.Value; Console.Write("Importing {0} content...", type); using (var result = session.DataAccess.Brokers.Content.ImportContentFromAssetFile(assetFile, type, content, thumbnailFile, new ContentImportOptions())) { if (result.IsSuccess) { Console.WriteLine("success"); return(true); } else { Console.WriteLine("failed: {0}", result.ToString()); return(false); } } } finally { File.Delete(thumbnailFile); } }
private static bool ImportContentFile(IServerSession session, string assetFile, ContentAssetType type) { Console.Write("Analyzing {0} file \"{1}\"...", type, assetFile); AssetInfo imageInfo = MediaAnalyzer.AnalyzeAssetFile(assetFile); if (!string.IsNullOrEmpty(imageInfo.ErrorMessage)) { Console.WriteLine("failed: {0}", imageInfo.ErrorMessage); return false; } else { Console.WriteLine("success"); } string thumbnailFile = Path.Combine(Path.GetTempPath(), new Oid().ToString() + ".jpg"); File.WriteAllBytes(thumbnailFile, imageInfo.ThumbnailImageBytes); try { IContent content = session.ModelFactory.CreateContent(); content.DurationInMilliseconds = 5000; content.Format = ContentFormat.Landscape; content.Name = type.ToString() + " Content"; content.ResolutionX = imageInfo.Width.Value; content.ResolutionY = imageInfo.Height.Value; Console.Write("Importing {0} content...", type); using (var result = session.DataAccess.Brokers.Content.ImportContentFromAssetFile(assetFile, type, content, thumbnailFile, new ContentImportOptions())) { if (result.IsSuccess) { Console.WriteLine("success"); return true; } else { Console.WriteLine("failed: {0}", result.ToString()); return false; } } } finally { File.Delete(thumbnailFile); } }