Beispiel #1
0
 public void Open(Library lib,string ImportType,ImportResult result)
 {
     Text = "Import " + ImportType + "s to " + lib.Name;
     _libName = lib.Name;
     foreach (string s in result.SuccessOn)
     {
         lboSuccess.Items.Add(s);
     }
     foreach (string s in result.WarningOn)
     {
         lboWarnings.Items.Add(s);
     }
     foreach (string s in result.BugOn)
     {
         lboBugs.Items.Add(s);
     }
     this.ShowDialog();
 }
        protected void AddToLibrary(bool log,bool DoNotSave)
        {
            ImportResult=new ImportResult(ImportType);
            if (( CurrentLib== null)

               || (lvwResults.CheckedIndices.Count == 0))
            {
                btnAddTo.Enabled = false;
                return;
            }
            Cursor = Cursors.WaitCursor;
            Refresh();
            HtmlData htmlData = HtmlData;
            lblProgress.Value = 0;
            lblProgress.Maximum = lvwResults.CheckedItems.Count;

            foreach (ListViewItem lvi in lvwResults.CheckedItems)
            {
                lblInfo.Text = "Working on " + lvi.Text;
                statusStrip1.Refresh();
                try
                {
                    if (SpecificAddTo(lvi, log, htmlData))
                    {
                        if (log)
                            Common.WriteToLog(String.Format("Adding {0} {1} to {2}", ImportType, lvi.Text, CurrentLib.Name));
                        ImportResult.SuccessOn.Add(lvi.Text);
                    }
                }
                catch (InvalidStructureException cex)
                {
                    if (log)
                        Common.WriteToLog(cex.Message);
                    Utils.LogSystem.Trace(cex);
                  //  MessageBox.Show(cex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ImportResult.BugOn.Add(cex.Message);

                    continue;
                }
                catch (FailToLogInException)
                {
                    if (log)
                        Common.WriteToLog("Could not log to D&D insider !");
                    MessageBox.Show("Could not log to D&D insider !" + Environment.NewLine + "Check your login and password.", "Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    Cursor = Cursors.Default;
                    return;
                }
                catch (Exception ex)
                {
                    if (log) Common.WriteToLog(ex.Message);
                    //MessageBox.Show("Error on importing : " + lvi.Text + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace);
                    Utils.LogSystem.Trace(lvi.Text + " " + ex);
                    ImportResult.BugOn.Add(lvi.Text + " : " + ex.Message);
                    continue;
                }

                finally
                {
                    lblProgress.Value++;
                }

            }
            string temp = ImportResult.NumberOfSuccess + " " + ImportType + ((ImportResult.NumberOfSuccess > 1) ? "s" : "") + ((DoNotSave) ? " converted without saving" : " added in " + CurrentLib.Name);
            lblInfo.Text = temp;
            ResultForm rf=new ResultForm();
            rf.Open(CurrentLib,ImportType,ImportResult);
            if (log) Common.WriteToLog(temp);
            if (ImportResult.SuccessOn.Count > 0 && !DoNotSave)
            {
                int index = cboLibraries.SelectedIndex;
                _mpApp.SaveLibrary(CurrentLib);
                cboLibraries.SelectedIndex = index;
            }
            Cursor = Cursors.Default;
        }