Commit 2f5d87653d4182acbff93443ac73890ea31cbc03

Authored by Schwirg László
1 parent fb6819fe

v1.3.0.0

FileCleaner és Backup package paraméterezésének jobbítása
Vrh.Log4Pro.MaintenanceConsole/Manager - BackupPackageManager.cs
... ... @@ -79,6 +79,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
79 79 var vars = new Dictionary<string, string>();
80 80 vars.Add("PACKAGENAME", bp.Xml_PackageName);
81 81 vars.Add("PACKAGETS", packagets);
  82 + vars.Add("PACKAGEKEY", bp.Xml_Key);
82 83  
83 84 var destinationfolder = Path.GetDirectoryName(bp.Xml_PackageFilePath);
84 85 if (!Path.IsPathRooted(destinationfolder)) { destinationfolder = Path.Combine(Directory.GetCurrentDirectory(), destinationfolder); }
... ... @@ -87,8 +88,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
87 88 var destinationfilename = Path.GetFileNameWithoutExtension(bp.Xml_PackageFilePath);
88 89 //string tempfolderpath = Tools.GetTemporaryFoldername(destinationfolder);
89 90  
90   - destinationfilename = StringConstructor.ResolveConstructor(vars, destinationfilename, "{}@@");
91   - destinationfolder = StringConstructor.ResolveConstructor(vars, destinationfolder, "{}@@");
  91 + destinationfilename = StringConstructor.ResolveConstructorR(vars, destinationfilename, "{}@@");
  92 + destinationfolder = StringConstructor.ResolveConstructorR(vars, destinationfolder, "{}@@");
92 93 var temprootfolder=string.IsNullOrEmpty(bp.Xml_TempDirectoryPath) ? destinationfolder : bp.Xml_TempDirectoryPath;
93 94  
94 95 string tempfolderpath = Path.Combine(temprootfolder, destinationfilename);
... ... @@ -197,7 +198,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
197 198 var destinationext = Path.GetExtension(destinationbackupfile); if (string.IsNullOrWhiteSpace(destinationext)) { destinationext = ".zip"; }
198 199 destinationbackupfile = Path.Combine(destinationfolderpath, destinationfile+destinationext);
199 200  
200   - destinationbackupfile = VRH.Common.StringConstructor.ResolveConstructor(vars, destinationbackupfile, "{}@@");
  201 + destinationbackupfile = VRH.Common.StringConstructor.ResolveConstructorR(vars, destinationbackupfile, "{}@@");
201 202  
202 203 if (File.Exists(destinationbackupfile)) { File.Delete(destinationbackupfile); }
203 204  
... ... @@ -227,7 +228,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
227 228 destinationfilename = destinationfilename??Path.GetFileNameWithoutExtension(sourcedirectorypath);
228 229  
229 230 string package___filepath = Path.Combine(destinationfolder, destinationfilename);
230   - package___filepath=VRH.Common.StringConstructor.ResolveConstructor(vars, package___filepath, "{}@@");
  231 + package___filepath=VRH.Common.StringConstructor.ResolveConstructorR(vars, package___filepath, "{}@@");
