Commit da66bb024213ac0973353761f4a8f073e8027b4c

Authored by Schwirg László
1 parent 323b8dca

v1.18.0.0

- megadhatók a backupnál és a filecleaner-ben a kizárható filenevek mask listája
Vrh.Log4Pro.MaintenanceConsole/Manager - BackupPackageManager.cs
@@ -90,7 +90,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS @@ -90,7 +90,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
90 foreach (var bf in bp.Xml_BackupFolderList) { BackupPackageManagerCore.FolderZipBackup(bf, tempfolderpath); } 90 foreach (var bf in bp.Xml_BackupFolderList) { BackupPackageManagerCore.FolderZipBackup(bf, tempfolderpath); }
91 foreach (var sqldb in bp.Xml_BackupSQLDataBaseList) { SQLDataBaseManagerNS.SQLDataBaseManager.Execute(sqldb.Xml_Key,sqldb.Xml_DBBackup,sqldb.Xml_ScriptBackup,sqldb.Xml_TableDataBackup, tempfolderpath, timestamp); } 91 foreach (var sqldb in bp.Xml_BackupSQLDataBaseList) { SQLDataBaseManagerNS.SQLDataBaseManager.Execute(sqldb.Xml_Key,sqldb.Xml_DBBackup,sqldb.Xml_ScriptBackup,sqldb.Xml_TableDataBackup, tempfolderpath, timestamp); }
92 92
93 - BackupPackageManagerCore.CreatePackageFile(bp.Xml_PackageName, tempfolderpath, destinationfilename,destinationfolder, bp.Xml_CreateExe, bp.Xml_SourceIncludeFilenameMaskList); 93 + BackupPackageManagerCore.CreatePackageFile(bp.Xml_PackageName, tempfolderpath, destinationfilename,destinationfolder, bp.Xml_CreateExe, bp.Xml_SourceIncludeFilenameMaskList, bp.Xml_ExcludeMaskList);
94 if (Directory.Exists(tempfolderpath)) { Directory.Delete(tempfolderpath,true); } 94 if (Directory.Exists(tempfolderpath)) { Directory.Delete(tempfolderpath,true); }
95 } 95 }
96 catch (Exception ex) { ColorConsole.WriteLine(ex.MessageNested(), ConsoleColor.Red); } 96 catch (Exception ex) { ColorConsole.WriteLine(ex.MessageNested(), ConsoleColor.Red); }
@@ -138,7 +138,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS @@ -138,7 +138,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
138 } 138 }
139 if (lineix == 2) 139 if (lineix == 2)
140 { 140 {
141 - ColorConsole.Write($"{bp.Xml_SourceIncludeFilenameMaskList}", ConsoleColor.White, prefix: "Mask:"); 141 + ColorConsole.Write($"{bp.Xml_SourceIncludeFilenameMaskList}", ConsoleColor.White, prefix: "Incl.mask:");
  142 + ColorConsole.Write($"{bp.Xml_ExcludeMaskList}", ConsoleColor.White, prefix: " Excl.mask:");
142 ColorConsole.Write($"{bp.SizePackageTotal}", ConsoleColor.White, prefix: ", Bytes to include:"); 143 ColorConsole.Write($"{bp.SizePackageTotal}", ConsoleColor.White, prefix: ", Bytes to include:");
143 ColorConsole.WriteLine(""); 144 ColorConsole.WriteLine("");
144 return " "; 145 return " ";
@@ -157,7 +158,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS @@ -157,7 +158,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
157 if (bf.FolderExists) 158 if (bf.FolderExists)
158 { 159 {
159 var di = new DirectoryInfo(bf.Xml_Path); 160 var di = new DirectoryInfo(bf.Xml_Path);
160 - bp.SizePackageTotal += Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS.FileCleanerManagerCore.DirSize(di, bf.Xml_IncludeFileNameMask, bf.Xml_IncludeFileFullPathRegex, recurse: true); 161 + bp.SizePackageTotal += Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS.FileCleanerManagerCore.DirSize(di, bf.Xml_IncludeFileNameMask, bf.Xml_ExcludeFileNameMaskList, bf.Xml_IncludeFileFullPathRegex, recurse: true);
161 } 162 }
162 } 163 }
163 return bp; 164 return bp;
@@ -183,6 +184,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS @@ -183,6 +184,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
183 string destinationbackupfile = bf.Xml_BackupToFile; 184 string destinationbackupfile = bf.Xml_BackupToFile;
184 if (string.IsNullOrEmpty(destinationbackupfile)) { destinationbackupfile = (new DirectoryInfo(foldertobackuppath)).Name + ".zip"; } 185 if (string.IsNullOrEmpty(destinationbackupfile)) { destinationbackupfile = (new DirectoryInfo(foldertobackuppath)).Name + ".zip"; }
185 string includefilenamemask = bf.Xml_IncludeFileNameMask; 186 string includefilenamemask = bf.Xml_IncludeFileNameMask;
  187 + string excludefilenamemask = bf.Xml_ExcludeFileNameMaskList;
