Skip to content
This repository was archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
scarpentier committed May 14, 2012
0 parents commit 42e27d2
Show file tree
Hide file tree
Showing 83 changed files with 2,088,916 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ServiceConfiguration.Cloud.cscfg
bin
obj
27 changes: 27 additions & 0 deletions DataFetcher/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;

namespace RezNetUsage.DataFetcher
{
using Core;

class Program
{
/// <summary>
/// Numéro du mois à downloader
/// </summary>
private const int Mois = 6; // juin

static void Main(string[] args)
{
Console.WriteLine("Déterminer la liste des chambres...");
Chambres chambres = AppartHelper.GetChambres();

Console.WriteLine("Télécharger l'utilisation des chambres...");
Usage usage = AppartHelper.GetUsage(chambres, Mois);

Console.WriteLine("Sauvegarder l'information dans un fichier XML...");
string filename = "20110" + (Mois >= 10 ? Mois.ToString() : "0" + Mois.ToString()) + " .xml";
usage.WriteXml(filename);
}
}
}
36 changes: 36 additions & 0 deletions DataFetcher/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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("DataFetcher")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("DataFetcher")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
[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("45bc0b7a-da79-40f8-96c3-c1851e593e9b")]

// 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")]
68 changes: 68 additions & 0 deletions DataFetcher/RezNetUsage.DataFetcher.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?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)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E1605538-6A9F-4B2B-8CC6-F5CA664FF1DC}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DataFetcher</RootNamespace>
<AssemblyName>DataFetcher</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<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|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.Entity" />
<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="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RezNetUsage.Core\RezNetUsage.Core.csproj">
<Project>{F6848D3F-1427-4EBC-A788-58CE7B93F054}</Project>
<Name>RezNetUsage.Core</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>
10 changes: 10 additions & 0 deletions DataFetcher/RezNetUsage.DataFetcher.csproj.vspscc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
""
{
"FILE_VERSION" = "9237"
"ENLISTMENT_CHOICE" = "NEVER"
"PROJECT_FILE_RELATIVE_PATH" = ""
"NUMBER_OF_EXCLUDED_FILES" = "0"
"ORIGINAL_PROJECT_FILE_PATH" = ""
"NUMBER_OF_NESTED_PROJECTS" = "0"
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
}
6 changes: 6 additions & 0 deletions RezNetUsage.Core/App.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="RezNetUsageDataEntities" connectionString="metadata=res://*/RezNetUsageData.csdl|res://*/RezNetUsageData.ssdl|res://*/RezNetUsageData.msl;provider=System.Data.SqlServerCe.3.5;provider connection string=&quot;Data Source=|DataDirectory|\RezNetUsageData.sdf&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
84 changes: 84 additions & 0 deletions RezNetUsage.Core/AppartHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RezNetUsage.Core
{
using System.Data;
using System.IO;
using System.Reflection;

public static class AppartHelper
{
public static bool IsAppartExist(int phase, int appart)
{
try {
// Instancier dataset Chambres
var chambres = GetChambres();

// Vérifier la présence de la chambre
DataRow[] foundrows = chambres.Tables[0].Select("Phase = " + phase + " AND Appartement = " + appart);

// Retourner le résultat
return (foundrows.Count() == 1);
} catch (Exception ex)
{
return false;
}
}

public static void RandomAppart(out int phase, out int appart)
{
// Instancier dataset Chambres
var chambres = GetChambres();

// Get random row
var rand = new Random();
DataRow dr = chambres.Tables[0].Rows[rand.Next(0, chambres.Tables[0].Rows.Count)];

phase = int.Parse((string)dr["Phase"]);
appart = int.Parse((string)dr["Appartement"]);
}

public static Chambres GetChambres()
{
// Instancier dataset Chambres
var chambres = new Chambres();

// Loader le data dans le dataset
var _assembly = Assembly.GetExecutingAssembly();
chambres.ReadXml(new StreamReader(_assembly.GetManifestResourceStream("RezNetUsage.Core.Chambres.xml")));

return chambres;
}

public static Usage GetUsage(Chambres chambres, int mois)
{
Usage usage = new Usage();

foreach (DataRow row in chambres.Tables[0].Rows)
{
Console.WriteLine(
"Téléchargement de l'utilisation de la chambre " + (string)row["Appartement"] + " de la phase " +
(string)row["Phase"]);
try
{
usage = UsageFactory.GetUsage(
usage, int.Parse((string)row["Phase"]), int.Parse((string)row["Appartement"]), mois);
}
catch (Exception ex)
{
Console.WriteLine("FAILED");
}
}

return usage;
}

public static Usage GetUsage(int phase, int appart, int mois)
{
return UsageFactory.GetUsage(phase, appart, mois);
}
}
}
Loading

0 comments on commit 42e27d2

Please sign in to comment.