Пример #1
0
        public static void AddMediaFile(MediaFileEntity entity, string applicationName, Guid userId, string userName)
        {
            using (var context = new PlayoutDbContext())
            {
                entity.CreatorId        = userId;
                entity.OriginalFileName = System.IO.Path.GetFileName(entity.OriginalFileName);

                context.MediaFiles.Add(entity);
                var action = new UserAction();

                action.ApplicationName = applicationName;

                action.Category = UserActionCategory.Add;
                //action.Data=
                action.Description = string.Format("标题:{0},原始文件名:{1},时长:{2}。",
                                                   entity.Title, entity.OriginalFileName, TimeSpan.FromSeconds(entity.Duration));

                action.Name = "导入素材";
                //action.Tag = "";
                action.UserId   = userId;
                action.UserName = userName;
                context.UserActions.Add(action);

                context.SaveChanges();
            }
        }
Пример #2
0
 public static ChannelInfo GetChannelInfo(Guid id)
 {
     using (var context = new PlayoutDbContext())
     {
         return(context.ChannelInfos.SingleOrDefault(i => i.Id == id));
     }
 }
Пример #3
0
 public static IEnumerable <BMDSwitcherInfo> GetBMDSwitcherInfos()
 {
     using (var context = new PlayoutDbContext())
     {
         return(context.BMDSwitchers.ToArray());
     }
 }
Пример #4
0
        public static void Save(IEnumerable <ChannelInfo> newItems, List <ChannelInfo> updatedItems, List <ChannelInfo> removeItems)
        {
            using (var context = new PlayoutDbContext())
            {
                //var allItems = context.ChannelInfos.ToArray();

                foreach (var item in newItems)
                {
                    context.ChannelInfos.Add(item);
                }

                foreach (var item in updatedItems)
                {
                    context.Entry(item).State = EntityState.Modified;
                }

                foreach (var item in removeItems)
                {
                    context.Entry(item).State = EntityState.Deleted;
                }

                try
                {
                    context.SaveChanges();
                }
                catch (Exception ex)
                {
                }
            }
        }
Пример #5
0
 public static UserEntity GetUser(string name, string password)
 {
     using (var context = new PlayoutDbContext())
     {
         return(context.Users.Include(u => u.Roles).SingleOrDefault(u => u.Name == name && u.Password == password && !u.Locked));
     }
 }
Пример #6
0
        public static void Save(IEnumerable <BMDSwitcherInfo> newItems, List <BMDSwitcherInfo> updatedItems, List <BMDSwitcherInfo> removeItems,
                                Func <BMDSwitcherInfo, IEnumerable <BMDSwitcherInputInfo> > factory)
        {
            using (var context = new PlayoutDbContext())
            {
                var allItems = context.BMDSwitchers.ToArray();

                foreach (var item in newItems)
                {
                    context.BMDSwitchers.Add(item);

                    foreach (var inputItem in factory(item))
                    {
                        item.InputInfos.Add(inputItem);
                    }
                }


                foreach (var item in updatedItems)
                {
                    var updateItem = allItems.SingleOrDefault(i => i.Id == item.Id);
                    if (updateItem != null)
                    {
                        updateItem.Name    = item.Name;
                        updateItem.Address = item.Address;
                    }
                }

                foreach (var item in removeItems)
                {
                    var removeItem = allItems.SingleOrDefault(i => i.Id == item.Id);
                    if (removeItem != null)
                    {
                        context.BMDSwitchers.Remove(removeItem);
                    }
                }
                context.SaveChanges();
            }
        }