186 string includefullpathregex = bf.Xml_IncludeFileFullPathRegex; 188 string includefullpathregex = bf.Xml_IncludeFileFullPathRegex;
187 189
188 var destinationfile = Path.GetFileNameWithoutExtension(destinationbackupfile); 190 var destinationfile = Path.GetFileNameWithoutExtension(destinationbackupfile);
@@ -192,7 +194,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS @@ -192,7 +194,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
192 if (File.Exists(destinationbackupfile)) { File.Delete(destinationbackupfile); } 194 if (File.Exists(destinationbackupfile)) { File.Delete(destinationbackupfile); }
193 195
194 if (!Path.IsPathRooted(foldertobackuppath)) { foldertobackuppath = Path.Combine(Directory.GetCurrentDirectory(), foldertobackuppath); } 196 if (!Path.IsPathRooted(foldertobackuppath)) { foldertobackuppath = Path.Combine(Directory.GetCurrentDirectory(), foldertobackuppath); }
195 - ZipTools.CreateEntriesFromDirectoryContent(foldertobackuppath, destinationbackupfile, includefilenamemask,includefullpathregex); 197 + ZipTools.CreateEntriesFromDirectoryContent(foldertobackuppath, destinationbackupfile, includefilenamemask, excludefilenamemask,includefullpathregex);
196 ColorConsole.WriteLine($"Folder backup created. Name:{foldertobackuppath}", ConsoleColor.DarkGreen); 198 ColorConsole.WriteLine($"Folder backup created. Name:{foldertobackuppath}", ConsoleColor.DarkGreen);
197 } 199 }
198 /// <summary> 200 /// <summary>
@@ -205,7 +207,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS @@ -205,7 +207,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
205 /// <param name="vars">substitution vars</param> 207 /// <param name="vars">substitution vars</param>
206 /// <param name="createexe">if true, exe self extractor will be created, otherwise zip file; the extension of the package file is zip or exe</param> 208 /// <param name="createexe">if true, exe self extractor will be created, otherwise zip file; the extension of the package file is zip or exe</param>
207 /// <param name="sourceincludefilenamemaskList">comma separated list of masks for the files to include (NOT regex! "old fashioned" masking characters, like ?/* can be used)</param> 209 /// <param name="sourceincludefilenamemaskList">comma separated list of masks for the files to include (NOT regex! "old fashioned" masking characters, like ?/* can be used)</param>
208 - public static void CreatePackageFile(string packagename,string sourcedirectorypath, string destinationfilename =null,string destinationfolder=null,bool createexe=true,string sourceincludefilenamemaskList=null) 210 + public static void CreatePackageFile(string packagename,string sourcedirectorypath, string destinationfilename =null,string destinationfolder=null,bool createexe=true,string sourceincludefilenamemaskList=null,string excludeliststring = null)
209 { 211 {
210 string[] sourceinclfnamemasklist = sourceincludefilenamemaskList.Split(','); 212 string[] sourceinclfnamemasklist = sourceincludefilenamemaskList.Split(',');
211 bool createselfextractor = createexe; 213 bool createselfextractor = createexe;
@@ -231,18 +233,23 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS @@ -231,18 +233,23 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
231 string addfilecommand = "a"; 233 string addfilecommand = "a";
232 string response; 234 string response;
233 string packagefile; 235 string packagefile;
  236 +
  237 + string[] excludelist = excludeliststring.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
  238 + string excludeswitches = "";
  239 + foreach (var exstr in excludelist) excludeswitches += $" -x!{exstr}";
  240 +
234 if (createselfextractor) 241 if (createselfextractor)
235 { 242 {
236 string archivetype_7z = "-t7z"; 243 string archivetype_7z = "-t7z";
237 string createsfx = "-sfx"; 244 string createsfx = "-sfx";
238 packagefile = packageEXEfilepath; 245 packagefile = packageEXEfilepath;
239 - response = Tools.ExecuteAndGetStdIo("7z.exe", $"{addfilecommand} {packagefile} {includeliststr} {recursesubdirs} {archivetype_7z} {createsfx}"); 246 + response = Tools.ExecuteAndGetStdIo("7z.exe", $"{addfilecommand} {packagefile} {includeliststr} {recursesubdirs} {excludeswitches} {archivetype_7z} {createsfx} ");
240 } 247 }
241 else 248 else
242 { 249 {
243 string archivetype_zip = "-tzip"; 250 string archivetype_zip = "-tzip";
244 packagefile = packageZIPfilepath; 251 packagefile = packageZIPfilepath;
245 - response = Tools.ExecuteAndGetStdIo("7z.exe", $"{addfilecommand} {packagefile} {includeliststr} {recursesubdirs} {archivetype_zip}"); 252 + response = Tools.ExecuteAndGetStdIo("7z.exe", $"{addfilecommand} {packagefile} {includeliststr} {recursesubdirs} {excludeswitches} {archivetype_zip}");
246 } 253 }
247 ColorConsole.WriteLine($"Backup package created. Package name:{packagename}, package file: {packagefile}", ConsoleColor.Green); 254 ColorConsole.WriteLine($"Backup package created. Package name:{packagename}, package file: {packagefile}", ConsoleColor.Green);
248 255
@@ -358,6 +365,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS @@ -358,6 +365,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
358 public string Xml_PackageFilePath; 365 public string Xml_PackageFilePath;
359 public string Xml_TempDirectoryPath; 366 public string Xml_TempDirectoryPath;
360 public string Xml_SourceIncludeFilenameMaskList; 367 public string Xml_SourceIncludeFilenameMaskList;
  368 + public string Xml_ExcludeMaskList;
361 public bool Xml_CreateExe; 369 public bool Xml_CreateExe;
362 public List<BackupFolder> Xml_BackupFolderList; 370 public List<BackupFolder> Xml_BackupFolderList;
363 public List<BackupSQLDataBase> Xml_BackupSQLDataBaseList; 371 public List<BackupSQLDataBase> Xml_BackupSQLDataBaseList;
@@ -394,6 +402,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS @@ -394,6 +402,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
394 Xml_Key = GetValue(nameof(XmlStructure.BackupPackage.Attributes.Key), backupackagexml, XmlStructure.BackupPackage.Attributes.Key.Values.DEFAULT); 402 Xml_Key = GetValue(nameof(XmlStructure.BackupPackage.Attributes.Key), backupackagexml, XmlStructure.BackupPackage.Attributes.Key.Values.DEFAULT);
395 Xml_Description = GetValue(nameof(XmlStructure.BackupPackage.Attributes.Description), backupackagexml, Xml_PackageName); 403 Xml_Description = GetValue(nameof(XmlStructure.BackupPackage.Attributes.Description), backupackagexml, Xml_PackageName);
396 Xml_SourceIncludeFilenameMaskList = GetValue(nameof(XmlStructure.BackupPackage.Attributes.IncludeFilenameMaskList), backupackagexml, XmlStructure.BackupPackage.Attributes.IncludeFilenameMaskList.Values.DEFAULT); 404 Xml_SourceIncludeFilenameMaskList = GetValue(nameof(XmlStructure.BackupPackage.Attributes.IncludeFilenameMaskList), backupackagexml, XmlStructure.BackupPackage.Attributes.IncludeFilenameMaskList.Values.DEFAULT);
  405 + Xml_ExcludeMaskList = GetValue(nameof(XmlStructure.BackupPackage.Attributes.ExcludeFilenameMaskList), backupackagexml, XmlStructure.BackupPackage.Attributes.ExcludeFilenameMaskList.Values.DEFAULT);
397 406
398 Xml_BackupFolderList = new List<BackupFolder>(); 407 Xml_BackupFolderList = new List<BackupFolder>();
399 //var conditionxmlList = GetAllXElements(foldertocleanxml, nameof(XmlStructure.FolderToClean.Conditions), nameof(XmlStructure.FolderToClean.Conditions.Condition)); 408 //var conditionxmlList = GetAllXElements(foldertocleanxml, nameof(XmlStructure.FolderToClean.Conditions), nameof(XmlStructure.FolderToClean.Conditions.Condition));
@@ -424,6 +433,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS @@ -424,6 +433,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
424 Xml_TempDirectoryPath = bp.Xml_TempDirectoryPath; 433 Xml_TempDirectoryPath = bp.Xml_TempDirectoryPath;
425 Xml_BackupSQLDataBaseList = bp.Xml_BackupSQLDataBaseList.Select(c => new BackupSQLDataBase(c)).ToList(); ; 434 Xml_BackupSQLDataBaseList = bp.Xml_BackupSQLDataBaseList.Select(c => new BackupSQLDataBase(c)).ToList(); ;
426 Xml_SourceIncludeFilenameMaskList = bp.Xml_SourceIncludeFilenameMaskList; 435 Xml_SourceIncludeFilenameMaskList = bp.Xml_SourceIncludeFilenameMaskList;
  436 + Xml_ExcludeMaskList = bp.Xml_ExcludeMaskList;
427 Xml_CreateExe = bp.Xml_CreateExe; 437 Xml_CreateExe = bp.Xml_CreateExe;
428 } 438 }
429 #endregion cloner constructor 439 #endregion cloner constructor
@@ -451,6 +461,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS @@ -451,6 +461,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
451 public static class Description { } 461 public static class Description { }
452 public static class CreateExe { public static class Values { public const bool DEFAULT = true; } } 462 public static class CreateExe { public static class Values { public const bool DEFAULT = true; } }
453 public static class IncludeFilenameMaskList { public static class Values { public const string DEFAULT = "*"; } } 463 public static class IncludeFilenameMaskList { public static class Values { public const string DEFAULT = "*"; } }
  464 + public static class ExcludeFilenameMaskList { public static class Values { public const string DEFAULT = ""; } }
