/// <summary> /// Fill up the list with groups /// </summary> public void FillGroupList() { benchClock = Stopwatch.StartNew(); ChannelGroup current = null; _channelGroupList = TVHome.Navigator.Groups; // empty list of channels currently in the // spin control spinGroup.Reset(); // start to fill them up again for (int i = 0; i < _channelGroupList.Count; i++) { current = _channelGroupList[i]; spinGroup.AddLabel(current.GroupName, i); // set selected if (current.GroupName.CompareTo(TVHome.Navigator.CurrentGroup.GroupName) == 0) { spinGroup.Value = i; } } if (_channelGroupList.Count < 2) { spinGroup.Visible = false; } benchClock.Stop(); Log.Debug("TvMiniGuide: FillGroupList finished after {0} ms", benchClock.ElapsedMilliseconds.ToString()); }
private void RefreshTabs() { // bugfix for tab removal, RemoveAt fails sometimes tabControl1.TabPages.Clear(); tabControl1.TabPages.Add(tabPage1); IList <ChannelGroup> groups = ChannelGroup.ListAll(); foreach (ChannelGroup group in groups) { TabPage page = new TabPage(group.GroupName); page.SuspendLayout(); ChannelsInGroupControl channelsInRadioGroupControl = new ChannelsInGroupControl(); channelsInRadioGroupControl.Location = new System.Drawing.Point(9, 9); channelsInRadioGroupControl.Anchor = ((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right; page.Controls.Add(channelsInRadioGroupControl); page.Tag = group; page.Location = new System.Drawing.Point(4, 22); page.Padding = new Padding(3); page.Size = new System.Drawing.Size(457, 374); page.UseVisualStyleBackColor = true; page.PerformLayout(); page.ResumeLayout(false); tabControl1.TabPages.Add(page); } }
public bool GetChannels(IChannelGroup group, out IList <IChannel> channels) { channels = new List <IChannel>(); ChannelGroup indexGroup = group as ChannelGroup; if (indexGroup == null) { return(false); } if (!CheckConnection(indexGroup.ServerIndex)) { return(false); } try { IList <WebChannelBasic> tvChannels = TvServer(indexGroup.ServerIndex).GetChannelsBasic(group.ChannelGroupId); foreach (WebChannelBasic webChannel in tvChannels) { channels.Add(new Channel { ChannelId = webChannel.Id, Name = webChannel.Title, ServerIndex = indexGroup.ServerIndex }); } return(true); } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Error(ex.Message); return(false); } }
/// <summary> /// Tries to get a list of programs for all channels of the given <paramref name="channelGroup"/> and time range. /// </summary> /// <param name="channelGroup">Channel group</param> /// <param name="from">Time from</param> /// <param name="to">Time to</param> /// <param name="programs">Returns programs</param> /// <returns><c>true</c> if at least one program could be found</returns> public bool GetProgramsGroup(IChannelGroup channelGroup, DateTime @from, DateTime to, out IList <IProgram> programs) { programs = null; ChannelGroup indexGroup = channelGroup as ChannelGroup; if (indexGroup == null) { return(false); } if (!CheckConnection(indexGroup.ServerIndex)) { return(false); } programs = new List <IProgram>(); try { IList <WebChannelPrograms <WebProgramDetailed> > tvPrograms = TvServer(indexGroup.ServerIndex).GetProgramsDetailedForGroup(channelGroup.ChannelGroupId, from, to); foreach (WebProgramDetailed webProgramDetailed in tvPrograms.SelectMany(webPrograms => webPrograms.Programs)) { programs.Add(new Program(webProgramDetailed, indexGroup.ServerIndex)); } } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Error(ex.Message); return(false); } return(programs.Count > 0); }
public static void Suspend() { if (IsActive) { ChannelGroup.setPaused(true); } }
public static void Resume() { if (IsActive) { ChannelGroup.setPaused(false); } }
public static void SaveChannels(IEnumerable<string> channels) { var channelGroup = new ChannelGroup(); channelGroup.ChannelIds = channels; ApplicationData.Current.RoamingSettings.Values["Channels"] = channelGroup.ToJson(); ApplicationData.Current.SignalDataChanged(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void start() throws Throwable public override void Start() { string className = this.GetType().Name; ExecutorService bossExecutor = newCachedThreadPool(daemon("Boss-" + className)); ExecutorService workerExecutor = newCachedThreadPool(daemon("Worker-" + className)); _bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(bossExecutor, workerExecutor, _config.MaxConcurrentTransactions)); _bootstrap.PipelineFactory = this; PortRangeSocketBinder portRangeSocketBinder = new PortRangeSocketBinder(_bootstrap); try { Connection connection = portRangeSocketBinder.BindToFirstAvailablePortInRange(_config.ServerAddress); Channel channel = connection.Channel; _socketAddress = connection.SocketAddress; _channelGroup = new DefaultChannelGroup(); _channelGroup.add(channel); _msgLog.info(className + " communication server started and bound to " + _socketAddress); } catch (Exception ex) { _msgLog.error("Failed to bind server to " + _socketAddress, ex); _bootstrap.releaseExternalResources(); _targetCallExecutor.shutdownNow(); _unfinishedTransactionExecutor.shutdownNow(); _silentChannelExecutor.shutdownNow(); throw new IOException(ex); } }
public void Stop(int channel, float blendTime = 0.0f, InterpolationType easeType = InterpolationType.InOutSine) { ChannelGroup channelGroup = GetChannelGroup(channel); if (channelGroup != null) { if (blendTime > 0.0f) { channelGroup._state = ChannelGroup.eState.Stopping; channelGroup._lerpSpeed = 1.0f / blendTime; channelGroup._lerpT = 0.0f; channelGroup._lerpEase = easeType; TrackEntry[] trackEntries = _animationState.Tracks.Items; if (IsTrackPlaying(trackEntries[channelGroup._primaryTrack._trackIndex])) { channelGroup._primaryTrack._origWeight = trackEntries[channelGroup._primaryTrack._trackIndex].Alpha; } for (int i = 0; i < channelGroup._backgroundTracks.Length; i++) { if (IsTrackPlaying(trackEntries[channelGroup._backgroundTracks[i]._trackIndex])) { channelGroup._backgroundTracks[i]._origWeight = trackEntries[channelGroup._backgroundTracks[i]._trackIndex].Alpha; } } } else { StopChannel(channelGroup); } } }
/// <summary> /// Tries to get a list of programs for all channels of the given <paramref name="channelGroup"/> and time range. /// </summary> /// <param name="channelGroup">Channel group</param> /// <param name="from">Time from</param> /// <param name="to">Time to</param> /// <returns><c>true</c> if at least one program could be found</returns> public async Task <AsyncResult <IList <IProgram> > > GetProgramsGroupAsync(IChannelGroup channelGroup, DateTime from, DateTime to) { ChannelGroup indexGroup = channelGroup as ChannelGroup; if (indexGroup == null || !CheckConnection(indexGroup.ServerIndex)) { return(new AsyncResult <IList <IProgram> >(false, null)); } var programs = new List <IProgram>(); try { IList <WebChannelPrograms <WebProgramDetailed> > tvPrograms = TvServer(indexGroup.ServerIndex).GetProgramsDetailedForGroup(channelGroup.ChannelGroupId, from, to); foreach (WebProgramDetailed webProgramDetailed in tvPrograms.SelectMany(webPrograms => webPrograms.Programs)) { programs.Add(new Program(webProgramDetailed, indexGroup.ServerIndex)); } } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Error(ex.Message); return(new AsyncResult <IList <IProgram> >(false, null)); } return(new AsyncResult <IList <IProgram> >(programs.Count > 0, programs)); }
public List <WebMiniEPG> GetTvMiniEPGForGroup(int idGroup) { List <WebMiniEPG> ret = new List <WebMiniEPG>(); if (!ConnectToDatabase()) { return(ret); } ChannelGroup group = null; try { group = ChannelGroup.Retrieve(idGroup); } catch (Exception) { } if (group == null) { return(ret); } IList <GroupMap> maps = group.ReferringGroupMap(); foreach (GroupMap map in maps) { ret.Add(new WebMiniEPG(map.ReferencedChannel())); } return(ret); }
private void LoadChannels() { try { _deletedChannels = new List <Channel>(); RefreshGuideChannels(); ChannelGroup group = _channelGroupControl.SelectedGroup; if (group != null) { _channels = new List <Channel>( Proxies.SchedulerService.GetChannelsInGroup(group.ChannelGroupId, false).Result); _isAllChannels = (group.ChannelGroupId == ChannelGroup.AllTvChannelsGroupId || group.ChannelGroupId == ChannelGroup.AllRadioChannelsGroupId); } else { _channels = new List <Channel>(); _isAllChannels = false; } _channelsBindingSource.DataSource = _channels; _channelsBindingSource.ResetBindings(false); } catch (Exception ex) { MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void MoveSelectedItemTo(MoveTo moveTo) { TreeNode node = _groupsTreeView.SelectedNode; if (node != null) { TreeNodeCollection nodes = node.Parent == null ? _groupsTreeView.Nodes : node.Parent.Nodes; int index = node.Index; int newIndex = index; switch (moveTo) { case MoveTo.Top: newIndex = 0; break; case MoveTo.Bottom: newIndex = nodes.Count - 1; break; case MoveTo.Up: if (newIndex > 0) { newIndex--; } break; case MoveTo.Down: if (newIndex < nodes.Count) { newIndex++; } break; } if (index != newIndex) { _inMoving = true; try { _groupsTreeView.SelectedNode = null; nodes.RemoveAt(index); nodes.Insert(newIndex, node); if (node.Parent != null) { ChannelGroup currentGroup = node.Parent.Tag as ChannelGroup; _groupsWithDirtyChannels[currentGroup.ChannelGroupId] = true; RemoveCheckboxOnNode(node); } else { RemoveGroupChannelsCheckBoxes(node); } _groupsTreeView.SelectedNode = node; } finally { _inMoving = false; } } } }
public bool Connect(string hostname) { try { string connStr; string provider; if (!GetDatabaseConnectionString(out connStr, out provider)) { return(false); } RemoteControl.HostName = hostname; Gentle.Framework.ProviderFactory.SetDefaultProviderConnectionString(connStr); me = new User(); me.IsAdmin = true; groups = ChannelGroup.ListAll(); radioGroups = RadioChannelGroup.ListAll(); channels = Channel.ListAll(); mappings = GroupMap.ListAll(); cards = Card.ListAll(); } catch (Exception ex) { lastException = ex; RemoteControl.Clear(); return(false); } return(true); }
public async Task <ActionResult <GetResult> > Edit([FromBody] ChannelGroup request) { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, MenuUtils.SitePermissions.SettingsContentGroup)) { return(Unauthorized()); } var groupInfo = await _contentGroupRepository.GetAsync(request.SiteId, request.Id); if (groupInfo.GroupName != request.GroupName && await _contentGroupRepository.IsExistsAsync(request.SiteId, request.GroupName)) { return(this.Error("保存失败,已存在相同名称的内容组!")); } groupInfo.GroupName = request.GroupName; groupInfo.Description = request.Description; await _contentGroupRepository.UpdateAsync(groupInfo); await _authManager.AddSiteLogAsync(request.SiteId, "修改内容组", $"内容组:{groupInfo.GroupName}"); var groups = await _contentGroupRepository.GetContentGroupsAsync(request.SiteId); return(new GetResult { Groups = groups }); }
public async Task <AsyncResult <IList <IChannel> > > GetChannelsAsync(IChannelGroup group) { var channels = new List <IChannel>(); ChannelGroup indexGroup = group as ChannelGroup; if (indexGroup == null || !CheckConnection(indexGroup.ServerIndex)) { return(new AsyncResult <IList <IChannel> >(false, null)); } try { IList <WebChannelBasic> tvChannels = TvServer(indexGroup.ServerIndex).GetChannelsBasic(group.ChannelGroupId); foreach (WebChannelBasic webChannel in tvChannels) { channels.Add(new Channel { ChannelId = webChannel.Id, Name = webChannel.Title, ServerIndex = indexGroup.ServerIndex }); } return(new AsyncResult <IList <IChannel> >(true, channels)); } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Error(ex.Message); return(new AsyncResult <IList <IChannel> >(false, null)); } }
private bool EnsureGroupChannels(TreeNode groupNode) { ChannelGroup group = groupNode.Tag as ChannelGroup; if (group != null) { if (groupNode.Nodes.Count == 1 && groupNode.Nodes[0].Text == _dummyChannelItemText) { try { var channels = Proxies.SchedulerService.GetChannelsInGroup(group.ChannelGroupId, false).Result; groupNode.Nodes.Clear(); foreach (Channel channel in channels) { AddChannelNode(groupNode, channel); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } } return(true); }
public void Stop(int channel, float blendTime = 0.0f, InterpolationType easeType = InterpolationType.InOutSine) { ChannelGroup channelGroup = GetChannelGroup(channel); if (channelGroup != null) { if (blendTime > 0.0f) { channelGroup._state = ChannelGroup.State.Stopping; channelGroup._lerpSpeed = 1.0f / blendTime; channelGroup._lerpT = 0.0f; channelGroup._lerpEase = easeType; if (IsChannelLayerPlaying(channelGroup._primaryLayer)) { channelGroup._primaryLayer._origWeight = channelGroup._primaryLayer._animation.weight; } for (int i = 0; i < channelGroup._backgroundLayers.Length; i++) { if (IsChannelLayerPlaying(channelGroup._backgroundLayers[i])) { channelGroup._backgroundLayers[i]._origWeight = channelGroup._backgroundLayers[i]._animation.weight; } } } else { StopChannel(channelGroup); } } }
private List <ChannelGroup> GetChangedGroups() { List <ChannelGroup> changedGroups = new List <ChannelGroup>(); string previousName = null; int sequence = 0; foreach (TreeNode groupNode in _groupsTreeView.Nodes) { ChannelGroup channelGroup = groupNode.Tag as ChannelGroup; if (previousName != null) { if (String.Compare(channelGroup.GroupName, previousName, StringComparison.InvariantCultureIgnoreCase) < 0) { sequence++; } } bool hasChanged = channelGroup.VisibleInGuide != groupNode.Checked || channelGroup.Sequence != sequence || channelGroup.ChannelGroupId == Guid.Empty || _changedGroupIds.Contains(channelGroup.ChannelGroupId); channelGroup.VisibleInGuide = groupNode.Checked; channelGroup.Sequence = sequence; if (hasChanged) { changedGroups.Add(channelGroup); } previousName = channelGroup.GroupName; } return(changedGroups); }
public List <WebChannel> GetChannelsInTvGroup(int idGroup) { List <WebChannel> channels = new List <WebChannel>(); if (!ConnectToDatabase()) { return(channels); } ChannelGroup group = null; try { group = ChannelGroup.Retrieve(idGroup); } catch (Exception) { } if (group == null) { return(channels); } IList <GroupMap> maps = group.ReferringGroupMap(); foreach (GroupMap map in maps) { channels.Add(new WebChannel(map.ReferencedChannel())); } return(channels); }
public IActionResult Gray() { ChannelGroup status = new ChannelGroup(); ViewBag.Message = status.GetStatus(); return(View()); }
public static void Async(ChannelGroup group) { foreach (var user in group.Channels) { if (user.ChannelId == FilePaths.ConfigExampleText) { CError.ErrorExampleObjectFound(); return; } CMessage.InctanceStarted(user, true); switch (user.Platform) { case Platform.Trovo: var TrovoGQL = new TrovoPluginGQL(user.ChannelId, TimeSpan.FromMinutes(user.MinutesTimeOut)); _ = TrovoGQL.RunInfinite(); break; case Platform.TrovoDeprecated: var OldTrovo = new TrovoPlugin(user.ChannelId, TimeSpan.FromMinutes(user.MinutesTimeOut)); _ = OldTrovo.RunInfinite(); // Discard await basically creates a new thread. break; case Platform.YouTube: var Runtime = new YouTubePlugin(user.ChannelId, TimeSpan.FromMinutes(user.MinutesTimeOut)); _ = Runtime.RunInfinite(); break; } } }
} // end private void InitForm() private void Reset() { ChannelGroup[] colGroups = null; ChannelGroup[] rowGroups = null; ChannelGroup masterColGroup = null; ChannelGroup masterRowGroup = null; Track treeTrack = null; pixel = 1; row = 1; col = 3; px = 1; dir = ""; face = ""; univ = 8; chNum = 388; pixelName = ""; dir = DirName(col); face = FaceName(col); txtCol.Text = col.ToString(); txtRow.Text = row.ToString(); txtPx.Text = px.ToString(); txtDir.Text = dir; txtFace.Text = face; txtPixel.Text = pixel.ToString("000"); txtUniv.Text = univ.ToString(); txtCh.Text = chNum.ToString("000"); pixelName = MakePixelName(); lblPixelName.Text = pixelName; }
private FMODAudioEngine() { FMODErr.Check(Factory.System_Create(ref _system)); uint version = 0; FMODErr.Check(_system.getVersion(ref version)); if (version < VERSION.number) { throw new ApplicationException( "Error! You are using an old version of FMOD " + version.ToString("X") + ". This program requires " + VERSION.number.ToString("X") + "."); } FMODErr.Check(_system.init(16, INITFLAG.NORMAL, IntPtr.Zero)); ChannelGroup channelGroup = null; FMODErr.Check(_system.getMasterChannelGroup(ref channelGroup)); _masterChannelGroup = new FMODGrouping(this, channelGroup); _scheduler = new EventLoopScheduler("AudioEngine"); _updateTimer = Observable.Interval(TimeSpan.FromMilliseconds(UpdateInterval), _scheduler).Do(_ => Update()); }
public override void MouseDown(NSEvent theEvent) { if (!ClickableGradients) { this.activeChannel = null; base.MouseDown(theEvent); return; } var location = ConvertPointFromView(theEvent.LocationInWindow, null); location = ConvertPointToLayer(location); foreach (var layer in Layer.Sublayers) { var hit = layer.PresentationLayer.HitTest(location) ?? layer.PresentationLayer.HitTest(new CGPoint(location.X, location.Y + 4)); for (var currentLayer = hit; currentLayer != null; currentLayer = currentLayer.SuperLayer) { this.activeChannel = Editors.FirstOrDefault(ce => ce.Gradient == currentLayer.ModelLayer); if (this.activeChannel != null) { var channel = this.activeChannel.Editor.ComponentEditor; var grad = this.activeChannel.Gradient; ViewModel.Color = channel.UpdateColorFromLocation( grad, ViewModel.Color, Layer.ConvertPointToLayer(location, grad.SuperLayer)); return; } } } base.MouseDown(theEvent); }
public async Task GetChannelGroupAndChannelData(string jsonPath) { GetAdapterAndLogin(); try { var channelHierarchy = new ChannelHierarchy(); var channelGroup = new ChannelGroup { ObjectID = "_", ChannelGroupName = string.Empty }; _cameras = _adapter.Cameras().ToList(); foreach (var camera in _cameras) { channelGroup.Channels.Add(new Channel { Name = camera.GetDisplayName(), ObjectID = camera.GetID() }); } channelHierarchy.ChannelGroups.Add(channelGroup); FileHelper.Serialize(channelHierarchy, jsonPath); } catch (Exception ex) { throw ex; } await Task.CompletedTask; }
public override void OnSectionActivated() { _cards = Card.ListAll(); base.OnSectionActivated(); RemoteControl.Instance.EpgGrabberEnabled = true; comboBoxGroups.Items.Clear(); IList <ChannelGroup> groups = ChannelGroup.ListAll(); foreach (ChannelGroup group in groups) { comboBoxGroups.Items.Add(new ComboBoxExItem(group.GroupName, -1, group.IdGroup)); } if (comboBoxGroups.Items.Count == 0) { comboBoxGroups.Items.Add(new ComboBoxExItem("(no groups defined)", -1, -1)); } comboBoxGroups.SelectedIndex = 0; timer1.Enabled = true; mpListView1.Items.Clear(); _repeat = chkRepeatTest.Checked; _channelNames = new Dictionary <int, string>(); IList <Channel> channels = Channel.ListAll(); foreach (Channel ch in channels) { _channelNames.Add(ch.IdChannel, ch.DisplayName); } _rndFrom = txtRndFrom.Value; _rndTo = txtRndTo.Value; }
public async Task <ActionResult <GetResult> > Add([FromBody] ChannelGroup request) { if (!await _authManager.HasSitePermissionsAsync(request.SiteId, Types.SitePermissions.SettingsContentGroup)) { return(Unauthorized()); } if (await _contentGroupRepository.IsExistsAsync(request.SiteId, request.GroupName)) { return(this.Error("保存失败,已存在相同名称的内容组!")); } var groupInfo = new ContentGroup { SiteId = request.SiteId, GroupName = request.GroupName, Description = request.Description }; await _contentGroupRepository.InsertAsync(groupInfo); await _authManager.AddSiteLogAsync(request.SiteId, "新增内容组", $"内容组:{groupInfo.GroupName}"); var groups = await _contentGroupRepository.GetContentGroupsAsync(request.SiteId); return(new GetResult { Groups = groups }); }
bool IsActive() { ChannelGroup masterGroup = MasterChannelGroup; bool masterGroupPaused = masterGroup == null || masterGroup.Pause; bool active = !masterGroupPaused; if (active && _SuspendWorkingWhenApplicationIsNotActive) { if (PlatformInfo.Platform == PlatformInfo.Platforms.Windows) { IntPtr h = hWnd; while (h != IntPtr.Zero) { active = IsWindow(h) != 0 && IsWindowVisible(h) != 0 && IsIconic(h) == 0; if (!active) { break; } h = GetParent(h); } } else { if (EngineApp.Instance.SystemPause) { active = false; } } } return(active); }
private ChannelGroup CreateEditor(IHostResourceProvider hostResources, ChannelEditor editor) { var ce = new ChannelGroup { Label = new UnfocusableTextField { StringValue = $"{editor.Name}:", Alignment = NSTextAlignment.Right, ToolTip = editor.ToolTip }, Editor = new ComponentSpinEditor(hostResources, editor) { BackgroundColor = NSColor.Clear, TranslatesAutoresizingMaskIntoConstraints = true }, Gradient = new UnanimatedGradientLayer { StartPoint = new CGPoint(0, 0), EndPoint = new CGPoint(1, 0), BorderWidth = .5f, } }; ce.Editor.ValueChanged += UpdateComponent; ce.Editor.EditingEnded += UpdateComponent; AddSubview(ce.Label); AddSubview(ce.Editor); Layer.AddSublayer(ce.Gradient); return(ce); }
public async Task <ActionResult <ListResult> > Add([FromBody] AddRequest request) { if (await _channelGroupRepository.IsExistsAsync(request.SiteId, request.GroupName)) { return(this.Error("保存失败,已存在相同名称的栏目组!")); } var groupInfo = new ChannelGroup { SiteId = request.SiteId, GroupName = request.GroupName, Description = request.Description }; await _channelGroupRepository.InsertAsync(groupInfo); await _authManager.AddSiteLogAsync(request.SiteId, "新增栏目组", $"栏目组:{groupInfo.GroupName}"); var groups = await _channelGroupRepository.GetChannelGroupsAsync(request.SiteId); var groupNames = groups.Select(x => x.GroupName); return(new ListResult { GroupNames = groupNames, Groups = groups }); }
public RESULT getChannelGroup(out ChannelGroup group) { group = null; IntPtr raw = 0; RESULT rESULT = Bus.FMOD_Studio_Bus_GetChannelGroup(this.rawPtr, out raw); if (rESULT != RESULT.OK) { return rESULT; } group = new ChannelGroup(raw); return rESULT; }
public ActionResult CreateChannelIndex2(int? id) { ChannelGroup model = null; if (id.HasValue) { model = bll.GetObjectById(x => x.ID == id.Value); return View("CreateChannel", model); } else { model = new ChannelGroup(); } return View("CreateChannel", model); }
// private static void Init() { if (initialized) return; if (SoundWorld.Instance == null) return; musicChannelGroup = SoundWorld.Instance.CreateChannelGroup(); if (musicChannelGroup != null) SoundWorld.Instance.MasterChannelGroup.AddGroup(musicChannelGroup); initialized = true; }
public JsonResult UpdateChannelGroup(ChannelGroup model) { string msg; if (!ModelState.IsValid) { msg = "数据验证失败"; return Json(new { Status = false, Message = msg }); } model.EnterpriseID = LoginUser.UserBasic.EnterpriseID; if (bll.UpdateChannelGroup(model, out msg)) { return Json(new { Status = true, Message = msg }); } return Json(new { Status = false, Message = msg }); }
public ActionResult CreateChannelGroup(ChannelGroup model) { string msg; ReturnData<string> returnData = new ReturnData<string>(); if (!ModelState.IsValid) { msg = "数据验证失败"; return Json(new { Status = false, Message = msg }); } model.EnterpriseID = LoginUser.UserBasic.EnterpriseID; bool success = bll.AddChannelGroup(model, out msg); if (success) { return Json(new { Status = true, Message = msg }); } return Json(new { Status = false, Message = msg }); }
public Main(Arguments args) { this.log = LogManager.GetLogger("Main"); this.fileStoragePath = args.FileStoragePath; // Clean up temp folder string tempFolder = Path.Combine(this.fileStoragePath, "tmp"); Directory.CreateDirectory(tempFolder); Directory.GetDirectories(tempFolder).ToList().ForEach(x => Directory.Delete(x, true)); if (!string.IsNullOrEmpty(args.VideoSystem)) { switch (args.VideoSystem.ToLower()) { case "omx": this.videoSystem = VideoSystems.OMX; break; default: throw new ArgumentException("Invalid video system type"); } } else this.videoSystem = VideoSystems.None; if (args.AudioSystem && this.videoSystem != VideoSystems.None) throw new ArgumentException("Cannot support both audio and video system concurrently"); if (this.videoSystem != VideoSystems.None) { // Disable console log output this.log.Info("Video System, turning off console logging and cursor"); var logConfig = LogManager.Configuration; var consoleTargets = new List<string>(); consoleTargets.AddRange(logConfig.AllTargets .OfType<NLog.Targets.ColoredConsoleTarget>() .Select(x => x.Name)); consoleTargets.AddRange(logConfig.AllTargets .OfType<NLog.Targets.ConsoleTarget>() .Select(x => x.Name)); foreach (var loggingRule in logConfig.LoggingRules) { loggingRule.Targets .Where(x => consoleTargets.Contains(x.Name) || consoleTargets.Contains(x.Name + "_wrapped")) .ToList() .ForEach(x => loggingRule.Targets.Remove(x)); } LogManager.Configuration = logConfig; Console.CursorVisible = false; Console.Clear(); } this.loadedSounds = new Dictionary<string, Sound>(); this.currentBgTrack = -1; this.random = new Random(); this.disposeList = new List<IDisposable>(); this.serialPorts = new Dictionary<int, SerialPort>(); string fileStoragePath = Path.GetFullPath(args.FileStoragePath); Directory.CreateDirectory(fileStoragePath); this.soundEffectPath = Path.Combine(fileStoragePath, FileTypes.AudioEffect.ToString()); this.trackPath = Path.Combine(fileStoragePath, FileTypes.AudioTrack.ToString()); this.videoPath = Path.Combine(fileStoragePath, FileTypes.Video.ToString()); this.autoStartBackgroundTrack = args.BackgroundTrackAutoStart; // Try to read instance id from disk try { using (var f = File.OpenText(Path.Combine(fileStoragePath, "MonoExpander_InstanceId.txt"))) { this.instanceId = f.ReadLine(); } } catch { // Generate new this.instanceId = Guid.NewGuid().ToString("n"); using (var f = File.CreateText(Path.Combine(fileStoragePath, "MonoExpander_InstanceId.txt"))) { f.WriteLine(this.instanceId); f.Flush(); } } this.log.Info("Instance Id {0}", this.instanceId); this.log.Info("Video Path {0}", this.videoPath); this.log.Info("Track Path {0}", this.trackPath); this.log.Info("FX Path {0}", this.soundEffectPath); this.backgroundAudioTracks = new List<string>(); if (!string.IsNullOrEmpty(args.BackgroundTracksPath)) { this.backgroundAudioTracks.AddRange(Directory.GetFiles(args.BackgroundTracksPath, "*.wav")); this.backgroundAudioTracks.AddRange(Directory.GetFiles(args.BackgroundTracksPath, "*.mp3")); } if (args.AudioSystem) { this.log.Info("Initializing FMOD sound system"); this.fmodSystem = new LowLevelSystem(); this.fxGroup = this.fmodSystem.CreateChannelGroup("FX"); this.trkGroup = this.fmodSystem.CreateChannelGroup("Track"); this.bgGroup = this.fmodSystem.CreateChannelGroup("Background"); } if (SupersonicSound.Wrapper.Util.IsUnix) { this.log.Info("Initializing PiFace"); try { this.piFace = new PiFaceDigitalDevice(); // Setup events foreach (var ip in this.piFace.InputPins) { ip.OnStateChanged += (s, e) => { SendInputMessage(e.pin.Id, e.pin.State); }; // Send current state SendInputMessage(ip.Id, ip.State); } } catch (Exception ex) { this.log.Warn(ex, "Failed to initialize PiFace"); } } if (!string.IsNullOrEmpty(args.SerialPort0) && args.SerialPort0BaudRate > 0) { this.log.Info("Initialize serial port 0 ({0}) for {1} bps", args.SerialPort0, args.SerialPort0BaudRate); var serialPort = new SerialPort(args.SerialPort0, args.SerialPort0BaudRate); serialPort.Open(); this.serialPorts.Add(0, serialPort); } this.log.Info("Initializing ExpanderCommunication client"); this.connections = new List<Tuple<IClientCommunication, MonoExpanderClient>>(); foreach (var server in args.Servers) { var client = new MonoExpanderClient(this); #if SIGNALR var communication = new SignalRClient( host: server.Host, port: server.Port, instanceId: InstanceId, dataReceivedAction: (t, d) => DataReceived(client, t, d)); #endif #if NETTY var communication = new NettyClient( host: server.Host, port: server.Port, instanceId: InstanceId, dataReceivedAction: (t, d) => DataReceived(client, t, d), connectedAction: () => SendMessage(new Ping())); #endif this.connections.Add(Tuple.Create((IClientCommunication)communication, client)); Task.Run(async () => await communication.StartAsync()).Wait(); } }
public bool ReadAllChannelGroups(out IList<IChannelGroup> allChannelGroups) { allChannelGroups = new List<IChannelGroup>(); try { string response = string.Empty; string command = PipeCommands.ReadAllChannelGroups.ToString(); Log.Debug("command=" + command); response = PipeClient.Instance.RunSingleCommand(command); Log.Debug("response=" + response); string[] allChannelGroupsString = response.Split('\n'); for (int i = 0; i < (allChannelGroupsString.Length-1) / 2; i++) { ChannelGroup mychannelgroup = new ChannelGroup(); mychannelgroup.Id = int.Parse(allChannelGroupsString[2*i]); mychannelgroup.GroupName = allChannelGroupsString[2*i + 1]; allChannelGroups.Add(mychannelgroup); } } catch (Exception exc) { Log.Debug("***Error ReadAllChannelGroups: Exception=" + exc.Message); return false; } return true; }
public bool ReadAllChannelGroups(out IList<ChannelGroup> allgroups) { allgroups = new List<ChannelGroup>(); try { IList<WebChannelGroup> tvGroups = TvServer(_server_index).GetGroups(); foreach (WebChannelGroup mychannelgroup in tvGroups) { ChannelGroup item = new ChannelGroup(); item.Id = mychannelgroup.Id; item.GroupName = mychannelgroup.GroupName; allgroups.Add(item); } return true; } catch (Exception ex) { Log.Error(ex.Message); } return false; }
private void ValidateChannelGroups(ChannelGroup[] channelGroups) { Assert.IsNotNull(channelGroups); Assert.IsNotEmpty(channelGroups); CollectionAssert.AllItemsAreUnique(channelGroups.Select(group => group.GroupName)); CollectionAssert.AllItemsAreUnique(channelGroups.Select(group => group.GroupId)); foreach (var group in channelGroups) { Assert.IsNotNull(group); Assert.IsNotEmpty(group.GroupName); Assert.IsNotEmpty(group.Channels); foreach (var channel in group.Channels) { Validator.ValidateChannel(channel); } } var channels = channelGroups.SelectMany(group => group.Channels).ToList(); Assert.IsTrue(channels.Any(channel => !string.IsNullOrEmpty(channel.Description))); Assert.IsTrue(channels.Any(channel => channel.SongCount > 0)); }