Skip to content

Commit

Permalink
refactoring configuration file to json schema
Browse files Browse the repository at this point in the history
  • Loading branch information
hcasado committed Oct 13, 2017
1 parent ee69dc1 commit 2aca85e
Show file tree
Hide file tree
Showing 26 changed files with 9,526 additions and 377 deletions.
116 changes: 0 additions & 116 deletions src/DBUpdate.Framework/Configuracion.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,13 @@
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="DinamoSoftware.Foundation">
<HintPath>..\Lib\DinamoSoftware.Foundation.dll</HintPath>
</Reference>
<Reference Include="Nini">
<HintPath>..\Lib\Nini.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Configuracion.cs" />
<Compile Include="GestorDeTransacciones.cs" />
<Compile Include="GestorDeIncidencias.cs" />
<Compile Include="Incidencia.cs" />
<Compile Include="IncidenciaFactory.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Script.cs" />
<Compile Include="ScriptFactory.cs" />
<Compile Include="TipoDeScript.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
Expand Down
21 changes: 0 additions & 21 deletions src/DBUpdate.Framework/TipoDeScript.cs

This file was deleted.

23 changes: 23 additions & 0 deletions src/DBUpdateManager.Core/Config/ConfigEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DBUpdateManager.Core.Config
{
public class ConfigEntity : IConfig
{

public string CarpetaDeIncidencias
{
get;
set;
}

public string ConnectionString
{
get;
set;
}
}
}
48 changes: 48 additions & 0 deletions src/DBUpdateManager.Core/Config/ConfigManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Newtonsoft.Json;

namespace DBUpdateManager.Core.Config
{
public class ConfigManager
{
private const string kConfigurationFile = "DBUpdateManager.config.json";

public ConfigEntity ReadConfig()
{
string json = string.Empty;
try
{
json = new StreamReader(kConfigurationFile).ReadToEnd();
}
catch (FileNotFoundException fex)
{
throw new ApplicationException("configuration file not found: " + kConfigurationFile, fex);
}
catch (Exception ex)
{
throw ex;
}

var entity = JsonConvert.DeserializeObject<ConfigEntity>(json);
return entity;
}

public void WriteConfig(ConfigEntity entity)
{
var json = JsonConvert.SerializeObject(entity);
try
{
new StreamWriter(kConfigurationFile).Write(json);
}
catch (Exception ex)
{
throw new ApplicationException("error writing file: " + kConfigurationFile, ex);
}
}

}
}
13 changes: 13 additions & 0 deletions src/DBUpdateManager.Core/Config/IConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DBUpdateManager.Core.Config
{
interface IConfig
{
string CarpetaDeIncidencias { get; }
string ConnectionString { get; }
}
}
66 changes: 66 additions & 0 deletions src/DBUpdateManager.Core/DBUpdateManager.Core.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7B2C7AC0-8FD7-46BB-908A-BA55DA2C30A3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DBUpdateManager.Core</RootNamespace>
<AssemblyName>DBUpdateManager.Core</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\Lib\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<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="Config\ConfigManager.cs" />
<Compile Include="Config\ConfigEntity.cs" />
<Compile Include="Config\IConfig.cs" />
<Compile Include="Db\TransactionManager.cs" />
<Compile Include="Issue\IssueEntity.cs" />
<Compile Include="Issue\IssueFactory.cs" />
<Compile Include="Issue\IssueManager.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Script\ScriptEntity.cs" />
<Compile Include="Script\ScriptFactory.cs" />
<Compile Include="Script\ScriptTypeEnum.cs" />
</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>
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
/***********************************************************************
* Module: GestorDeActualizacionBD.cs
* Author: Administrator
* Purpose: Definition of the Class Labs.GestorActualizacionBD.Core.GestorDeActualizacionBD
***********************************************************************/

using System;
using System.Collections;
using System;
using System.Collections.Generic;
using System.IO;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using DBUpdateManager.Core.Config;
using System.Data;

namespace Labs.GestorActualizacionBD.Framework
namespace DBUpdateManager.Core.Db
{
public class GestorDeTransacciones
public class TransactionManager
{

protected SqlConnection _Cnn = null;
protected SqlTransaction _Tnx = null;
protected ConfigManager _CnfMgr = null;

public GestorDeTransacciones()
public TransactionManager()
{

}

public void BeginTransaction()
{
_Cnn = new SqlConnection(Configuracion.Instancia.ConnectionString);
_CnfMgr = new ConfigManager();
_Cnn = new SqlConnection(_CnfMgr.ReadConfig().ConnectionString);
_Cnn.Open();

//IsolationLevel.ReadUncommitted allows mix DMLs and DDLs into same db script.
Expand Down Expand Up @@ -60,7 +56,7 @@ public void EjecutarSql(string sql)
{
SqlCommand cmd = new SqlCommand(sql, _Cnn, _Tnx);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
cmd.ExecuteNonQuery();
}
}
}
}
Loading

0 comments on commit 2aca85e

Please sign in to comment.