Skip to content

Commit

Permalink
Properties, Config.txt y Gitignore actualizado.
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidtfederico committed Oct 9, 2012
1 parent b3d45d0 commit a1fdb09
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 23 deletions.
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
[Bb]in/
#[Bb]in/
[Oo]bj/

# mstest test results
Expand All @@ -14,7 +14,6 @@ TestResults
*.sln.docstates

# Build results
[Dd]ebug/
[Rr]elease/
x64/
*_i.c
Expand All @@ -35,8 +34,12 @@ x64/
*.log
*.vspscc
*.vssscc
*.exe
*.exe.config
*.cache
.builds


# Visual C++ cache files
ipch/
*.aps
Expand Down Expand Up @@ -89,7 +92,6 @@ csx
AppPackages/

# Others
[Bb]in
[Oo]bj
sql
TestResults
Expand Down
19 changes: 14 additions & 5 deletions GrouponDesktop/Core/AppContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,28 @@ public sealed class AppContext

public AppContext()
{
this.loadConfig("Data\\Config.txt");
this.createDBManager();
}

private void createDBManager()
{
DBManager m = new DBManager("user id=gd;" +
"password=gd2012;server=localhost\\SQLSERVER2008;" +
"Trusted_Connection=yes;" +
"database=GD2C2012; " +
"connection timeout=60");
DBManager m = new DBManager("user id=" + Properties.getProperty("dbuser") +
";password=" + Properties.getProperty("dbpasswd") +
";server=" + Properties.getProperty("dburl") +
";Trusted_Connection=yes;" +
"database=" + Properties.getProperty("dbname") +
";connection timeout=60");
appContext.Add(typeof(DBManager), m);
}

private void loadConfig(String path)
{
Properties p = new Properties(path);
Console.WriteLine(Properties.getProperty("fecha"));
appContext.Add(typeof(Properties),p);
}

public static Object getObject(Type t)
{
return appContext[t];
Expand Down
1 change: 1 addition & 0 deletions GrouponDesktop/Core/DBManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class DBManager

public DBManager(String connectionString)
{
Console.WriteLine(connectionString);
sqlConnection.ConnectionString = connectionString;
}

Expand Down
35 changes: 35 additions & 0 deletions GrouponDesktop/Core/Properties.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.IO;

namespace GrouponDesktop.Core
{
class Properties
{
private static Dictionary<String, String> properties = new Dictionary<String, String>();

public Properties(String filePath)
{
this.loadProperties(filePath);
}

public void loadProperties(String path)
{
foreach(String line in File.ReadAllLines(path)){
if(line.StartsWith("#")) continue;
properties.Add(line.Substring(0, line.IndexOf("=")).Trim(), line.Substring(line.IndexOf("=")+1).Trim());
}
}

public static String getProperty(String key) {
return properties[key];
}

public void setProperty(String key, String value) {
properties.Add(key, value);
}
}
}
5 changes: 5 additions & 0 deletions GrouponDesktop/Data/Config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fecha=5/10/2011
dbuser=gd
dbpasswd=gd2012
dburl=localhost\SQLSERVER2008
dbname=GD2C2012
11 changes: 5 additions & 6 deletions GrouponDesktop/GrouponDesktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,7 @@
<ItemGroup>
<Compile Include="Core\AppContext.cs" />
<Compile Include="Core\DBManager.cs" />
<Compile Include="GUI\AbmCliente\Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GUI\AbmCliente\Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Core\Properties.cs" />
<Compile Include="GD2C2012DataSet.cs">
<DependentUpon>GD2C2012DataSet.xsd</DependentUpon>
<SubType>Component</SubType>
Expand Down Expand Up @@ -147,6 +142,7 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Folder Include="GUI\AbmCliente\" />
<Folder Include="GUI\AbmProveedor\" />
<Folder Include="GUI\ArmarCupon\" />
<Folder Include="GUI\CargaCredito\" />
Expand All @@ -159,6 +155,9 @@
<Folder Include="GUI\PublicarCupon\" />
<Folder Include="GUI\RegistroConsumoCupon\" />
</ItemGroup>
<ItemGroup>
<Content Include="Data\Config.txt" />
</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.
Expand Down
12 changes: 3 additions & 9 deletions GrouponDesktop/Login.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using GrouponDesktop.Core;

namespace GrouponDesktop
{
Expand All @@ -19,15 +20,8 @@ public Login()

private void button1_Click(object sender, EventArgs e)
{
/*
* Ésto es claramente temporal y para probar la conexión, si alguien se conecta
* así de ahora en más, muere en la horca, así de una (?.
*/
SqlConnection myConnection = new SqlConnection("user id=gd;" +
"password=gd2012;server=localhost\\SQLSERVER2008;" +
"Trusted_Connection=yes;" +
"database=GD2C2012; " +
"connection timeout=60");
DBManager manager = (DBManager) AppContext.getObject(typeof(DBManager));
SqlConnection myConnection = manager.getConnection();
try
{
myConnection.Open();
Expand Down
2 changes: 2 additions & 0 deletions GrouponDesktop/MainClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using GrouponDesktop.Core;

namespace GrouponDesktop
{
Expand All @@ -13,6 +14,7 @@ static class MainClass
[STAThread]
static void Main()
{
new AppContext();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Login());
Expand Down
5 changes: 5 additions & 0 deletions GrouponDesktop/bin/Debug/Data/Config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fecha=5/10/2011
dbuser=gd
dbpasswd=gd2012
dburl=localhost\SQLSERVER2008
dbname=GD2C2012

0 comments on commit a1fdb09

Please sign in to comment.