コード例 #1
0
        /// <summary>
        /// Notify a pairup.
        /// </summary>
        /// <param name="connectorClient">The connector client</param>
        /// <param name="tenantId">The tenant id</param>
        /// <param name="teamName">The team name</param>
        /// <param name="pair">The pairup</param>
        /// <returns>Number of users notified successfully</returns>
        private async Task <int> NotifyPair(ConnectorClient connectorClient, string tenantId, string teamName,
                                            Tuple <ChannelAccount, ChannelAccount> pair)
        {
            this.telemetryClient.TrackTrace($"Sending pairup notification to {pair.Item1.Id} and {pair.Item2.Id}");

            var teamsPerson1 = pair.Item1.AsTeamsChannelAccount();
            var teamsPerson2 = pair.Item2.AsTeamsChannelAccount();

            var notifiedResults = 0;

            // Fill in person2's info in the card for person1
            var cardForPerson1 =
                PairUpNotificationAdaptiveCard.GetCard(teamName, teamsPerson1, teamsPerson2, this.botDisplayName);

            if (await NotifyUser(connectorClient, cardForPerson1, teamsPerson1, tenantId))
            {
                notifiedResults++;
                await dataProvider.UserMatchInfoSave(teamsPerson1.Email, teamsPerson1.ObjectId,
                                                     teamsPerson2.Email, teamsPerson2.ObjectId);

                await dataProvider.BotLastMessageUpdate(teamsPerson1.ObjectId, teamsPerson1.Email, BotMessageTypes.NewMatchedPair);
            }

            // Fill in person1's info in the card for person2
            var cardForPerson2 =
                PairUpNotificationAdaptiveCard.GetCard(teamName, teamsPerson2, teamsPerson1, this.botDisplayName);

            if (await NotifyUser(connectorClient, cardForPerson2, teamsPerson2, tenantId))
            {
                notifiedResults++;
                await dataProvider.UserMatchInfoSave(teamsPerson2.Email, teamsPerson2.ObjectId,
                                                     teamsPerson1.Email, teamsPerson1.ObjectId);

                await dataProvider.BotLastMessageUpdate(teamsPerson2.ObjectId, teamsPerson2.Email, BotMessageTypes.NewMatchedPair);
            }

            // Send notifications and return the number that was successful
            return(notifiedResults);
        }