コード例 #1
0
        public async Task SendAsync(UserNotification notification, ChannelSetting setting, string configuration, SendOptions options,
                                    CancellationToken ct)
        {
            if (options.IsUpdate)
            {
                return;
            }

            using (Telemetry.Activities.StartActivity("MessagingChannel/SendAsync"))
            {
                var job = new MessagingJob(notification, setting);

                var integrations = integrationManager.Resolve <IMessagingSender>(options.App, notification);

                foreach (var(_, sender) in integrations)
                {
                    await sender.AddTargetsAsync(job, options.User);
                }

                // Should not happen because we check before if there is at least one target.
                if (job.Targets.Count == 0)
                {
                    await UpdateAsync(notification, ProcessStatus.Skipped);
                }

                await userNotificationQueue.ScheduleAsync(
                    job.ScheduleKey,
                    job,
                    job.Delay,
                    false, ct);
            }
        }
コード例 #2
0
        public async Task SendAsync(UserNotification notification, ChannelSetting setting, string configuration, SendOptions options,
                                    CancellationToken ct)
        {
            using (Telemetry.Activities.StartActivity("SmsChannel/SendAsync"))
            {
                var webhook = integrationManager.Resolve <WebhookDefinition>(configuration, options.App, notification);

                // The webhook must match the name or the conditions.
                if (webhook == null || !ShouldSend(webhook, options.IsUpdate, setting.Template))
                {
                    return;
                }

                var job = new WebhookJob(notification, setting, configuration, webhook, options.IsUpdate);

                // Do not use scheduling when the notification is an update.
                if (job.IsUpdate)
                {
                    await userNotificationQueue.ScheduleAsync(
                        job.ScheduleKey,
                        job,
                        default(Instant),
                        false, ct);
                }
                else
                {
                    await userNotificationQueue.ScheduleAsync(
                        job.ScheduleKey,
                        job,
                        job.Delay,
                        false, ct);
                }
            }
        }
コード例 #3
0
        public async Task SendAsync(UserNotification notification, ChannelSetting setting, string configuration, SendOptions options,
                                    CancellationToken ct)
        {
            using (Telemetry.Activities.StartActivity("WebPushChannel/SendAsync"))
            {
                var subscription = options.User.WebPushSubscriptions.FirstOrDefault(x => x.Endpoint == configuration);

                if (subscription == null)
                {
                    return;
                }

                var job = new WebPushJob(notification, setting, subscription, serializer, options.IsUpdate);

                // Do not use scheduling when the notification is an update.
                if (options.IsUpdate)
                {
                    await userNotificationQueue.ScheduleAsync(
                        job.ScheduleKey,
                        job,
                        default(Instant),
                        false, ct);
                }
                else
                {
                    await userNotificationQueue.ScheduleAsync(
                        job.ScheduleKey,
                        job,
                        job.Delay,
                        false, ct);
                }
            }
        }
コード例 #4
0
        public IEnumerable <string> GetConfigurations(UserNotification notification, ChannelSetting setting, SendOptions options)
        {
            var webhooks = integrationManager.Resolve <WebhookDefinition>(options.App, notification);

            foreach (var(id, _) in webhooks)
            {
                yield return(id);
            }
        }
コード例 #5
0
 /// <summary>
 /// チャンネルの編集を開始する
 /// </summary>
 private void LoadChannelEdit()
 {
     if (channelListView.SelectedIndices[0] != -1)
     {
         ChannelSetting ch = (ChannelSetting)channelListView.Items[channelListView.SelectedIndices[0]].Tag;
         channelNameTextBox.Text                 = ch.Name;
         channelPasswordTextBox.Text             = ch.Password;
         channelIgnoreUnreadSortCheckBox.Checked = ch.IgnoreInUnreadCountSort;
     }
 }
コード例 #6
0
        public IEnumerable <string> GetConfigurations(UserNotification notification, ChannelSetting settings, SendOptions options)
        {
            var senders = integrationManager.Resolve <IMessagingSender>(options.App, notification);

            // Targets are email-addresses or phone-numbers or anything else to identify an user.
            if (senders.Any(x => x.Target.HasTarget(options.User)))
            {
                yield return(MessagingJob.DefaultToken);
            }
        }
