/// <summary>
 /// Converts a <see cref="Shot"/> into a <see cref="Sql.Shot"/>.
 /// </summary>
 /// <param name="shot">The <see cref="Shot"/> being converted.</param>
 /// <param name="sqlShot">The converted <see cref="Sql.Shot"/> that contains equivalent values from the <paramref name="shot"/>.</param>
 /// <param name="items">The existent items to look for the items of the shot.</param>
 public static void ConvertToSqlShot(Shot shot, SqlShot sqlShot, IEnumerable <SqlItem> items)
 {
     sqlShot.Item         = ConvertToSqlItem(shot.Source, items);
     sqlShot.TrackMarkIn  = shot.TrackAnchor.MarkIn;
     sqlShot.TrackMarkOut = shot.TrackAnchor.MarkOut;
     sqlShot.ItemMarkIn   = shot.SourceAnchor.MarkIn;
     sqlShot.ItemMarkOut  = shot.SourceAnchor.MarkOut;
     sqlShot.Volume       = shot.Volume;
 }
        /// <summary>
        /// Creates a sql track for testing.
        /// </summary>
        /// <param name="trackType">The track type of the track being created.</param>
        /// <param name="shot">The shot being added to the track being created.</param>
        /// <returns>A sql track with values.</returns>
        private static SqlTrack CreateSqlTrack(string trackType, SqlShot shot)
        {
            var track = new SqlTrack();

            track.Id        = 1;
            track.TrackType = trackType;
            track.Shots.Add(shot);

            return(track);
        }
        /// <summary>
        /// Asserts that the <paramref name="sqlShot"/> contains equivalent values from the <paramref name="shot"/>.
        /// </summary>
        /// <param name="shot">The shot with expected values.</param>
        /// <param name="sqlShot">The shot with actual values.</param>
        public static void AssertShot(Shot shot, SqlShot sqlShot)
        {
            Assert.AreEqual(shot.Volume, sqlShot.Volume);

            Assert.AreEqual(shot.TrackAnchor.MarkIn, sqlShot.TrackMarkIn);
            Assert.AreEqual(shot.TrackAnchor.MarkOut, sqlShot.TrackMarkOut);
            Assert.AreEqual(shot.SourceAnchor.MarkIn, sqlShot.ItemMarkIn);
            Assert.AreEqual(shot.SourceAnchor.MarkOut, sqlShot.ItemMarkOut);

            AssertItem(shot.Source, sqlShot.Item);
        }
        /// <summary>
        /// Asserts that the <paramref name="shot"/> contains equivalent values from the <paramref name="sqlShot"/>.
        /// </summary>
        /// <param name="sqlShot">The shot with expected values.</param>
        /// <param name="shot">The shot with actual values.</param>
        public static void AssertShot(SqlShot sqlShot, Shot shot)
        {
            Assert.AreEqual(string.Format(IdUrlTemplate, sqlShot.Id), shot.Id.ToString());
            Assert.AreEqual(sqlShot.Volume, shot.Volume);

            Assert.AreEqual(sqlShot.TrackMarkIn, shot.TrackAnchor.MarkIn);
            Assert.AreEqual(sqlShot.TrackMarkOut, shot.TrackAnchor.MarkOut);
            Assert.AreEqual(sqlShot.ItemMarkIn, shot.SourceAnchor.MarkIn);
            Assert.AreEqual(sqlShot.ItemMarkOut, shot.SourceAnchor.MarkOut);

            AssertItem(sqlShot.Item, shot.Source);

            AssertComment(sqlShot.Comments.First(), shot.Comments[0]);
        }
        /// <summary>
        /// Creates a sql shot for testing.
        /// </summary>
        /// <param name="item">The sql item associated to the shot being created.</param>
        /// <returns>A sql shot with values.</returns>
        private static SqlShot CreateSqlShot(SqlItem item)
        {
            var shot = new SqlShot();

            shot.Id           = 1;
            shot.Item         = item;
            shot.ItemMarkIn   = 10;
            shot.ItemMarkOut  = 20.5;
            shot.TrackMarkIn  = 60;
            shot.TrackMarkOut = 200;
            shot.Volume       = (decimal)0.7;
            shot.Comments.Add(CreateSqlComment());

            return(shot);
        }
        public void ShouldConvertShotToSqlShot()
        {
            var shot    = SqlHelper.CreateShot();
            var sqlShot = new SqlShot();

            var item = SqlHelper.CreateSqlItem();

            item.Id = shot.Source.Id.ToString();
            item.Resources.First().Id = shot.Source.Resources[0].Id.ToString();

            var items = new List <SqlItem> {
                item
            };

            SqlDataProviderTranslator.ConvertToSqlShot(shot, sqlShot, items);

            SqlHelper.AssertShot(shot, sqlShot);
        }
        /// <summary>
        /// Converts the <see cref="SqlShot"/> to <see cref="Shot"/>.
        /// </summary>
        /// <param name="sqlShot">The <see cref="SqlShot"/> to be converted.</param>
        /// <returns>The converted <see cref="Shot"/>.</returns>
        private static Shot ConvertToShot(SqlShot sqlShot, IMetadataLocator metadataLocator)
        {
            Shot shot = new Shot
            {
                Id          = CreateUri(sqlShot.Id),
                Source      = ConvertToMediaItem(sqlShot.Item, metadataLocator),
                TrackAnchor = new Anchor {
                    MarkIn = sqlShot.TrackMarkIn, MarkOut = sqlShot.TrackMarkOut
                },
                SourceAnchor = new Anchor {
                    MarkIn = sqlShot.ItemMarkIn, MarkOut = sqlShot.ItemMarkOut
                },
                Volume = sqlShot.Volume.GetValueOrDefault()
            };

            foreach (SqlComment comment in sqlShot.Comments)
            {
                shot.Comments.Add(ConvertToComment(comment));
            }

            return(shot);
        }
