init
This commit is contained in:
33
DataPRO/Modules/InstallerCustomActions/LocalSQLDB/App.config
Normal file
33
DataPRO/Modules/InstallerCustomActions/LocalSQLDB/App.config
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="LocalSQLDB.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
<applicationSettings>
|
||||
<LocalSQLDB.Properties.Settings>
|
||||
<setting name="RegistryDataPROExe" serializeAs="String">
|
||||
<value>DataPRO.exe</value>
|
||||
</setting>
|
||||
<setting name="ApplicationSettings" serializeAs="String">
|
||||
<value>applicationSettings</value>
|
||||
</setting>
|
||||
<setting name="LocalDbFolder" serializeAs="String">
|
||||
<value>db</value>
|
||||
</setting>
|
||||
<setting name="Mdf" serializeAs="String">
|
||||
<value>.mdf</value>
|
||||
</setting>
|
||||
<setting name="LogLdf" serializeAs="String">
|
||||
<value>_log.ldf</value>
|
||||
</setting>
|
||||
<setting name="DataPRO" serializeAs="String">
|
||||
<value>DataPRO</value>
|
||||
</setting>
|
||||
</LocalSQLDB.Properties.Settings>
|
||||
</applicationSettings>
|
||||
</configuration>
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Security.Principal;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace LocalSQLDB
|
||||
{
|
||||
class LocalDBPreparation
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var targetDir = string.Empty;
|
||||
Version productVersion = new Version();
|
||||
for (var i = 0; i < args.Length; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
targetDir = args[i];
|
||||
break;
|
||||
case 1:
|
||||
productVersion = new Version(args[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var localDBPrepare = new LocalDBPrepare(targetDir, productVersion);
|
||||
localDBPrepare.PrepareDB();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message + " - Installation will be cancelled");
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using Microsoft.Win32;
|
||||
using LocalSQLDB.Properties;
|
||||
|
||||
namespace LocalSQLDB
|
||||
{
|
||||
public class LocalDBPrepare
|
||||
{
|
||||
public LocalDBPrepare(string targetDir, Version productVersion)
|
||||
{
|
||||
_targetDir = targetDir;
|
||||
_installingVersion = productVersion;
|
||||
}
|
||||
|
||||
static string _targetDir = string.Empty;
|
||||
static Version _installingVersion = new Version();
|
||||
|
||||
private Configuration _newConfig;
|
||||
private SettingElementCollection _newSettings = new SettingElementCollection();
|
||||
private Dictionary<string, string> _newSettingsDictionary = new Dictionary<string, string>();
|
||||
|
||||
private enum DbType
|
||||
{
|
||||
Centralized = 0,
|
||||
Local = 1
|
||||
}
|
||||
|
||||
private enum ConfigSettings
|
||||
{
|
||||
DBType,
|
||||
LocalDbHost,
|
||||
DBName,
|
||||
UseNTLMAuthentication,
|
||||
LocalDBUser,
|
||||
LocalDBPassword
|
||||
}
|
||||
|
||||
public bool PrepareDB()
|
||||
{
|
||||
//Only attach to SqlLocalDb if DataPRO will be using a local (not centralized) database
|
||||
GetNewConfig();
|
||||
|
||||
var dbType = DbType.Local;
|
||||
try
|
||||
{
|
||||
DbType intDbType;
|
||||
if (Enum.TryParse(_newSettingsDictionary[ConfigSettings.DBType.ToString()], out intDbType))
|
||||
{
|
||||
switch (intDbType)
|
||||
{
|
||||
case DbType.Centralized:
|
||||
dbType = DbType.Centralized;
|
||||
break;
|
||||
case DbType.Local:
|
||||
default:
|
||||
dbType = DbType.Local;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dbType = DbType.Local;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
dbType = DbType.Local;
|
||||
}
|
||||
|
||||
if (dbType == DbType.Centralized)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var dbName = Settings.Default.DataPRO;
|
||||
try { dbName = _newSettingsDictionary[ConfigSettings.DBName.ToString()]; }
|
||||
catch { dbName = Settings.Default.DataPRO; }
|
||||
|
||||
if (string.Equals(dbName, Settings.Default.DataPRO, StringComparison.CurrentCultureIgnoreCase)) return true;
|
||||
|
||||
var dbFileName = System.IO.Path.Combine(_targetDir, Settings.Default.LocalDbFolder, dbName + Settings.Default.Mdf);
|
||||
var dbFileLogName = System.IO.Path.Combine(_targetDir, Settings.Default.LocalDbFolder, dbName + Settings.Default.LogLdf);
|
||||
|
||||
var sourceFileName = string.Empty;
|
||||
//if (_newSettingsDictionary[ConfigSettings.DBCopy.ToString()])
|
||||
//{
|
||||
string mostRecentlyInstalledLowerVersion;
|
||||
var mostRecentlyInstalledSubKeyName = Common.PreviousInstall.GetMostRecentlyInstalledSubKeyName(_installingVersion, out mostRecentlyInstalledLowerVersion);
|
||||
if (mostRecentlyInstalledSubKeyName == string.Empty) return false;
|
||||
//if (_newSettingsDictionary[ConfigSettings.DBCopy.ToString()])
|
||||
//{
|
||||
var _previousDir = Common.PreviousInstall.GetMostRecentlyInstalledPath(mostRecentlyInstalledSubKeyName);
|
||||
sourceFileName = System.IO.Path.Combine(_previousDir, Settings.Default.LocalDbFolder, Settings.Default.DataPRO + Settings.Default.Mdf);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
sourceFileName = System.IO.Path.Combine(_targetDir, Settings.Default.LocalDbFolder, Settings.Default.DataPRO + Settings.Default.Mdf);
|
||||
//}
|
||||
System.IO.File.Copy(sourceFileName, dbFileName);
|
||||
//System.IO.File.Delete(sourceFileName);
|
||||
|
||||
//if (_newSettingsDictionary[ConfigSettings.DBCopy.ToString()])
|
||||
//{
|
||||
// sourceFileName = System.IO.Path.Combine(_previousDir, Settings.Default.LocalDbFolder, Settings.Default.DataPRO + Settings.Default.LogLdf);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
sourceFileName = System.IO.Path.Combine(_targetDir, Settings.Default.LocalDbFolder, Settings.Default.DataPRO + Settings.Default.LogLdf);
|
||||
//}
|
||||
System.IO.File.Copy(sourceFileName, dbFileLogName);
|
||||
//System.IO.File.Delete(sourceFileName);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GetNewConfig()
|
||||
{
|
||||
var newPath = string.Empty;
|
||||
//Open the new config file just installed
|
||||
newPath = _targetDir + Settings.Default.RegistryDataPROExe;
|
||||
_newConfig = ConfigurationManager.OpenExeConfiguration(@newPath);
|
||||
_newSettings = GetConfigApplicationSettings();
|
||||
_newSettingsDictionary = _newSettings.Cast<SettingElement>().ToDictionary(newSetting => newSetting.Name, newSetting => newSetting.Value.ValueXml.InnerXml);
|
||||
}
|
||||
|
||||
private SettingElementCollection GetConfigApplicationSettings()
|
||||
{
|
||||
var configurationSectionGroup = _newConfig.SectionGroups[Settings.Default.ApplicationSettings];
|
||||
if (configurationSectionGroup == null) return null;
|
||||
var clientSettingsSection = configurationSectionGroup.Sections[0] as System.Configuration.ClientSettingsSection;
|
||||
return clientSettingsSection != null ? clientSettingsSection.Settings : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{BEA0001C-8CC8-468A-ADF0-94FF9B1FFCB1}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>LocalSQLDB</RootNamespace>
|
||||
<AssemblyName>LocalSQLDB</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="LocalDBPreparation.cs" />
|
||||
<Compile Include="LocalDBPrepare.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Common\Installer.Common.csproj">
|
||||
<Project>{7a025307-d06e-48ff-a443-dcd16530a6dd}</Project>
|
||||
<Name>Installer.Common</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("LocalSQLDB")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("LocalSQLDB")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("0eca4183-1b37-41ac-8ccf-8b3a59d0a834")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// 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.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
80
DataPRO/Modules/InstallerCustomActions/LocalSQLDB/Properties/Settings.Designer.cs
generated
Normal file
80
DataPRO/Modules/InstallerCustomActions/LocalSQLDB/Properties/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,80 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace LocalSQLDB.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("DataPRO.exe")]
|
||||
public string RegistryDataPROExe {
|
||||
get {
|
||||
return ((string)(this["RegistryDataPROExe"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("applicationSettings")]
|
||||
public string ApplicationSettings {
|
||||
get {
|
||||
return ((string)(this["ApplicationSettings"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("db")]
|
||||
public string LocalDbFolder {
|
||||
get {
|
||||
return ((string)(this["LocalDbFolder"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute(".mdf")]
|
||||
public string Mdf {
|
||||
get {
|
||||
return ((string)(this["Mdf"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("_log.ldf")]
|
||||
public string LogLdf {
|
||||
get {
|
||||
return ((string)(this["LogLdf"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("DataPRO")]
|
||||
public string DataPRO {
|
||||
get {
|
||||
return ((string)(this["DataPRO"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="LocalSQLDB.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="RegistryDataPROExe" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">DataPRO.exe</Value>
|
||||
</Setting>
|
||||
<Setting Name="ApplicationSettings" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">applicationSettings</Value>
|
||||
</Setting>
|
||||
<Setting Name="LocalDbFolder" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">db</Value>
|
||||
</Setting>
|
||||
<Setting Name="Mdf" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">.mdf</Value>
|
||||
</Setting>
|
||||
<Setting Name="LogLdf" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">_log.ldf</Value>
|
||||
</Setting>
|
||||
<Setting Name="DataPRO" Type="System.String" Scope="Application">
|
||||
<Value Profile="(Default)">DataPRO</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
Reference in New Issue
Block a user