454 public static class PackageFilePath{ public static class Values { public const string DEFAULT = "BackupPackage_{TIMESTAMP}_{PACKAGENAME}"; } } 465 public static class PackageFilePath{ public static class Values { public const string DEFAULT = "BackupPackage_{TIMESTAMP}_{PACKAGENAME}"; } }
455 public static class TempDirectoryPath { public static class Values { public const string DEFAULT = ""; } } 466 public static class TempDirectoryPath { public static class Values { public const string DEFAULT = ""; } }
456 } 467 }
@@ -462,6 +473,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS @@ -462,6 +473,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
462 public static class Description { } 473 public static class Description { }
463 public static class BackupToFile { } 474 public static class BackupToFile { }
464 public static class IncludeNameMask { public class Values { public const string DEFAULT = "*"; } } 475 public static class IncludeNameMask { public class Values { public const string DEFAULT = "*"; } }
  476 + public static class ExcludeNameMaskList { public class Values { public const string DEFAULT = ""; } }
465 public static class IncludePathRegexp { public class Values { public const string DEFAULT = ".*"; } } 477 public static class IncludePathRegexp { public class Values { public const string DEFAULT = ".*"; } }
466 } 478 }
467 } 479 }
@@ -488,6 +500,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS @@ -488,6 +500,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
488 Xml_Description = GetValue(nameof(XmlStructure.BackupPackage.BackupFolder.Attributes.Description), backupfolderxml, Xml_Path); 500 Xml_Description = GetValue(nameof(XmlStructure.BackupPackage.BackupFolder.Attributes.Description), backupfolderxml, Xml_Path);
489 Xml_BackupToFile = GetValue(nameof(XmlStructure.BackupPackage.BackupFolder.Attributes.BackupToFile), backupfolderxml, ""); 501 Xml_BackupToFile = GetValue(nameof(XmlStructure.BackupPackage.BackupFolder.Attributes.BackupToFile), backupfolderxml, "");
490 Xml_IncludeFileNameMask = GetValue(nameof(XmlStructure.BackupPackage.BackupFolder.Attributes.IncludeNameMask), backupfolderxml, XmlStructure.BackupPackage.BackupFolder.Attributes.IncludeNameMask.Values.DEFAULT); 502 Xml_IncludeFileNameMask = GetValue(nameof(XmlStructure.BackupPackage.BackupFolder.Attributes.IncludeNameMask), backupfolderxml, XmlStructure.BackupPackage.BackupFolder.Attributes.IncludeNameMask.Values.DEFAULT);
  503 + Xml_ExcludeFileNameMaskList = GetValue(nameof(XmlStructure.BackupPackage.BackupFolder.Attributes.ExcludeNameMaskList), backupfolderxml, XmlStructure.BackupPackage.BackupFolder.Attributes.ExcludeNameMaskList.Values.DEFAULT);
