From: <br...@us...> - 2008-08-31 10:42:26
|
Revision: 342 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=342&view=rev Author: brus07 Date: 2008-08-31 10:42:35 +0000 (Sun, 31 Aug 2008) Log Message: ----------- Now Getter for web can be realize in Plugin. Realized WebGetter in Plugin. Old WebGate generate exception when using. Modified Paths: -------------- ACMServer/trunk/ACMServer/Library/Connector/Connector.csproj ACMServer/trunk/ACMServer/Library/Connector/Getter/IGetter.cs ACMServer/trunk/ACMServer/Library/Connector/WebConnector.cs ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/WebGatePlugin/WebGate.cs ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/WebGatePlugin/WebGatePlugin.csproj ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/WebGatePlugin/WebGetter.cs Added Paths: ----------- ACMServer/trunk/ACMServer/Library/Connector/Getter/WebGetterOld.cs Removed Paths: ------------- ACMServer/trunk/ACMServer/Library/Connector/Getter/WebGetter.cs Modified: ACMServer/trunk/ACMServer/Library/Connector/Connector.csproj =================================================================== --- ACMServer/trunk/ACMServer/Library/Connector/Connector.csproj 2008-08-31 09:56:44 UTC (rev 341) +++ ACMServer/trunk/ACMServer/Library/Connector/Connector.csproj 2008-08-31 10:42:35 UTC (rev 342) @@ -39,7 +39,7 @@ </ItemGroup> <ItemGroup> <Compile Include="Getter\IGetter.cs" /> - <Compile Include="Getter\WebGetter.cs" /> + <Compile Include="Getter\WebGetterOld.cs" /> <Compile Include="SocketClient.cs" /> <Compile Include="SocketServer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> Modified: ACMServer/trunk/ACMServer/Library/Connector/Getter/IGetter.cs =================================================================== --- ACMServer/trunk/ACMServer/Library/Connector/Getter/IGetter.cs 2008-08-31 09:56:44 UTC (rev 341) +++ ACMServer/trunk/ACMServer/Library/Connector/Getter/IGetter.cs 2008-08-31 10:42:35 UTC (rev 342) @@ -6,5 +6,10 @@ { SystemMessage GetInfoFromSite(); void Send(SystemMessage message); + string PathToSource + { + get; + set; + } } } Deleted: ACMServer/trunk/ACMServer/Library/Connector/Getter/WebGetter.cs =================================================================== --- ACMServer/trunk/ACMServer/Library/Connector/Getter/WebGetter.cs 2008-08-31 09:56:44 UTC (rev 341) +++ ACMServer/trunk/ACMServer/Library/Connector/Getter/WebGetter.cs 2008-08-31 10:42:35 UTC (rev 342) @@ -1,96 +0,0 @@ -using System; -using System.Threading; -using System.Windows.Forms; -using System.Net; -using System.IO; -using System.Text; -using AcmContester.Library.LibraryExtention.Data; -using AcmContester.Library.LibraryExtention; - -namespace AcmContester.Library.Connector.Getter -{ - class WebGetter: IWebGetter - { - //"http://127.0.0.1/d"; - string fullPathToWebPages = ""; - - public string FullPathToWebPages - { - get - { - checkAddress(); - return fullPathToWebPages; - } - set - { - fullPathToWebPages = value; - } - } - - private void checkAddress() - { - if (fullPathToWebPages == "") - { - StreamReader s = new StreamReader("InDataW.txt", Encoding.Default); - fullPathToWebPages = s.ReadLine(); - s.Close(); - } - } - - public void Send(SystemMessage message) - { - SendX(message.Message); - } - - public SystemMessage GetInfoFromSite() - { - checkAddress(); - object ob = GetInfoFromSiteX(); - SystemMessage sysMes = new SystemMessage(ob.ToString()); - return sysMes; - } - - void SendX(string message) - { - string res = ""; - string id = ""; - string usedMemory = ""; - string usedTime = ""; - try - { - //TODO: - Result result = Result.CreateFromXml(message); - res = result.res; - id = result.Submit.id.ToString(); - usedMemory = result.usedMemory.ToString(); - usedTime = result.usedTime.ToString(); - } - catch (Exception) - { - return; - } - 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 GetInfoFromSiteX() - { - HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(fullPathToWebPages + "/get.php"); - myRequest.Method = "GET"; - WebResponse myResponse = myRequest.GetResponse(); - StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8); - string result = sr.ReadToEnd(); - sr.Close(); - myResponse.Close(); - if (result.Length == 0) - return null; - return result; - } - } -} Copied: ACMServer/trunk/ACMServer/Library/Connector/Getter/WebGetterOld.cs (from rev 339, ACMServer/trunk/ACMServer/Library/Connector/Getter/WebGetter.cs) =================================================================== --- ACMServer/trunk/ACMServer/Library/Connector/Getter/WebGetterOld.cs (rev 0) +++ ACMServer/trunk/ACMServer/Library/Connector/Getter/WebGetterOld.cs 2008-08-31 10:42:35 UTC (rev 342) @@ -0,0 +1,44 @@ +using System; +using System.Threading; +using System.Windows.Forms; +using System.Net; +using System.IO; +using System.Text; +using AcmContester.Library.LibraryExtention.Data; +using AcmContester.Library.LibraryExtention; + +namespace AcmContester.Library.Connector.Getter +{ + class WebGetterOld: IWebGetter + { + //"http://127.0.0.1/d"; + string fullPathToWebPages = ""; + + public void Send(SystemMessage message) + { + throw new Exception("The method or operation is not implemented."); + } + + public SystemMessage GetInfoFromSite() + { + throw new Exception("The method or operation is not implemented."); + } + + #region IWebGetter Members + + + public string PathToSource + { + get + { + return fullPathToWebPages; + } + set + { + fullPathToWebPages = value; + } + } + + #endregion + } +} Property changes on: ACMServer/trunk/ACMServer/Library/Connector/Getter/WebGetterOld.cs ___________________________________________________________________ Added: svn:mergeinfo + Modified: ACMServer/trunk/ACMServer/Library/Connector/WebConnector.cs =================================================================== --- ACMServer/trunk/ACMServer/Library/Connector/WebConnector.cs 2008-08-31 09:56:44 UTC (rev 341) +++ ACMServer/trunk/ACMServer/Library/Connector/WebConnector.cs 2008-08-31 10:42:35 UTC (rev 342) @@ -15,7 +15,7 @@ public event EventHandler onChecking; public event EventHandler onChecked; - private IWebGetter getter = new WebGetter(); + private IWebGetter getter = new WebGetterOld(); private WebConnector() { @@ -23,7 +23,7 @@ } public WebConnector(IWebGetter getter): this() { - //this.getter = getter; + this.getter = getter; } private void Init() { @@ -42,11 +42,12 @@ //TODO: get { - return ((WebGetter)getter).FullPathToWebPages; + + return getter.PathToSource; } set { - ((WebGetter)getter).FullPathToWebPages = value; + getter.PathToSource = value; } } Modified: ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/WebGatePlugin/WebGate.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/WebGatePlugin/WebGate.cs 2008-08-31 09:56:44 UTC (rev 341) +++ ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/WebGatePlugin/WebGate.cs 2008-08-31 10:42:35 UTC (rev 342) @@ -10,7 +10,8 @@ { private static WebGate instance = new WebGate(); - private WebGate(): base(new WebGetter()) + private WebGate() + : base(new WebGetter()) { } Modified: ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/WebGatePlugin/WebGatePlugin.csproj =================================================================== --- ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/WebGatePlugin/WebGatePlugin.csproj 2008-08-31 09:56:44 UTC (rev 341) +++ ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/WebGatePlugin/WebGatePlugin.csproj 2008-08-31 10:42:35 UTC (rev 342) @@ -51,6 +51,10 @@ <Project>{211DD6A5-2D73-439E-8722-ED2C89ED1DDB}</Project> <Name>Connector</Name> </ProjectReference> + <ProjectReference Include="..\..\..\Library\Data\Data.csproj"> + <Project>{30C0EFA3-36A8-4C6F-8FEC-28F771D4933F}</Project> + <Name>Data</Name> + </ProjectReference> <ProjectReference Include="..\..\..\Library\LibraryExtention\LibraryExtention.csproj"> <Project>{A8135069-F8BA-4E5D-835F-3FF3F350AA5D}</Project> <Name>LibraryExtention</Name> Modified: ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/WebGatePlugin/WebGetter.cs =================================================================== --- ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/WebGatePlugin/WebGetter.cs 2008-08-31 09:56:44 UTC (rev 341) +++ ACMServer/trunk/ACMServer/Plugins/MediatorPlugins/WebGatePlugin/WebGetter.cs 2008-08-31 10:42:35 UTC (rev 342) @@ -1,23 +1,112 @@ using System; using AcmContester.Library.Connector.Getter; using AcmContester.Library.LibraryExtention; +using System.IO; +using System.Text; +using AcmContester.Library.LibraryExtention.Data; +using System.Net; namespace AcmContester.Plugins.MediatorPlugins.WebGatePlugin { class WebGetter: IWebGetter { + //"http://127.0.0.1/d"; + string fullPathToWebPages = ""; + + public string FullPathToWebPages + { + get + { + checkAddress(); + return fullPathToWebPages; + } + set + { + fullPathToWebPages = value; + } + } + + private void checkAddress() + { + if (fullPathToWebPages == "") + { + StreamReader s = new StreamReader("InDataW.txt", Encoding.Default); + fullPathToWebPages = s.ReadLine(); + s.Close(); + } + } + #region IWebGetter Members public SystemMessage GetInfoFromSite() { - throw new Exception("The method or operation is not implemented."); + checkAddress(); + object ob = GetInfoFromSiteX(); + SystemMessage sysMes = new SystemMessage(ob.ToString()); + return sysMes; } public void Send(SystemMessage message) { - throw new Exception("The method or operation is not implemented."); + SendX(message.Message); } + public string PathToSource + { + get + { + return fullPathToWebPages; + } + set + { + fullPathToWebPages = value; + } + } + #endregion + + + void SendX(string message) + { + string res = ""; + string id = ""; + string usedMemory = ""; + string usedTime = ""; + try + { + //TODO: + Result result = Result.CreateFromXml(message); + res = result.res; + id = result.Submit.id.ToString(); + usedMemory = result.usedMemory.ToString(); + usedTime = result.usedTime.ToString(); + } + catch (Exception) + { + return; + } + 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 GetInfoFromSiteX() + { + HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(fullPathToWebPages + "/get.php"); + myRequest.Method = "GET"; + WebResponse myResponse = myRequest.GetResponse(); + StreamReader sr = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.UTF8); + string result = sr.ReadToEnd(); + sr.Close(); + myResponse.Close(); + if (result.Length == 0) + return null; + return result; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |