123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- using System;
- using System.IO;
- using System.Windows;
- using System.Windows.Controls;
- using Microsoft.Win32;
- using AIPlatform.Protocol.Utilities;
- namespace aipdev
- {
- /// <summary>
- /// Interaction logic for DeveloperCenter.xaml
- /// </summary>
- public partial class DeveloperCenter : UserControl, IContentPage
- {
- public string PageName { get; set; }
- public bool IsHomePage { get; set; }
- public bool IsModalPage { get; set; }
- public DeveloperCenter()
- {
- InitializeComponent();
- PageName = "DeveloperCenter";
- IsHomePage = false;
- IsModalPage = false;
- }
- public void Close()
- {
- //throw new NotImplementedException();
- }
- public async void OnShow(object arg)
- {
- ContentManager.ShowLoading();
- try
- {
- var developer = await DeveloperManager.Shared.GetAccountAsync();
- DevName.Text = developer.Name;
- DevFullName.Text = developer.FullName;
- if (developer.DeveloperAuthorityInfo != null && !string.IsNullOrEmpty(developer.DeveloperAuthorityInfo.WorkTokenId))
- {
- WorkToken.Visibility = Visibility.Visible;
- WorkToken.Text = developer.DeveloperAuthorityInfo.WorkTokenId;
- WorkTokenExpireTime.Text = developer.DeveloperAuthorityInfo.WorkTokenExpireTime.ToString();
- }
- else
- {
- WorkToken.Visibility = Visibility.Hidden;
- WorkTokenExpireTime.Text = string.Empty;
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(Application.Current.MainWindow, $"加载开发者信息失败:{ex.Translate()}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- finally
- {
- ContentManager.HideLoading();
- }
- }
- public void OnHide()
- {
- //DoNothing
- }
- private void OnChangePasswordClick(object sender, RoutedEventArgs e)
- {
- var changePasswordWindow = new ChangePasswordWindow() { Owner = Application.Current.MainWindow };
- changePasswordWindow.ShowDialog();
- }
- private async void OnDownloadSdkClick(object sender, RoutedEventArgs e)
- {
- ContentManager.ShowLoading();
- try
- {
- var sdkData = await DeveloperManager.Shared.DownloadSdkAsync();
- if (sdkData != null)
- {
- var saveFileDialog = new SaveFileDialog
- {
- //FileName = "sdk",
- Filter = "*.zip|*.zip"
- };
- if (saveFileDialog.ShowDialog() == true)
- {
- await File.WriteAllBytesAsync(saveFileDialog.FileName, sdkData);
- }
- }
- else
- {
- throw new InvalidOperationException("服务器未返回SDK数据");
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(Application.Current.MainWindow, $"下载SDK失败:{ex.Translate()}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- finally
- {
- ContentManager.HideLoading();
- }
- }
- private async void OnDownloadSimulatorClick(object sender, RoutedEventArgs e)
- {
- ContentManager.ShowLoading();
- try
- {
- var simulatorData = await DeveloperManager.Shared.DownloadSdkSimulatorAsync();
- if (simulatorData != null)
- {
- var saveFileDialog = new SaveFileDialog
- {
- //FileName = "Simulator",
- Filter = "*.zip|*.zip"
- };
- if (saveFileDialog.ShowDialog() == true)
- {
- await File.WriteAllBytesAsync(saveFileDialog.FileName, simulatorData);
- }
- }
- else
- {
- throw new InvalidOperationException("服务器未返回SDK模拟器数据");
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(Application.Current.MainWindow, $"下载SDK模拟器失败:{ex.Translate()}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- finally
- {
- ContentManager.HideLoading();
- }
- }
- }
- }
|