Commit da66bb024213ac0973353761f4a8f073e8027b4c
1 parent
323b8dca
v1.18.0.0
- megadhatók a backupnál és a filecleaner-ben a kizárható filenevek mask listája
Showing
9 changed files
with
76 additions
and
29 deletions
Show diff stats
Vrh.Log4Pro.MaintenanceConsole/Manager - BackupPackageManager.cs
| ... | ... | @@ -90,7 +90,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS |
| 90 | 90 | foreach (var bf in bp.Xml_BackupFolderList) { BackupPackageManagerCore.FolderZipBackup(bf, tempfolderpath); } |
| 91 | 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 | 94 | if (Directory.Exists(tempfolderpath)) { Directory.Delete(tempfolderpath,true); } |
| 95 | 95 | } |
| 96 | 96 | catch (Exception ex) { ColorConsole.WriteLine(ex.MessageNested(), ConsoleColor.Red); } |
| ... | ... | @@ -138,7 +138,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS |
| 138 | 138 | } |
| 139 | 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 | 143 | ColorConsole.Write($"{bp.SizePackageTotal}", ConsoleColor.White, prefix: ", Bytes to include:"); |
| 143 | 144 | ColorConsole.WriteLine(""); |
| 144 | 145 | return " "; |
| ... | ... | @@ -157,7 +158,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS |
| 157 | 158 | if (bf.FolderExists) |
| 158 | 159 | { |
| 159 | 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 | 164 | return bp; |
| ... | ... | @@ -183,6 +184,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS |
| 183 | 184 | string destinationbackupfile = bf.Xml_BackupToFile; |
| 184 | 185 | if (string.IsNullOrEmpty(destinationbackupfile)) { destinationbackupfile = (new DirectoryInfo(foldertobackuppath)).Name + ".zip"; } |
| 185 | 186 | string includefilenamemask = bf.Xml_IncludeFileNameMask; |
| 187 | + string excludefilenamemask = bf.Xml_ExcludeFileNameMaskList; | |
| 186 | 188 | string includefullpathregex = bf.Xml_IncludeFileFullPathRegex; |
| 187 | 189 | |
| 188 | 190 | var destinationfile = Path.GetFileNameWithoutExtension(destinationbackupfile); |
| ... | ... | @@ -192,7 +194,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS |
| 192 | 194 | if (File.Exists(destinationbackupfile)) { File.Delete(destinationbackupfile); } |
| 193 | 195 | |
| 194 | 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 | 198 | ColorConsole.WriteLine($"Folder backup created. Name:{foldertobackuppath}", ConsoleColor.DarkGreen); |
| 197 | 199 | } |
| 198 | 200 | /// <summary> |
| ... | ... | @@ -205,7 +207,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS |
| 205 | 207 | /// <param name="vars">substitution vars</param> |
| 206 | 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 | 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 | 212 | string[] sourceinclfnamemasklist = sourceincludefilenamemaskList.Split(','); |
| 211 | 213 | bool createselfextractor = createexe; |
| ... | ... | @@ -231,18 +233,23 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS |
| 231 | 233 | string addfilecommand = "a"; |
| 232 | 234 | string response; |
| 233 | 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 | 241 | if (createselfextractor) |
| 235 | 242 | { |
| 236 | 243 | string archivetype_7z = "-t7z"; |
| 237 | 244 | string createsfx = "-sfx"; |
| 238 | 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 | 248 | else |
| 242 | 249 | { |
| 243 | 250 | string archivetype_zip = "-tzip"; |
| 244 | 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 | 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 | 365 | public string Xml_PackageFilePath; |
| 359 | 366 | public string Xml_TempDirectoryPath; |
| 360 | 367 | public string Xml_SourceIncludeFilenameMaskList; |
| 368 | + public string Xml_ExcludeMaskList; | |
| 361 | 369 | public bool Xml_CreateExe; |
| 362 | 370 | public List<BackupFolder> Xml_BackupFolderList; |
| 363 | 371 | public List<BackupSQLDataBase> Xml_BackupSQLDataBaseList; |
| ... | ... | @@ -394,6 +402,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS |
| 394 | 402 | Xml_Key = GetValue(nameof(XmlStructure.BackupPackage.Attributes.Key), backupackagexml, XmlStructure.BackupPackage.Attributes.Key.Values.DEFAULT); |
| 395 | 403 | Xml_Description = GetValue(nameof(XmlStructure.BackupPackage.Attributes.Description), backupackagexml, Xml_PackageName); |
| 396 | 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 | 407 | Xml_BackupFolderList = new List<BackupFolder>(); |
| 399 | 408 | //var conditionxmlList = GetAllXElements(foldertocleanxml, nameof(XmlStructure.FolderToClean.Conditions), nameof(XmlStructure.FolderToClean.Conditions.Condition)); |
| ... | ... | @@ -424,6 +433,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS |
| 424 | 433 | Xml_TempDirectoryPath = bp.Xml_TempDirectoryPath; |
| 425 | 434 | Xml_BackupSQLDataBaseList = bp.Xml_BackupSQLDataBaseList.Select(c => new BackupSQLDataBase(c)).ToList(); ; |
| 426 | 435 | Xml_SourceIncludeFilenameMaskList = bp.Xml_SourceIncludeFilenameMaskList; |
| 436 | + Xml_ExcludeMaskList = bp.Xml_ExcludeMaskList; | |
| 427 | 437 | Xml_CreateExe = bp.Xml_CreateExe; |
| 428 | 438 | } |
| 429 | 439 | #endregion cloner constructor |
| ... | ... | @@ -451,6 +461,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS |
| 451 | 461 | public static class Description { } |
| 452 | 462 | public static class CreateExe { public static class Values { public const bool DEFAULT = true; } } |
| 453 | 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 | 465 | public static class PackageFilePath{ public static class Values { public const string DEFAULT = "BackupPackage_{TIMESTAMP}_{PACKAGENAME}"; } } |
| 455 | 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 | 473 | public static class Description { } |
| 463 | 474 | public static class BackupToFile { } |
| 464 | 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 | 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 | 500 | Xml_Description = GetValue(nameof(XmlStructure.BackupPackage.BackupFolder.Attributes.Description), backupfolderxml, Xml_Path); |
| 489 | 501 | Xml_BackupToFile = GetValue(nameof(XmlStructure.BackupPackage.BackupFolder.Attributes.BackupToFile), backupfolderxml, ""); |
| 490 | 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 | 504 | Xml_IncludeFileFullPathRegex = GetValue(nameof(XmlStructure.BackupPackage.BackupFolder.Attributes.IncludePathRegexp), backupfolderxml, XmlStructure.BackupPackage.BackupFolder.Attributes.IncludePathRegexp.Values.DEFAULT); |
| 492 | 505 | } |
| 493 | 506 | public BackupFolder(BackupFolder bf) |
| ... | ... | @@ -497,12 +510,14 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS |
| 497 | 510 | Xml_BackupToFile = bf.Xml_BackupToFile; |
| 498 | 511 | FolderExists = bf.FolderExists; |
| 499 | 512 | Xml_IncludeFileNameMask = bf.Xml_IncludeFileNameMask; |
| 513 | + Xml_ExcludeFileNameMaskList= bf.Xml_ExcludeFileNameMaskList; | |
| 500 | 514 | Xml_IncludeFileFullPathRegex = bf.Xml_IncludeFileFullPathRegex; |
| 501 | 515 | } |
| 502 | 516 | public string Xml_Path; |
| 503 | 517 | public string Xml_Description; |
| 504 | 518 | public string Xml_BackupToFile; |
| 505 | 519 | public string Xml_IncludeFileNameMask; |
| 520 | + public string Xml_ExcludeFileNameMaskList; | |
| 506 | 521 | public string Xml_IncludeFileFullPathRegex; |
| 507 | 522 | public bool FolderExists; |
| 508 | 523 | ... | ... |
Vrh.Log4Pro.MaintenanceConsole/Manager - FileCleanerManager.cs
| ... | ... | @@ -16,6 +16,7 @@ using System.Diagnostics; |
| 16 | 16 | using Vrh.Log4Pro.MaintenanceConsole.MenuNS; |
| 17 | 17 | using Vrh.Log4Pro.MaintenanceConsole.ColorConsoleNS; |
| 18 | 18 | using Vrh.Log4Pro.MaintenanceConsole.CommandLineParserNS; |
| 19 | +using Vrh.Log4Pro.MaintenanceConsole.ToolsNS; | |
| 19 | 20 | |
| 20 | 21 | using Vrh.XmlProcessing; |
| 21 | 22 | using VRH.Common; |
| ... | ... | @@ -128,7 +129,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS |
| 128 | 129 | ColorConsole.Write($"{ws.Xml_Recurse}", fc2, prefix: "Recurse:", bracket: "[]"); |
| 129 | 130 | var fc0 = ws.Xml_RemoveEmptyFolder ? ConsoleColor.Green : ConsoleColor.Yellow; |
| 130 | 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 | 134 | return " "; |
| 133 | 135 | } |
| 134 | 136 | else if (lineix == 3) |
| ... | ... | @@ -175,8 +177,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS |
| 175 | 177 | if (ftc.FolderExists) |
| 176 | 178 | { |
| 177 | 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 | 182 | ftc.SizeSelectedCleaned = FileCleanerManagerCore.CleanFolderFiles(di,ftc,delete:false); |
| 181 | 183 | } |
| 182 | 184 | return ftc; |
| ... | ... | @@ -199,17 +201,25 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS |
| 199 | 201 | #endregion IsDirectoryEmpty |
| 200 | 202 | |
| 201 | 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 | 206 | long size = 0; |
| 205 | 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 | 218 | // Add subdirectory sizes. |
| 209 | 219 | if (recurse) |
| 210 | 220 | { |
| 211 | 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 | 224 | return size; |
| 215 | 225 | } |
| ... | ... | @@ -291,6 +301,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS |
| 291 | 301 | var fl = fi.Length; |
| 292 | 302 | try |
| 293 | 303 | { |
| 304 | + if (Regex.Match(fi.Name, ZipTools.FileNameMaskListToRegex(ftc.Xml_ExcludeMaskList)).Success) continue; | |
| 294 | 305 | if (delete) { File.Delete(fi.FullName); } |
| 295 | 306 | cleanedsize += fl; |
| 296 | 307 | } |
| ... | ... | @@ -361,6 +372,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS |
| 361 | 372 | public bool Xml_Recurse; |
| 362 | 373 | public bool Xml_RemoveEmptyFolder; |
| 363 | 374 | public string Xml_IncludeMask; |
| 375 | + public string Xml_ExcludeMaskList; | |
| 364 | 376 | public string Xml_IncludeFullpathRegexp; |
| 365 | 377 | public bool Xml_OrConditionList = true; |
| 366 | 378 | public List<Condition> Xml_ConditionList; |
| ... | ... | @@ -394,6 +406,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS |
| 394 | 406 | Xml_Recurse = GetValue(nameof(XmlStructure.FolderToClean.Attributes.Recurse), foldertocleanxml, XmlStructure.FolderToClean.Attributes.Recurse.Values.DEFAULT); |
| 395 | 407 | Xml_RemoveEmptyFolder = GetValue(nameof(XmlStructure.FolderToClean.Attributes.RemoveEmptyFolder), foldertocleanxml, XmlStructure.FolderToClean.Attributes.RemoveEmptyFolder.Values.DEFAULT); |
| 396 | 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 | 410 | Xml_IncludeFullpathRegexp = GetValue(GetXElement(foldertocleanxml,nameof(XmlStructure.FolderToClean.IncludeFullpathRegexp)), XmlStructure.FolderToClean.IncludeFullpathRegexp.Values.DEFAULT); |
| 398 | 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 | 430 | Xml_Recurse = ftc.Xml_Recurse; |
| 418 | 431 | Xml_RemoveEmptyFolder = ftc.Xml_RemoveEmptyFolder; |
| 419 | 432 | Xml_IncludeMask = ftc.Xml_IncludeMask; |
| 433 | + Xml_ExcludeMaskList = ftc.Xml_ExcludeMaskList; | |
| 420 | 434 | Xml_IncludeFullpathRegexp = ftc.Xml_IncludeFullpathRegexp; |
| 421 | 435 | Xml_OrConditionList = ftc.Xml_OrConditionList; |
| 422 | 436 | Xml_ConditionList = ftc.Xml_ConditionList.Select(c=>new Condition(c)).ToList(); ; |
| ... | ... | @@ -498,6 +512,13 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS |
| 498 | 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 | 523 | public static class IncludeFullpathRegexp |
| 503 | 524 | { | ... | ... |
Vrh.Log4Pro.MaintenanceConsole/Manager - SQLDataBaseManager.cs
| ... | ... | @@ -546,7 +546,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS |
| 546 | 546 | string ZIPbackupFullName = Path.Combine(backupdirectorypath, ZIPbackupfilename); |
| 547 | 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 | 550 | if (File.Exists(backupFullName)) { File.Delete(backupFullName); } |
| 551 | 551 | returnfilename = ZIPbackupFullName; |
| 552 | 552 | } |
| ... | ... | @@ -926,7 +926,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS |
| 926 | 926 | ScriptOneObject(sqlserver, tempbackupdirectorypath, backupfilenamemask + backupfilenameext, sqldatabase.Views.Cast<SqlSmoObject>().ToList(), vars); |
| 927 | 927 | ScriptOneObject(sqlserver, tempbackupdirectorypath, backupfilenamemask + backupfilenameext, sqldatabase.Tables.Cast<SqlSmoObject>().ToList(), vars); |
| 928 | 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 | 930 | var resultfilename = zipfilefullpath == null ? "-" : Path.GetFileName(zipfilefullpath); |
| 931 | 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 | 1048 | if (createZip) |
| 1049 | 1049 | { |
| 1050 | 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 | 1053 | var resultfilename = zipfilefullpath == null ? "-" : Path.GetFileName(zipfilefullpath); |
| 1054 | 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 | 32 | // You can specify all the values or you can default the Build and Revision Numbers |
| 33 | 33 | // by using the '*' as shown below: |
| 34 | 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 | 74 | } |
| 75 | 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 | 89 | public static void Extract1stFileFromZIP(string targetfilefullpath, string ZIPfilefullpath) |
| 78 | 90 | { |
| 79 | 91 | if (File.Exists(targetfilefullpath)) { File.Delete(targetfilefullpath); } |
| ... | ... | @@ -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 | 115 | if (File.Exists(ZIPfilefullpath)) { File.Delete(ZIPfilefullpath); } |
| 104 | 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 | 119 | var archivedfiles = new List<string>(); |
| 107 | 120 | using (ZipArchive archive = ZipFile.Open(ZIPfilefullpath, ZipArchiveMode.Create)) |
| 108 | 121 | { |
| ... | ... | @@ -113,10 +126,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS |
| 113 | 126 | int cpl = ColorConsole.CursorLeft; |
| 114 | 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 | 132 | try |
| 122 | 133 | { | ... | ... |
Vrh.Log4Pro.MaintenanceConsole/Vrh.Log4Pro.MaintenanceConsole.csproj
| ... | ... | @@ -359,13 +359,13 @@ |
| 359 | 359 | <Reference Include="WindowsBase" /> |
| 360 | 360 | </ItemGroup> |
| 361 | 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 | 364 | <Compile Include="ConsoleFunction - CommandLineParser.cs" /> |
| 365 | 365 | <Compile Include="ConsoleFunction - ColorConsole.cs" /> |
| 366 | 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 | 369 | <Compile Include="Manager - FTPManager.cs" /> |
| 370 | 370 | <Compile Include="Manager - BackupPackageManager.cs" /> |
| 371 | 371 | <Compile Include="Manager - InstallManager.cs" /> | ... | ... |