Beispiel #1
0
        /// <summary>
        /// Adds a title to the db
        /// </summary>
        /// <param name="title"></param>
        /// <returns></returns>
        public static bool AddTitle(Title title)
        {
            using (OMLEngine.Dao.LocalDataContext db = new OMLEngine.Dao.LocalDataContext(false))
            {
                // Set default titletype if none specified
                if ((title.TitleType == 0))
                {
                    title.TitleType = TitleTypes.Root | TitleTypes.Video;
                }

                // setup all the collections objects
                // todo : solomon : this should go away once it's understood how people
                // will be added
                Dao.TitleDao.SetupCollectionsToBeAdded(db.Context, title);

                // setup all the images
                UpdatesImagesForTitle(title.DaoTitle);

                // reset the % complete
                title.DaoTitle.ResetPercentComplete();

                // todo : solomon : do your duplicate logic here
                Dao.TitleCollectionDao.AddTitle(db.Context, title.DaoTitle);

                return(true);
            }
        }
Beispiel #2
0
        public static int?GetImageIdForTitleThreadSafe(int titleId, ImageType imageType)
        {
            using (Dao.LocalDataContext db = new OMLEngine.Dao.LocalDataContext(true))
            {
                int imageId = (from a in db.Context.ImageMappings
                               where a.TitleId == titleId
                               where a.ImageType == (byte)imageType
                               select a.ImageId).FirstOrDefault();

                return(imageId);
            }
        }
Beispiel #3
0
        private static Image GetImageByIdThreadSafe(int id)
        {
            Image image = null;

            using (Dao.LocalDataContext db = new OMLEngine.Dao.LocalDataContext(true))
            {
                Dao.DBImage dbImage = db.Context.DBImages.SingleOrDefault(i => i.Id == id);

                if (dbImage != null)
                {
                    image = ByteArrayToImage(dbImage.Image.ToArray());
                }
            }

            return(image);
        }
Beispiel #4
0
        /// <summary>
        /// Checks if the image [fileName] has allready been stored for the
        /// [titleid]
        /// </summary>
        /// <param name="titleId"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static bool CheckImageOriginalNameTitleThreadSafe(int titleId, string fileName)
        {
            using (Dao.LocalDataContext db = new OMLEngine.Dao.LocalDataContext(true))
            {
                int count = (from a in db.Context.ImageMappings
                             where a.OriginalName == Path.GetFileName(fileName)
                             where a.TitleId == titleId
                             select a).Count();

                if (count == 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
        private static Image GetImageByIdThreadSafe(int id)
        {
            Image image = null;

            using (Dao.LocalDataContext db = new OMLEngine.Dao.LocalDataContext(true))
            {
                Dao.DBImage dbImage = db.Context.DBImages.SingleOrDefault(i => i.Id == id);

                if (dbImage != null)
                {
                    image = ByteArrayToImage(dbImage.Image.ToArray());
                }
            }

            return image;
        }
        public static int? GetImageIdForTitleThreadSafe(int titleId, ImageType imageType)
        {
            using (Dao.LocalDataContext db = new OMLEngine.Dao.LocalDataContext(true))
            {
                int imageId = (from a in db.Context.ImageMappings
                                  where a.TitleId == titleId
                                  where a.ImageType == (byte)imageType
                                  select a.ImageId).FirstOrDefault();

                return imageId;
            }
        }
        /// <summary>
        /// Checks if the image [fileName] has allready been stored for the 
        /// [titleid]
        /// </summary>
        /// <param name="titleId"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static bool CheckImageOriginalNameTitleThreadSafe(int titleId, string fileName)
        {
            using (Dao.LocalDataContext db = new OMLEngine.Dao.LocalDataContext(true))
            {
                int count = (from a in db.Context.ImageMappings
                             where a.OriginalName == Path.GetFileName(fileName)
                             where a.TitleId == titleId
                             select a).Count();

                if (count == 0)
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
        }
        /// <summary>
        /// Adds a title to the db
        /// </summary>
        /// <param name="title"></param>
        /// <returns></returns>
        public static bool AddTitle(Title title)
        {
            using (OMLEngine.Dao.LocalDataContext db = new OMLEngine.Dao.LocalDataContext(false))
            {
                // Set default titletype if none specified
                if ((title.TitleType == 0)) { title.TitleType = TitleTypes.Root | TitleTypes.Video; }

                // setup all the collections objects
                // todo : solomon : this should go away once it's understood how people
                // will be added
                Dao.TitleDao.SetupCollectionsToBeAdded(db.Context, title);

                // setup all the images
                UpdatesImagesForTitle(title.DaoTitle);

                // reset the % complete
                title.DaoTitle.ResetPercentComplete();

                // todo : solomon : do your duplicate logic here
                Dao.TitleCollectionDao.AddTitle(db.Context, title.DaoTitle);

                return true;
            }
        }