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; }
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; }