Esempio n. 1
0
        protected async Task <ITaskService> InitListTypeIds(WaterfallStepContext sc)
        {
            var state = await ToDoStateAccessor.GetAsync(sc.Context);

            if (!state.ListTypeIds.ContainsKey(state.ListType))
            {
                var emailService = await MailService.InitAsync(state.MsGraphToken);

                var senderMailAddress = await emailService.GetSenderMailAddressAsync();

                var recovered = await RecoverListTypeIdsAsync(sc, senderMailAddress);

                if (!recovered)
                {
                    if (ServiceManager is OneNoteService)
                    {
                        await sc.Context.SendActivityAsync(sc.Context.Activity.CreateReply(ToDoSharedResponses.SettingUpOneNoteMessage));
                    }
                    else
                    {
                        await sc.Context.SendActivityAsync(sc.Context.Activity.CreateReply(ToDoSharedResponses.SettingUpOutlookMessage));
                    }

                    var service = await ServiceManager.InitAsync(state.MsGraphToken, state.ListTypeIds);

                    var taskWebLink = await service.GetTaskWebLink();

                    var emailContent = string.Format(ToDoStrings.EmailContent, taskWebLink);
                    await emailService.SendMessageAsync(emailContent, ToDoStrings.EmailSubject);

                    if (ServiceManager is OneNoteService)
                    {
                        await sc.Context.SendActivityAsync(sc.Context.Activity.CreateReply(ToDoSharedResponses.AfterOneNoteSetupMessage));
                    }
                    else
                    {
                        await sc.Context.SendActivityAsync(sc.Context.Activity.CreateReply(ToDoSharedResponses.AfterOutlookSetupMessage));
                    }

                    await StoreListTypeIdsAsync(sc, senderMailAddress);

                    return(service);
                }
            }

            return(await ServiceManager.InitAsync(state.MsGraphToken, state.ListTypeIds));
        }
Esempio n. 2
0
        public ToDoSkill(ISkillConfiguration services, ConversationState conversationState, UserState userState, IBotTelemetryClient telemetryClient, ITaskService serviceManager = null, bool skillMode = false)
        {
            _skillMode         = skillMode;
            _services          = services ?? throw new ArgumentNullException(nameof(services));
            _userState         = userState ?? throw new ArgumentNullException(nameof(userState));
            _conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState));
            _telemetryClient   = telemetryClient ?? throw new ArgumentNullException(nameof(telemetryClient));

            var isOutlookProvider = _services.Properties.ContainsKey("TaskServiceProvider") &&
                                    _services.Properties["TaskServiceProvider"].ToString().Equals(ProviderTypes.Outlook.ToString(), StringComparison.InvariantCultureIgnoreCase);
            ITaskService taskService = new OneNoteService();

            if (isOutlookProvider)
            {
                taskService = new OutlookService();
            }

            _serviceManager = serviceManager ?? taskService;
            MailService     = new MailService();

            _dialogs = new DialogSet(_conversationState.CreateProperty <DialogState>(nameof(DialogState)));
        }