コード例 #7
0
 /// <summary>
 /// チャンネルの編集を反映する
 /// </summary>
 private void ApplyChannelEdit()
 {
     if (m_lastSettingIndex != -1)
     {
         ChannelSetting ch = (ChannelSetting)channelListView.Items[m_lastSettingIndex].Tag;
         ch.Name     = channelNameTextBox.Text;
         ch.Password = channelPasswordTextBox.Text;
         ch.IgnoreInUnreadCountSort = channelIgnoreUnreadSortCheckBox.Checked;
         channelListView.Items[m_lastSettingIndex].Text = ch.Name;
     }
 }
コード例 #8
0
        public IEnumerable <string> GetConfigurations(UserNotification notification, ChannelSetting settings, SendOptions options)
        {
            if (!integrationManager.IsConfigured <ISmsSender>(options.App, notification))
            {
                yield break;
            }

            if (!string.IsNullOrWhiteSpace(options.User.PhoneNumber))
            {
                yield return(options.User.PhoneNumber);
            }
        }
コード例 #9
0
        public IEnumerable <string> GetConfigurations(UserNotification notification, ChannelSetting settings, SendOptions options)
        {
            if (!integrationManager.IsConfigured <IEmailSender>(options.App, notification))
            {
                yield break;
            }

            if (notification.Silent || string.IsNullOrEmpty(options.User.EmailAddress))
            {
                yield break;
            }

            yield return(options.User.EmailAddress);
        }
コード例 #10
0
        public IEnumerable <string> GetConfigurations(UserNotification notification, ChannelSetting settings, SendOptions options)
        {
            if (!integrationManager.IsConfigured <IMobilePushSender>(options.App, notification))
            {
                yield break;
            }

            foreach (var token in options.User.MobilePushTokens)
            {
                if (!string.IsNullOrWhiteSpace(token.Token))
                {
                    yield return(token.Token);
                }
            }
        }
コード例 #11
0
        public IEnumerable <string> GetConfigurations(UserNotification notification, ChannelSetting settings, SendOptions options)
        {
            if (notification.Silent)
            {
                yield break;
            }

            foreach (var subscription in options.User.WebPushSubscriptions)
            {
                if (!string.IsNullOrWhiteSpace(subscription.Endpoint) &&
                    subscription.Keys.ContainsKey("p256dh") &&
                    subscription.Keys.ContainsKey("auth"))
                {
                    yield return(subscription.Endpoint);
                }
            }
        }
コード例 #12
0
        /// <summary>
        /// 追加する
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addChannelButton_Click(object sender, EventArgs e)
        {
            ListViewItem   item = new ListViewItem();
            ChannelSetting ch   = new ChannelSetting(Resources.ChannelSettingNewChannel);

            item.Tag = ch;
            channelListView.Items.Add(item);
            item.Selected = true;

            Application.DoEvents();

            channelNameTextBox.Focus();
            if (channelNameTextBox.TextLength > 2)
            {
                channelNameTextBox.Select(1, channelNameTextBox.TextLength - 1);
            }
        }
コード例 #13
0
        public async Task SendAsync(UserNotification notification, ChannelSetting settings, string configuration, SendOptions options,
                                    CancellationToken ct)
        {
            using (Telemetry.Activities.StartActivity("WebChannel/SendAsync"))
            {
                try
                {
                    await streamClient.SendAsync(notification);

                    await userNotificationStore.CollectAndUpdateAsync(notification, Name, configuration, ProcessStatus.Handled, ct : ct);
                }
                catch (Exception ex)
                {
                    await userNotificationStore.CollectAndUpdateAsync(notification, Name, configuration, ProcessStatus.Failed, ct : ct);

                    log.LogError(ex, "Failed to send web message.");
                }
            }
        }
コード例 #14
0
        public async Task SendAsync(UserNotification notification, ChannelSetting setting, string configuration, SendOptions options,
                                    CancellationToken ct)
        {
            if (options.IsUpdate)
            {
                return;
            }

            using (Telemetry.Activities.StartActivity("EmailChannel/SendAsync"))
            {
                var job = new EmailJob(notification, setting, configuration);

                await userNotificationQueue.ScheduleGroupedAsync(
                    job.ScheduleKey,
                    job,
                    job.Delay,
                    false, ct);
            }
        }
