diff --git a/README.md b/README.md index 4ceb1eb..f15338a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # cleancode-webget-tool - +#rachid [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/rhwy/cleancode-webget-tool?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) diff --git a/Students/Rachid OUADI/nget -v1/nget/nget.sln b/Students/Rachid OUADI/nget -v1/nget/nget.sln new file mode 100644 index 0000000..e5424d4 --- /dev/null +++ b/Students/Rachid OUADI/nget -v1/nget/nget.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nget", "nget\nget.csproj", "{29FC1442-DEA5-4EF1-95BC-C1EA44B9980B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {29FC1442-DEA5-4EF1-95BC-C1EA44B9980B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {29FC1442-DEA5-4EF1-95BC-C1EA44B9980B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {29FC1442-DEA5-4EF1-95BC-C1EA44B9980B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {29FC1442-DEA5-4EF1-95BC-C1EA44B9980B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Students/Rachid OUADI/nget -v1/nget/nget/App.config b/Students/Rachid OUADI/nget -v1/nget/nget/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Students/Rachid OUADI/nget -v1/nget/nget/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Students/Rachid OUADI/nget -v1/nget/nget/Program.cs b/Students/Rachid OUADI/nget -v1/nget/nget/Program.cs new file mode 100644 index 0000000..b4187af --- /dev/null +++ b/Students/Rachid OUADI/nget -v1/nget/nget/Program.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; +using System.Timers; + +namespace nget +{ + class Program + { + static void Main(string[] args) + { + bool bonArg = false; + try + { + if (args.Length == 3) + { + if (args[0] == "get" && args.Length == 3) + { + + using (var client = new WebClient()) + { + string result = client.DownloadString(args[2]); + Console.WriteLine(result); + bonArg = true; + + } + } + } + else if (args.Length == 5) + { + if (args[0] == "get" && args[3] == "-save") + { + using (var client = new WebClient()) + { + string result = client.DownloadString(args[2]); + File.WriteAllText(args[4], result); + bonArg = true; + + } + } + + + if (args[0] == "get" && args[3] == "-times") + { + + + for (int i = 0; i < Convert.ToInt32(args[4]); i++) + { + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + using (var client = new WebClient()) + { + string result = client.DownloadString(args[2]); + } + + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + + Console.WriteLine("Chargement numero " + (i + 1) + " : " + ts.Milliseconds + "ms"); + bonArg = true; + } + } + } + else if (args.Length == 6) + { + Stopwatch stopWatch = new Stopwatch(); + ArrayList tps = new ArrayList(); + + for (int i = 0; i < Convert.ToInt32(args[4]); i++) + { + stopWatch.Start(); + using (var client = new WebClient()) + { + string result = client.DownloadString(args[2]); + } + + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + tps.Add(Convert.ToInt32(ts.Milliseconds)); + } + double dbResult = 0.0; + for (int i = 0; i < tps.Count; i++) + { + dbResult += Convert.ToDouble(tps[i]); + } + dbResult = dbResult / Convert.ToInt32(args[4]); + Console.WriteLine("time : " + dbResult + "ms"); + bonArg = true; + } + if (bonArg == false) + { + Console.WriteLine("Bad arg"); + Console.ReadLine(); + Environment.Exit(0); + } + } + + catch (Exception e) + { + Console.WriteLine(e.ToString()); + } + + Console.ReadLine(); + + } + } +} diff --git a/Students/Rachid OUADI/nget -v1/nget/nget/Properties/AssemblyInfo.cs b/Students/Rachid OUADI/nget -v1/nget/nget/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..35e4194 --- /dev/null +++ b/Students/Rachid OUADI/nget -v1/nget/nget/Properties/AssemblyInfo.cs @@ -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("nget")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("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("3146940c-7709-4a84-90c9-794c48787df0")] + +// 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")] diff --git a/Students/Rachid OUADI/nget -v1/nget/nget/nget.csproj b/Students/Rachid OUADI/nget -v1/nget/nget/nget.csproj new file mode 100644 index 0000000..bd7a33e --- /dev/null +++ b/Students/Rachid OUADI/nget -v1/nget/nget/nget.csproj @@ -0,0 +1,66 @@ + + + + + Debug + AnyCPU + {29FC1442-DEA5-4EF1-95BC-C1EA44B9980B} + Exe + Properties + nget + nget + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Students/Rachid OUADI/nget -v2/nget-v2/nget-v2.sln b/Students/Rachid OUADI/nget -v2/nget-v2/nget-v2.sln new file mode 100644 index 0000000..cf31a21 --- /dev/null +++ b/Students/Rachid OUADI/nget -v2/nget-v2/nget-v2.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nget-v2", "nget-v2\nget-v2.csproj", "{005DA57B-91D7-453B-9B91-CE6DE6348950}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {005DA57B-91D7-453B-9B91-CE6DE6348950}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {005DA57B-91D7-453B-9B91-CE6DE6348950}.Debug|Any CPU.Build.0 = Debug|Any CPU + {005DA57B-91D7-453B-9B91-CE6DE6348950}.Release|Any CPU.ActiveCfg = Release|Any CPU + {005DA57B-91D7-453B-9B91-CE6DE6348950}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Students/Rachid OUADI/nget -v2/nget-v2/nget-v2/App.config b/Students/Rachid OUADI/nget -v2/nget-v2/nget-v2/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/Students/Rachid OUADI/nget -v2/nget-v2/nget-v2/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Students/Rachid OUADI/nget -v2/nget-v2/nget-v2/Program.cs b/Students/Rachid OUADI/nget -v2/nget-v2/nget-v2/Program.cs new file mode 100644 index 0000000..bac71cd --- /dev/null +++ b/Students/Rachid OUADI/nget -v2/nget-v2/nget-v2/Program.cs @@ -0,0 +1,162 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace nget_v2 +{ + class Program + { + static bool bonArg; //= false; + static void Main(string[] args) + { + bonArg = false; + + try + { + + + + string[] typeOfExecution = { "get", "test" }; + bool result = IsPresentTOE(args[0], typeOfExecution); + if(result==false) + { + Console.WriteLine("Bad Argument"); + System.Environment.Exit(1); + } + + string[] typeOfArgsForTheExecution = { "-url" }; + result = IsPresentTOE(args[1], typeOfArgsForTheExecution); + if(result==false) + { + Console.WriteLine("Bad Argument"); + System.Environment.Exit(1); + } + + string[] additionalArgsToExecution = { "-times", "-avg" }; + + + if (args.Length == 3) + { + if (args[0] == "get" && args.Length == 3) + { + GetContent(args); + } + } + else if (args.Length == 5) + { + if (args[0] == "get" && args[3] == "-save") + { + GetAndSaveContent(args); + } + if (args[0] == "get" && args[3] == "-times") + { + GetTimeLoad(args); + } + } + else if (args.Length == 6) + { + GetTimeAvgLoad(args); + } + if (bonArg == false) + { + Console.WriteLine("Bad arg"); + Console.ReadLine(); + Environment.Exit(0); + } + } + + catch (Exception e) + { + Console.WriteLine(e.ToString()); + } + + Console.ReadLine(); + + } + + private static bool IsPresentTOE(string arg,string[] tabArg) + { + if (tabArg.Contains(arg) == true) + { + return true; + } + return false; + + } + + private static void GetTimeAvgLoad(string[] _args) + { + Stopwatch stopWatch = new Stopwatch(); + ArrayList tps = new ArrayList(); + + for (int i = 0; i < Convert.ToInt32(_args[4]); i++) + { + stopWatch.Start(); + using (var client = new WebClient()) + { + string result = client.DownloadString(_args[2]); + } + + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + tps.Add(Convert.ToInt32(ts.Milliseconds)); + } + double dbResult = 0.0; + for (int i = 0; i < tps.Count; i++) + { + dbResult += Convert.ToDouble(tps[i]); + } + dbResult = dbResult / Convert.ToInt32(_args[4]); + Console.WriteLine("time : " + dbResult + "ms"); + bonArg = true; + } + + private static void GetTimeLoad(string []_args) + { + for (int i = 0; i < Convert.ToInt32(_args[4]); i++) + { + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + using (var client = new WebClient()) + { + string result = client.DownloadString(_args[2]); + } + + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + + Console.WriteLine("Chargement numero " + (i + 1) + " : " + ts.Milliseconds + "ms"); + bonArg = true; + } + } + + private static void GetAndSaveContent(string[] _args) + { + using (var client = new WebClient()) + { + string result = client.DownloadString(_args[2]); + File.WriteAllText(_args[4], result); + bonArg = true; + + } + } + + private static void GetContent(string[] _args) + { + using (var client = new WebClient()) + { + string result = client.DownloadString(_args[2]); + Console.WriteLine(result); + bonArg = true; + + } + } + + } +} diff --git a/Students/Rachid OUADI/nget -v2/nget-v2/nget-v2/Properties/AssemblyInfo.cs b/Students/Rachid OUADI/nget -v2/nget-v2/nget-v2/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..aa780ee --- /dev/null +++ b/Students/Rachid OUADI/nget -v2/nget-v2/nget-v2/Properties/AssemblyInfo.cs @@ -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("nget-v2")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("nget-v2")] +[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("e2636ffa-15d8-411e-b174-0ac753ea2712")] + +// 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")] diff --git a/Students/Rachid OUADI/nget -v2/nget-v2/nget-v2/nget-v2.csproj b/Students/Rachid OUADI/nget -v2/nget-v2/nget-v2/nget-v2.csproj new file mode 100644 index 0000000..06029e5 --- /dev/null +++ b/Students/Rachid OUADI/nget -v2/nget-v2/nget-v2/nget-v2.csproj @@ -0,0 +1,58 @@ + + + + + Debug + AnyCPU + {005DA57B-91D7-453B-9B91-CE6DE6348950} + Exe + Properties + nget_v2 + nget-v2 + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file