Browse Source

Fixed exception when network connection is not available; use MTOM message encoding.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4940 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
aac9d32ea2
  1. 3
      src/AddIns/Misc/UsageDataCollector/UsageDataCollector/UsageDataCollector.csproj
  2. 18
      src/AddIns/Misc/UsageDataCollector/UsageDataCollector/UsageDataUploader.cs
  3. 28
      src/AddIns/Misc/UsageDataCollector/UsageDataCollector/app.config

3
src/AddIns/Misc/UsageDataCollector/UsageDataCollector/UsageDataCollector.csproj

@ -61,8 +61,5 @@ @@ -61,8 +61,5 @@
<Compile Include="UsageDataSessionWriter.cs" />
<Compile Include="UsageDataUploader.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

18
src/AddIns/Misc/UsageDataCollector/UsageDataCollector/UsageDataUploader.cs

@ -80,6 +80,8 @@ namespace ICSharpCode.UsageDataCollector @@ -80,6 +80,8 @@ namespace ICSharpCode.UsageDataCollector
EndpointAddress epa = new EndpointAddress(uploadUrl);
BasicHttpBinding binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.None;
binding.TransferMode = TransferMode.Streamed;
binding.MessageEncoding = WSMessageEncoding.Mtom;
StartUpload(binding, epa);
}
@ -117,14 +119,24 @@ namespace ICSharpCode.UsageDataCollector @@ -117,14 +119,24 @@ namespace ICSharpCode.UsageDataCollector
File.WriteAllBytes(Path.Combine(Path.GetTempPath(), "SharpDevelopUsageData.xml.gz"), data);
UDCUploadServiceClient client = new UDCUploadServiceClient(binding, endpoint);
client.BeginUploadUsageData("sharpdevelop", new MemoryStream(data),
ar => UsageDataUploaded(ar, client, commaSeparatedSessionIDList), null);
try {
client.BeginUploadUsageData("sharpdevelop", new MemoryStream(data),
ar => UsageDataUploaded(ar, client, commaSeparatedSessionIDList), null);
} catch (EndpointNotFoundException) {
// ignore error (maybe currently not connected to network)
}
}
}
void UsageDataUploaded(IAsyncResult result, UDCUploadServiceClient client, string commaSeparatedSessionIDList)
{
client.EndUploadUsageData(result);
try {
client.EndUploadUsageData(result);
} catch (EndpointNotFoundException) {
// ignore error (maybe currently not connected to network)
}
client.Close();
RemoveUploadedData(commaSeparatedSessionIDList);
}

28
src/AddIns/Misc/UsageDataCollector/UsageDataCollector/app.config

@ -1,28 +0,0 @@ @@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IUDCUploadService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://build.sharpdevelop.net/udc.upload/uploadusagedata.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUDCUploadService"
contract="Service.IUDCUploadService" name="BasicHttpBinding_IUDCUploadService" />
</client>
</system.serviceModel>
</configuration>
Loading…
Cancel
Save