From: <br...@us...> - 2009-01-24 22:39:01
|
Revision: 462 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=462&view=rev Author: brus07 Date: 2009-01-24 22:38:57 +0000 (Sat, 24 Jan 2009) Log Message: ----------- Added new project for doing concrete connection to Web and can modification of this project to easy using other type and style of connection. Modified Paths: -------------- ACMServer/trunk/ACMServer/ACMMediator.sln ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/WebGatePlugin/WebGetter.cs Added Paths: ----------- ACMServer/trunk/ACMServer/Library/ConcreteConnector/ ACMServer/trunk/ACMServer/Library/ConcreteConnector/SampleWebConnector/ ACMServer/trunk/ACMServer/Library/ConcreteConnector/SampleWebConnector/Properties/ ACMServer/trunk/ACMServer/Library/ConcreteConnector/SampleWebConnector/Properties/AssemblyInfo.cs ACMServer/trunk/ACMServer/Library/ConcreteConnector/SampleWebConnector/SampleWebConnector.cs ACMServer/trunk/ACMServer/Library/ConcreteConnector/SampleWebConnector/SampleWebConnector.csproj Modified: ACMServer/trunk/ACMServer/ACMMediator.sln =================================================================== --- ACMServer/trunk/ACMServer/ACMMediator.sln 2009-01-17 21:05:36 UTC (rev 461) +++ ACMServer/trunk/ACMServer/ACMMediator.sln 2009-01-24 22:38:57 UTC (rev 462) @@ -33,6 +33,10 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubmitterGUIPlugin", "Plugins\TesterPlugins\SubmitterGUIPlugin\SubmitterGUIPlugin.csproj", "{E255910C-499D-48E2-9846-7EB24DE32C4A}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ConcreteConnector", "ConcreteConnector", "{4E42F296-7321-4193-9E35-9B7202005229}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleWebConnector", "Library\ConcreteConnector\SampleWebConnector\SampleWebConnector.csproj", "{45B4D72E-CD81-42A7-AD46-3471380A290F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -87,6 +91,10 @@ {E255910C-499D-48E2-9846-7EB24DE32C4A}.Debug|Any CPU.Build.0 = Debug|Any CPU {E255910C-499D-48E2-9846-7EB24DE32C4A}.Release|Any CPU.ActiveCfg = Release|Any CPU {E255910C-499D-48E2-9846-7EB24DE32C4A}.Release|Any CPU.Build.0 = Release|Any CPU + {45B4D72E-CD81-42A7-AD46-3471380A290F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {45B4D72E-CD81-42A7-AD46-3471380A290F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {45B4D72E-CD81-42A7-AD46-3471380A290F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {45B4D72E-CD81-42A7-AD46-3471380A290F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -96,6 +104,7 @@ {A8135069-F8BA-4E5D-835F-3FF3F350AA5D} = {9AC82C0B-F256-41DD-9B4A-A59EC7EB4890} {30C0EFA3-36A8-4C6F-8FEC-28F771D4933F} = {9AC82C0B-F256-41DD-9B4A-A59EC7EB4890} {4EB54D66-105B-4CFD-8883-CBE7CA70AFA5} = {9AC82C0B-F256-41DD-9B4A-A59EC7EB4890} + {4E42F296-7321-4193-9E35-9B7202005229} = {9AC82C0B-F256-41DD-9B4A-A59EC7EB4890} {E4F4B91E-CC25-410B-B53A-E2507EFA4FCB} = {D80861F5-3751-4D49-884B-1A10FE1BCB07} {69FB4176-F298-4AF7-B714-B6758AA9A58E} = {D80861F5-3751-4D49-884B-1A10FE1BCB07} {D67E1C70-DFE6-4C3E-BCA9-DD3DB9CB4B30} = {D80861F5-3751-4D49-884B-1A10FE1BCB07} @@ -104,5 +113,6 @@ {8F305004-8FB7-4F85-8063-3A7041DB840F} = {D67E1C70-DFE6-4C3E-BCA9-DD3DB9CB4B30} {79EB24DD-AF0D-40D0-974E-198F4D8C92BC} = {D67E1C70-DFE6-4C3E-BCA9-DD3DB9CB4B30} {E255910C-499D-48E2-9846-7EB24DE32C4A} = {D67E1C70-DFE6-4C3E-BCA9-DD3DB9CB4B30} + {45B4D72E-CD81-42A7-AD46-3471380A290F} = {4E42F296-7321-4193-9E35-9B7202005229} EndGlobalSection EndGlobal Property changes on: ACMServer/trunk/ACMServer/Library/ConcreteConnector ___________________________________________________________________ Added: tsvn:logminsize + 5 Property changes on: ACMServer/trunk/ACMServer/Library/ConcreteConnector/SampleWebConnector ___________________________________________________________________ Added: svn:ignore + bin obj SampleWebConnector.csproj.user Added: tsvn:logminsize + 5 Property changes on: ACMServer/trunk/ACMServer/Library/ConcreteConnector/SampleWebConnector/Properties ___________________________________________________________________ Added: tsvn:logminsize + 5 Added: ACMServer/trunk/ACMServer/Library/ConcreteConnector/SampleWebConnector/Properties/AssemblyInfo.cs =================================================================== --- ACMServer/trunk/ACMServer/Library/ConcreteConnector/SampleWebConnector/Properties/AssemblyInfo.cs (rev 0) +++ ACMServer/trunk/ACMServer/Library/ConcreteConnector/SampleWebConnector/Properties/AssemblyInfo.cs 2009-01-24 22:38:57 UTC (rev 462) @@ -0,0 +1,35 @@ +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("SampleWebConnector")] +[assembly: AssemblyDescription("http://acm.lviv.ua")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("AcmContester")] +[assembly: AssemblyProduct("SampleWebConnector")] +[assembly: AssemblyCopyright("Copyright © AcmContester 2009")] +[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("b7266d48-2a23-40f7-85a8-e1f06ce11ce7")] + +// 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 Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyFileVersion("1.0.0.0")] Added: ACMServer/trunk/ACMServer/Library/ConcreteConnector/SampleWebConnector/SampleWebConnector.cs =================================================================== --- ACMServer/trunk/ACMServer/Library/ConcreteConnector/SampleWebConnector/SampleWebConnector.cs (rev 0) +++ ACMServer/trunk/ACMServer/Library/ConcreteConnector/SampleWebConnector/SampleWebConnector.cs 2009-01-24 22:38:57 UTC (rev 462) @@ -0,0 +1,98 @@ +using System; +using AcmContester.Library.Connector.Getter; +using AcmContester.Library.LibraryExtention; +using AcmContester.Library.LibraryExtention.Data; +using System.Net; +using System.IO; + +namespace AcmContester.Library.ConcreateConnector.SampleWebConnector +{ + public class SampleWebConnector : IGetter + { + //"http://127.0.0.1/d"; + string fullPathToWebPages = ""; + + #region IGetter Members + + public string PathToSource + { + get + { + return fullPathToWebPages; + } + set + { + fullPathToWebPages = value; + } + } + + public SystemMessage GetData() + { + return new SystemMessage(GetFullInfoFromSite()); + } + + public void Send(SystemMessage message) + { + if (message.IsType("TestingResult") == true) + { + SendTestingResultToSite(message.Message); + } + } + + #endregion + + + void SendTestingResultToSite(string message) + { + string res = ""; + string id = ""; + string usedMemory = ""; + string usedTime = ""; + + //TODO: + Result result = Result.CreateFromXml(message); + res = result.res; + id = result.Submit.id.ToString(); + usedMemory = result.usedMemory.ToString(); + usedTime = result.usedTime.ToString(); + + string fullURL = fullPathToWebPages + "/set.php?"; + fullURL += "res=" + res; + fullURL += "&id=" + id; + fullURL += "&usedMemory=" + usedMemory; + fullURL += "&usedTime=" + usedTime; + HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(fullURL); + myRequest.Method = "GET"; + WebResponse myResponse = myRequest.GetResponse(); + myResponse.Close(); + } + + + + string GetFullInfoFromSite() + { + string result = null; + try + { + HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(fullPathToWebPages + "/get.php"); + myRequest.Method = "GET"; + //myRequest.Timeout = 100000; + WebResponse myResponse = myRequest.GetResponse(); + StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8); + result = sr.ReadToEnd(); + sr.Close(); + myResponse.Close(); + if (result.Length == 0) + return null; + } + catch (WebException wex) + { + if (wex.Status == WebExceptionStatus.Timeout) + { + return "SystemResult: Timeout"; + } + } + return result; + } + } +} Added: ACMServer/trunk/ACMServer/Library/ConcreteConnector/SampleWebConnector/SampleWebConnector.csproj =================================================================== --- ACMServer/trunk/ACMServer/Library/ConcreteConnector/SampleWebConnector/SampleWebConnector.csproj (rev 0) +++ ACMServer/trunk/ACMServer/Library/ConcreteConnector/SampleWebConnector/SampleWebConnector.csproj 2009-01-24 22:38:57 UTC (rev 462) @@ -0,0 +1,61 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.50727</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{45B4D72E-CD81-42A7-AD46-3471380A290F}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>SampleWebConnector</RootNamespace> + <AssemblyName>SampleWebConnector</AssemblyName> + </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="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="SampleWebConnector.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\Connector\Connector.csproj"> + <Project>{211DD6A5-2D73-439E-8722-ED2C89ED1DDB}</Project> + <Name>Connector</Name> + </ProjectReference> + <ProjectReference Include="..\..\Data\Data.csproj"> + <Project>{30C0EFA3-36A8-4C6F-8FEC-28F771D4933F}</Project> + <Name>Data</Name> + </ProjectReference> + <ProjectReference Include="..\..\LibraryExtention\LibraryExtention.csproj"> + <Project>{A8135069-F8BA-4E5D-835F-3FF3F350AA5D}</Project> + <Name>LibraryExtention</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\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> \ No newline at end of file Modified: ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/WebGatePlugin/WebGetter.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/WebGatePlugin/WebGetter.cs 2009-01-17 21:05:36 UTC (rev 461) +++ ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/WebGatePlugin/WebGetter.cs 2009-01-24 22:38:57 UTC (rev 462) @@ -6,6 +6,7 @@ using AcmContester.Library.LibraryExtention.Data; using System.Net; using System.Collections.Generic; +using AcmContester.Library.ConcreateConnector.SampleWebConnector; namespace AcmContester.Plugins.MediatorPlugins.WebGatePlugin { @@ -14,6 +15,8 @@ //"http://127.0.0.1/d"; string fullPathToWebPages = ""; + IGetter getter = new SampleWebConnector(); + DataMediator container = new DataMediator(); public WebGetter() @@ -26,11 +29,13 @@ get { checkAddress(); + getter.PathToSource = fullPathToWebPages; return fullPathToWebPages; } set { fullPathToWebPages = value; + getter.PathToSource = value; } } @@ -39,7 +44,7 @@ if (fullPathToWebPages == "") { StreamReader s = new StreamReader("InDataW.txt", Encoding.Default); - fullPathToWebPages = s.ReadLine(); + PathToSource = s.ReadLine(); s.Close(); } } @@ -55,7 +60,11 @@ public void Send(SystemMessage message) { if (message.IsType("TestingResult") == true) - SendTestingResultToSite(message.Message); + { + Send(message); + Result result = Result.CreateFromXml(message.Message); + container.Return(result); + } //jaksho inakshyj typ, todi potribno bude inakshu funkciju vyklykaty } @@ -63,46 +72,22 @@ { get { + getter.PathToSource = fullPathToWebPages; return fullPathToWebPages; } set { fullPathToWebPages = value; + getter.PathToSource = fullPathToWebPages; } } #endregion - void SendTestingResultToSite(string message) - { - string res = ""; - string id = ""; - string usedMemory = ""; - string usedTime = ""; - //TODO: - Result result = Result.CreateFromXml(message); - res = result.res; - id = result.Submit.id.ToString(); - usedMemory = result.usedMemory.ToString(); - usedTime = result.usedTime.ToString(); - - string fullURL = fullPathToWebPages + "/set.php?"; - fullURL += "res=" + res; - fullURL += "&id=" + id; - fullURL += "&usedMemory=" + usedMemory; - fullURL += "&usedTime=" + usedTime; - HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(fullURL); - myRequest.Method = "GET"; - WebResponse myResponse = myRequest.GetResponse(); - myResponse.Close(); - - container.Return(result); - } - SystemMessage GetMessageFromSite() { - string getAll = GetFullInfoFromSite(); + string getAll = getter.GetData().Message; if (String.IsNullOrEmpty(getAll) == true) return new SystemMessage("", "Empty"); if (getAll.Contains("submitList") == true) @@ -138,31 +123,5 @@ resultList.Items = result.ToArray(); return new SystemMessage(resultList.ToString(), "TestingSubmitList"); } - - string GetFullInfoFromSite() - { - string result = null; - try - { - HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(fullPathToWebPages + "/get.php"); - myRequest.Method = "GET"; - //myRequest.Timeout = 100000; - WebResponse myResponse = myRequest.GetResponse(); - StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8); - result = sr.ReadToEnd(); - sr.Close(); - myResponse.Close(); - if (result.Length == 0) - return null; - } - catch (WebException wex) - { - if (wex.Status == WebExceptionStatus.Timeout) - { - return "SystemResult: Timeout"; - } - } - return result; - } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |