Exemplo n.º 1
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            data.RingIsActive = true;

            try
            {
                if (String.IsNullOrEmpty(data.Url))
                {
                    msgs.AddLog("ERROR. You need to define document id.");
                    return;
                }
                else
                {
                    msgs.AddLog("Try authorize.");
                    string downloadUrl = String.Format(url, data.Url);
                    Stream s           = await driveService.DownloadFile(downloadUrl, msg => msgs.AddLog(msg));

                    msgs.AddLog("Download file completed.");

                    reader = new CopyReader("", preferences.Model.Key);
                    reader.Open(s);

                    Resources res = await reader.GetValuesAsync(preferences.Model.LastWorkSheet, (msg) => {
                        msgs.AddLog(msg);
                    });


                    if (String.IsNullOrEmpty(preferences.Model.Path) || String.IsNullOrEmpty(preferences.Model.Name))
                    {
                        msgs.AddLog("ERROR. You have to define path to save and name resx resources.");
                    }

                    var resx = new ResxCreator();

                    await resx.CreateResxAsync(res, preferences.Model.Path, preferences.Model.Name, (msg) =>
                    {
                        msgs.AddLog(msg);
                    });

                    preferences.SetLastUrl(data.Url);

                    string path = preferences.GetPath();

                    preferences.SaveModel(path);
                }
            }
            catch (Exception)
            {
                msgs.AddLog("Error. Try again.");
            }

            data.RingIsActive = false;
        }
Exemplo n.º 2
0
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(preferences.Model.Key))
                {
                    msgs.AddLog("ERROR. You have to define key in settings.");
                    return;
                }

                data.RingIsActive = true;

                reader = new CopyReader(data.Path, preferences.Model.Key);
                reader.Open();

                Resources res = await reader.GetValuesAsync(preferences.Model.LastWorkSheet, (msg) =>
                {
                    msgs.AddLog(msg);
                });


                if (String.IsNullOrEmpty(preferences.Model.Path) || String.IsNullOrEmpty(preferences.Model.Name))
                {
                    msgs.AddLog("ERROR. You have to define path to save and name resx resources.");
                    data.RingIsActive = false;
                    return;
                }

                var resx = new ResxCreator();

                await resx.CreateResxAsync(res, preferences.Model.Path, preferences.Model.Name, (msg) =>
                {
                    msgs.AddLog(msg);
                });

                string path = preferences.GetPath();

                preferences.SaveModel(path);
            }
            catch
            {
                msgs.AddLog("Error");
            }


            data.RingIsActive = false;
        }