예제 #8
0
        public void ShouldDeleteProject()
        {
            var context = new RoughCutEditorEntities();

            using (TransactionScope transactionScope = new TransactionScope())
            {
                var libraryId    = CreateId(typeof(Services.Contracts.Container).Name);
                var dataProvider = new DataProvider(this.loggerService, null, libraryId);

                Item item = Item.CreateItem(1, "title", "Video");
                item.Description = "description";
                item.Resources   = new EntityCollection <Resource>();
                Resource resource = Resource.CreateResource(1, "\test\test.wmv", "Master");
                resource.VideoFormat             = VideoFormat.CreateVideoFormat(1);
                resource.VideoFormat.Duration    = 10;
                resource.VideoFormat.FrameRate   = "Smpte25";
                resource.VideoFormat.ResolutionX = 200;
                resource.VideoFormat.ResolutionY = 500;
                item.Resources.Add(resource);

                context.AddToItem(item);

                TitleTemplate titleTemplate = TitleTemplate.CreateTitleTemplate(1, "TemplateName");

                context.AddToTitleTemplate(titleTemplate);

                context.SaveChanges();

                Project project = Project.CreateProject(1, "creator", DateTime.Now);
                project.Duration         = 100;
                project.Resolution       = "HD";
                project.AutoSaveInterval = 100;
                project.StartTimeCode    = 3600;
                project.SmpteFrameRate   = "Smpte2997NonDrop";
                project.RippleMode       = true;

                Container mediaBin = Container.CreateContainer(1);
                mediaBin.Items.Add(item);

                Container container = Container.CreateContainer(2);
                mediaBin.Containers.Add(container);

                project.MediaBin = mediaBin;

                Comment comment = Comment.CreateComment(1, "Text", "Timeline", "user", DateTime.Today);
                comment.MarkIn  = 1200;
                comment.MarkOut = 1500;

                Comment shotComment = Comment.CreateComment(2, "Text", "Shot", "user", DateTime.Today);
                shotComment.MarkIn  = 170;
                shotComment.MarkOut = 180;

                project.Comments.Add(comment);
                project.Comments.Add(shotComment);

                Track track = Track.CreateTrack(1, "Video");

                Shot shot = Shot.CreateShot(1);
                shot.Item         = item;
                shot.ItemMarkIn   = 150;
                shot.ItemMarkOut  = 200;
                shot.TrackMarkIn  = 500;
                shot.TrackMarkOut = 0;
                shot.Volume       = 5;
                shot.Comments.Add(shotComment);

                track.Shots = new EntityCollection <Shot>();
                track.Shots.Add(shot);

                project.Tracks.Add(track);

                Title title = Title.CreateTitle(1, 600, 100, "Main", "Sub");
                title.TitleTemplate = titleTemplate;

                project.Titles.Add(title);

                context.AddToProject(project);

                context.SaveChanges();

                var retrievedProject = dataProvider.LoadProject(new Uri(string.Format("http://temp/{0}", project.Id)));

                bool result = dataProvider.DeleteProject(new Uri(string.Format("http://temp/{0}", project.Id)));
                var  retrievedDeletedProject = dataProvider.LoadProject(new Uri(string.Format("http://temp/{0}", project.Id)));

                Assert.IsTrue(result);
                Assert.IsNull(retrievedDeletedProject.Id);
            }
        }