491 Xml_IncludeFileFullPathRegex = GetValue(nameof(XmlStructure.BackupPackage.BackupFolder.Attributes.IncludePathRegexp), backupfolderxml, XmlStructure.BackupPackage.BackupFolder.Attributes.IncludePathRegexp.Values.DEFAULT); 504 Xml_IncludeFileFullPathRegex = GetValue(nameof(XmlStructure.BackupPackage.BackupFolder.Attributes.IncludePathRegexp), backupfolderxml, XmlStructure.BackupPackage.BackupFolder.Attributes.IncludePathRegexp.Values.DEFAULT);
492 } 505 }
493 public BackupFolder(BackupFolder bf) 506 public BackupFolder(BackupFolder bf)
@@ -497,12 +510,14 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS @@ -497,12 +510,14 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
497 Xml_BackupToFile = bf.Xml_BackupToFile; 510 Xml_BackupToFile = bf.Xml_BackupToFile;
498 FolderExists = bf.FolderExists; 511 FolderExists = bf.FolderExists;
499 Xml_IncludeFileNameMask = bf.Xml_IncludeFileNameMask; 512 Xml_IncludeFileNameMask = bf.Xml_IncludeFileNameMask;
  513 + Xml_ExcludeFileNameMaskList= bf.Xml_ExcludeFileNameMaskList;
500 Xml_IncludeFileFullPathRegex = bf.Xml_IncludeFileFullPathRegex; 514 Xml_IncludeFileFullPathRegex = bf.Xml_IncludeFileFullPathRegex;
501 } 515 }
502 public string Xml_Path; 516 public string Xml_Path;
503 public string Xml_Description; 517 public string Xml_Description;
504 public string Xml_BackupToFile; 518 public string Xml_BackupToFile;
505 public string Xml_IncludeFileNameMask; 519 public string Xml_IncludeFileNameMask;
  520 + public string Xml_ExcludeFileNameMaskList;
506 public string Xml_IncludeFileFullPathRegex; 521 public string Xml_IncludeFileFullPathRegex;
507 public bool FolderExists; 522 public bool FolderExists;
508 523
Vrh.Log4Pro.MaintenanceConsole/Manager - FileCleanerManager.cs
@@ -16,6 +16,7 @@ using System.Diagnostics; @@ -16,6 +16,7 @@ using System.Diagnostics;
16 using Vrh.Log4Pro.MaintenanceConsole.MenuNS; 16 using Vrh.Log4Pro.MaintenanceConsole.MenuNS;
17 using Vrh.Log4Pro.MaintenanceConsole.ColorConsoleNS; 17 using Vrh.Log4Pro.MaintenanceConsole.ColorConsoleNS;
18 using Vrh.Log4Pro.MaintenanceConsole.CommandLineParserNS; 18 using Vrh.Log4Pro.MaintenanceConsole.CommandLineParserNS;
  19 +using Vrh.Log4Pro.MaintenanceConsole.ToolsNS;
19 20
20 using Vrh.XmlProcessing; 21 using Vrh.XmlProcessing;
21 using VRH.Common; 22 using VRH.Common;
@@ -128,7 +129,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS @@ -128,7 +129,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
128 ColorConsole.Write($"{ws.Xml_Recurse}", fc2, prefix: "Recurse:", bracket: "[]"); 129 ColorConsole.Write($"{ws.Xml_Recurse}", fc2, prefix: "Recurse:", bracket: "[]");
129 var fc0 = ws.Xml_RemoveEmptyFolder ? ConsoleColor.Green : ConsoleColor.Yellow; 130 var fc0 = ws.Xml_RemoveEmptyFolder ? ConsoleColor.Green : ConsoleColor.Yellow;
130 ColorConsole.Write($"{ws.Xml_RemoveEmptyFolder}", fc0, prefix: ", Remove empty folder:", bracket: "[]"); 131 ColorConsole.Write($"{ws.Xml_RemoveEmptyFolder}", fc0, prefix: ", Remove empty folder:", bracket: "[]");
131 - ColorConsole.WriteLine(ws.Xml_IncludeMask, ConsoleColor.Yellow, prefix: ", Include mask:"); 132 + ColorConsole.Write(ws.Xml_IncludeMask, ConsoleColor.Yellow, prefix: ", Include mask:");
  133 + ColorConsole.WriteLine(ws.Xml_ExcludeMaskList, ConsoleColor.Yellow, prefix: ", Exclude mask:");
