Automatically 7Zip mailbox

Edit/Select All/Select None Menu items
7Zip Library
7Zip Library - Accessible for c# (Add reference to this)
This commit is contained in:
Rich
2012-04-26 22:03:44 +00:00
parent 1f9f65ae18
commit c16424e008
4 changed files with 93 additions and 5 deletions

View File

@@ -7,7 +7,7 @@ using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Xml;
using SevenZip;
namespace Sync
{
@@ -127,7 +127,11 @@ namespace Sync
foreach (XmlAttribute xa in xl)
if(xa.Value.ToUpper().EndsWith("SQL"))
retval.Add(xa.Value);
xl = doc.DocumentElement.SelectNodes(@"//ns:EmbeddedResource/@Include",nsmgr);
xl = doc.DocumentElement.SelectNodes(@"//ns:Content/@Include", nsmgr);
foreach (XmlAttribute xa in xl)
if (xa.Value.ToUpper().EndsWith("DLL"))
retval.Add(xa.Value);
xl = doc.DocumentElement.SelectNodes(@"//ns:EmbeddedResource/@Include", nsmgr);
foreach (XmlAttribute xa in xl)
if (!xa.Value.ToUpper().EndsWith("LICX"))
retval.Add(xa.Value);
@@ -199,6 +203,24 @@ namespace Sync
fc.MoveSSToMailBox(tbSourceSafe.Text, tbSSMailBox.Text);
}
}
BuildZipOfMailBox(tbMailBox.Text);
}
private void BuildZipOfMailBox(string mailbox)
{
SevenZipCompressor.SetLibraryPath(Application.StartupPath + @"\7z.dll");
SevenZipCompressor cmpr = new SevenZipCompressor();
cmpr.PreserveDirectoryRoot = true;
string zipName = string.Format("{0} To SS {1}.7z", mailbox, DateTime.Now.ToString("yyyyMMdd HHmm"));
cmpr.CompressDirectory(mailbox, zipName, "*.*", true);
MessageBox.Show(string.Format("{0} created!", zipName), "Mailbox Zip Created", MessageBoxButtons.OK, MessageBoxIcon.Information);
//if (System.IO.File.Exists(@"c:\program files\7-zip\7z.exe"))
//{
// string args = string.Format(@"a -t7z ""{0} To SS {1}.7z"" ""{0}\*.*"" -r", mailbox, DateTime.Now.ToString("yyyyMMdd HHmm"));
// System.Diagnostics.Process p = System.Diagnostics.Process.Start(@"c:\program files\7-zip\7z", args);
// p.WaitForExit();
//}
//"c:\program files\7-zip\7z" a -t7z "C:\Development\MailBox\Proms To SS 20120424 1850.7z" "C:\Development\MailBox\Proms\*.*" -r
}
private void checkedOutToolStripMenuItem_Click(object sender, EventArgs e)
{
@@ -427,9 +449,23 @@ namespace Sync
sb.Append((fis.Exists ? "" : " =>NEW") + "\t" + fi.Name + "\r\n");
}
}
Clipboard.Clear();
Clipboard.SetText(sb.ToString());
MessageBox.Show(sb.ToString(), "Copied to Clipboard", MessageBoxButtons.OK, MessageBoxIcon.Information);
try
{
Clipboard.Clear();
Clipboard.SetText(sb.ToString());
MessageBox.Show(sb.ToString(), "Copied to Clipboard", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
StringBuilder sb2 = new StringBuilder();
string prefix = "";
while (ex != null)
{
sb2.AppendLine(string.Format("{0}{1} - {2}",prefix, ex.GetType().Name, ex.Message));
prefix += " ";
}
MessageBox.Show(sb2.ToString(), "Error saving Clipboard", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void dgv_MouseDown(object sender, MouseEventArgs e)
{
@@ -439,5 +475,27 @@ namespace Sync
dgv.CurrentCell = dgv[0, info.RowIndex];
dgv.Rows[info.RowIndex].Selected = true;
}
private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
{
if (_CheckedOut == null || _CheckedOut.Count == 0)
{
MessageBox.Show("Don't you really think you should get a list first!", "Hey Moron!", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop);
return;
}
foreach (FileCompare fc in _CheckedOut) fc.ToProcess = true;
dgv.Refresh();
}
private void selectNoneToolStripMenuItem_Click(object sender, EventArgs e)
{
if (_CheckedOut == null || _CheckedOut.Count == 0)
{
MessageBox.Show("Don't you really think you should get a list first!", "Hey Moron!", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop);
return;
}
foreach (FileCompare fc in _CheckedOut) fc.ToProcess = false;
dgv.Refresh();
}
}
}