Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@


English readme not available at this time, it's only available in [french](readme.fr.md)

Gaetan Marzilli
[email protected]
22 changes: 22 additions & 0 deletions Students/Marzilli-Gaetan/nget-v1/Projet_NGET/Projet_NGET.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Projet_NGET", "Projet_NGET\Projet_NGET.csproj", "{756BCACB-2FD9-4EC7-AB17-24F01752D4E9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{756BCACB-2FD9-4EC7-AB17-24F01752D4E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{756BCACB-2FD9-4EC7-AB17-24F01752D4E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{756BCACB-2FD9-4EC7-AB17-24F01752D4E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{756BCACB-2FD9-4EC7-AB17-24F01752D4E9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
146 changes: 146 additions & 0 deletions Students/Marzilli-Gaetan/nget-v1/Projet_NGET/Projet_NGET/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.IO;
using System.Net;
using System.Text.RegularExpressions;

namespace Projet_NGET
{
class Program
{
/// <summary>
/// Main de l'application
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
if (args != null)
{
if (args.Length > 2) {
switch (args[0])
{
case "get":
if (args[1].Equals("-url"))
{
AfficherPageWeb(args[2]);
}

if (args.Length > 3)
{
if (args[3].Equals("-save"))
{
string contenuSite = ContenuPageWeb(args[2]);
SauvegardeFichier(args[4], contenuSite);
}
}
break;
case "test":
if (args[1].Equals("-url"))
{
if (args[2] != null)
{
if (args.Length > 3)
{
if (args[3].Equals("-times"))
{
if (args[5].Equals("-avg"))
{
AfficherPageWebAvecTimer(args[2], int.Parse(args[4]), 1);
}
else
{
AfficherPageWebAvecTimer(args[2], int.Parse(args[4]), 0);
}
}
}
}
}
break;
default:
Console.WriteLine("Default case");
break;
}
}
}

}

/// <summary>
/// Affichage du contenu d'une page web.
/// </summary>
/// <param name="uneURL"></param>
public static void AfficherPageWeb(string uneURL)
{
WebClient client = new WebClient();
Console.WriteLine("Downloading {0}", uneURL);
string contenuPage = client.DownloadString(uneURL);
Console.WriteLine(contenuPage);
}

/// <summary>
/// Affichage du contenu d'une page web.
/// </summary>
/// <param name="uneURL"></param>
/// <param name="nbChargement"></param>
/// <param name="moyenne"></param>
public static void AfficherPageWebAvecTimer(string uneURL, int nbChargement, int moyenne)
{
int timer = 0;

for (int i = 0; i < nbChargement; i++)
{
DateTime start = DateTime.Now;

WebClient client = new WebClient();
Console.WriteLine("Downloading {0}", uneURL);
string contenuPage = client.DownloadString(uneURL);

DateTime end = DateTime.Now;


TimeSpan time = (end - start);
Console.WriteLine(time.Milliseconds.ToString() + " ms");

timer += int.Parse(time.Milliseconds.ToString());

if (moyenne == 1 && i == nbChargement - 1)
{
System.Console.WriteLine("Moyenne : ", timer / nbChargement + " ms.");
}
}


}

/// <summary>
/// Retourne le contenu d'une page web en format string.
/// </summary>
/// <param name="uneURL"></param>
/// <returns name="contenuPage"></returns>
public static string ContenuPageWeb(string uneURL)
{
WebClient client = new WebClient();
string contenuPage = client.DownloadString(uneURL);
return contenuPage;
}

/// <summary>
/// Sauvegarde le contenu de la page web dans un fichier.
/// </summary>
/// <param name="unPatch"></param>
/// <param name="contenuSite"></param>
public static void SauvegardeFichier(string unPatch, string contenuSite)
{
using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"" + unPatch, true))
{
Console.WriteLine("Ecriture dans le fichier", unPatch);
file.WriteLine(contenuSite);
Console.WriteLine("Ecriture terminée");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?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>{756BCACB-2FD9-4EC7-AB17-24F01752D4E9}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Projet_NGET</RootNamespace>
<AssemblyName>Projet_NGET</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</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|AnyCPU' ">
<PlatformTarget>AnyCPU</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.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>
<None Include="App.config" />
</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
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Les informations générales relatives à un assembly dépendent de
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
// associées à un assembly.
[assembly: AssemblyTitle("Projet_NGET")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Projet_NGET")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
[assembly: ComVisible(false)]

// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM
[assembly: Guid("75fc5e87-36b4-4ac6-8814-a649f4d3624b")]

// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
//
// Version principale
// Version secondaire
// Numéro de build
// Révision
//
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]