132 return " "; 134 return " ";
133 } 135 }
134 else if (lineix == 3) 136 else if (lineix == 3)
@@ -175,8 +177,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS @@ -175,8 +177,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
175 if (ftc.FolderExists) 177 if (ftc.FolderExists)
176 { 178 {
177 var di = new DirectoryInfo(ftc.Xml_DirectoryPath); 179 var di = new DirectoryInfo(ftc.Xml_DirectoryPath);
178 - ftc.SizeFolderTotal = FileCleanerManagerCore.DirSize(di,"*","",ftc.Xml_Recurse);  
179 - ftc.SizeSelectedBeforeClean = FileCleanerManagerCore.DirSize(di, ftc.Xml_IncludeMask, ftc.Xml_IncludeFullpathRegexp, ftc.Xml_Recurse); 180 + ftc.SizeFolderTotal = FileCleanerManagerCore.DirSize(di,"*","","",ftc.Xml_Recurse);
  181 + ftc.SizeSelectedBeforeClean = FileCleanerManagerCore.DirSize(di, ftc.Xml_IncludeMask,ftc.Xml_ExcludeMaskList, ftc.Xml_IncludeFullpathRegexp, ftc.Xml_Recurse);
180 ftc.SizeSelectedCleaned = FileCleanerManagerCore.CleanFolderFiles(di,ftc,delete:false); 182 ftc.SizeSelectedCleaned = FileCleanerManagerCore.CleanFolderFiles(di,ftc,delete:false);
181 } 183 }
182 return ftc; 184 return ftc;
@@ -199,17 +201,25 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS @@ -199,17 +201,25 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
199 #endregion IsDirectoryEmpty 201 #endregion IsDirectoryEmpty
200 202
201 #region public GetDirSize 203 #region public GetDirSize
202 - public static long DirSize(DirectoryInfo d, string filenamemask, string filefullpathregex, bool recurse) 204 + public static long DirSize(DirectoryInfo d, string includefilenamemask,string excludefilenamemaskcsvlist, string filefullpathregex, bool recurse)
203 { 205 {
204 long size = 0; 206 long size = 0;
205 // Add file sizes. 207 // Add file sizes.
206 - FileInfo[] fis = d.GetFiles(filenamemask, SearchOption.TopDirectoryOnly);  
207 - if (fis != null) { foreach (FileInfo fi in fis) { if (Regex.Match(fi.FullName, filefullpathregex).Success) { size += fi.Length; } } } 208 + FileInfo[] fis = d.GetFiles(includefilenamemask, SearchOption.TopDirectoryOnly);
  209 + if (fis != null)
  210 + {
  211 + foreach (FileInfo fi in fis)
  212 + {
  213 + bool toinclude1 = Regex.Match(fi.FullName, filefullpathregex, RegexOptions.IgnoreCase).Success;
  214 + bool toinclude2 = Regex.Match(fi.Name, ZipTools.FileNameMaskListToRegex(excludefilenamemaskcsvlist), RegexOptions.IgnoreCase).Success;
  215 + if (toinclude1 && toinclude2) { size += fi.Length; }
  216 + }
  217 + }
208 // Add subdirectory sizes. 218 // Add subdirectory sizes.
209 if (recurse) 219 if (recurse)
210 { 220 {
211 DirectoryInfo[] dis = d.GetDirectories(); 221 DirectoryInfo[] dis = d.GetDirectories();
212 - if (dis != null) { foreach (DirectoryInfo di in dis) { size += DirSize(di, filenamemask, filefullpathregex, recurse); } } 222 + if (dis != null) { foreach (DirectoryInfo di in dis) { size += DirSize(di, includefilenamemask, excludefilenamemaskcsvlist, filefullpathregex, recurse); } }
213 } 223 }
214 return size; 224 return size;
215 } 225 }
@@ -291,6 +301,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS @@ -291,6 +301,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
291 var fl = fi.Length; 301 var fl = fi.Length;
292 try 302 try
293 { 303 {
  304 + if (Regex.Match(fi.Name, ZipTools.FileNameMaskListToRegex(ftc.Xml_ExcludeMaskList)).Success) continue;
294 if (delete) { File.Delete(fi.FullName); } 305 if (delete) { File.Delete(fi.FullName); }
295 cleanedsize += fl; 306 cleanedsize += fl;
296 } 307 }
@@ -361,6 +372,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS @@ -361,6 +372,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
361 public bool Xml_Recurse; 372 public bool Xml_Recurse;
362 public bool Xml_RemoveEmptyFolder; 373 public bool Xml_RemoveEmptyFolder;
363 public string Xml_IncludeMask; 374 public string Xml_IncludeMask;
  375 + public string Xml_ExcludeMaskList;
