private async void btnLoadAppInfo_Click_1(object sender, RoutedEventArgs e)
        {
            SavedAppInfo savedAppInfo = await AppInfoRepository.Instance.GetSavedAppInfo();

            if (savedAppInfo.MobileServices.Count == 0)
            {
                await Alert("Error", "There are no saved applications.");
            }
            else
            {
                Popup           popup = new Popup();
                SaveAppsControl page  = new SaveAppsControl(savedAppInfo.MobileServices);
                page.CloseRequested += (snd, ea) =>
                {
                    if (page.ApplicationUrl != null && page.ApplicationKey != null)
                    {
                        this.txtAppUrl.Text = page.ApplicationUrl;
                        this.txtAppKey.Text = page.ApplicationKey;
                    }

                    popup.IsOpen = false;
                };

                popup.Child  = page;
                popup.IsOpen = true;
            }
        }
        private async void btnSaveAppInfo_Click_1(object sender, RoutedEventArgs e)
        {
            SavedAppInfo appInfo = await AppInfoRepository.Instance.GetSavedAppInfo();

            string appUrl = this.txtAppUrl.Text;
            string appKey = this.txtAppKey.Text;

            if (string.IsNullOrEmpty(appUrl) || string.IsNullOrEmpty(appKey))
            {
                await Alert("Error", "Please enter valid application URL / key");
            }
            else
            {
                if (appInfo.MobileServices.Any(ms => ms.AppKey == appKey && ms.AppUrl == appUrl))
                {
                    await Alert("Information", "Mobile service info already saved");
                }
                else
                {
                    appInfo.MobileServices.Add(new MobileServiceInfo {
                        AppUrl = appUrl, AppKey = appKey
                    });
                    await AppInfoRepository.Instance.SaveAppInfo(appInfo);
                    await Alert("Information", "Mobile service info successfully saved");
                }
            }
        }
        private async void btnSendLogs_Click_1(object sender, RoutedEventArgs e)
        {
            int selectedIndex = this.lstTestGroups.SelectedIndex;

            if (selectedIndex >= 0)
            {
                // Saves URL in local storage
                SavedAppInfo appInfo = await AppInfoRepository.Instance.GetSavedAppInfo();

                string uploadUrl = this.txtUploadLogsUrl.Text;
                if (appInfo.LastUploadUrl != uploadUrl)
                {
                    appInfo.LastUploadUrl = uploadUrl;
                    await AppInfoRepository.Instance.SaveAppInfo(appInfo);
                }

                ZumoTestGroup testGroup = allTests[selectedIndex];
                List <string> lines     = new List <string>();
                foreach (var test in testGroup.AllTests)
                {
                    lines.Add(string.Format("Logs for test {0} (status = {1})", test.Name, test.Status));
                    lines.AddRange(test.GetLogs());
                    lines.Add("-----------------------");
                }

                UploadLogsControl uploadLogsPage = new UploadLogsControl(testGroup.Name, string.Join("\n", lines), uploadUrl);
                await uploadLogsPage.Display();
            }
            else
            {
                await Alert("Error", "A test group needs to be selected");
            }
        }
Esempio n. 4
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (this.lstTestGroups.ItemsSource == null)
            {
                List <ListViewForTestGroup> sources = allTestGroups.Select((tg, i) => new ListViewForTestGroup(i + 1, tg)).ToList();
                this.lstTestGroups.ItemsSource = sources;

                SavedAppInfo savedAppInfo = await AppInfoRepository.Instance.GetSavedAppInfo();

                this.txtUploadUrl.Text = savedAppInfo.LastUploadUrl ?? "";
                if (savedAppInfo.LastService != null && !string.IsNullOrEmpty(savedAppInfo.LastService.AppUrl) && !string.IsNullOrEmpty(savedAppInfo.LastService.AppKey))
                {
                    this.txtAppUrl.Text = savedAppInfo.LastService.AppUrl;
                    this.txtAppKey.Text = savedAppInfo.LastService.AppKey;
                }
            }

            // Check if any of the text box values can be found in app settings
            // This is used for test automation, and takes precedence over saved app info.
            Action <TextBox, string> overrideFromAppSettings = (control, settingName) =>
            {
                string value;
                if (System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings.TryGetValue <string>(settingName, out value))
                {
                    control.Text = value;
                }
            };

            overrideFromAppSettings(this.txtAppUrl, "appUrl");
            overrideFromAppSettings(this.txtAppKey, "appKey");
            overrideFromAppSettings(this.txtUploadUrl, "uploadUrl");
        }
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            List <ListViewForTestGroup> sources = allTests.Select((tg, i) => new ListViewForTestGroup(i + 1, tg)).ToList();

            this.lstTestGroups.ItemsSource = sources;
            SavedAppInfo savedAppInfo = await AppInfoRepository.Instance.GetSavedAppInfo();

            this.txtUploadLogsUrl.Text = savedAppInfo.LastUploadUrl ?? "";
            if (savedAppInfo.LastService != null && !string.IsNullOrEmpty(savedAppInfo.LastService.AppUrl) && !string.IsNullOrEmpty(savedAppInfo.LastService.AppKey))
            {
                this.txtAppUrl.Text = savedAppInfo.LastService.AppUrl;
                this.txtAppKey.Text = savedAppInfo.LastService.AppKey;
            }
        }
        private async Task SaveAppInfo()
        {
            SavedAppInfo appInfo = await AppInfoRepository.Instance.GetSavedAppInfo() ?? new SavedAppInfo();

            string uploadUrl = this.txtUploadUrl.Text;
            string appUrl    = this.txtAppUrl.Text;
            string appKey    = this.txtAppKey.Text;

            if (appInfo.LastUploadUrl != uploadUrl || appInfo.LastService.AppUrl != appUrl || appInfo.LastService.AppKey != appKey)
            {
                appInfo.LastUploadUrl      = uploadUrl;
                appInfo.LastService.AppUrl = appUrl;
                appInfo.LastService.AppKey = appKey;
                await AppInfoRepository.Instance.SaveAppInfo(appInfo);
            }
        }