using System.Diagnostics.Contracts;
using System.IO;
using System.Linq;
+using System.Net;
using System.Net.NetworkInformation;
using System.Security.Cryptography;
using System.ServiceModel.Description;
CloudClient=new CloudFilesClient(UserName,ApiKey);
- var proxyUri = ProxyFromSettings();
- CloudClient.Proxy = proxyUri;
+ var proxy = ProxyFromSettings();
+ CloudClient.Proxy = proxy;
CloudClient.UsePithos = true;
CloudClient.AuthenticationUrl = this.AuthenticationUrl;
public string AuthenticationUrl { get; set; }
- private Uri ProxyFromSettings()
+ private WebProxy ProxyFromSettings()
{
if (Settings.UseManualProxy)
{
- var proxyUri = new UriBuilder
- {
- Host = Settings.ProxyServer,
- Port = Settings.ProxyPort
- };
+ var proxy = new WebProxy(Settings.ProxyServer, Settings.ProxyPort);
+ //If the proxy requires specific authentication settings, use them
if (Settings.ProxyAuthentication)
{
- proxyUri.UserName = Settings.ProxyUsername;
- proxyUri.Password = Settings.ProxyPassword;
+ proxy.Credentials=new NetworkCredential(Settings.ProxyUsername,Settings.ProxyPassword,Settings.ProxyDomain);
}
- return proxyUri.Uri;
+ //Otherwise, if there are generic authentication settings, use them
+ if (!String.IsNullOrWhiteSpace(CredentialCache.DefaultNetworkCredentials.UserName))
+ {
+ proxy.Credentials = CredentialCache.DefaultNetworkCredentials;
+ }
+ return proxy;
}
return null;
}
private void StartWorkflowAgent()
{
- //On Vista and up we can check for a network connection
+ WorkflowAgent.StatusNotification = StatusNotification;
+
+/* //On Vista and up we can check for a network connection
bool connected=Environment.OSVersion.Version.Major < 6 || NetworkListManager.IsConnectedToInternet;
//If we are not connected retry later
if (!connected)
{
Task.Factory.StartNewDelayed(10000, StartWorkflowAgent);
return;
- }
+ }*/
try
{
- WorkflowAgent.StatusNotification = StatusNotification;
WorkflowAgent.Start();
}
catch (Exception)