Exemplo n.º 1
0
        private async void bMultiUpload_Click(object sender, EventArgs e)
        {
            OpenFileDialog thisDialog = new OpenFileDialog();

            thisDialog.Filter           = "Chummer files (*.chum5)|*.chum5|All files (*.*)|*.*";
            thisDialog.FilterIndex      = 1;
            thisDialog.RestoreDirectory = true;
            thisDialog.Multiselect      = true;
            thisDialog.Title            = "Please Select Chummer File(s) for Batch-Upload";

            if (thisDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            foreach (var file in thisDialog.FileNames)
            {
                try
                {
                    Log.Trace("Loading: " + file);
                    var c = new Character {
                        FileName = file
                    };
                    if (!(await c.Load(null, false)))
                    {
                        continue;
                    }
                    Log.Trace("Character loaded: " + c.Name);
                    CharacterExtended ce = new CharacterExtended(c, null);
                    await ce.UploadInBackground();
                }
                catch (Exception ex)
                {
                    string msg = "Exception while loading " + file + ":";
                    msg += Environment.NewLine + ex.ToString();
                    Log.Warn(msg);
                    /* run your code here */
                    MessageBox.Show(msg);
                }
            }

            MessageBox.Show("Upload of " + thisDialog.FileNames.Length + " files finished (successful or not - its over).");
        }
Exemplo n.º 2
0
        private void bMultiUpload_Click(object sender, EventArgs e)
        {
            OpenFileDialog thisDialog = new OpenFileDialog();

            thisDialog.Filter           = "Chummer files (*.chum5)|*.chum5|All files (*.*)|*.*";
            thisDialog.FilterIndex      = 1;
            thisDialog.RestoreDirectory = true;
            thisDialog.Multiselect      = true;
            thisDialog.Title            = "Please Select Chummer File(s) for Batch-Upload";

            if (thisDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            foreach (var file in thisDialog.FileNames)
            {
                try
                {
                    Debug.WriteLine("Loading: " + file);
                    var c = new Character {
                        FileName = file
                    };
                    if (!c.Load())
                    {
                        continue;
                    }
                    Debug.WriteLine("Character loaded: " + c.Name);
                    CharacterExtended ce = new CharacterExtended(c, null);
                    ce.UploadInBackground();
                }
                catch (Exception ex)
                {
                    string msg = "Exception while loading " + file + ":";
                    msg += Environment.NewLine + ex.ToString();
                    Debug.Write(msg);
                    System.Diagnostics.Trace.TraceWarning(msg);
                    throw;
                }
            }
        }