Exemplo n.º 1
0
        private ChannelSwitcher()
        {
#if true
            _channels            = PlayoutRepository.GetChannelInfos();
            this._defaultChannel = _channels.SingleOrDefault(i => i.Special);

            this._switchers = PlayoutRepository.GetBMDSwitcherInfos();
            if (_switchers.Any())
            {
                _currentSwitcher = _switchers.Single(i => i.Id == SettingsManager.BMDSwitcherId);
                IEnumerable <BMDSwitcherInputInfo> inputs =
                    PlayoutRepository.GetSwitcherInputInfos(SettingsManager.BMDSwitcherId, false);

                foreach (var channel in _channels)
                {
                    _channelInputMap.Add(channel.Id, inputs.SingleOrDefault(i => i.ChannelId == channel.Id));
                }

                _switcherOperator = FCSPlayout.SwitcherManagement.SwitcherWrapper.Get(_currentSwitcher.Address);
                _switcherOperator.CurrentProgramChanged += _switcherOperator_CurrentProgramChanged;
            }
            else
            {
            }
#endif
        }
Exemplo n.º 2
0
        public static void AddAction(UserAction action)
        {
            action.UserName = CurrentUser.Name;
            action.UserId   = CurrentUser.Id;

            PlayoutRepository.AddAction(action);
        }
 internal void Save()
 {
     PlayoutRepository.Save(this.ChannelInfos.Except(_updatedItems).Where(i => i.IsNew() && !string.IsNullOrEmpty(i.Title)),
                            _updatedItems, _removedItems);
     _updatedItems.Clear();
     _removedItems.Clear();
 }
        public override void Add(IPlayerItem playerItem)
        {
            var record = new PlayRecord();

            record.PlayItemId     = playerItem.PlayItem.Id;
            record.PlaybillItemId = playerItem.PlayItem.PlaybillItem.Id;
            record.ScheduleMode   = playerItem.PlayItem.PlaybillItem.ScheduleMode;

            record.SourceId    = playerItem.PlayItem.PlaybillItem.MediaSource.Id;
            record.SourceTitle = playerItem.PlayItem.PlaybillItem.MediaSource.Title;
            var sourceDuration = playerItem.PlayItem.PlaybillItem.MediaSource.Duration;

            if (sourceDuration != null)
            {
                record.SourceDuration = sourceDuration.Value.TotalSeconds;
            }

            record.SourceCategory = playerItem.PlayItem.PlaybillItem.MediaSource.Category;


            record.ActualStartTime = playerItem.StartTime;
            //var loadTime = this.LoadTime;
            record.ActualStopTime = playerItem.StopTime;

            record.PlayItemStartTime  = playerItem.PlayItem.StartTime;
            record.LoadMarkerIn       = playerItem.LoadRange.StartPosition.TotalSeconds;
            record.LoadMarkerDuration = playerItem.LoadRange.Duration.TotalSeconds;

            record.PlayItemMarkerIn = playerItem.PlayItem.PlayRange.StartPosition.TotalSeconds;
            record.PlayItemDuration = playerItem.PlayItem.CalculatedPlayDuration.TotalSeconds;

            PlayoutRepository.AddPlayRecord(record);
        }
