Пример #1
0
        private async void DeleteLogsButton_Click(object sender, RoutedEventArgs e)
        {
            var selected = LogFilesCollection.Where(item => item.IsSelected);
            var logs     = await LogUtil.GetLogFilesAsync();

            var fileList = new List <StorageFile>();

            foreach (var sel in selected)
            {
                var temp = logs.Where(file => file.Path == sel.Path).FirstOrDefault();
                if (temp != null)
                {
                    fileList.Add(temp as StorageFile);
                }
            }

            if (fileList.Count > 0)
            {
                var deleteConfirmText = string.Format(fileList.Count > 1 || fileList.Count == 0 ?
                                                      Common.GetLocalizedText("DeleteLogsText") :
                                                      Common.GetLocalizedText("DeleteLogText"), fileList.Count);
                if (!await AppService.YesNoAsync(Common.GetLocalizedText("ConfirmationTitleText"), deleteConfirmText))
                {
                    return;
                }

                foreach (var file in fileList)
                {
                    await file.DeleteAsync();
                }

                var deleteSuccessText = string.Format(fileList.Count > 1 || fileList.Count == 0 ?
                                                      Common.GetLocalizedText("DeletedLogsText") :
                                                      Common.GetLocalizedText("DeletedLogText"), fileList.Count);
                PageService.ShowNotification(deleteSuccessText);
                RefreshUI();
            }
            else
            {
                PageService.ShowNotification(Common.GetLocalizedText("NoLogsSelectedText"));
            }
        }
Пример #2
0
        private async void EmailLogsButton_Click(object sender, RoutedEventArgs e)
        {
            var provider = App.AuthManager.GetGraphProvider();

            if (provider == null)
            {
                return;
            }

            if (!provider.IsTokenValid())
            {
                AppService.DisplayAadSignInDialog(typeof(LogsPage));
                return;
            }

            var selected = LogFilesCollection.Where(item => item.IsSelected);
            var logs     = await LogUtil.GetLogFilesAsync();

            var fileList = new List <StorageFile>();

            foreach (var sel in selected)
            {
                var temp = logs.Where(file => file.Path == sel.Path).FirstOrDefault();
                if (temp != null)
                {
                    fileList.Add(temp as StorageFile);
                }
            }

            if (fileList.Count > 0)
            {
                var emailConfirmText = string.Format(fileList.Count > 1 || fileList.Count == 0 ?
                                                     Common.GetLocalizedText("EmailLogsSelfText") :
                                                     Common.GetLocalizedText("EmailLogSelfText"), fileList.Count);
                if (!await AppService.YesNoAsync(Common.GetLocalizedText("EmailLogsText"), emailConfirmText))
                {
                    return;
                }

                var messageContent = LogUtil.CreateMessageContent(GetType().Name, CustomContentService?.GetContent <string>(CustomContentConstants.BugTemplate));
                using (var graphHelper = new GraphHelper(provider))
                {
                    try
                    {
                        var email = await LogUtil.EmailLogsAsync(graphHelper, "[Smart Display] LOG MAILER", messageContent, fileList.ToArray());

                        var emailSuccessText = string.Format(fileList.Count > 1 || fileList.Count == 0 ?
                                                             Common.GetLocalizedText("EmailedLogsText") :
                                                             Common.GetLocalizedText("EmailedLogText"), fileList.Count, email);
                        PageService.ShowNotification(emailSuccessText);
                    }
                    catch (Exception ex)
                    {
                        PageService.ShowNotification(string.Format(Common.GetLocalizedText("EmailLogsProblemText"), ex.Message));
                    }
                }
            }
            else
            {
                PageService.ShowNotification(Common.GetLocalizedText("NoLogsSelectedText"));
            }
        }