364 public string Xml_IncludeFullpathRegexp; 376 public string Xml_IncludeFullpathRegexp;
365 public bool Xml_OrConditionList = true; 377 public bool Xml_OrConditionList = true;
366 public List<Condition> Xml_ConditionList; 378 public List<Condition> Xml_ConditionList;
@@ -394,6 +406,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS @@ -394,6 +406,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
394 Xml_Recurse = GetValue(nameof(XmlStructure.FolderToClean.Attributes.Recurse), foldertocleanxml, XmlStructure.FolderToClean.Attributes.Recurse.Values.DEFAULT); 406 Xml_Recurse = GetValue(nameof(XmlStructure.FolderToClean.Attributes.Recurse), foldertocleanxml, XmlStructure.FolderToClean.Attributes.Recurse.Values.DEFAULT);
395 Xml_RemoveEmptyFolder = GetValue(nameof(XmlStructure.FolderToClean.Attributes.RemoveEmptyFolder), foldertocleanxml, XmlStructure.FolderToClean.Attributes.RemoveEmptyFolder.Values.DEFAULT); 407 Xml_RemoveEmptyFolder = GetValue(nameof(XmlStructure.FolderToClean.Attributes.RemoveEmptyFolder), foldertocleanxml, XmlStructure.FolderToClean.Attributes.RemoveEmptyFolder.Values.DEFAULT);
396 Xml_IncludeMask = GetValue(nameof(XmlStructure.FolderToClean.Attributes.IncludeMask), foldertocleanxml, XmlStructure.FolderToClean.Attributes.IncludeMask.Values.DEFAULT); 408 Xml_IncludeMask = GetValue(nameof(XmlStructure.FolderToClean.Attributes.IncludeMask), foldertocleanxml, XmlStructure.FolderToClean.Attributes.IncludeMask.Values.DEFAULT);
  409 + Xml_ExcludeMaskList = GetValue(nameof(XmlStructure.FolderToClean.Attributes.ExcludeMaskList), foldertocleanxml, XmlStructure.FolderToClean.Attributes.ExcludeMaskList.Values.DEFAULT);
397 Xml_IncludeFullpathRegexp = GetValue(GetXElement(foldertocleanxml,nameof(XmlStructure.FolderToClean.IncludeFullpathRegexp)), XmlStructure.FolderToClean.IncludeFullpathRegexp.Values.DEFAULT); 410 Xml_IncludeFullpathRegexp = GetValue(GetXElement(foldertocleanxml,nameof(XmlStructure.FolderToClean.IncludeFullpathRegexp)), XmlStructure.FolderToClean.IncludeFullpathRegexp.Values.DEFAULT);
398 Xml_IncludeFullpathRegexp = Xml_IncludeFullpathRegexp.Replace("{DTSREGEX}", commondatetimestampregex).Replace("{TSREGEX}", commontimestampregex).Replace("{DSREGEX}", commondatestampregex); 411 Xml_IncludeFullpathRegexp = Xml_IncludeFullpathRegexp.Replace("{DTSREGEX}", commondatetimestampregex).Replace("{TSREGEX}", commontimestampregex).Replace("{DSREGEX}", commondatestampregex);
399 412
@@ -417,6 +430,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS @@ -417,6 +430,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
417 Xml_Recurse = ftc.Xml_Recurse; 430 Xml_Recurse = ftc.Xml_Recurse;
418 Xml_RemoveEmptyFolder = ftc.Xml_RemoveEmptyFolder; 431 Xml_RemoveEmptyFolder = ftc.Xml_RemoveEmptyFolder;
419 Xml_IncludeMask = ftc.Xml_IncludeMask; 432 Xml_IncludeMask = ftc.Xml_IncludeMask;
  433 + Xml_ExcludeMaskList = ftc.Xml_ExcludeMaskList;
420 Xml_IncludeFullpathRegexp = ftc.Xml_IncludeFullpathRegexp; 434 Xml_IncludeFullpathRegexp = ftc.Xml_IncludeFullpathRegexp;
421 Xml_OrConditionList = ftc.Xml_OrConditionList; 435 Xml_OrConditionList = ftc.Xml_OrConditionList;
422 Xml_ConditionList = ftc.Xml_ConditionList.Select(c=>new Condition(c)).ToList(); ; 436 Xml_ConditionList = ftc.Xml_ConditionList.Select(c=>new Condition(c)).ToList(); ;
@@ -498,6 +512,13 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS @@ -498,6 +512,13 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
498 public const string DEFAULT = "*.*"; 512 public const string DEFAULT = "*.*";
499 } 513 }
500 } 514 }
  515 + public static class ExcludeMaskList
  516 + {
  517 + public static class Values
  518 + {
  519 + public const string DEFAULT = "";
  520 + }
  521 + }