Exemplo n.º 5
0
        //public PlayItemEntity ToEntity(PlaybillEntity billEntity, IPlayItem playItem)
        //{
        //    var dtoItem = new PlayItemEntity();
        //    dtoItem.Id = playItem.Id;

        //    dtoItem.StartTime = playItem.StartTime;
        //    dtoItem.PlayDuration = playItem.CalculatedPlayDuration.TotalSeconds;
        //    dtoItem.MarkerIn = playItem.PlayRange.StartPosition.TotalSeconds;
        //    dtoItem.MarkerDuration = playItem.PlayRange.Duration.TotalSeconds;

        //    dtoItem.PlaybillItem = ToEntity(billEntity, playItem.PlaybillItem);
        //    return dtoItem;
        //}

        //public PlaybillItemEntity ToEntity(PlaybillEntity billEntity, IPlaybillItem billItem)
        //{
        //    var dtoItem = new PlaybillItemEntity();
        //    dtoItem.Id = billItem.Id;

        //    dtoItem.Playbill = billEntity;

        //    dtoItem.StartTime = billItem.StartTime;
        //    dtoItem.MarkerIn = billItem.PlayRange.StartPosition.TotalSeconds;
        //    dtoItem.ScheduleMode = billItem.ScheduleMode;
        //    dtoItem.MarkerDuration = billItem.PlayRange.Duration.TotalSeconds;

        //    if (billItem.MediaSource.Category!=MediaSourceCategory.Null)
        //    {
        //        dtoItem.MediaSourceId = billItem.MediaSource.Id;
        //    }
        //    else
        //    {
        //        dtoItem.MediaSourceTitle = billItem.MediaSource.Title;
        //        dtoItem.MediaSourceDuration = billItem.MediaSource.Duration.Value.TotalSeconds;
        //    }

        //    var autoBillItem = billItem as AutoPlaybillItem;
        //    if (autoBillItem != null)
        //    {
        //        dtoItem.IsAutoPadding = autoBillItem.IsAutoPadding;
        //    }


        //    var fileMediaSource = billItem.MediaSource as IFileMediaSource;
        //    if (fileMediaSource != null)
        //    {
        //        dtoItem.AudioGain = fileMediaSource.AudioGain;
        //    }

        //    if (billItem.CGItems != null)
        //    {
        //        dtoItem.CGContents = CGItemCollection.ToXml(billItem.CGItems);
        //    }

        //    return dtoItem;
        //}

        public static Playbill Load(Guid id, IList <IPlayItem> playItemList)
        {
            PlaybillEntity billEntity = PlayoutRepository.GetPlaybill(id); // GetEntity(id);
            Playbill       playbill   = null;
            Dictionary <Guid, IPlaybillItem> playbillItemDict = new Dictionary <Guid, IPlaybillItem>();

            if (billEntity != null)
            {
                playbill = new Playbill(billEntity);
                for (int i = 0; i < billEntity.PlayItems.Count; i++)
                {
                    PlayItemEntity playItemEntity = billEntity.PlayItems[i];
                    IPlaybillItem  playbillItem   = null;
                    if (!playbillItemDict.ContainsKey(playItemEntity.PlaybillItemId))
                    {
                        playbillItem = playItemEntity.PlaybillItem.ToPlaybillItem();
                        // FromEntity(playItemEntity.PlaybillItem);
                        playbillItemDict.Add(playItemEntity.PlaybillItemId, playbillItem);
                    }
                    else
                    {
                        playbillItem = playbillItemDict[playItemEntity.PlaybillItemId];
                    }

                    IPlayItem playItem = playItemEntity.ToPlayItem(playbillItem); // FromEntity(playItemEntity,playbillItem);
                    playItemList.Add(playItem);
                }
            }
            return(playbill);
        }
Exemplo n.º 6
0
        public static bool Login(string name, string password, string applicationName)
        {
            if (_user != null)
            {
                throw new InvalidOperationException();
            }
            var userEntity = PlayoutRepository.GetUser(name, PasswordProcessor.Current.Encrypt(password));

            if (userEntity == null)
            {
                return(false);
            }

            var user = new User {
                Id = userEntity.Id, Name = userEntity.Name, Roles = userEntity.Roles.Select(r => r.Name).ToArray()
            };

            if (!user.IsInRole(applicationName) && !user.IsAdmin())
            {
                return(false);
            }

            _user = user;
            var action = new UserAction
            {
                Category        = UserActionCategory.Login,
                ApplicationName = applicationName,
                Name            = "登录",
                Description     = string.Format("登录: {0}", applicationName),
            };

            UserService.AddAction(action);

            return(true);
        }