コード例 #15
0
        /// <summary>
        /// 入室
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void joinMenuItem_Click(object sender, EventArgs e)
        {
            // チャンネルが選択されていない場合、抜ける
            if (openedChannelListview.SelectedIndices.Count == 0)
            {
                return;
            }
            Channel ch = openedChannelListview.Items[openedChannelListview.SelectedIndices[0]].Tag as Channel;

            if (ch.IsChannel && (!ch.IsJoin))
            {
                // チャンネルパスワード指定接続
                ChannelSetting chSetting = SettingManager.Data.Profiles.ActiveProfile.Channels.SearchChannel(ch.Name);
                if ((chSetting != null) && (!string.IsNullOrEmpty(chSetting.Password)))
                {
                    (Owner as EbIrcMainForm).IRCClient.JoinChannel(ch.Name, chSetting.Password);
                }
                else
                {
                    (Owner as EbIrcMainForm).IRCClient.JoinChannel(ch.Name, ch.Password);
                }
            }
        }
コード例 #16
0
        public async Task SendAsync(UserNotification notification, ChannelSetting setting, string configuration, SendOptions options,
                                    CancellationToken ct)
        {
            using (Telemetry.Activities.StartActivity("MobilePushChannel/SendAsync"))
            {
                var token = options.User.MobilePushTokens.SingleOrDefault(x => x.Token == configuration);

                if (token == null)
                {
                    return;
                }

                if (token.DeviceType == MobileDeviceType.iOS)
                {
                    await TryWakeupAsync(notification, token, ct);
                }

                var job = new MobilePushJob(notification, setting, configuration, token.DeviceType, options.IsUpdate);

                if (options.IsUpdate)
                {
                    await userNotificationQueue.ScheduleAsync(
                        job.ScheduleKey,
                        job,
                        default(Instant),
                        false, ct);
                }
                else
                {
                    await userNotificationQueue.ScheduleAsync(
                        job.ScheduleKey,
                        job,
                        job.Delay,
                        false, ct);
                }
            }
        }
コード例 #17
0
 private static void _SetChannel(int controller, int robotType, ChannelSetting ch)
 {
     channels[controller][robotType] = ch;
     MainForm.Instance.SetChannel(controller, robotType, ch.ToString());
 }
コード例 #18
0
        public static ChannelSettingDto FromDomainObject(ChannelSetting source)
        {
            var result = SimpleMapper.Map(source, new ChannelSettingDto());

            return(result);
        }
コード例 #19
0
 public IEnumerable <string> GetConfigurations(UserNotification notification, ChannelSetting settings, SendOptions options)
 {
     yield return(Name);
 }
コード例 #20
0
 private void UpdateSetting(ChannelSetting s)
 {
     if (s != null)
     {
         Name = s.Name;
         Neutral = s.NeutralPosition/4.0;
         Minimum = s.MinimumPosition/4.0;
         Maximum = s.MaximumPosition/4.0;
     }
     else
     {
         Minimum = 0;
         Maximum = 9000;
     }
 }
コード例 #21
0
        public static void SetChannel(int controller, int robotType, ChannelSetting ch)
        {
            var oldBots = new HashSet<int>();
            var newBots = new HashSet<int>();
            //add all live bots in the column to the old set
            for (int i = 0; i < ControllerCount; i++)
                if(alive[i])
                    channels[i][robotType].bots.ForEach(id => oldBots.Add(id));

            //set the new channel
            _SetChannel(controller, robotType, ch);
            var chSet = new HashSet<int>(ch.bots);

            //set any channels that overlap with the new one to 255 (none)
            for (int i = 0; i < ControllerCount; i++)
                if (i != controller && channels[i][robotType].bots.Any(chSet.Contains))
                    _SetChannel(i, robotType, SimpleChannel(255));

            //add all live bots in the column to the new set
            for (int i = 0; i < ControllerCount; i++)
                if (alive[i])
                    channels[i][robotType].bots.ForEach(id => newBots.Add(id));

            //stop any old bots that aren't in the new config
            oldBots.ExceptWith(newBots);
            StopBots(oldBots);

            //save channel config
            var s = new StringBuilder();
            for(int i = 0; i < ControllerCount; i++)
                for (int j = 0; j < channels[i].Length; j++)
                    s.Append("" + i + ',' + j + ',' + channels[i][j] + '|');

            Properties.Settings.Default.Channels = s.ToString();
        }