This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -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;
}
}
}

View File

@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" 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>{8620652F-F86E-466A-8D7B-D3088A7B0C05}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>RegAddProductCode</RootNamespace>
<AssemblyName>RegAddProductCode</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<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.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AddProductCode.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>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>