Exemplo n.º 7
0
        public void Save(IMediaSource replaceAutoPadding, IUser currentUser)
        {
            ValidatePlayItems();
            if (_entity == null)
            {
                _entity = new PlaybillEntity();
            }

            var playItemEntities = ToEntities(_entity, this.PlayItemCollection, replaceAutoPadding);

            _entity.StartTime = playItemEntities[0].StartTime;
            _entity.Duration  = playItemEntities[playItemEntities.Count - 1].StopTime.Subtract(_entity.StartTime).TotalSeconds;

            var oldId       = _entity.Id;
            var oldEditorId = _entity.LastEditorId;

            try
            {
                PlayoutRepository.SavePlaybill(_entity, playItemEntities, currentUser);
            }
            catch (Exception ex)
            {
                _entity.Id           = oldId;
                _entity.LastEditorId = oldEditorId;
                throw;
            }
        }
Exemplo n.º 8
0
 internal void Initialize(Guid switcherId)
 {
     _switcherId = switcherId;
     foreach (var item in PlayoutRepository.GetSwitcherInputInfos(switcherId))
     {
         this.SwitcherInputInfos.Add(item);
     }
 }
Exemplo n.º 9
0
        private Guid _switcherId = Guid.Empty; // int.MinValue;

        public SwitcherChannelSettingsViewModel()
        {
            this.ChannelInfos       = new ObservableCollection <ChannelInfo>(PlayoutRepository.GetChannelInfos());
            this.SwitcherInputInfos = new ObservableCollection <BMDSwitcherInputInfo>();
            _nullInfo = new ChannelInfo {
                Title = "未设置"
            };
            this.ChannelInfos.Add(_nullInfo);
        }
Exemplo n.º 10
0
        public ChannelItemListViewModel(IRegionManager regionManager)
        {
            this.Channels = new List <ChannelMediaSource>(PlayoutRepository.GetChannelInfos(true).Select(i => new ChannelMediaSource(i)));

            // TODO: 从配置中获取默认时长。
            _playRange = new PlayRange(TimeSpan.FromMinutes(30));

            _regionManager = regionManager;
        }
Exemplo n.º 11
0
        private PlayoutSettings GetPlayoutSettings()
        {
            var result = new PlayoutSettings();

            result.RendererSettings.VideoDevice = Properties.Settings.Default.RendererDeviceName;
            result.PlaylistSettings             = PlayoutRepository.GetMPlaylistSettings();
            result.CGItems = PlayoutRepository.GetCGItems();
            return(result);
        }
Exemplo n.º 12
0
        public BMDSwitcherSettingsViewModel()
        {
            this.SwitcherInputInfos = new ObservableCollection <BMDSwitcherInputInfo>();
            this.SwitcherInfos      = new ObservableCollection <BMDSwitcherInfo>(PlayoutRepository.GetBMDSwitcherInfos());

            _removeCommand = new DelegateCommand(ExecuteRemove, CanExecuteRemove);
            _addCommand    = new DelegateCommand(ExecuteAdd);
            _useItCommand  = new DelegateCommand(ExecuteUseCurrent, CanExecuteUseCurrent);
            UpdateCurrentUse();
        }
Exemplo n.º 13
0
 public SwitcherChannelSettingsWindow()
 {
     InitializeComponent();
     foreach (var info in PlayoutRepository.GetBMDSwitcherInfos())
     {
         TabItem tabItem = new TabItem();
         tabItem.Header = info.Name;
         var uc = new SwitcherChannelSettings(info.Id);
         tabItem.Content = uc;
         _controls.Add(uc);
         this.tabControl.Items.Add(tabItem);
     }
 }
Exemplo n.º 14
0
        protected override void ConfigureContainer()
        {
            base.ConfigureContainer();
            this.Container.RegisterInstance(new InteractionRequests());

            this.Container.RegisterInstance <IUserService>(new UserServiceAdapter());
            this.Container.RegisterInstance <IMediaFileImageResolver>(new MediaFileImageResolver());
            this.Container.RegisterInstance <IMediaFilePathResolver>(new MediaFilePathResolver(MediaFileStorage.Primary));
            this.Container.RegisterInstance <IPlayoutConfiguration>(PlayoutConfiguration.Current);

            this.Container.RegisterInstance(PlayoutRepository.GetMPlaylistSettings());

            this.Container.RegisterInstance <IMediaFileService>(new DefaultMediaFileService(null));
        }
