/// <summary> /// Gets the Channels from the server and updates both /// the Direct and Group message panels. /// </summary> public void FetchChannels(bool fetchmessages = true) { if (InvokeRequired) { Invoke(new Action(() => { FetchChannels(fetchmessages); })); return; } this.fetchedChannels = new List <Channel>(); foreach (var c in this.session.REST.GetAllChannels()) { this.fetchedChannels.Add(c); } try { this.currentChannel = this.currentChannel ?? this.fetchedChannels?[0]; if (fetchmessages) { SetCurrentViewedChannel((int)this.currentChannel?.ThreadId); } if (!this.panel7.TryCreateComponents <Channel>(this.fetchedChannels) || !this.panel8.TryCreateComponents <Channel>(this.fetchedChannels)) { MessageBox.Show("failed to create the sidepanel(s)."); Application.Exit(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private Channel PlaySound(LowLevelSystem system, Sound sound) { Console.WriteLine("Playing"); //Play the sound, but start it paused var channel = system.PlaySound(sound, null, true); //Set a callback on the channel, this is called for all events on the channel channel.SetCallback((type, data1, data2) => { //When we get the "end" event start playing the next sound if (type == ChannelControlCallbackType.End) { Console.WriteLine("Callback: Finished, playing next sound"); PlaySound(system, LoadNextSound(system)); } }); //Unpause the channel channel.Pause = false; //Save this channel _currentChannel = channel; return(channel); }
private bool ReportChannelPosition(Channel?channel, string trackId, AudioTypes audioType, ref int?lastPos) { if (channel.HasValue) { var chn = channel.Value; int?pos = (int?)chn.GetPosition(TimeUnit.Milliseconds); if (pos == lastPos) { return(false); } lastPos = pos; if (pos.HasValue) { SendMessage(new AudioPositionChanged { Id = trackId, Type = audioType, Position = pos.Value }); return(true); } } lastPos = null; return(false); }
private void DoCount(WI_Count req) { var promise = req.Promise; try { Channel?ch = GetChannelOrNull(req.Variable); if (ch == null) { promise.SetResult(0); } else { Timestamp start = req.StartInclusive; Timestamp end = req.EndInclusive; QualityFilter filter = req.Filter; long res; if (start == Timestamp.Empty && end == Timestamp.Max && filter == QualityFilter.ExcludeNone) { res = ch.CountAll(); } else { res = ch.CountData(start, end, Map(filter)); } promise.SetResult(res); } } catch (Exception exp) { promise.SetException(exp); } }
private void DoDeleteInterval(WI_DeleteInterval req) { var promise = req.Promise; try { Channel?ch = GetChannelOrNull(req.Variable); if (ch == null) { promise.SetResult(0); } else { Timestamp start = req.StartInclusive; Timestamp end = req.EndInclusive; long res; if (start == Timestamp.Empty && end == Timestamp.Max) { res = ch.DeleteAll(); } else { res = ch.DeleteData(req.StartInclusive, req.EndInclusive); } promise.SetResult(res); } } catch (Exception exp) { promise.SetException(exp); } }
private void currentChannelChanged(ValueChangedEvent <Channel> channel) { Channel?newChannel = channel.NewValue; loading.Show(); // Channel is null when leaving the currently selected channel if (newChannel == null) { // Find another channel to switch to newChannel = channelManager.JoinedChannels.FirstOrDefault(c => c != channel.OldValue); if (newChannel == null) { selectorActive.Value = true; } else { currentChannel.Value = newChannel; } return; } LoadComponentAsync(new DrawableChannel(newChannel), loaded => { currentChannelContainer.Clear(); currentChannelContainer.Add(loaded); loading.Hide(); }); }
/// <summary> /// Sets the currently viewed channel and updates the message box pane. /// </summary> /// <param name="index">the id of the channel</param> public void SetCurrentViewedChannel(int id) { if (InvokeRequired) { Invoke(new Action(() => { SetCurrentViewedChannel(id); })); return; } if (id == this.currentChannel?.ThreadId) { return; } IEnumerable <Entity> list = this.fetchedChannels.Any(u => u.ThreadId == id)? this.fetchedChannels.Where(u => u.ThreadId == id).Select(u => (Entity)u).ToList <Entity>():null; this.currentChannel = (Channel)(list.Any() ? list.First() : null); this.label42.Text = this.currentChannel?.Title; this.label2.Text = this.currentChannel?.Description; if (this.currentChannel?.ManagerUser == this.user?.UserId) { this.button1.Enabled = true; this.button1.Visible = true; } else { this.button1.Enabled = false; this.button1.Visible = false; } this.panel4.FetchMessages((Channel)this.currentChannel); }
private void PlayTrack() { if (this.fmodSystem == null) { return; } var sound = this.currentTrkSound; if (!sound.HasValue) { // No sound loaded return; } try { var chn = this.currentTrkChannel; if (chn.HasValue) { // Make sure we reset this first so we can ignore the callback this.currentTrkChannel = null; chn?.Stop(); } } catch (FmodInvalidHandleException) { // Ignore } var channel = this.fmodSystem.PlaySound(sound.Value, this.trkGroup, true); string trackName = this.currentTrack; channel.SetCallback((type, data1, data2) => { if (type == ChannelControlCallbackType.End) { this.log.Debug("Track {0} ended", trackName); SendMessage(new AudioFinished { Id = trackName, Type = AudioTypes.Track }); } }); this.currentTrkChannel = channel; // Play channel.Pause = false; // Send status message SendMessage(new AudioStarted { Id = trackName, Type = AudioTypes.Track }); }
/// <summary> /// Set the update channel. /// </summary> public void SetChannel(Channel channel) { this.channel = channel; var channelFile = Path.Combine(config.Get("home"), "update-channel"); fileSystem.Write(channelFile, channel.ToString()); io.WriteError($"Write the channel file: {channelFile}", true, Verbosities.Debug); }
protected override async Task <BoolResult> StartupCoreAsync(OperationContext context) { _channel = new Channel(_configuration.GrpcHost, _configuration.GrpcPort, ChannelCredentials.Insecure); await _channel.ConnectAsync(); _client = new Grpc.RoxisService.RoxisServiceClient(_channel); return(BoolResult.Success); }
/// <summary> /// Initializes a new instance of the <see cref="DeliveryResult" /> class. /// </summary> /// <param name="status">status.</param> /// <param name="channel">channel.</param> /// <param name="messageId">Unique identifier for the message.</param> /// <param name="error">Human-readable description of what went wrong, *null* in case of success or if the message has not been processed yet.</param> /// <param name="err">err.</param> /// <param name="timestamp">When this status was received by Omnichannel API.</param> public DeliveryResult(Status?status = default(Status?), Channel?channel = default(Channel?), string messageId = default(string), string error = default(string), ErrorCodeOmnichannelMachine?err = default(ErrorCodeOmnichannelMachine?), DateTime?timestamp = default(DateTime?)) { this.Status = status; this.Channel = channel; this.MessageId = messageId; this.Error = error; this.Err = err; this.Timestamp = timestamp; }
public override void AddOrUpdate_Add_Duplicate_Keeps_Collection_Count_Before_Save() { Channel?channel = RandomLocalChannel; int cntGuild = channel.Guild.Channels.Count; _context.AddOrUpdate(channel); Assert.AreEqual(cntGuild, channel.Guild.Channels.Count); }
private static async Task <int> Main(string[] args) { string hostname = RequireEnvValue("HELIUM_CI_SERVER_HOST"); int port = RequireEnvValueInt("HELIUM_CI_SERVER_PORT"); string apiKey = RequireEnvValue("HELIUM_CI_AGENT_KEY"); int maxJobs = Environment.GetEnvironmentVariable("HELIUM_CI_AGENT_MAX_JOBS") is {} maxJobStr&& int.TryParse(maxJobStr, out var maxJobsInt) ? maxJobsInt : 1; var logger = LoggerFactory.Create(builder => { builder.SetMinimumLevel(LogLevel.Trace); builder.AddConsole(); }).CreateLogger("helium-agent"); foreach (var dir in Directory.GetDirectories(AgentWorkspacesDir)) { Directory.Delete(dir, recursive: true); } Console.WriteLine("Helium CI Agent"); Channel?channel = null; var cancel = new CancellationTokenSource(); Console.CancelKeyPress += (_, e) => { if (!cancel.IsCancellationRequested) { e.Cancel = true; cancel.Cancel(); channel?.ShutdownAsync(); } }; channel = new Channel(hostname, port, ChannelCredentials.Insecure); try { var client = new BuildServer.BuildServerClient(channel); var runner = new BuildAgent(logger, client, apiKey, AgentWorkspacesDir, maxJobs); await runner.JobLoop(cancel.Token); } catch (OperationCanceledException) {} finally { try { await channel.ShutdownAsync(); } catch {} } return(0); }
/// <summary> /// Lists trackers for the guild in which the command was sent in /// </summary> /// <param name="message">The request message</param> /// <param name="discordService">The discord service</param> /// <param name="context">The database context</param> private static async Task ListTrackersAsync( SocketMessage message , DiscordService discordService , DatabaseContext context ) { Channel?channel = context.GetChannel(message.Channel.Id); if (channel == null) { return; } IEnumerable <Tracker> trackers = context.GetActiveTrackers(channel.Guild); if (!trackers.Any()) { await discordService .ReplyAsync(message, "No active trackers found!") .ConfigureAwait(false); return; } int gameAbbreviationLength = Math .Max(trackers .OrderByDescending(t => t.Game.Abbreviation.Length) .Select(t => t.Game) .First() .Abbreviation.Length + 2 , "Abbreviation".Length + 2); int gameNameLength = trackers .OrderByDescending(t => t.Game.Name.Length) .Select(t => t.Game) .First() .Name .Length + 2; string reply = "```\r\n"; reply += "Abbreviation".PadRight(gameAbbreviationLength); reply += "Game".PadRight(gameNameLength); reply += "Channel\r\n"; foreach (Tracker tracker in trackers) { string entry = $"{tracker.Game.Abbreviation.PadRight(gameAbbreviationLength)}{tracker.Game.Name.PadRight(gameNameLength)}#{tracker.Channel.DisplayName}"; reply += $"{entry}\r\n"; } reply += "```"; await discordService.ReplyAsync(message, reply).ConfigureAwait(false); }
public Task ConnectAsync() { var credentials = _useClientCertificate ? GetCertificateCredentials() : ChannelCredentials.Insecure; _channel = new Channel(Target, credentials); _client = new Greeter.GreeterClient(_channel); return(_channel.ConnectAsync()); }
private void OnChannelDeleted(JsonChannel arg) { Channel?channel = Channels.RemoveChannel(arg.Id); if (channel is null) { return; } ChannelDeleted?.Invoke(this, channel); }
public Invite(string code, Guild?guild, Channel?channel, User?inviter, User?targerUser, TargetUserType?targetUserType, int?approximatePresenceCount, int approximateMemberCount) { Code = code; Guild = guild; Channel = channel; Inviter = inviter; TargerUser = targerUser; TargetUserType = targetUserType; ApproximatePresenceCount = approximatePresenceCount; ApproximateMemberCount = approximateMemberCount; }
/// <summary> /// 指定されたチャンネル又はスレッドに表示するメッセージのIDとReactionLogIDの最大値、レコード数を取得する。 /// </summary> /// <param name="channel">対象チャンネル</param> /// <param name="parentMessage">対象スレッドの親メッセージID</param> /// <returns>メッセージごとのReactionLogIDの最大値と数</returns> /// <remarks><paramref name="channel"/>, <paramref name="parentMessage"/>のどちらかに値を設定すること</remarks> private DataTable SelectMaxReactionIds(Channel?channel, Message?parentMessage) { // SQL組み立て StringBuilder sql = new StringBuilder(); sql.Append("SELECT "); sql.Append("message.id AS message_id, "); sql.Append("MAX(reactionLog.id) AS max_reaction_log_id, "); sql.Append("COUNT(reactionLog.id) AS reaction_log_count "); sql.Append($"FROM {MessageTableName} AS message "); sql.Append($"LEFT OUTER JOIN {ReactionLogDAO.ReactionLogTableName} AS reactionLog "); sql.Append("ON message.ID = reactionLog.message_id "); sql.Append("WHERE "); if (channel != null) { sql.Append("message.channel_id = @channel_id "); sql.Append("AND message.displays_to_channel = 1 "); } else { sql.Append("message.id = @parent_message_id OR message.parent_message_id = @parent_message_id "); } sql.Append("AND message.is_deleted = 0 "); sql.Append("GROUP BY message.id; "); using var con = Connection.Create(); using var cmd = con.CreateCommand(); cmd.CommandText = sql.ToString(); // パラメータ生成 & 値設定 if (channel != null) { cmd.Parameters.Add("@channel_id", MySqlDbType.Int32); cmd.Parameters["@channel_id"].Value = channel.Id; } else { cmd.Parameters.Add("@parent_message_id", MySqlDbType.Int32); cmd.Parameters["@parent_message_id"].Value = parentMessage !.Id; } cmd.Prepare(); // SQL実行 using var da = new MySqlDataAdapter(cmd); using var dt = new DataTable(); da.Fill(dt); return(dt); }
public override void AddOrUpdate_Add_Increases_Collection_Count_Before_Save() { Game? game = RandomLocalGame; Channel?channel = RandomLocalChannel; int cntGame = game.Trackers.Count; int cntChannel = channel.Trackers.Count; Tracker tracker = new Tracker(channel, game); _context.AddOrUpdate(tracker); Assert.AreEqual(cntGame + 1, game.Trackers.Count); Assert.AreEqual(cntChannel + 1, channel.Trackers.Count); }
private byte GetAdcControlWord(Maxim186Configuration config, Channel?channel = null) { int word = 0; channel = channel ?? config.Channel; word = 1 << 7; // Reserved Bit word |= (int)channel.Value << 4; // channel word |= (int)config.Polarity << 3; word |= (int)config.ConversionType << 2; word |= (int)config.PowerMode; return((byte)word); }
public void SwapChannel(Channel?channel) { if (channel == null) { return; } var nonNullChannel = channel.Value; _previousChannel = _currentChannel; _currentChannel = channel; _deltinSwapper.SwapChannel(nonNullChannel); }
public override void AddOrUpdate_Add_Duplicate_Keeps_Collection_Count_After_Save() { Channel?channel = RandomLocalChannel; int cntGuild = channel.Guild.Channels.Count; _context.AddOrUpdate(channel); SaveChanges(); Guild guild = _context.GetGuild(channel.Guild.Snowflake); Assert.IsNotNull(guild); Assert.AreEqual(cntGuild, guild.Channels.Count); }
private void Ofd_FileOk(object sender, System.ComponentModel.CancelEventArgs e) { sourceBitmap = new StegoBitmap(ofd.FileName); imgSource.Source = GetSource(sourceBitmap.GetImage()); Channel?result = Stego.HasHiddenValue(sourceBitmap); if (result.HasValue) { tbInput.Text = Stego.GetHiddenValue(sourceBitmap, result.Value); } else { CalculateLabels(); } }
private void Init() { if (client != null) { return; } var section = configuration.GetSection("FileServer"); channel = new Channel($"{section["HostName"]}:{section["Port"]}", ChannelCredentials.Insecure, new[] { new ChannelOption(ChannelOptions.MaxReceiveMessageLength, 2147483647), new ChannelOption(ChannelOptions.MaxSendMessageLength, 150 * 1048576) }); client = new Files.FilesClient(channel); }
public static Channel AddOrUpdate(this DatabaseContext context, Channel channel) { Channel?c = GetChannel(context, channel.Snowflake); if (c == null) { context.Channels.Local.Add(channel); return(channel); } else { AssignAttributes(c, channel); return(c); } }
public async Task <ActionResult> _Guide(State?state, Channel?channel, int?days) { try { var model = await GetGuide( state ?? State.SA, channel ?? Channel.Seven, DateTime.Today.AddDays(days ?? 0)); return(PartialView(model)); } catch (Exception e) { return(Json(new { Success = false, Message = e.Message }, JsonRequestBehavior.AllowGet)); } }
public override void AddOrUpdate_Add_Duplicate_Keeps_Collection_Count_After_Save() { Tracker tracker = RandomLocalActiveTracker; int cntGame = tracker.Game.Trackers.Count; int cntChannel = tracker.Channel.Trackers.Count; _context.AddOrUpdate(tracker); SaveChanges(); Game? game = _context.GetGame(tracker.Game.Abbreviation); Channel?channel = _context.GetChannel(tracker.Channel.Snowflake); Assert.IsNotNull(game); Assert.IsNotNull(channel); Assert.AreEqual(cntGame, game.Trackers.Count); Assert.AreEqual(cntChannel, channel.Trackers.Count); }
public async Task ConnectAsync() { var credentials = _useClientCertificate ? GetCertificateCredentials() : ChannelCredentials.Insecure; _channel = new Channel(Target, credentials); _client = new GreetService.GreetServiceClient(_channel); await _channel.ConnectAsync(); var options = new CallOptions(deadline: _deadline, cancellationToken: _cts.Token); _call = _client.SayHellos(new HelloRequest { Name = "World" }, options); }
public override void AddOrUpdate_Add_Increases_Collection_Count_After_Save() { Game? game = RandomLocalGame; Channel?channel = _context.Channels.Local.First(c => !c.Trackers.Any(t => t.GameId.Equals(game.Id))); int cntGame = game.Trackers.Count; int cntChannel = channel.Trackers.Count; Tracker tracker = new Tracker(channel, game); _context.AddOrUpdate(tracker); SaveChanges(); game = _context.GetGame(game.Abbreviation); channel = _context.GetChannel(channel.Snowflake); Assert.IsNotNull(game); Assert.IsNotNull(channel); Assert.AreEqual(cntGame + 1, game.Trackers.Count); Assert.AreEqual(cntChannel + 1, channel.Trackers.Count); }
public int Compare(Channel?x, Channel?y) { int result; if (x != null) { result = x.Position.CompareTo(y?.Position); } else if (y != null) { result = -y.Position.CompareTo(x?.Position); } else { result = 0; } return(result); }
private void PlaySound(string fileName, bool playOnNewChannel, double leftVol = 1.0, double? rightVol = null) { if (this.fmodSystem == null) return; var sound = LoadSound(fileName); sound.LoopCount = 0; if (!playOnNewChannel) { try { this.currentFxChannel?.Stop(); } catch (FmodInvalidHandleException) { // Ignore } } var channel = this.fmodSystem.PlaySound(sound, this.fxGroup, true); if (!rightVol.HasValue) rightVol = leftVol; channel.FmodChannel.setMixLevelsOutput((float)leftVol, (float)rightVol.Value, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); // Play channel.Pause = false; if (!playOnNewChannel) this.currentFxChannel = channel; }
private void PlayNextBackground() { if (this.fmodSystem == null) return; // Find next background track if (this.backgroundAudioTracks.Count == 0) // No tracks return; int index; while (true) { index = this.random.Next(this.backgroundAudioTracks.Count - 1); if (this.backgroundAudioTracks.Count > 1 && this.currentBgTrack == index) continue; break; } this.currentBgTrack = index; string fileName = this.backgroundAudioTracks[index]; this.currentBgTrackName = Path.GetFileName(fileName); this.log.Info("Play background track {0}", Path.GetFileName(fileName)); var sound = this.fmodSystem.CreateStream(fileName, Mode.Default); try { var chn = this.currentBgChannel; if (chn.HasValue) { // Make sure we reset this first so we can ignore the callback this.currentBgChannel = null; chn?.Stop(); } } catch (FmodInvalidHandleException) { // Ignore } if (this.currentBgSound.HasValue) this.disposeList.Add(this.currentBgSound); this.currentBgSound = null; var channel = this.fmodSystem.PlaySound(sound, this.bgGroup, true); string bgName = this.currentBgTrackName; channel.SetCallback((type, data1, data2) => { if (type == ChannelControlCallbackType.End) { this.log.Debug("Background {0} ended", bgName); SendMessage(new AudioFinished { Id = bgName, Type = AudioTypes.Background }); if (this.currentBgChannel.HasValue) PlayNextBackground(); } }); this.currentBgSound = sound; this.currentBgChannel = channel; // Play channel.Pause = false; SendMessage(new AudioStarted { Id = bgName, Type = AudioTypes.Background }); }
private void PlayTrack() { if (this.fmodSystem == null) return; var sound = this.currentTrkSound; if (!sound.HasValue) // No sound loaded return; try { var chn = this.currentTrkChannel; if (chn.HasValue) { // Make sure we reset this first so we can ignore the callback this.currentTrkChannel = null; chn?.Stop(); } } catch (FmodInvalidHandleException) { // Ignore } var channel = this.fmodSystem.PlaySound(sound.Value, this.trkGroup, true); string trackName = this.currentTrack; channel.SetCallback((type, data1, data2) => { if (type == ChannelControlCallbackType.End) { this.log.Debug("Track {0} ended", trackName); SendMessage(new AudioFinished { Id = trackName, Type = AudioTypes.Track }); } }); this.currentTrkChannel = channel; // Play channel.Pause = false; // Send status message SendMessage(new AudioStarted { Id = trackName, Type = AudioTypes.Track }); }