예제 #9
0
        public void ShouldLoadProject()
        {
            var context = new RoughCutEditorEntities();

            using (TransactionScope transactionScope = new TransactionScope())
            {
                var libraryId    = CreateId(typeof(Services.Contracts.Container).Name);
                var dataProvider = new DataProvider(this.loggerService, null, libraryId);

                Item item = Item.CreateItem(1, "title", "Video");
                item.Description = "description";
                item.Resources   = new EntityCollection <Resource>();
                Resource resource = Resource.CreateResource(1, "\test\test.wmv", "Master");
                resource.VideoFormat             = VideoFormat.CreateVideoFormat(1);
                resource.VideoFormat.Duration    = 10;
                resource.VideoFormat.FrameRate   = "Smpte25";
                resource.VideoFormat.ResolutionX = 200;
                resource.VideoFormat.ResolutionY = 500;
                item.Resources.Add(resource);

                context.AddToItem(item);

                TitleTemplate titleTemplate = TitleTemplate.CreateTitleTemplate(1, "TemplateName");

                context.AddToTitleTemplate(titleTemplate);

                context.SaveChanges();

                Project project = Project.CreateProject(1, "creator", DateTime.Now);
                project.Duration         = 100;
                project.Resolution       = "HD";
                project.AutoSaveInterval = 100;
                project.StartTimeCode    = 3600;
                project.SmpteFrameRate   = "Smpte2997NonDrop";
                project.RippleMode       = true;

                Container mediaBin = Container.CreateContainer(1);
                mediaBin.Items.Add(item);

                Container container = Container.CreateContainer(2);
                container.Items.Add(item);
                mediaBin.Containers.Add(container);

                project.MediaBin = mediaBin;

                Comment comment = Comment.CreateComment(3, "Text", "Timeline", "user", DateTime.Today);
                comment.MarkIn  = 1200;
                comment.MarkOut = 1500;

                Comment shotComment = Comment.CreateComment(4, "Text", "Shot", "user", DateTime.Today);
                shotComment.MarkIn  = 170;
                shotComment.MarkOut = 180;

                project.Comments.Add(comment);
                project.Comments.Add(shotComment);

                Track track = Track.CreateTrack(1, "Video");

                Shot shot = Shot.CreateShot(1);
                shot.Item         = item;
                shot.ItemMarkIn   = 150;
                shot.ItemMarkOut  = 200;
                shot.TrackMarkIn  = 500;
                shot.TrackMarkOut = 0;
                shot.Volume       = 5;
                shot.Comments.Add(shotComment);

                track.Shots = new EntityCollection <Shot>();
                track.Shots.Add(shot);

                project.Tracks.Add(track);

                Title title = Title.CreateTitle(1, 600, 100, "Main", "Sub");
                title.TitleTemplate = titleTemplate;

                project.Titles.Add(title);

                context.AddToProject(project);

                context.SaveChanges();

                var retrievedProject = dataProvider.LoadProject(new Uri(string.Format(IdUrlTemplate, project.Id)));

                Assert.AreEqual(project.Duration, retrievedProject.Duration);
                Assert.AreEqual(project.Resolution, retrievedProject.Resolution);
                Assert.AreEqual(project.AutoSaveInterval, retrievedProject.AutoSaveInterval);
                Assert.AreEqual(project.StartTimeCode, retrievedProject.StartTimeCode);
                Assert.AreEqual(project.SmpteFrameRate, retrievedProject.SmpteFrameRate);
                Assert.AreEqual(project.RippleMode, retrievedProject.RippleMode);
                Assert.AreEqual(project.Creator, retrievedProject.Creator);
                Assert.IsNotNull(retrievedProject.MediaBin);
                Assert.AreEqual(string.Format(IdUrlTemplate, mediaBin.Id), retrievedProject.MediaBin.Id.ToString());
                Assert.AreEqual(1, retrievedProject.MediaBin.Items.Count);
                Assert.AreEqual(1, retrievedProject.MediaBin.Containers.Count);
                Assert.AreEqual(0, retrievedProject.MediaBin.Containers[0].Items.Count);
                Assert.AreEqual(1, retrievedProject.Sequences[0].Tracks.Count);
                Assert.AreEqual(string.Format(IdUrlTemplate, track.Id), retrievedProject.Sequences[0].Tracks[0].Id.ToString());
                Assert.AreEqual(track.TrackType, retrievedProject.Sequences[0].Tracks[0].TrackType);
                Assert.AreEqual(track.Shots.Count, retrievedProject.Sequences[0].Tracks[0].Shots.Count);
                Assert.AreEqual(string.Format(IdUrlTemplate, shot.Id), retrievedProject.Sequences[0].Tracks[0].Shots[0].Id.ToString());
                Assert.AreEqual(shot.TrackMarkIn, retrievedProject.Sequences[0].Tracks[0].Shots[0].TrackAnchor.MarkIn);
                Assert.AreEqual(shot.TrackMarkOut, retrievedProject.Sequences[0].Tracks[0].Shots[0].TrackAnchor.MarkOut);
                Assert.AreEqual(shot.ItemMarkIn, retrievedProject.Sequences[0].Tracks[0].Shots[0].SourceAnchor.MarkIn);
                Assert.AreEqual(shot.ItemMarkOut, retrievedProject.Sequences[0].Tracks[0].Shots[0].SourceAnchor.MarkOut);
                Assert.AreEqual(shot.Volume, retrievedProject.Sequences[0].Tracks[0].Shots[0].Volume);
                Assert.AreEqual(1, retrievedProject.Sequences[0].Tracks[0].Shots[0].Comments.Count);
                Assert.AreEqual(string.Format(IdUrlTemplate, shotComment.Id), retrievedProject.Sequences[0].Tracks[0].Shots[0].Comments[0].Id.ToString());
                Assert.AreEqual(shotComment.Creator, retrievedProject.Sequences[0].Tracks[0].Shots[0].Comments[0].Creator);
                Assert.AreEqual(shotComment.Created, retrievedProject.Sequences[0].Tracks[0].Shots[0].Comments[0].Created);
                Assert.AreEqual(shotComment.Text, retrievedProject.Sequences[0].Tracks[0].Shots[0].Comments[0].Text);
                Assert.AreEqual(shotComment.CommentType, retrievedProject.Sequences[0].Tracks[0].Shots[0].Comments[0].Type);
                Assert.AreEqual(shotComment.MarkIn, retrievedProject.Sequences[0].Tracks[0].Shots[0].Comments[0].MarkIn);
                Assert.AreEqual(shotComment.MarkOut, retrievedProject.Sequences[0].Tracks[0].Shots[0].Comments[0].MarkOut);
                Assert.AreEqual(2, retrievedProject.Comments.Count);
                Assert.AreEqual(string.Format(IdUrlTemplate, comment.Id), retrievedProject.Comments[1].Id.ToString());
                Assert.AreEqual(comment.Created, retrievedProject.Comments[1].Created);
                Assert.AreEqual(comment.Creator, retrievedProject.Comments[1].Creator);
                Assert.AreEqual(comment.Text, retrievedProject.Comments[1].Text);
                Assert.AreEqual(comment.CommentType, retrievedProject.Comments[1].Type);
                Assert.AreEqual(comment.MarkIn, retrievedProject.Comments[1].MarkIn);
                Assert.AreEqual(comment.MarkOut, retrievedProject.Comments[1].MarkOut);
                Assert.AreEqual(string.Format(IdUrlTemplate, shotComment.Id), retrievedProject.Comments[0].Id.ToString());
                Assert.AreEqual(shotComment.Created, retrievedProject.Comments[0].Created);
                Assert.AreEqual(shotComment.Creator, retrievedProject.Comments[0].Creator);
                Assert.AreEqual(shotComment.Text, retrievedProject.Comments[0].Text);
                Assert.AreEqual(shotComment.CommentType, retrievedProject.Comments[0].Type);
                Assert.AreEqual(shotComment.MarkIn, retrievedProject.Comments[0].MarkIn);
                Assert.AreEqual(shotComment.MarkOut, retrievedProject.Comments[0].MarkOut);
                Assert.AreEqual(string.Format(IdUrlTemplate, item.Id), retrievedProject.Sequences[0].Tracks[0].Shots[0].Source.Id.ToString());
                Assert.AreEqual(item.Title, retrievedProject.Sequences[0].Tracks[0].Shots[0].Source.Title);
                Assert.AreEqual(item.Description, retrievedProject.Sequences[0].Tracks[0].Shots[0].Source.Description);
                Assert.IsInstanceOfType(retrievedProject.Sequences[0].Tracks[0].Shots[0].Source, typeof(VideoItem));
                Assert.AreEqual(string.Format(IdUrlTemplate, item.Resources.First().Id), retrievedProject.Sequences[0].Tracks[0].Shots[0].Source.Resources[0].Id.ToString());
                Assert.AreEqual(item.Resources.First().Ref, retrievedProject.Sequences[0].Tracks[0].Shots[0].Source.Resources[0].Ref);
                Assert.AreEqual(item.Resources.First().VideoFormat.Duration, ((VideoItem)retrievedProject.Sequences[0].Tracks[0].Shots[0].Source).Duration);
                Assert.AreEqual(item.Resources.First().VideoFormat.FrameRate, ((VideoItem)retrievedProject.Sequences[0].Tracks[0].Shots[0].Source).FrameRate.ToString());
                Assert.AreEqual(item.Resources.First().VideoFormat.ResolutionX, ((VideoItem)retrievedProject.Sequences[0].Tracks[0].Shots[0].Source).Width);
                Assert.AreEqual(item.Resources.First().VideoFormat.ResolutionY, ((VideoItem)retrievedProject.Sequences[0].Tracks[0].Shots[0].Source).Height);
                Assert.AreEqual(1, retrievedProject.Titles.Count);
                Assert.AreEqual(string.Format(IdUrlTemplate, title.Id), retrievedProject.Titles[0].Id.ToString());
                Assert.AreEqual(title.MainText, retrievedProject.Titles[0].TextBlockCollection[0].Text);
                Assert.AreEqual(title.SubText, retrievedProject.Titles[0].TextBlockCollection[1].Text);
                Assert.AreEqual(title.TrackMarkIn, retrievedProject.Titles[0].TrackAnchor.MarkIn);
                Assert.AreEqual(title.TrackMarkOut, retrievedProject.Titles[0].TrackAnchor.MarkOut);
                Assert.AreEqual(string.Format(IdUrlTemplate, title.TitleTemplate.Id), retrievedProject.Titles[0].TitleTemplate.Id.ToString());
                Assert.AreEqual(title.TitleTemplate.TemplateName, retrievedProject.Titles[0].TitleTemplate.TemplateName);
            }
        }