Exemplo n.º 15
0
        private void EditCGItems()
        {
            var items = PlayoutRepository.GetCGItems();

            this.EditCGItemsInteractionRequest.Raise(new EditCGItemsConfirmation {
                Title = "编辑字幕", Items = items.Clone()
            },
                                                     c =>
            {
                if (c.Confirmed)
                {
                    PlayoutRepository.SaveCGItems(c.Items);
                }
            });
        }
Exemplo n.º 16
0
        public static IEnumerable <PlaybillEntity> LoadPlaybills(DateTime minStopTime, DateTime prevStartTime)
        {
            return(PlayoutRepository.LoadPlaybills(minStopTime, prevStartTime));

            //List<PlaybillEntity> result = new List<PlaybillEntity>();
            //using (var ctx = new PlayoutDbContext())
            //{
            //    var temp = ctx.Playbills.ToList();
            //    foreach (var item in temp)
            //    {
            //        result.Add(new BindablePlaybill(item));
            //    }
            //}
            //return result;
        }
Exemplo n.º 17
0
        private void miFormatSettings_Click(object sender, RoutedEventArgs e)
        {
            //var videoFormatName = Settings.Default.VideoFormatName;
            //var audioFormatName = Settings.Default.AudioFormatName;
            var formatWindow = new FormatWindow(PlayoutRepository.GetMPlaylistSettings());

            //formatWindow.SetFormats(videoFormatName, audioFormatName);

            if (formatWindow.ShowDialog() == true)
            {
                PlayoutRepository.SaveMPlaylistSettings(formatWindow.MPlaylistSettings);

                //Settings.Default.VideoFormatName = formatWindow.VideoFormat;
                //Settings.Default.AudioFormatName = formatWindow.AudioFormat;
                //Settings.Default.Save();
            }
        }
Exemplo n.º 18
0
        protected override void OnStartup(StartupEventArgs e)
        {
            //MediaSourcePathResolver.Current = new DefaultMediaSourcePathResolver(
            //    ConfigurationManager.AppSettings["primaryStorage"],
            //    ConfigurationManager.AppSettings["secondaryStorage"]);

            //PlayoutRepository.GetSettings();

            ChannelInfo channel = PlayoutRepository.GetAutoPaddingChannel();

            if (channel != null)
            {
                PlayoutConfiguration.Current.AutoPaddingMediaSource = new ChannelMediaSource(channel);
                //Playbill.PaddingMediaSource = new ChannelMediaSource(channel);
            }

            this.Initialize();
            base.OnStartup(e);
            var bootstrapper = new Bootstrapper();

            bootstrapper.Run();
        }
Exemplo n.º 19
0
        public static SettingInfo GetSetting(string name, string groupName = null)
        {
            var settings = PlayoutRepository.GetSettings(name, groupName);

            // First, workstation
            var setting = settings.SingleOrDefault(i => i.Scope.MachineName == MachineName && i.Scope.ApplicationName == ApplicationName);

            if (setting != null)
            {
                return(setting);
            }

            // Second, application
            setting = settings.SingleOrDefault(i => i.Scope.ApplicationName == ApplicationName);
            if (setting != null)
            {
                return(setting);
            }

            // Third, machine
            return(settings.SingleOrDefault(i => i.Scope.MachineName == MachineName));
        }
Exemplo n.º 20
0
        protected override void ConfigureContainer()
        {
            base.ConfigureContainer();

            this.Container.RegisterInstance(PlayoutRepository.GetMPlaylistSettings());
            this.Container.RegisterInstance(new InteractionRequests());
            this.Container.RegisterInstance <IMediaFileImageResolver>(new MediaFileImageResolver());
            this.Container.RegisterInstance <IUserService>(new UserServiceAdapter());
            this.Container.RegisterInstance <IMediaFilePathResolver>(new MediaFilePathResolver(MediaFileStorage.Primary));

            this.Container.RegisterType <IDestinationStreamManager, FileSystemDestinationStreamManager>(new ContainerControlledLifetimeManager());
            this.Container.RegisterType <IFileUploader, DefaultFileUploader>(new ContainerControlledLifetimeManager());
            this.Container.RegisterType <IMediaFileService, DefaultMediaFileService>(new ContainerControlledLifetimeManager());

            this.Container.RegisterInstance <IImageSourceDecoder>(DefaultImageSourceDecoder.Instance);
            this.Container.RegisterInstance <IImagePlaceholderProvider>(new DefaultImagePlaceholderProvider(150, 150));
            this.Container.RegisterInstance <IMediaFileInfoExtractor>(MLMediaFileInfoExtractor.Instance);

            this.Container.RegisterType <MediaFileItemManager>(new ContainerControlledLifetimeManager());

            this.Container.RegisterInstance <MediaFileDurationGetter>(new MLMediaFileDurationGetter());
        }
