diff --git a/Vrh.Log4Pro.MaintenanceConsole/Manager - BackupPackageManager.cs b/Vrh.Log4Pro.MaintenanceConsole/Manager - BackupPackageManager.cs
index b5f5695..7ea2f97 100644
--- a/Vrh.Log4Pro.MaintenanceConsole/Manager - BackupPackageManager.cs
+++ b/Vrh.Log4Pro.MaintenanceConsole/Manager - BackupPackageManager.cs
@@ -86,21 +86,20 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
var destinationfilename = Path.GetFileNameWithoutExtension(bp.Xml_PackageFilePath);
//string tempfolderpath = Tools.GetTemporaryFoldername(destinationfolder);
- string tempfolderpath = StringConstructor.ResolveConstructor(vars, Path.Combine(destinationfolder,destinationfilename), "{}@@");
- if (Directory.Exists(tempfolderpath)) { Directory.Delete(tempfolderpath, true); }
+ destinationfilename = StringConstructor.ResolveConstructor(vars, destinationfilename, "{}@@");
+ destinationfolder = StringConstructor.ResolveConstructor(vars, destinationfolder, "{}@@");
+ var temprootfolder=string.IsNullOrEmpty(bp.Xml_TempDirectoryPath) ? destinationfolder : bp.Xml_TempDirectoryPath;
+
+ string tempfolderpath = Path.Combine(temprootfolder, destinationfilename);
+
+ if (Directory.Exists(tempfolderpath)) { Directory.Delete(tempfolderpath, true); }
if (!Directory.Exists(tempfolderpath)) { Directory.CreateDirectory(tempfolderpath); }
- foreach (var bf in bp.Xml_BackupFolderList)
- {
- BackupPackageManagerCore.FolderZipBackup(bf, tempfolderpath, vars);
- }
- foreach (var sqldb in bp.Xml_BackupSQLDataBaseList)
- {
- SQLDataBaseManagerNS.SQLDataBaseManager.Execute(sqldb.Xml_Key,sqldb.Xml_DBBackup,sqldb.Xml_ScriptBackup,sqldb.Xml_TableDataBackup, tempfolderpath, timestamp);
- }
+ foreach (var bf in bp.Xml_BackupFolderList) { BackupPackageManagerCore.FolderZipBackup(bf, tempfolderpath, vars); }
+ foreach (var sqldb in bp.Xml_BackupSQLDataBaseList) { SQLDataBaseManagerNS.SQLDataBaseManager.Execute(sqldb.Xml_Key,sqldb.Xml_DBBackup,sqldb.Xml_ScriptBackup,sqldb.Xml_TableDataBackup, tempfolderpath, timestamp); }
- BackupPackageManagerCore.CreatePackageFile(bp, tempfolderpath, vars);
+ BackupPackageManagerCore.CreatePackageFile(bp.Xml_PackageName, tempfolderpath, vars, destinationfilename,destinationfolder, bp.Xml_CreateExe, bp.Xml_SourceIncludeFilenameMaskList);
if (Directory.Exists(tempfolderpath)) { Directory.Delete(tempfolderpath,true); }
}
catch (Exception ex) { ColorConsole.WriteLine(ex.MessageNested(), ConsoleColor.Red); }
@@ -210,21 +209,24 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
/// Create package compressed file
///
/// package descriptor
- /// source directory, where the package content files are located;
- /// the package file will be created with the same name with zip or exe extension in its parent directory
+ /// source directory, where the package content files are located
+ /// the folder to store the created package file; if null the package file will be created in the parent directory of sourcedirectorypath
+ /// the name of the package file; if null the package file name will be the same as the "last" directory name in sourcedirectorypath
/// substitution vars
- public static void CreatePackageFile(BackupPackage bp,string sourcedirectorypath, Dictionary vars)
+ /// if true, exe self extractor will be created, otherwise zip file; the extension of the package file is zip or exe
+ /// comma separated list of masks for the files to include (NOT regex! "old fashioned" masking characters, like ?/* can be used)
+ public static void CreatePackageFile(string packagename,string sourcedirectorypath, Dictionary vars,string destinationfilename =null,string destinationfolder=null,bool createexe=true,string sourceincludefilenamemaskList=null)
{
- string[] sourceincludefilenamemasklist = bp.Xml_SourceIncludeFilenameMaskList.Split(',');
- bool createselfextractor = bp.Xml_CreateExe;
+ string[] sourceinclfnamemasklist = sourceincludefilenamemaskList.Split(',');
+ bool createselfextractor = createexe;
if (!Path.IsPathRooted(sourcedirectorypath)) { sourcedirectorypath = Path.Combine(Directory.GetCurrentDirectory(), sourcedirectorypath); }
- var destinationfolder = Path.GetDirectoryName(sourcedirectorypath);
+ destinationfolder = destinationfolder??Path.GetDirectoryName(sourcedirectorypath);
if (!Path.IsPathRooted(destinationfolder)) { destinationfolder = Path.Combine(Directory.GetCurrentDirectory(), destinationfolder); }
- var destinationfile = Path.GetFileNameWithoutExtension(sourcedirectorypath);
+ destinationfilename = destinationfilename??Path.GetFileNameWithoutExtension(sourcedirectorypath);
- string package___filepath = Path.Combine(destinationfolder, destinationfile);
+ string package___filepath = Path.Combine(destinationfolder, destinationfilename);
package___filepath=VRH.Common.StringConstructor.ResolveConstructor(vars, package___filepath, "{}@@");
string packageEXEfilepath = package___filepath + ".exe";
@@ -233,7 +235,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
if (File.Exists(packageZIPfilepath)) { File.Delete(packageZIPfilepath); }
List includefilepathlist = new List();
- foreach (var includefilenamemask in sourceincludefilenamemasklist) { includefilepathlist.Add(Path.Combine(sourcedirectorypath, includefilenamemask)); }
+ foreach (var includefilenamemask in sourceinclfnamemasklist) { includefilepathlist.Add(Path.Combine(sourcedirectorypath, includefilenamemask)); }
string includeliststr = String.Join(" ", includefilepathlist.ToArray());
string recursesubdirs = "-r";
@@ -253,7 +255,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
packagefile = packageZIPfilepath;
response = Tools.ExecuteAndGetStdIo("7z.exe", $"{addfilecommand} {packagefile} {includeliststr} {recursesubdirs} {archivetype_zip}");
}
- ColorConsole.WriteLine($"Backup package created. Package name:{bp.Xml_PackageName}, package file: {packagefile}", ConsoleColor.Green);
+ ColorConsole.WriteLine($"Backup package created. Package name:{packagename}, package file: {packagefile}", ConsoleColor.Green);
// 7 - Zip[64] 16.04 : Copyright(c) 1999 - 2016 Igor Pavlov : 2016 - 10 - 04
@@ -334,10 +336,11 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
public BackupPackageManagerXmlProcessor(string xmlcs, string basefolder, string lcid) : base(xmlcs, basefolder, lcid, null)
{
_backuppackagelist = new List();
+ var tmpdirpath = GetValue(nameof(BackupPackage.XmlStructure.Attributes.TempDirectoryPath), GetRootElement(),"");
var bpxmllist = GetAllXElements(nameof(BackupPackage.XmlStructure.BackupPackage));
if (bpxmllist != null && bpxmllist.Any())
{
- foreach (var bpxml in bpxmllist) { var bp = new BackupPackage(bpxml); if (bp.Valid) { _backuppackagelist.Add(bp); } }
+ foreach (var bpxml in bpxmllist) { var bp = new BackupPackage(bpxml, tmpdirpath); if (bp.Valid) { _backuppackagelist.Add(bp); } }
}
}
#endregion constructor
@@ -356,6 +359,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
public string Xml_PackageName;
public string Xml_Description;
public string Xml_PackageFilePath;
+ public string Xml_TempDirectoryPath;
public string Xml_SourceIncludeFilenameMaskList;
public bool Xml_CreateExe;
public List Xml_BackupFolderList;
@@ -369,7 +373,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
#endregion basic constructor
#region xml constructor
- public BackupPackage(XElement backupackagexml)
+ public BackupPackage(XElement backupackagexml,string tmpdirectorypath)
{
Valid = true;
string ATTRIBUTEMANDATORY = nameof(XmlStructure.BackupPackage) + " attribute is mandatory! Name: {0}";
@@ -379,6 +383,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
Xml_Description = GetValue(nameof(XmlStructure.BackupPackage.Attributes.Description), backupackagexml, Xml_PackageName);
Xml_PackageFilePath = GetValue(nameof(XmlStructure.BackupPackage.Attributes.PackageFilePath), backupackagexml, "");
if (string.IsNullOrWhiteSpace(Xml_PackageFilePath)) { throw new ApplicationException(string.Format(ATTRIBUTEMANDATORY, XmlStructure.BackupPackage.Attributes.PackageFilePath.Values.DEFAULT)); }
+ Xml_TempDirectoryPath = tmpdirectorypath;
Xml_SourceIncludeFilenameMaskList = GetValue(nameof(XmlStructure.BackupPackage.Attributes.IncludeFilenameMaskList), backupackagexml, XmlStructure.BackupPackage.Attributes.IncludeFilenameMaskList.Values.DEFAULT);
@@ -412,36 +417,41 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
Xml_Description = bp.Xml_Description;
Xml_BackupFolderList = bp.Xml_BackupFolderList.Select(c=>new BackupFolder(c)).ToList(); ;
Xml_PackageFilePath=bp.Xml_PackageFilePath;
+ Xml_TempDirectoryPath = bp.Xml_TempDirectoryPath;
Xml_BackupSQLDataBaseList = bp.Xml_BackupSQLDataBaseList.Select(c => new BackupSQLDataBase(c)).ToList(); ;
Xml_SourceIncludeFilenameMaskList = bp.Xml_SourceIncludeFilenameMaskList;
- }
- #endregion cloner constructor
+ }
+ #endregion cloner constructor
#region XmlStructure
public static class XmlStructure
+ {
+ public static class Attributes
{
- public static class BackupPackage
+ public static class TempDirectoryPath { public static class Values { public const string DEFAULT = ""; } }
+ }
+ public static class BackupPackage
+ {
+ public static class Attributes
+ {
+ public static class Key { public static class Values { public const string DEFAULT = ""; } }
+ public static class Name { }
+ public static class Description { }
+ public static class CreateExe { public static class Values { public const bool DEFAULT = true; } }
+ public static class IncludeFilenameMaskList { public static class Values { public const string DEFAULT = "*"; } }
+ public static class PackageFilePath{ public static class Values { public const string DEFAULT = "BackupPackage_{TIMESTAMP}_{PACKAGENAME}"; } }
+ }
+ public static class BackupFolder
{
public static class Attributes
{
- public static class Key { public static class Values { public const string DEFAULT = ""; } }
- public static class Name { }
+ public static class Path { public static class Values { public const string DEFAULT = ""; } }
public static class Description { }
- public static class CreateExe { public static class Values { public const bool DEFAULT = true; } }
- public static class IncludeFilenameMaskList { public static class Values { public const string DEFAULT = "*"; } }
- public static class PackageFilePath{ public static class Values { public const string DEFAULT = "BackupPackage_{TIMESTAMP}_{PACKAGENAME}"; } }
- }
- public static class BackupFolder
- {
- public static class Attributes
- {
- public static class Path { public static class Values { public const string DEFAULT = ""; } }
- public static class Description { }
- public static class BackupToFile { }
- public static class IncludeNameMask { public class Values { public const string DEFAULT = "*"; } }
- public static class IncludePathRegexp { public class Values { public const string DEFAULT = ".*"; } }
- }
+ public static class BackupToFile { }
+ public static class IncludeNameMask { public class Values { public const string DEFAULT = "*"; } }
+ public static class IncludePathRegexp { public class Values { public const string DEFAULT = ".*"; } }
}
+ }
public static class BackupSQLDataBase
{
public static class Attributes
@@ -512,6 +522,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.BackupPackageManagerNS
}
}
#endregion BackupFolder class
+
#region BackupSQLDataBase class
public class BackupSQLDataBase : XmlLinqBase
{
diff --git a/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs b/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs
index d65e6ee..702760c 100644
--- a/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs
+++ b/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.2.3.0")]
-[assembly: AssemblyFileVersion("1.2.3.0")]
+[assembly: AssemblyVersion("1.2.4.0")]
+[assembly: AssemblyFileVersion("1.2.4.0")]
--
libgit2 0.21.2