231 232  
232 233 string packageEXEfilepath = package___filepath + ".exe";
233 234 string packageZIPfilepath = package___filepath + ".zip";
... ... @@ -331,16 +332,24 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
331 332 #region BackupPackageManagerXmlProcessor class
332 333 public class BackupPackageManagerXmlProcessor : XmlParser
333 334 {
334   - private List<BackupPackage> _backuppackagelist;
  335 + private List<BackupPackage> _backuppackagelist= new List<BackupPackage>();
335 336 #region constructor
336 337 public BackupPackageManagerXmlProcessor(string xmlcs, string basefolder, string lcid) : base(xmlcs, basefolder, lcid, null)
337 338 {
338   - _backuppackagelist = new List<BackupPackage>();
339   - var tmpdirpath = GetValue(nameof(BackupPackage.XmlStructure.Attributes.TempDirectoryPath), GetRootElement(),"");
  339 + string tmpdirpath="", packagefilepath="", packagename="", createexe="";
  340 + var ca = GetXElement(nameof(BackupPackage.XmlStructure.CommonAttributes));
  341 + if (ca != null)
  342 + {
  343 + tmpdirpath = GetValue(nameof(BackupPackage.XmlStructure.CommonAttributes.Attributes.TempDirectoryPath), ca, "");
  344 + packagefilepath = GetValue(nameof(BackupPackage.XmlStructure.CommonAttributes.Attributes.PackageFilePath), ca, "");
  345 + packagename = GetValue(nameof(BackupPackage.XmlStructure.CommonAttributes.Attributes.PackageName), ca, "");
  346 + createexe = GetValue(nameof(BackupPackage.XmlStructure.CommonAttributes.Attributes.CreateExe), ca, "");
  347 + }
  348 +
340 349 var bpxmllist = GetAllXElements(nameof(BackupPackage.XmlStructure.BackupPackage));
341 350 if (bpxmllist != null && bpxmllist.Any())
342 351 {
343   - foreach (var bpxml in bpxmllist) { var bp = new BackupPackage(bpxml, tmpdirpath); if (bp.Valid) { _backuppackagelist.Add(bp); } }
  352 + foreach (var bpxml in bpxmllist) { var bp = new BackupPackage(bpxml, tmpdirpath, packagefilepath, packagename, createexe); if (bp.Valid) { _backuppackagelist.Add(bp); } }
344 353 }
345 354 }
346 355 #endregion constructor
... ... @@ -373,24 +382,31 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
373 382 #endregion basic constructor
374 383  
375 384 #region xml constructor
376   - public BackupPackage(XElement backupackagexml,string tmpdirectorypath)
  385 + public BackupPackage(XElement backupackagexml,string commontmpdirectorypath,string commonpackagefilepath=null,string commonpackagename=null,string commoncreateexe=null)
377 386 {
378 387 Valid = true;
379 388 string ATTRIBUTEMANDATORY = nameof(XmlStructure.BackupPackage) + " attribute is mandatory! Name: {0}";
380   - Xml_Key = GetValue(nameof(XmlStructure.BackupPackage.Attributes.Key), backupackagexml, XmlStructure.BackupPackage.Attributes.Key.Values.DEFAULT);
  389 +
381 390 Xml_PackageName = backupackagexml.Attribute(XName.Get(nameof(XmlStructure.BackupPackage.Attributes.Name)))?.Value;
  391 + if (string.IsNullOrWhiteSpace(Xml_PackageName)) { Xml_PackageName=commonpackagename; }
382 392 if (string.IsNullOrWhiteSpace(Xml_PackageName)) { throw new ApplicationException(string.Format(ATTRIBUTEMANDATORY, nameof(XmlStructure.BackupPackage.Attributes.Name))); }
383   - Xml_Description = GetValue(nameof(XmlStructure.BackupPackage.Attributes.Description), backupackagexml, Xml_PackageName);
  393 +
384 394 Xml_PackageFilePath = GetValue(nameof(XmlStructure.BackupPackage.Attributes.PackageFilePath), backupackagexml, "");
  395 + if (string.IsNullOrWhiteSpace(Xml_PackageFilePath)) { Xml_PackageFilePath= commonpackagefilepath; }
385 396 if (string.IsNullOrWhiteSpace(Xml_PackageFilePath)) { throw new ApplicationException(string.Format(ATTRIBUTEMANDATORY, XmlStructure.BackupPackage.Attributes.PackageFilePath.Values.DEFAULT)); }
386   - Xml_TempDirectoryPath = tmpdirectorypath;
387 397  
388   - Xml_SourceIncludeFilenameMaskList = GetValue(nameof(XmlStructure.BackupPackage.Attributes.IncludeFilenameMaskList), backupackagexml, XmlStructure.BackupPackage.Attributes.IncludeFilenameMaskList.Values.DEFAULT);
  398 + Xml_TempDirectoryPath =GetValue(nameof(XmlStructure.BackupPackage.Attributes.TempDirectoryPath), backupackagexml, "");
  399 + if (string.IsNullOrWhiteSpace(Xml_TempDirectoryPath)) { Xml_TempDirectoryPath= commontmpdirectorypath; }
389 400  
390 401 string XmlCreateExestring = GetValue(nameof(XmlStructure.BackupPackage.Attributes.CreateExe), backupackagexml, XmlStructure.BackupPackage.Attributes.CreateExe.Values.DEFAULT.ToString());
  402 + if (string.IsNullOrWhiteSpace(XmlCreateExestring)) { XmlCreateExestring = commoncreateexe; }
391 403 if (string.IsNullOrWhiteSpace(XmlCreateExestring)) { XmlCreateExestring = XmlStructure.BackupPackage.Attributes.CreateExe.Values.DEFAULT.ToString(); }
392 404 Xml_CreateExe = bool.Parse(XmlCreateExestring);
393 405  
  406 + Xml_Key = GetValue(nameof(XmlStructure.BackupPackage.Attributes.Key), backupackagexml, XmlStructure.BackupPackage.Attributes.Key.Values.DEFAULT);
  407 + Xml_Description = GetValue(nameof(XmlStructure.BackupPackage.Attributes.Description), backupackagexml, Xml_PackageName);
  408 + Xml_SourceIncludeFilenameMaskList = GetValue(nameof(XmlStructure.BackupPackage.Attributes.IncludeFilenameMaskList), backupackagexml, XmlStructure.BackupPackage.Attributes.IncludeFilenameMaskList.Values.DEFAULT);
  409 +
394 410 Xml_BackupFolderList = new List<BackupFolder>();
395 411 //var conditionxmlList = GetAllXElements(foldertocleanxml, nameof(XmlStructure.FolderToClean.Conditions), nameof(XmlStructure.FolderToClean.Conditions.Condition));
396 412 var backupfolderxmlList = backupackagexml.Elements(XName.Get(nameof(XmlStructure.BackupPackage.BackupFolder)));
... ... @@ -426,9 +442,16 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
426 442 #region XmlStructure
427 443 public static class XmlStructure
428 444 {
429   - public static class Attributes
  445 +
  446 + public static class CommonAttributes
430 447 {
431   - public static class TempDirectoryPath { public static class Values { public const string DEFAULT = ""; } }
  448 + public static class Attributes
  449 + {
  450 + public static class TempDirectoryPath { public static class Values { public const string DEFAULT = ""; } }
  451 + public static class PackageFilePath { public static class Values { public const string DEFAULT = ""; } }
  452 + public static class PackageName { public static class Values { public const string DEFAULT = ""; } }
  453 + public static class CreateExe { public static class Values { public const string DEFAULT = ""; } }
  454 + }
432 455 }
433 456 public static class BackupPackage
434 457 {
... ... @@ -440,6 +463,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
440 463 public static class CreateExe { public static class Values { public const bool DEFAULT = true; } }
441 464 public static class IncludeFilenameMaskList { public static class Values { public const string DEFAULT = "*"; } }
442 465 public static class PackageFilePath{ public static class Values { public const string DEFAULT = "BackupPackage_{TIMESTAMP}_{PACKAGENAME}"; } }
  466 + public static class TempDirectoryPath { public static class Values { public const string DEFAULT = ""; } }
443 467 }
444 468 public static class BackupFolder
445 469 {
... ...
Vrh.Log4Pro.MaintenanceConsole/Manager - FileCleanerManager.cs
... ... @@ -124,9 +124,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
124 124 }
125 125 else if (lineix == 2)
126 126 {
127   - ColorConsole.Write($"{ws.Xml_CleanupDays}", ConsoleColor.Yellow, prefix: "Cleanup days:", bracket: "[]");
128 127 var fc2 = ws.Xml_Recurse ? ConsoleColor.Green : ConsoleColor.Yellow;
129   - ColorConsole.Write($"{ws.Xml_Recurse}", fc2, prefix: ", Recurse:", bracket: "[]");
  128 + ColorConsole.Write($"{ws.Xml_Recurse}", fc2, prefix: "Recurse:", bracket: "[]");
130 129 var fc0 = ws.Xml_RemoveEmptyFolder ? ConsoleColor.Green : ConsoleColor.Yellow;
131 130 ColorConsole.Write($"{ws.Xml_RemoveEmptyFolder}", fc0, prefix: ", Remove empty folder:", bracket: "[]");
132 131 ColorConsole.WriteLine(ws.Xml_IncludeMask, ConsoleColor.Yellow, prefix: ", Include mask:");
... ... @@ -142,8 +141,18 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
142 141 if (lineix != INDEXBASE) { ColorConsole.Write(ws.Xml_OrConditionList ? "OR" : "AND", ConsoleColor.Yellow,suffix:" "); }
143 142 ColorConsole.Write("Condition:");
144 143 ColorConsole.Write(c.Type.ToString(),ConsoleColor.Yellow, prefix: " Type:");
145   - if (c.Type==FolderToClean.ConditionType.TimeStampInName) { ColorConsole.Write(c.TimestampConstructor, ConsoleColor.Yellow, prefix: ", TS constructor:"); }
146   - ColorConsole.Write(c.Limit.ToString(), ConsoleColor.Yellow, prefix: ", Limit:",suffix: c.Type == FolderToClean.ConditionType.Length ? "bytes" : "days");
  144 + if (c.Type==FolderToClean.ConditionType.Length) //hossz alapján
  145 + {
  146 + int climit = c.Limit.HasValue ? c.Limit.Value : ws.common_limitbytes.HasValue ? ws.common_limitbytes.Value: FolderToClean.XmlStructure.CommonAttributes.Attributes.LimitBytes.Values.DEFAULT;
  147 + ColorConsole.Write(climit.ToString(), ConsoleColor.Yellow, prefix: ", Limit:", suffix: "bytes");
  148 + }
  149 + else // időbélyeg alapján
  150 + {
  151 + var ctsc = !string.IsNullOrWhiteSpace(c.TimestampConstructor) ? c.TimestampConstructor : !string.IsNullOrWhiteSpace(ws.common_timestampconstructor) ? ws.common_timestampconstructor : FolderToClean.XmlStructure.CommonAttributes.Attributes.TimestampConstructor.Values.DEFAULT;
  152 + ColorConsole.Write(ctsc, ConsoleColor.Yellow, prefix: ", TS constructor:");
  153 + int climit = c.Limit.HasValue ? c.Limit.Value : ws.common_limitdays.HasValue ? ws.common_limitdays.Value : FolderToClean.XmlStructure.CommonAttributes.Attributes.LimitDays.Values.DEFAULT;
  154 + ColorConsole.Write(climit.ToString(), ConsoleColor.Yellow, prefix: ", Limit:", suffix: "days");
  155 + }
147 156 ColorConsole.WriteLine();
148 157 return " ";
149 158 }
... ... @@ -198,7 +207,6 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
198 207 var rgxmatch = rgx.Match(fi.FullName);
199 208 if (rgxmatch.Success)
200 209 {
201   - var daystodelete = ftc.Xml_CleanupDays;
202 210 var conditionlist = ftc.Xml_ConditionList;
203 211 if (conditionlist == null || !conditionlist.Any()) { return true; }
204 212  
... ... @@ -213,18 +221,22 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
213 221 bool conditionresult = false;
214 222 if (c.Type == FolderToClean.ConditionType.TimeStampInName)
215 223 {
216   - var fileTSstr = VRH.Common.StringConstructor.ResolveConstructor(groupnamevalues, c.TimestampConstructor, "{}@@");
  224 + var fileTSstr = VRH.Common.StringConstructor.ResolveConstructorR(groupnamevalues, c.TimestampConstructor, "{}@@");
217 225  
218 226 try { var fileTS = DateTime.Parse(fileTSstr); conditionresult = DateTime.Now.Subtract(fileTS).TotalDays > c.Limit; }
219 227 catch
220 228 {
221 229 var tscn = nameof(FolderToClean.XmlStructure.FolderToClean.Conditions.Condition.Attributes.TimestampConstructor);
222 230 var fprn = nameof(FolderToClean.XmlStructure.FolderToClean.IncludeFullpathRegexp);
223   - throw new Exception(
224   - $"Error in condition, type {FolderToClean.ConditionType.TimeStampInName}. {tscn} or {fprn} value incorrect!"
  231 + string exmsg = $"Error in condition, type {FolderToClean.ConditionType.TimeStampInName}. {tscn} or {fprn} value incorrect!"
225 232 + $"\n Folder: {ftc.Xml_DirectoryPath}"
  233 + + $"\n File: {fi.Name}"
226 234 + $"\n {tscn} : {c.TimestampConstructor}"
227   - + $"\n {tscn} after substitution: {fileTSstr}");
  235 + + $"\n {tscn} after substitution: {fileTSstr}"
  236 + + $"\n CONDITION RESULT FALSE IS USED!";
  237 + //throw new Exception(exmsg);
  238 + ColorConsole.WriteLine(exmsg, ConsoleColor.Yellow);
  239 + conditionresult = false; // ha nincs benne timestamp, akkor nem teljesül
228 240 }
229 241 }
230 242 else if (c.Type == FolderToClean.ConditionType.CreationTime)
... ... @@ -255,7 +267,6 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
255 267 #region public CleanFiles
256 268 public static long CleanFolderFiles(DirectoryInfo d,FolderToClean ftc, bool delete)
257 269 {
258   - int daystodelete = ftc.Xml_CleanupDays;
259 270 long cleanedsize = 0;
260 271 // Add file sizes.
261 272 FileInfo[] fis = d.GetFiles(ftc.Xml_IncludeMask, SearchOption.TopDirectoryOnly);
... ... @@ -291,16 +302,28 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
291 302 public class FileCleanerManagerXmlProcessor : XmlParser
292 303 {
293 304 private List<FolderToClean> _foldertocleanlist;
294   - private int commoncleanupdays;
295 305 #region constructor
296 306 public FileCleanerManagerXmlProcessor(string xmlcs, string basefolder, string lcid) : base(xmlcs, basefolder, lcid, null)
297 307 {
298 308 _foldertocleanlist = new List<FolderToClean>();
299   - commoncleanupdays = GetValue(nameof(FolderToClean.XmlStructure.Attributes.CleanupDays),this.RootElement, FolderToClean.XmlStructure.Attributes.CleanupDays.Values.DEFAULT);
  309 + var commonattributeselement = GetXElement(nameof(FolderToClean.XmlStructure.CommonAttributes));
  310 + string commonlimitdaysstring = GetValue(nameof(FolderToClean.XmlStructure.CommonAttributes.Attributes.LimitDays), commonattributeselement, (string)null);
  311 + int? commonlimitdays =
  312 + string.IsNullOrWhiteSpace(commonlimitdaysstring) ? (int?)null
  313 + : int.TryParse(commonlimitdaysstring, out int _commonlimitdays) ? _commonlimitdays
  314 + : (int?)null; // ha hibás a megadott érték, akkor olyan, mintha nem is lenne megadva
  315 +
  316 + string commonlimitbytessstring = GetValue(nameof(FolderToClean.XmlStructure.CommonAttributes.Attributes.LimitBytes), commonattributeselement, (string)null);
  317 + int? commonlimitbytes =
  318 + string.IsNullOrWhiteSpace(commonlimitbytessstring) ? (int?)null
  319 + : int.TryParse(commonlimitbytessstring, out int _commonlimitbytes) ? _commonlimitbytes
  320 + : (int?)null; // ha hibás a megadott érték, akkor olyan, mintha nem is lenne megadva
  321 +
  322 + string commontimestampconstructor = GetValue(nameof(FolderToClean.XmlStructure.CommonAttributes.Attributes.TimestampConstructor), commonattributeselement, (string)null);
300 323 var ftcxmllist = GetAllXElements(nameof(FolderToClean.XmlStructure.FolderToClean));
301 324 if (ftcxmllist != null && ftcxmllist.Any())
302 325 {
303   - foreach (var ftcxml in ftcxmllist) { var ws = new FolderToClean(ftcxml, commoncleanupdays); if (ws.Valid) { _foldertocleanlist.Add(ws); } }
  326 + foreach (var ftcxml in ftcxmllist) { var ws = new FolderToClean(ftcxml, commonlimitdays, commonlimitbytes,commontimestampconstructor); if (ws.Valid) { _foldertocleanlist.Add(ws); } }
304 327 }
305 328 }
306 329 #endregion constructor
... ... @@ -323,21 +346,28 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
323 346 public string Xml_IncludeFullpathRegexp;
324 347 public bool Xml_OrConditionList = true;
325 348 public List<Condition> Xml_ConditionList;
326   - public int Xml_CleanupDays;
327 349  
328 350 public bool FolderExists;
329 351 public long SizeFolderTotal;
330 352 public long SizeSelectedBeforeClean;
331 353 public long SizeSelectedAfterClean { get { return SizeSelectedBeforeClean - SizeSelectedCleaned; } }
332 354 public long SizeSelectedCleaned;
  355 +
  356 + public int? common_limitdays;
  357 + public int? common_limitbytes;
  358 + public string common_timestampconstructor;
  359 +
333 360 #endregion fields
334 361  
335 362 #region basic constructor
336 363 public FolderToClean() { }
337 364 #endregion basic constructor
338 365 #region xml constructor
339   - public FolderToClean(XElement foldertocleanxml,int commoncleanupdays)
  366 + public FolderToClean(XElement foldertocleanxml,int? commonlimitdays,int? commonlimitbytes,string commontimestampconstructor)
340 367 {
  368 + common_limitdays = commonlimitdays;
  369 + common_limitbytes = commonlimitbytes;
  370 + common_timestampconstructor = commontimestampconstructor;
341 371 Valid = true;
342 372 string ATTRIBUTEMANDATORY = nameof(XmlStructure.FolderToClean) + " attribute is mandatory! Name: {0}";
343 373 Xml_Key = GetValue(nameof(XmlStructure.FolderToClean.Attributes.Key), foldertocleanxml, XmlStructure.FolderToClean.Attributes.Key.Values.DEFAULT);
... ... @@ -347,7 +377,6 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
347 377 Xml_RemoveEmptyFolder = GetValue(nameof(XmlStructure.FolderToClean.Attributes.RemoveEmptyFolder), foldertocleanxml, XmlStructure.FolderToClean.Attributes.RemoveEmptyFolder.Values.DEFAULT);
348 378 Xml_IncludeMask = GetValue(nameof(XmlStructure.FolderToClean.Attributes.IncludeMask), foldertocleanxml, XmlStructure.FolderToClean.Attributes.IncludeMask.Values.DEFAULT);
349 379 Xml_IncludeFullpathRegexp = GetValue(GetXElement(foldertocleanxml,nameof(XmlStructure.FolderToClean.IncludeFullpathRegexp)), XmlStructure.FolderToClean.IncludeFullpathRegexp.Values.DEFAULT);
350   - Xml_CleanupDays = GetValue(GetXElement(foldertocleanxml,nameof(XmlStructure.FolderToClean.Attributes.CleanupDays)), commoncleanupdays);
351 380 Xml_ConditionList = new List<Condition>();
352 381 //var conditionxmlList = GetAllXElements(foldertocleanxml, nameof(XmlStructure.FolderToClean.Conditions), nameof(XmlStructure.FolderToClean.Conditions.Condition));
353 382 var conditionsxml = foldertocleanxml.Element(XName.Get(nameof(XmlStructure.FolderToClean.Conditions)));
... ... @@ -355,7 +384,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
355 384 if (conditionxmlList!=null && conditionxmlList.Any())
356 385 {
357 386 Xml_OrConditionList = GetValue(nameof(XmlStructure.FolderToClean.Conditions.Attributes.OrConditionList), conditionsxml, XmlStructure.FolderToClean.Conditions.Attributes.OrConditionList.Values.DEFAULT);
358   - foreach (var conditionxml in conditionxmlList) { Xml_ConditionList.Add(new Condition(conditionxml)); }
  387 + foreach (var conditionxml in conditionxmlList) { Xml_ConditionList.Add(new Condition(conditionxml, commontimestampconstructor, commonlimitdays, commonlimitbytes)); }
359 388 }
360 389 }
361 390 #endregion xml constructor
... ... @@ -370,7 +399,6 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
370 399 Xml_IncludeMask = ftc.Xml_IncludeMask;
371 400 Xml_IncludeFullpathRegexp = ftc.Xml_IncludeFullpathRegexp;
372 401 Xml_OrConditionList = ftc.Xml_OrConditionList;
373   - Xml_CleanupDays = ftc.Xml_CleanupDays;
374 402 Xml_ConditionList = ftc.Xml_ConditionList.Select(c=>new Condition(c)).ToList(); ;
375 403 }
376 404 #endregion cloner constructor
... ... @@ -387,30 +415,36 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
387 415 }
388 416 #endregion cloner constructor
389 417 #region constructor
390   - public Condition(XElement cxml)
  418 + public Condition(XElement cxml, string commontimestampconstructor,int? commonlimitdays,int? commonlimitbytes)
391 419 {
392 420 var typestr = GetValue(nameof(XmlStructure.FolderToClean.Conditions.Condition.Attributes.Type), cxml, XmlStructure.FolderToClean.Conditions.Condition.Attributes.Type.Values.DEFAULT);
393 421 this.Type = (ConditionType)Enum.Parse(typeof(ConditionType),typestr);
394   - TimestampConstructor = GetValue(nameof(XmlStructure.FolderToClean.Conditions.Condition.Attributes.TimestampConstructor), cxml, XmlStructure.FolderToClean.Conditions.Condition.Attributes.TimestampConstructor.Values.DEFAULT);
395   - Limit = GetValue(nameof(XmlStructure.FolderToClean.Conditions.Condition.Attributes.Limit), cxml, XmlStructure.FolderToClean.Conditions.Condition.Attributes.Limit.Values.DEFAULT);
  422 +
  423 + TimestampConstructor = GetValue(nameof(XmlStructure.FolderToClean.Conditions.Condition.Attributes.TimestampConstructor), cxml, commontimestampconstructor);
  424 + if (string.IsNullOrWhiteSpace(TimestampConstructor)) { TimestampConstructor = XmlStructure.CommonAttributes.Attributes.TimestampConstructor.Values.DEFAULT; }
  425 +
  426 + string limitstring = GetValue<string>(nameof(XmlStructure.FolderToClean.Conditions.Condition.Attributes.Limit), cxml, null);
  427 + if (string.IsNullOrWhiteSpace(limitstring)) { Limit = this.Type == ConditionType.Length ? commonlimitbytes: commonlimitdays; }
  428 + else if (!string.IsNullOrWhiteSpace(limitstring) && int.TryParse(limitstring, out int _limit)) { Limit = _limit; }
  429 +
  430 + if (!Limit.HasValue) { Limit = this.Type == ConditionType.Length ? XmlStructure.CommonAttributes.Attributes.LimitBytes.Values.DEFAULT : XmlStructure.CommonAttributes.Attributes.LimitDays.Values.DEFAULT; }
396 431 }
397 432 #endregion constructor
398 433 public ConditionType Type;
399 434 public string TimestampConstructor;
400   - public int Limit;
  435 + public int? Limit;
401 436 }
402 437 #endregion Condition
403 438 #region XmlStructure
404 439 public static class XmlStructure
405 440 {
406   - public static class Attributes
  441 + public static class CommonAttributes
407 442 {
408   - public static class CleanupDays
  443 + public static class Attributes
409 444 {
410   - public static class Values
411   - {
412   - public const int DEFAULT = 7;
413   - }
  445 + public static class LimitDays { public static class Values { public const int DEFAULT = 7; } }
  446 + public static class LimitBytes { public static class Values { public const int DEFAULT = 500000; } }
  447 + public static class TimestampConstructor { public static class Values { public const string DEFAULT = "{YEAR}.{MONTH}.{DAY} {HOUR}:{MINUTE}:{SECOND}"; } }
414 448 }
415 449 }
416 450 public static class FolderToClean
... ... @@ -419,13 +453,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
419 453 {
420 454 public static class Key { public static class Values { public const string DEFAULT = ""; } }
421 455 public static class Directory { }
422   - public static class CleanupDays
423   - {
424   - public static class Values
425   - {
426   - public const int DEFAULT = XmlStructure.Attributes.CleanupDays.Values.DEFAULT;
427   - }
428   - }
  456 + public static class LimitDays { public static class Values { public const int DEFAULT = XmlStructure.CommonAttributes.Attributes.LimitDays.Values.DEFAULT; } }
429 457 public static class Recurse
430 458 {
431 459 public static class Values
... ... @@ -483,20 +511,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.FileCleanerManagerNS
483 511 public static class CreationTime { }
484 512 }
485 513 }
486   - public static class TimestampConstructor
487   - {
488   - public static class Values
489   - {
490   - public const string DEFAULT = "{YEAR}.{MONTH}.{DAY} {HOUR}:{MINUTE}:{SECOND}";
491   - }
492   - }
493   - public static class Limit
494   - {
495   - public static class Values
496   - {
497   - public const int DEFAULT = XmlStructure.Attributes.CleanupDays.Values.DEFAULT;
498   - }
499   - }
  514 + public static class TimestampConstructor { }
  515 + public static class Limit { }
500 516 }
501 517 }
502 518 }
... ...
Vrh.Log4Pro.MaintenanceConsole/Manager - SQLDataBaseManager.cs
... ... @@ -403,7 +403,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
403 403 vars.Add(nameof(DBSubstitutionName.DBDATAGROUP), "");
404 404 vars.Add(nameof(DBSubstitutionName.BACKUPTS), backupts);
405 405  
406   - backupfileNameOnly = VRH.Common.StringConstructor.ResolveConstructor(vars, backupfileNameOnly, "{}@@");
  406 + backupfileNameOnly = VRH.Common.StringConstructor.ResolveConstructorR(vars, backupfileNameOnly, "{}@@");
407 407  
408 408 string backupfilename = backupfileNameOnly + ".bak";
409 409 string backupFullName = Path.Combine(backupdirectorypath, backupfilename);
... ... @@ -443,7 +443,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
443 443 vars.Add(nameof(DBSubstitutionName.DBONAME), "");
444 444 vars.Add(nameof(DBSubstitutionName.DBDATAGROUP), "");
445 445 vars.Add(nameof(DBSubstitutionName.BACKUPTS), "*");
446   - filenamemask = VRH.Common.StringConstructor.ResolveConstructor(vars, filenamemask, "{}@@");
  446 + filenamemask = VRH.Common.StringConstructor.ResolveConstructorR(vars, filenamemask, "{}@@");
447 447 var filelist = new DirectoryInfo(sqld.Xml_BackupTargetDirectoryPath)?.GetFiles(filenamemask)?.ToList();
448 448 var filelistordered = filelist?.OrderByDescending(x => x.CreationTime).ToList();
449 449 return filelistordered;
... ... @@ -590,7 +590,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
590 590 {
591 591 var sqlc = new Microsoft.Data.SqlClient.SqlConnection(sqlconnectionstring);
592 592  
593   - sqltxt = VRH.Common.StringConstructor.ResolveConstructor(vars, sqltxt, "{}@@");
  593 + sqltxt = VRH.Common.StringConstructor.ResolveConstructorR(vars, sqltxt, "{}@@");
594 594  
595 595 sqlc.Open();
596 596 string SQLBatchTxt = ""; // ebben lesznek az sql script-en belüli batch-ek összerakva
... ... @@ -731,7 +731,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
731 731 {
732 732 vars[nameof(DBSubstitutionName.DBONAME)] = "";
733 733 vars[nameof(DBSubstitutionName.DBDATAGROUP)] = "";
734   - string zipfilename = VRH.Common.StringConstructor.ResolveConstructor(vars, backupfilenamemask, "{}@@") + ".zip";
  734 + string zipfilename = VRH.Common.StringConstructor.ResolveConstructorR(vars, backupfilenamemask, "{}@@") + ".zip";
735 735 zipfilefullpath = Path.Combine(backupdirectorypath, zipfilename);
736 736 tempbackupdirectorypath = Path.Combine(backupdirectorypath, "TEMP_" + Path.GetFileNameWithoutExtension(zipfilename));
737 737 if (Directory.Exists(tempbackupdirectorypath)) { Directory.Delete(tempbackupdirectorypath, recursive: true); }
... ... @@ -776,7 +776,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
776 776 vars[nameof(DBSubstitutionName.DBONAME)]=namevalue;
777 777 vars[nameof(DBSubstitutionName.DBDATAGROUP)]=sqldbobj.GetType().Name;
778 778  
779   - string filename = VRH.Common.StringConstructor.ResolveConstructor(vars, backupfilenamemask, "{}@@");
  779 + string filename = VRH.Common.StringConstructor.ResolveConstructorR(vars, backupfilenamemask, "{}@@");
780 780 if (lastfilename!=filename)
781 781 {
782 782 var i = 2;
... ... @@ -849,7 +849,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
849 849 {
850 850 vars[nameof(DBSubstitutionName.DBONAME)] = "";
851 851 vars[nameof(DBSubstitutionName.DBDATAGROUP)] = "";
852   - string zipfilename = VRH.Common.StringConstructor.ResolveConstructor(vars, backupfilenamemask, "{}@@") + ".zip";
  852 + string zipfilename = VRH.Common.StringConstructor.ResolveConstructorR(vars, backupfilenamemask, "{}@@") + ".zip";
853 853 tempbackupdirectorypath = Path.Combine(backupdirectorypath, "TEMP_"+Path.GetFileNameWithoutExtension(zipfilename));
854 854 zipfilefullpath = Path.Combine(backupdirectorypath, zipfilename);
855 855 if (Directory.Exists(tempbackupdirectorypath)) { Directory.Delete(tempbackupdirectorypath, recursive: true); }
... ... @@ -911,7 +911,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
911 911 string tn_schemaname = tn.Split('.')[1];
912 912 string tn_name = tn.Split('.')[2];
913 913 vars[nameof(DBSubstitutionName.DBONAME)] = $"{tn_schemaname}.{tn_name}";
914   - filename = VRH.Common.StringConstructor.ResolveConstructor(vars, backupfilenamemask, "{}@@");
  914 + filename = VRH.Common.StringConstructor.ResolveConstructorR(vars, backupfilenamemask, "{}@@");
915 915 filefullname = Path.Combine(backupdirectorypath, filename);
916 916 if (lastfilefullname!=filefullname && lastfilefullname!=null)
917 917 {
... ...
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.2.4.0")]
36   -[assembly: AssemblyFileVersion("1.2.4.0")]
  35 +[assembly: AssemblyVersion("1.3.0.0")]
  36 +[assembly: AssemblyFileVersion("1.3.0.0")]
... ...
Vrh.Log4Pro.MaintenanceConsole/Vrh.Log4Pro.MaintenanceConsole.csproj
... ... @@ -336,14 +336,14 @@
336 336 <Reference Include="Microsoft.CSharp" />
337 337 <Reference Include="System.Data" />
338 338 <Reference Include="System.Xml" />
339   - <Reference Include="VRH.Common, Version=2.20.1.0, Culture=neutral, processorArchitecture=MSIL">
340   - <HintPath>..\packages\VRH.Common.2.20.1\lib\net45\VRH.Common.dll</HintPath>
  339 + <Reference Include="VRH.Common, Version=2.21.2.0, Culture=neutral, processorArchitecture=MSIL">
  340 + <HintPath>..\packages\VRH.Common.2.21.2\lib\net45\VRH.Common.dll</HintPath>
341 341 </Reference>
342 342 <Reference Include="Vrh.Web.Providers, Version=2.0.2.0, Culture=neutral, processorArchitecture=MSIL">
343 343 <HintPath>..\packages\VRH.Web.Providers.2.0.2\lib\net452\Vrh.Web.Providers.dll</HintPath>
344 344 </Reference>
345   - <Reference Include="Vrh.XmlProcessing, Version=1.26.1.0, Culture=neutral, processorArchitecture=MSIL">
346   - <HintPath>..\packages\Vrh.XmlProcessing.1.26.1\lib\net45\Vrh.XmlProcessing.dll</HintPath>
  345 + <Reference Include="Vrh.XmlProcessing, Version=1.27.0.0, Culture=neutral, processorArchitecture=MSIL">
  346 + <HintPath>..\packages\Vrh.XmlProcessing.1.27.0\lib\net45\Vrh.XmlProcessing.dll</HintPath>
347 347 </Reference>
348 348 </ItemGroup>
349 349 <ItemGroup>
... ...
Vrh.Log4Pro.MaintenanceConsole/packages.config
... ... @@ -71,7 +71,7 @@
71 71 <package id="System.Threading.Timer" version="4.0.1" targetFramework="net472" />
72 72 <package id="System.Xml.ReaderWriter" version="4.0.11" targetFramework="net472" />
73 73 <package id="System.Xml.XDocument" version="4.0.11" targetFramework="net472" />
74   - <package id="VRH.Common" version="2.20.1" targetFramework="net472" />
  74 + <package id="VRH.Common" version="2.21.2" targetFramework="net472" />
75 75 <package id="VRH.Web.Providers" version="2.0.2" targetFramework="net472" />
76   - <package id="Vrh.XmlProcessing" version="1.26.1" targetFramework="net472" />
  76 + <package id="Vrh.XmlProcessing" version="1.27.0" targetFramework="net472" />
77 77 </packages>
78 78 \ No newline at end of file
... ...