Exemplo n.º 21
0
        protected override void ConfigureContainer()
        {
            base.ConfigureContainer();
            this.Container.RegisterInstance <IUserService>(new UserServiceAdapter());
            this.Container.RegisterInstance(new InteractionRequests());

            MediaFileStorage currentStorage =
                (MediaFileStorage)Enum.Parse(typeof(MediaFileStorage), ConfigurationManager.AppSettings["storageType"], true);

            this.Container.RegisterInstance <IMediaFilePathResolver>(new MediaFilePathResolver(currentStorage));
            this.Container.RegisterInstance <IMediaFileImageResolver>(new MediaFileImageResolver());

            this.Container.RegisterInstance <IPlayoutConfiguration>(PlayoutConfiguration.Current);
            this.Container.RegisterInstance(PlayoutRepository.GetMPlaylistSettings());

            this.Container.RegisterType <PlayItemCollection>(new ContainerControlledLifetimeManager());
            this.Container.RegisterType <IPlaylist3, Playlist3>();

            this.Container.RegisterInstance <ObservableCollection <BindablePlayItem> >("playedCollection",
                                                                                       new ObservableCollection <BindablePlayItem>());

            this.Container.RegisterInstance <IMediaFileService>(new DefaultMediaFileService(null));
        }
Exemplo n.º 22
0
 public PagingItems <MediaFileEntity> GetMediaFiles(MediaItemSearchOptions searchOptions, PagingInfo pagingInfo)
 {
     return(PlayoutRepository.GetMediaFiles(searchOptions, pagingInfo));
 }
Exemplo n.º 23
0
 public void DeleteMediaFile(MediaFileEntity entity, string applicationName)
 {
     PlayoutRepository.DeleteMediaFile(entity, applicationName, UserService.CurrentUser.Id, UserService.CurrentUser.Name);
 }
Exemplo n.º 24
0
 internal void Save()
 {
     PlayoutRepository.Save(_switcherId, (IEnumerable <BMDSwitcherInputInfo>) this.SwitcherInputInfos);
 }
Exemplo n.º 25
0
 public ChannelSettingsViewModel()
 {
     this.ChannelInfos = new ObservableCollection <ChannelInfo>(PlayoutRepository.GetChannelInfos());
     _removeCommand    = new DelegateCommand(ExecuteRemove, CanExecuteRemove);
     _addCommand       = new DelegateCommand(ExecuteAdd);
 }
Exemplo n.º 26
0
 public AddChannelMediaItemsConfirmation()
 {
     this.Channels = new List <ChannelInfo>(PlayoutRepository.GetChannelInfos(true));
 }
Exemplo n.º 27
0
 public void Initialize()
 {
     PlayoutRepository.Register(this.MachineName, this.ApplicationName);
 }
Exemplo n.º 28
0
 public static void SaveGlobalSetting(string name, string value, string tag = null, string groupName = null)
 {
     PlayoutRepository.SaveSetting(null, null, groupName, name, value, tag);
 }
Exemplo n.º 29
0
 public ChannelSelectionViewModel()
 {
     this.ChannelInfos = new ObservableCollection <ChannelInfo>(PlayoutRepository.GetChannelInfos());
 }
Exemplo n.º 30
0
 internal void Save()
 {
     PlayoutRepository.Save(this.SwitcherInfos.Except(_updatedItems).Where(i => i.IsNew() && !string.IsNullOrEmpty(i.Address)), _updatedItems, _removedItems, CreateInputInfo);
     _updatedItems.Clear();
     _removedItems.Clear();
 }