Installer mods.

This commit is contained in:
McMak 2015-04-27 20:21:09 +03:00
parent c22d6b60f3
commit 47adf43407
23 changed files with 1381 additions and 567 deletions

View file

@ -38,25 +38,27 @@ namespace WebsitePanel.Setup
public sealed class AppConfig
{
public const string AppConfigFileNameWithoutExtension = "WebsitePanel.Installer.exe";
static AppConfig()
{
ConfigurationPath = DefaultConfigurationPath;
}
private AppConfig()
{
}
private static Configuration appConfig = null;
private static XmlDocument xmlConfig = null;
public static void LoadConfiguration()
public static string ConfigurationPath { get; set; }
public static string DefaultConfigurationPath { get { return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AppConfigFileNameWithoutExtension); } }
public static void LoadConfiguration(ExeConfigurationFileMap FnMap = null, ConfigurationUserLevel CuLevel = ConfigurationUserLevel.None)
{
//
var exePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AppConfigFileNameWithoutExtension);
//
appConfig = ConfigurationManager.OpenExeConfiguration(exePath);
//
if (FnMap == null)
appConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationPath);
else
appConfig = ConfigurationManager.OpenMappedExeConfiguration(FnMap, CuLevel);
ConfigurationSection section = appConfig.Sections["installer"];
if (section == null)
throw new ConfigurationErrorsException("instalelr section not found");
throw new ConfigurationErrorsException("installer section not found in " + appConfig.FilePath);
string strXml = section.SectionInformation.GetRawXml();
xmlConfig = new XmlDocument();
xmlConfig.LoadXml(strXml);

View file

@ -48,9 +48,9 @@ namespace WebsitePanel.Setup
/// <param name="bar">Progress bar.</param>
/// <param name="source">Source folder.</param>
/// <param name="destination">Destination folder.</param>
public CopyProcess(ProgressBar bar, string source, string destination)
public CopyProcess(object bar, string source, string destination)
{
this.progressBar = bar;
this.progressBar = bar as ProgressBar;
this.sourceFolder = new DirectoryInfo(source);
this.destFolder = new DirectoryInfo(destination);
}
@ -63,9 +63,13 @@ namespace WebsitePanel.Setup
// unzip
long totalSize = FileUtils.CalculateFolderSize(sourceFolder.FullName);
long copied = 0;
progressBar.Minimum = 0;
progressBar.Maximum = 100;
progressBar.Value = 0;
if (progressBar != null)
{
progressBar.Minimum = 0;
progressBar.Maximum = 100;
progressBar.Value = 0;
}
int i = 0;
List<DirectoryInfo> folders = new List<DirectoryInfo>();
@ -122,7 +126,10 @@ namespace WebsitePanel.Setup
copied += files[i].Length;
if (totalSize != 0)
{
progressBar.Value = Convert.ToInt32(copied * 100 / totalSize);
if (progressBar != null)
{
progressBar.Value = Convert.ToInt32(copied * 100 / totalSize);
}
}
}
}

View file

@ -170,5 +170,7 @@ namespace WebsitePanel.Setup
}
catch { }
}
public static TraceListenerCollection Listeners { get { return Trace.Listeners; } }
}
}

View file

@ -286,7 +286,8 @@ namespace WebsitePanel.Setup
Windows7,
WindowsServer2008R2,
Windows8,
WindowsServer2012
WindowsServer2012,
WindowsServer2012R2
}
public static string GetName(WindowsVersion version)
@ -428,6 +429,9 @@ namespace WebsitePanel.Setup
else
ret = WindowsVersion.WindowsServer2012;
break;
case 3:
ret = WindowsVersion.WindowsServer2012R2;
break;
}
break;
}

View file

@ -338,8 +338,8 @@ namespace WebsitePanel.Setup
/// <param name="domain"></param>
/// <returns></returns>
internal static string GetSid(string userAccount, string domain)
{
if(domain == null)
{
if(string.IsNullOrWhiteSpace(domain))
domain = Environment.MachineName;
// try to get user account

View file

@ -481,11 +481,11 @@ namespace WebsitePanel.Setup
public static void StopService(string serviceName)
{
ServiceController sc = new ServiceController(serviceName);
// Start the service if the current status is stopped.
// Stop the service if the current status is not stopped.
if (sc.Status != ServiceControllerStatus.Stopped &&
sc.Status != ServiceControllerStatus.StopPending)
{
// Start the service, and wait until its status is "Running".
// Stop the service, and wait until its status is "Running".
sc.Stop();
sc.WaitForStatus(ServiceControllerStatus.Stopped);
}

View file

@ -150,7 +150,7 @@ namespace WebsitePanel.Setup
FileUtils.CreateDirectory(path);
SecurityUtils.GrantNtfsPermissions(path, userDomain, userAccount, NtfsPermission.Modify, true, true);
SecurityUtils.GrantNtfsPermissionsBySid(path, SystemSID.NETWORK_SERVICE, NtfsPermission.Modify, true, true);
SecurityUtils.GrantNtfsPermissionsBySid(path, SystemSID.NETWORK_SERVICE, NtfsPermission.Modify, true, true);
}
/// <summary>

View file

@ -46,9 +46,9 @@ namespace WebsitePanel.Setup.Common
int totalFiles = 0;
int files = 0;
public ZipIndicator(ProgressBar progressBar, string sourcePath, string zipFile)
public ZipIndicator(object progressBar, string sourcePath, string zipFile)
{
this.progressBar = progressBar;
this.progressBar = progressBar as ProgressBar;
this.sourcePath = sourcePath;
this.zipFile = zipFile;
}
@ -71,8 +71,11 @@ namespace WebsitePanel.Setup.Common
{
string fileName = e.CurrentEntry.FileName;
files++;
this.progressBar.Value = Convert.ToInt32(files * 100 / totalFiles);
this.progressBar.Update();
if (this.progressBar != null)
{
this.progressBar.Value = Convert.ToInt32(files * 100 / totalFiles);
this.progressBar.Update();
}
}
}
}