501 } 522 }
502 public static class IncludeFullpathRegexp 523 public static class IncludeFullpathRegexp
503 { 524 {
Vrh.Log4Pro.MaintenanceConsole/Manager - SQLDataBaseManager.cs
@@ -546,7 +546,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS @@ -546,7 +546,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
546 string ZIPbackupFullName = Path.Combine(backupdirectorypath, ZIPbackupfilename); 546 string ZIPbackupFullName = Path.Combine(backupdirectorypath, ZIPbackupfilename);
547 if (File.Exists(ZIPbackupFullName)) { File.Delete(ZIPbackupFullName); } 547 if (File.Exists(ZIPbackupFullName)) { File.Delete(ZIPbackupFullName); }
548 548
549 - ZipTools.CreateEntriesFromDirectoryContent(backupdirectorypath, ZIPbackupFullName, backupfilename, "", removearchivedfiles: false, storepathinzip: false); 549 + ZipTools.CreateEntriesFromDirectoryContent(backupdirectorypath, ZIPbackupFullName, backupfilename, "","", removearchivedfiles: false, storepathinzip: false);
550 if (File.Exists(backupFullName)) { File.Delete(backupFullName); } 550 if (File.Exists(backupFullName)) { File.Delete(backupFullName); }
551 returnfilename = ZIPbackupFullName; 551 returnfilename = ZIPbackupFullName;
552 } 552 }
@@ -926,7 +926,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS @@ -926,7 +926,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
926 ScriptOneObject(sqlserver, tempbackupdirectorypath, backupfilenamemask + backupfilenameext, sqldatabase.Views.Cast<SqlSmoObject>().ToList(), vars); 926 ScriptOneObject(sqlserver, tempbackupdirectorypath, backupfilenamemask + backupfilenameext, sqldatabase.Views.Cast<SqlSmoObject>().ToList(), vars);
927 ScriptOneObject(sqlserver, tempbackupdirectorypath, backupfilenamemask + backupfilenameext, sqldatabase.Tables.Cast<SqlSmoObject>().ToList(), vars); 927 ScriptOneObject(sqlserver, tempbackupdirectorypath, backupfilenamemask + backupfilenameext, sqldatabase.Tables.Cast<SqlSmoObject>().ToList(), vars);
928 ScriptOneObject(sqlserver, tempbackupdirectorypath, backupfilenamemask + backupfilenameext, sqldatabase.Triggers.Cast<SqlSmoObject>().ToList(), vars); 928 ScriptOneObject(sqlserver, tempbackupdirectorypath, backupfilenamemask + backupfilenameext, sqldatabase.Triggers.Cast<SqlSmoObject>().ToList(), vars);
929 - if (createZip) { ZipTools.CreateEntriesFromDirectoryContent(tempbackupdirectorypath, zipfilefullpath, "*.sql", backupts,removearchivedfiles:true, storepathinzip: false); } 929 + if (createZip) { ZipTools.CreateEntriesFromDirectoryContent(tempbackupdirectorypath, zipfilefullpath, "*.sql","", backupts,removearchivedfiles:true, storepathinzip: false); }
930 var resultfilename = zipfilefullpath == null ? "-" : Path.GetFileName(zipfilefullpath); 930 var resultfilename = zipfilefullpath == null ? "-" : Path.GetFileName(zipfilefullpath);
931 ColorConsole.WriteLine($"SQL scripts created. DB name:'{dbname}'. BAK/ZIP file name:'{resultfilename}'", ConsoleColor.DarkGreen); 931 ColorConsole.WriteLine($"SQL scripts created. DB name:'{dbname}'. BAK/ZIP file name:'{resultfilename}'", ConsoleColor.DarkGreen);
932 } 932 }
@@ -1048,7 +1048,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS @@ -1048,7 +1048,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
1048 if (createZip) 1048 if (createZip)
1049 { 1049 {
1050 string fullpathregex = Regex.Escape(string.Join(";",backupfilepathlist)).Replace(';','|'); 1050 string fullpathregex = Regex.Escape(string.Join(";",backupfilepathlist)).Replace(';','|');
1051 - ZipTools.CreateEntriesFromDirectoryContent(tempbackupdirectorypath, zipfilefullpath, "*.sql", fullpathregex, removearchivedfiles: true, storepathinzip: false); 1051 + ZipTools.CreateEntriesFromDirectoryContent(tempbackupdirectorypath, zipfilefullpath, "*.sql","", fullpathregex, removearchivedfiles: true, storepathinzip: false);
1052 } 1052 }
1053 var resultfilename = zipfilefullpath == null ? "-" : Path.GetFileName(zipfilefullpath); 1053 var resultfilename = zipfilefullpath == null ? "-" : Path.GetFileName(zipfilefullpath);
1054 ColorConsole.WriteLine($"SQL data scripts created. DB name:'{dbname}'. BAK/ZIP file name:'{resultfilename}'", ConsoleColor.DarkGreen); 1054 ColorConsole.WriteLine($"SQL data scripts created. DB name:'{dbname}'. BAK/ZIP file name:'{resultfilename}'", ConsoleColor.DarkGreen);
Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices; @@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
32 // You can specify all the values or you can default the Build and Revision Numbers 32 // You can specify all the values or you can default the Build and Revision Numbers
33 // by using the '*' as shown below: 33 // by using the '*' as shown below:
34 // [assembly: AssemblyVersion("1.0.*")] 34 // [assembly: AssemblyVersion("1.0.*")]
35 -[assembly: AssemblyVersion("1.17.1.0")]  
36 -[assembly: AssemblyFileVersion("1.17.1.0")] 35 +[assembly: AssemblyVersion("1.18.0.0")]
  36 +[assembly: AssemblyFileVersion("1.18.0.0")]
Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools - Http.cs renamed to Vrh.Log4Pro.MaintenanceConsole/Tools - Http.cs
Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools - Membership.cs renamed to Vrh.Log4Pro.MaintenanceConsole/Tools - Membership.cs
Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools - TcpIp.cs renamed to Vrh.Log4Pro.MaintenanceConsole/Tools - TcpIp.cs
Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools.cs renamed to Vrh.Log4Pro.MaintenanceConsole/Tools.cs
@@ -74,6 +74,18 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS @@ -74,6 +74,18 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS
74 } 74 }
75 public static class ZipTools 75 public static class ZipTools
76 { 76 {
  77 + public static string FileNameMaskListToRegex(string excludefilenamemaskcsvlist)
  78 + {
  79 + string pattern = "";
  80 + string regexor = "";
  81 + foreach (var exclmask in excludefilenamemaskcsvlist.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries))
  82 + {
  83 + pattern += regexor + "(^" + Regex.Escape(exclmask.Replace(".", "__DOT__").Replace("*", "__STAR__").Replace("?", "__QM__"))
  84 + .Replace("__DOT__", "[.]").Replace("__STAR__", ".*").Replace("__QM__", ".") + "$)";
  85 + regexor = "|";
  86 + }
  87 + return "(" + pattern + ")";
  88 + }
77 public static void Extract1stFileFromZIP(string targetfilefullpath, string ZIPfilefullpath) 89 public static void Extract1stFileFromZIP(string targetfilefullpath, string ZIPfilefullpath)
78 { 90 {
79 if (File.Exists(targetfilefullpath)) { File.Delete(targetfilefullpath); } 91 if (File.Exists(targetfilefullpath)) { File.Delete(targetfilefullpath); }
@@ -98,11 +110,12 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS @@ -98,11 +110,12 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS
98 } 110 }
99 } 111 }
100 112
101 - public static void CreateEntriesFromDirectoryContent(string sourcefolderpath, string ZIPfilefullpath, string includefilenamemask, string includefullpathregex, bool removearchivedfiles = false,bool storepathinzip = true) 113 + public static void CreateEntriesFromDirectoryContent(string sourcefolderpath, string ZIPfilefullpath, string includefilenamemask, string excludefilenamemasklist, string includefullpathregex, bool removearchivedfiles = false,bool storepathinzip = true)
102 { 114 {
103 if (File.Exists(ZIPfilefullpath)) { File.Delete(ZIPfilefullpath); } 115 if (File.Exists(ZIPfilefullpath)) { File.Delete(ZIPfilefullpath); }
104 DirectoryInfo di = new DirectoryInfo(sourcefolderpath); 116 DirectoryInfo di = new DirectoryInfo(sourcefolderpath);
105 - var rgx = new Regex(includefullpathregex??""); 117 + var inclrgx = new Regex(includefullpathregex??"");
  118 + var exclrgx = new Regex(FileNameMaskListToRegex(excludefilenamemasklist) ?? "");
106 var archivedfiles = new List<string>(); 119 var archivedfiles = new List<string>();
107 using (ZipArchive archive = ZipFile.Open(ZIPfilefullpath, ZipArchiveMode.Create)) 120 using (ZipArchive archive = ZipFile.Open(ZIPfilefullpath, ZipArchiveMode.Create))
108 { 121 {
@@ -113,10 +126,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS @@ -113,10 +126,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS
113 int cpl = ColorConsole.CursorLeft; 126 int cpl = ColorConsole.CursorLeft;
114 foreach (var fi in fis) 127 foreach (var fi in fis)
115 { 128 {
116 - var entryname = storepathinzip  
117 - ? fi.FullName.Substring((Path.GetPathRoot(fi.FullName)?.Length) ?? 0)  
118 - : fi.Name;  
119 - if (rgx.Match(fi.FullName).Success) 129 + var entryname = storepathinzip ? fi.FullName.Substring((Path.GetPathRoot(fi.FullName)?.Length) ?? 0) : fi.Name;
  130 + if (inclrgx.Match(fi.FullName).Success && !exclrgx.Match(fi.Name).Success)
120 { 131 {
121 try 132 try
122 { 133 {
Vrh.Log4Pro.MaintenanceConsole/Vrh.Log4Pro.MaintenanceConsole.csproj
@@ -359,13 +359,13 @@ @@ -359,13 +359,13 @@
359 <Reference Include="WindowsBase" /> 359 <Reference Include="WindowsBase" />
360 </ItemGroup> 360 </ItemGroup>
361 <ItemGroup> 361 <ItemGroup>
362 - <Compile Include="ConsoleFunction - Tools - Http.cs" />  
363 - <Compile Include="ConsoleFunction - Tools - TcpIp.cs" /> 362 + <Compile Include="Tools - Http.cs" />
  363 + <Compile Include="Tools - TcpIp.cs" />
364 <Compile Include="ConsoleFunction - CommandLineParser.cs" /> 364 <Compile Include="ConsoleFunction - CommandLineParser.cs" />
365 <Compile Include="ConsoleFunction - ColorConsole.cs" /> 365 <Compile Include="ConsoleFunction - ColorConsole.cs" />
366 <Compile Include="ConsoleFunction - Menu.cs" /> 366 <Compile Include="ConsoleFunction - Menu.cs" />
367 - <Compile Include="ConsoleFunction - Tools - Membership.cs" />  
368 - <Compile Include="ConsoleFunction - Tools.cs" /> 367 + <Compile Include="Tools - Membership.cs" />
  368 + <Compile Include="Tools.cs" />
369 <Compile Include="Manager - FTPManager.cs" /> 369 <Compile Include="Manager - FTPManager.cs" />
370 <Compile Include="Manager - BackupPackageManager.cs" /> 370 <Compile Include="Manager - BackupPackageManager.cs" />
371 <Compile Include="Manager - InstallManager.cs" /> 371 <Compile Include="Manager - InstallManager.cs" />