コード例 #1
0
        private static async Task <ArgumentHandleResult> ProcessGoogleSpreadsheetsLocale(string id, [CanBeNull] string locale, bool around)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new InformativeException(ToolsStrings.Common_IdIsMissing);
            }

            var url = around
                    ? $@"{InternalUtils.MainApiDomain}/u/around?id={id}" : $@"https://docs.google.com/spreadsheets/d/{id}/export?format=xlsx&authuser=0";
            await Task.Run(() => {
                if (File.Exists(LocaleHelper.GetGoogleSheetsFilename()))
                {
                    FileUtils.Recycle(LocaleHelper.GetGoogleSheetsFilename());
                    FileUtils.TryToDelete(LocaleHelper.GetGoogleSheetsFilename());
                }
            });

            await LoadRemoteFileToNew(url, LocaleHelper.GetGoogleSheetsFilename());

            SettingsHolder.Locale.LoadUnpacked = true;
            if (locale != null)
            {
                SettingsHolder.Locale.LocaleName = locale;
            }

            ActionExtension.InvokeInMainThreadAsync(() => {
                if (ModernDialog.ShowMessage(AppStrings.CustomLocalesUpdated_Message, AppStrings.CustomLocalesUpdated_Title, MessageBoxButton.YesNo) ==
                    MessageBoxResult.Yes)
                {
                    WindowsHelper.RestartCurrentApplication();
                }
            });

            return(ArgumentHandleResult.Successful);
        }
コード例 #2
0
        private static async Task <ArgumentHandleResult> ProcessGoogleSpreadsheetsLocale(string id, [CanBeNull] string locale, bool around)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new InformativeException("ID is missing");
            }

            var url = around
                    ? $@"{InternalUtils.MainApiDomain}/u/around?id={id}" : $@"https://docs.google.com/spreadsheets/d/{id}/export?format=xlsx&authuser=0";

            await LoadRemoveFileToNew(url, LocaleHelper.GetGoogleSheetsFilename());

            SettingsHolder.Locale.LoadUnpacked = true;
            if (locale != null)
            {
                SettingsHolder.Locale.LocaleName = locale;
            }

            if (ModernDialog.ShowMessage("Custom locales updated. Would you like to restart app now?", "Locales updated", MessageBoxButton.YesNo) ==
                MessageBoxResult.Yes)
            {
                WindowsHelper.RestartCurrentApplication();
            }

            return(ArgumentHandleResult.Successful);
        }