Utilisateur:ZX81-bot/SaveFullLog
Index: AWB/AWB/Main.cs
=======================================================
modifier--- AWB/AWB/Main.cs (revision 1021) +++ AWB/AWB/Main.cs (working copy) @@ -696,6 +696,7 @@
NudgeTimer.Stop(); sameArticleNudges = 0;
+ LogListener.CurRevId(webBrowserEdit.CurRevisionId());
LogControl1.AddLog(false, LogListener); if (listMaker1.Count == 0)
@@ -3196,5 +3197,222 @@
userTalkWarningsLoaded = true; userTalkTemplatesRegex = new Regex(finalRegex, RegexOptions.Compiled | RegexOptions.IgnoreCase); }
+
+ private void SaveFullLog()
+ {
+ try
+ {
+ StringBuilder strList = new StringBuilder("");
+ StreamWriter sw;
+ string strListFile;
+ string logLine;
+
+ DateTime dateEdit;
+ DateTime dateStart = new DateTime(2099, 12, 31);
+ DateTime dateEnd = new DateTime(2000, 1, 1);
+ foreach (AWBLogListener log in LogControl1.lvSaved.Items)
+ {
+ dateEdit = Convert.ToDateTime(log.TimeStamp);
+ if (dateEdit.CompareTo(dateStart) < 0 )
+ dateStart = dateEdit;
+ if (dateEdit.CompareTo(dateEnd) > 0)
+ dateEnd = dateEdit;
+ }
+ foreach (AWBLogListener log in LogControl1.lvIgnored.Items)
+ {
+ dateEdit = Convert.ToDateTime(log.TimeStamp);
+ if (dateEdit.CompareTo(dateStart) < 0)
+ dateStart = dateEdit;
+ if (dateEdit.CompareTo(dateEnd) > 0)
+ dateEnd = dateEdit;
+ }
+
+ logLine = "Début : " + dateStart.ToString() + "
\r\n";
+ logLine += "Fin : " + dateEnd.ToString() + "
\r\n";
+ logLine += "Historique : [{{fullurl:Special:Contributions"
+ + "|target=" + Variables.User.Name + "&offset="
+ + Regex.Replace(dateEnd.ToString("s"), "\\D", "") + "}} "
+ + "Special:Contributions/" + Variables.User.Name + "]
";
+ strList.AppendLine(logLine);
+
+ logLine = "Mode : ";
+ if (!chkAutoMode.Checked)
+ logLine += "semi-";
+ logLine += "automatique
";
+ strList.AppendLine(logLine);
+
+ logLine = "Outil utilisé : AutoWikiBrowser version "
+ + AboutBox.AssemblyVersion + " modifiée par TiChou
";
+ strList.AppendLine(logLine);
+
+ if (chkGeneralFixes.Checked || chkAutoTagger.Checked ||
+ chkUnicodifyWhole.Checked || chkRegExTypo.Checked)
+ {
+ logLine = "Options AWB activées :\r\n";
+ if (chkGeneralFixes.Checked)
+ logLine += "*Apply general fixes\r\n";
+ if (chkAutoTagger.Checked)
+ logLine += "*Auto tag\r\n";
+ if (chkUnicodifyWhole.Checked)
+ logLine += "*Unicodify whole article\r\n";
+ if (chkRegExTypo.Checked)
+ logLine += "*RegexTypoFix\r\n";
+
+ logLine += "
";
+ strList.AppendLine(logLine);
+ }
+
+ if (chkFindandReplace.Checked)
+ {
+ List<Replacement> Replacements = findAndReplace.GetList();
+ if (Replacements.Count > 0)
+ {
+ logLine = "Expressions rationnelles utilisées pour les modifications de texte :\r\n";
+ logLine += "\r\n";
+
+ foreach (Replacement rep in Replacements)
+ {
+ if (!rep.Enabled)
+ continue;
+
+ logLine += "*s/" + HttpUtility.HtmlEncode(rep.Find) + ""
+ + "/" + HttpUtility.HtmlEncode(rep.Replace) + "/";
+
+ if ((rep.RegularExpressinonOptions & RegexOptions.IgnoreCase) != 0)
+ logLine += "i";
+ if ((rep.RegularExpressinonOptions & RegexOptions.Multiline) != 0)
+ logLine += "m";
+ if ((rep.RegularExpressinonOptions & RegexOptions.Singleline) != 0)
+ logLine += "s";
+
+ logLine += "\r\n";
+ }
+
+ logLine += "
";
+ strList.AppendLine(logLine);
+ }
+
+ string[] Templates = substTemplates.TemplateList;
+ if (Templates.Length > 0)
+ {
+ logLine = "Modèles substitués :\r\n";
+
+ foreach (string template in Templates)
+ if (template.Trim() != "")
+ logLine += "*{{" + template + "}}\r\n";
+
+ logLine += "
";
+ strList.AppendLine(logLine);
+ }
+ }
+
+ if (chkAppend.Checked)
+ {
+ if (rdoAppend.Checked)
+ logLine = "Texte ajouté à la fin :";
+ else
+ logLine = "Texte ajouté au début :";
+ logLine += "\r\n
"+ HttpUtility.HtmlEncode(txtAppendMessage.Text) + "
";
+ strList.AppendLine(logLine);
+ }
+
+ if (cmboCategorise.SelectedIndex > 0)
+ {
+ switch (cmboCategorise.SelectedIndex)
+ {
+ case 1:
+ logLine = "Catégorie "
+ + txtNewCategory.Text + " remplacée par catégorie [[:Catégorie:"
+ + txtNewCategory2.Text + "|" + txtNewCategory2.Text + "]]";
+ break;
+ case 2:
+ logLine = "Catégorie "
+ + txtNewCategory.Text + " ajoutée";
+ break;
+ case 3:
+ logLine = "Catégorie "
+ + txtNewCategory.Text + " supprimée";
+ break;
+ default:
+ break;
+ }
+
+ logLine += "
";
+ strList.AppendLine(logLine);
+ }
+
+ if (cmboImages.SelectedIndex > 0)
+ {
+ switch (cmboCategorise.SelectedIndex)
+ {
+ case 1:
+ logLine = "Image "
+ + txtImageReplace.Text + " remplacée par image [[:Image:"
+ + txtImageWith.Text + "|" + txtImageWith.Text + "]]";
+ break;
+ case 2:
+ logLine = "Image "
+ + txtImageReplace.Text + " supprimée";
+ break;
+ case 3:
+ logLine = "Image "
+ + txtImageReplace.Text + " commentée avec le commentaire « "
+ + txtImageWith.Text + " »";
+ break;
+ default:
+ break;
+ }
+
+ logLine += "
";
+ strList.AppendLine(logLine);
+ }
+
+ if (cModule.ModuleEnabled && cModule.Module != null)
+ {
+ logLine = "Module activé :\r\n
" + HttpUtility.HtmlEncode(cModule.Code) + "
";
+ strList.AppendLine(logLine);
+ }
+
+ logLine = "Articles modifiés :\r\n";
+ foreach (AWBLogListener log in LogControl1.lvSaved.Items)
+ {
+ logLine += "#" + log.TimeStamp + " " + log.Text + " "
+ + "([{{fullurl:" + log.Text
+ + "|diff=prev&oldid=" + log.CurRevisionId + "}} diff] • "
+ + "hist)\r\n";
+ }
+ logLine += "
";
+ strList.AppendLine(logLine);
+
+ logLine = "Articles non modifiés :\r\n";
+ foreach (AWBLogListener log in LogControl1.lvIgnored.Items)
+ {
+ logLine += "#" + log.TimeStamp + " " + log.Text + " ";
+ logLine += "(" + log.SkippedBy + " : " + log.SkipReason + ")\r\n";
+ }
+ strList.AppendLine(logLine);
+
+ if (saveListDialog.ShowDialog() == DialogResult.OK)
+ {
+ strListFile = saveListDialog.FileName;
+ sw = new StreamWriter(strListFile, false, Encoding.UTF8);
+ sw.Write(strList);
+ sw.Close();
+ }
+ }
+ catch (IOException ex)
+ {
+ MessageBox.Show(ex.Message, "File error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void btnSaveFullLog_Click(object sender, EventArgs e)
+ {
+ SaveFullLog();
+ }
} }
Index: AWB/AWB/Main.Designer.cs
=======================================================
modifier--- AWB/AWB/Main.Designer.cs (revision 1021) +++ AWB/AWB/Main.Designer.cs (working copy) @@ -309,6 +309,7 @@
this.tpEdit = new System.Windows.Forms.TabPage(); this.txtEdit = new System.Windows.Forms.TextBox(); this.tpLogs = new System.Windows.Forms.TabPage();
+ this.btnSaveFullLog = new System.Windows.Forms.Button();
this.LogControl1 = new WikiFunctions.Logging.LogControl(); this.webBrowserEdit = new WikiFunctions.Browser.WebControl(); this.mnuTextBox.SuspendLayout();
@@ -2849,6 +2850,7 @@
// // tpLogs //
+ this.tpLogs.Controls.Add(this.btnSaveFullLog);
this.tpLogs.Controls.Add(this.LogControl1); this.tpLogs.Location = new System.Drawing.Point(4, 22); this.tpLogs.Name = "tpLogs";
@@ -2858,6 +2860,16 @@
this.tpLogs.Text = "View log"; this.tpLogs.UseVisualStyleBackColor = true; //
+ // btnSaveFullLog + // + this.btnSaveFullLog.Location = new System.Drawing.Point(168, 141); + this.btnSaveFullLog.Name = "btnSaveFullLog"; + this.btnSaveFullLog.Size = new System.Drawing.Size(75, 24); + this.btnSaveFullLog.TabIndex = 23; + this.btnSaveFullLog.Text = "Save full log"; + this.btnSaveFullLog.UseVisualStyleBackColor = true; + this.btnSaveFullLog.Click += new System.EventHandler(this.btnSaveFullLog_Click); + //
// LogControl1 // this.LogControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@@ -3241,6 +3253,7 @@
private System.Windows.Forms.ToolStripMenuItem enlargeEditAreaToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator23; private WikiFunctions.Logging.LogControl LogControl1;
+ private System.Windows.Forms.Button btnSaveFullLog;
}
Index: AWB/WikiFunctions/LogControl.Designer.cs
=======================================================
modifier--- AWB/WikiFunctions/LogControl.Designer.cs (revision 1021) +++ AWB/WikiFunctions/LogControl.Designer.cs (working copy) @@ -64,6 +64,7 @@
this.lvSaved = new WikiFunctions.NoFlickerListView(); this.colSuccessSave = new System.Windows.Forms.ColumnHeader(); this.colSuccessTime = new System.Windows.Forms.ColumnHeader();
+ this.colSuccessRevId = new System.Windows.Forms.ColumnHeader();
this.mnuListView.SuspendLayout(); this.SuspendLayout(); //
@@ -328,7 +329,8 @@
| System.Windows.Forms.AnchorStyles.Right))); this.lvSaved.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.colSuccessSave,
- this.colSuccessTime}); + this.colSuccessTime, + this.colSuccessRevId});
this.lvSaved.ContextMenuStrip = this.mnuListView; this.lvSaved.FullRowSelect = true; this.lvSaved.Location = new System.Drawing.Point(6, 16);
@@ -350,6 +352,10 @@
// this.colSuccessTime.Text = "Time"; //
+ // colSuccessRevId + // + this.colSuccessRevId.Text = "Revision Id"; + //
// LogControl // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -373,12 +379,12 @@
#endregion
- private NoFlickerListView lvIgnored; + public NoFlickerListView lvIgnored;
private System.Windows.Forms.ColumnHeader colIgnoreArticle; private System.Windows.Forms.ColumnHeader colIgnoreTime; private System.Windows.Forms.ColumnHeader colSkippedBy; private System.Windows.Forms.ColumnHeader colSkipReason;
- private NoFlickerListView lvSaved; + public NoFlickerListView lvSaved;
private System.Windows.Forms.ColumnHeader colSuccessSave; private System.Windows.Forms.ColumnHeader colSuccessTime; private System.Windows.Forms.Button btnAddToList;
@@ -408,5 +414,6 @@
private System.Windows.Forms.ToolStripSeparator toolStripSeparator6; private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem resetToolStripMenuItem;
+ private System.Windows.Forms.ColumnHeader colSuccessRevId;
} }
Index: AWB/WikiFunctions/Logging.cs
=======================================================
modifier--- AWB/WikiFunctions/Logging.cs (revision 1021) +++ AWB/WikiFunctions/Logging.cs (working copy) @@ -111,6 +111,11 @@
mArticle = ArticleTitle; }
+ public void CurRevId(string CurRevisionId) + { + base.SubItems.Add(CurRevisionId); + } +
public void UserSkipped() { Skip("User", "Clicked ignore");
@@ -177,6 +182,11 @@
get { return GetSubItemText(1); } }
+ public string CurRevisionId + { + get { return GetSubItemText(2); } + } +
public string SkippedBy { get { return GetSubItemText(2); }
Index: AWB/WikiFunctions/RegExTypoFix.cs
=======================================================
modifierCannot display: file marked as a binary type. svn:mime-type = application/octet-stream Index: AWB/WikiFunctions/SubstTemplates.cs
=======================================================
modifier--- AWB/WikiFunctions/SubstTemplates.cs (revision 1021) +++ AWB/WikiFunctions/SubstTemplates.cs (working copy) @@ -51,7 +51,7 @@
string templ = Variables.NamespacesCaseInsensitive[10]; if (templ[0] == '(') {
- templ = templ.Insert(templ.Length - 2, "|[Mm]sg:|"); + templ = templ.Insert(templ.Length - 1, "|[Mm]sg:|");
} else {
Index: AWB/WikiFunctions/WebControl.cs
=======================================================
modifier--- AWB/WikiFunctions/WebControl.cs (revision 1021) +++ AWB/WikiFunctions/WebControl.cs (working copy) @@ -51,6 +51,7 @@
} Regex LoginRegex = new Regex("var wgUserName = (.*?);", RegexOptions.Compiled);
+ Regex RevIdRegex = new Regex("var wgCurRevisionId = \"(\\d+)\";", RegexOptions.Compiled);
Timer timer1 = new Timer();
@@ -270,6 +271,22 @@
} /// <summary>
+ /// Gets the current revision ID + /// </summary> + public string CurRevisionId() + { + if (this.Document == null) + return ""; + + Match m = RevIdRegex.Match(this.DocumentText); + + if (m.Groups[1].Value == "null") + return ""; + + return m.Groups[1].Value; + } + + /// <summary>
/// Gets a value indicating whether there is a new message /// </summary> public bool NewMessage