[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Configuration.DefaultSettingValueAttribute("http://pithos.dev.grnet.gr/pithos.html")]
+ [global::System.Configuration.DefaultSettingValueAttribute("http://pithos.dev.grnet.gr")]
public string PithosSite {
get {
return ((string)(this["PithosSite"]));
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="PithosSite" Type="System.String" Scope="Application">
- <Value Profile="(Default)">http://pithos.dev.grnet.gr/pithos.html</Value>
+ <Value Profile="(Default)">http://pithos.dev.grnet.gr</Value>
</Setting>
<Setting Name="Accounts" Type="Pithos.Interfaces.AccountsCollection" Scope="User">
<Value Profile="(Default)">
}
if (!String.IsNullOrWhiteSpace(Monitor.UserName) &&
!String.IsNullOrWhiteSpace(Monitor.ApiKey))
- Monitor.Start();
+ try
+ {
+ Monitor.Start();
+ }
+ catch (Exception exc)
+ {
+ MessageBox.Show("An exception occured. Can't start monitoring");
+ }
}
}
}
<setting name="UseManualProxy" serializeAs="String">
<value>False</value>
</setting>
+ <setting name="Accounts" serializeAs="Xml">
+ <value>
+ <ArrayOfAccountSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <AccountSettings>
+ </AccountSettings>
+ </ArrayOfAccountSettings>
+ </value>
+ </setting>
</Pithos.Client.WPF.Properties.Settings>
</userSettings>
<connectionStrings>
<applicationSettings>
<Pithos.Client.WPF.Properties.Settings>
<setting name="PithosSite" serializeAs="String">
- <value>http://pithos.dev.grnet.gr/pithos.html</value>
+ <value>http://pithos.dev.grnet.gr</value>
</setting>
<setting name="PithosAuthenticationUrl" serializeAs="String">
<value>https://pithos.dev.grnet.gr</value>
[System.ComponentModel.Composition.Import]
public IPithosSettings Settings { get; set; }
- private JobQueue _statusUpdateQueue;
+ private JobQueue _statusUpdateQueue=new JobQueue();
public StatusKeeper()
{
using System.Collections.Specialized;
using System.Diagnostics;
using System.Diagnostics.Contracts;
+using System.IO;
using System.Net;
using System.Runtime.Serialization;
+using System.Threading.Tasks;
namespace Pithos.Network
{
protected override WebResponse GetWebResponse(WebRequest request)
{
+ try
+ {
+
var response = (HttpWebResponse)base.GetWebResponse(request);
StatusCode = response.StatusCode;
StatusDescription = response.StatusDescription;
return response;
+ }
+ catch (WebException exc)
+ {
+ if (exc.Response.ContentLength > 0)
+ {
+ string content;
+ content = GetContent(exc.Response);
+ Trace.TraceError(content);
+ }
+ throw;
+ }
+ }
+
+ private static string GetContent(WebResponse webResponse)
+ {
+ string content;
+ using (var stream = webResponse.GetResponseStream())
+ using (var reader = new StreamReader(stream))
+ {
+ content = reader.ReadToEnd();
+ }
+ return content;
}
public string DownloadStringWithRetry(string address,int retries=0)
var actualRetries = (retries == 0) ? Retries : retries;
- var func = Retry(() =>
+
+ var task = Retry(() =>
{
var uriString = String.Join("/", BaseAddress, actualAddress);
var content = base.DownloadString(uriString);
}, actualRetries);
- var result = func();
+ var result = task.Result;
return result;
}
var actualAddress = GetActualAddress(address);
var actualRetries = (retries == 0) ? Retries : retries;
- var func = Retry(() =>
+ var task = Retry(() =>
{
var uriString = String.Join("/",BaseAddress ,actualAddress);
var uri = new Uri(uriString);
return 0;
}, actualRetries);
- func();
+ task.Wait();
}
private string GetActualAddress(string address)
throw new ArgumentNullException("address");
var actualRetries = (retries == 0) ? Retries : retries;
- var func = Retry(() =>
+ var task = Retry(() =>
{
var content = base.DownloadString(address);
}, actualRetries);
- var result = func();
+ var result = task.Result;
return result;
}
throw new WebException(String.Format("{0} with code {1} - {2}", message, StatusCode, StatusDescription));
}
- private Func<T> Retry<T>(Func< T> original, int retryCount)
+ /*private Func<T> Retry<T>(Func< T> original, int retryCount)
{
return () =>
{
}
}
};
+ }*/
+
+ private Task<T> Retry<T>(Func< T> original, int retryCount)
+ {
+ return Task.Factory.StartNew(() => original()).ContinueWith(_original =>
+ {
+ if(_original.IsFaulted )
+ {
+ var e = _original.Exception.InnerException;
+ if (e is WebException)
+ {
+ var we = (e as WebException);
+ var statusCode = ((HttpWebResponse) we.Response).StatusCode;
+ this.StatusCode = statusCode;
+
+ if (we.Status==WebExceptionStatus.Timeout ||
+ (we.Status==WebExceptionStatus.ProtocolError && statusCode==HttpStatusCode.ServiceUnavailable))
+ {
+ TimedOut = true;
+ if (retryCount == 0)
+ {
+ Trace.TraceError("[ERROR] Timed out too many times. {0}\n", e);
+ throw new RetryException("Timed out too many times.", e);
+ }
+ Trace.TraceError(
+ "[RETRY] Timed out after {0} ms. Will retry {1} more times\n{2}", Timeout,
+ retryCount, e);
+ return Retry(original, retryCount - 1);
+ }
+
+ if (statusCode==HttpStatusCode.NotFound)
+ return new Task<T>(() => default(T));
+ }
+ throw e;
+ }
+ else
+ return Task<T>.Factory.StartNew(() => _original.Result);
+ }).Unwrap();
}
private IntPtr _gotoBitmap=IntPtr.Zero;
private IntPtr _versionBitmap = IntPtr.Zero;
+ private IntPtr _propertiesBitmap = IntPtr.Zero;
public FileContextMenu()
{
_gotoBitmap = GetBitmapPtr(Resources.MenuGoToPithos);
_versionBitmap = GetBitmapPtr(Resources.MenuHistory);
+ _propertiesBitmap = GetBitmapPtr(Resources.MenuProperties);
DisplayFlags=DisplayFlags.All,
MenuBitmap = _gotoBitmap
}},
+ /*{"showProperties",new MenuItem{
+ MenuText = "&Pithos File Properties",
+ Verb = "showProperties",
+ VerbCanonicalName = "PITHOSProperties",
+ VerbHelpText = "Pithos File Properties",
+ MenuDisplayId = 2,
+ MenuCommand=OnShowProperties,
+ DisplayFlags=DisplayFlags.File,
+ MenuBitmap = _propertiesBitmap
+ }},*/
{"prevVersions",new MenuItem{
MenuText = "&Show Previous Versions",
Verb = "prevVersions",
VerbCanonicalName = "PITHOSPrevVersions",
VerbHelpText = "Go to Pithos and display previous versions",
- MenuDisplayId = 2,
+ MenuDisplayId = 3,
MenuCommand=OnVerbDisplayFileName,
DisplayFlags=DisplayFlags.File,
MenuBitmap=_versionBitmap
NativeMethods.DeleteObject(_versionBitmap);
_versionBitmap = IntPtr.Zero;
}
+ if (_propertiesBitmap != IntPtr.Zero)
+ {
+ NativeMethods.DeleteObject(_propertiesBitmap);
+ _propertiesBitmap = IntPtr.Zero;
+ }
}
private static IntPtr GetBitmapPtr(Bitmap gotoBitmap)
return hbitmap;
}
+ void OnShowProperties(IntPtr hWnd)
+ {
+
+ }
void OnVerbDisplayFileName(IntPtr hWnd)
{
void OnGotoPithos(IntPtr hWnd)
{
- Context.Settings.Reload();
- Process.Start(Context.Settings.PithosSite);
+ var settings = Context.Settings;
+ var activeAccount = settings.Accounts.FirstOrDefault(acc => acc.IsActive);
+ var address = String.Format("{0}/ui/?token={1}&user={2}",
+ settings.PithosSite,
+ activeAccount.ApiKey,
+ Uri.EscapeUriString(activeAccount.AccountName));
+
+ settings.Reload();
+ Process.Start(address);
}
<LastGenOutput>Reference.cs</LastGenOutput>
</None>
</ItemGroup>
+ <ItemGroup>
+ <None Include="Resources\MenuProperties.bmp" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>if exist "$(TargetPath).locked" del "$(TargetPath).locked"
{
public static void EnsureHost()
{
+ return;
if (Process.GetProcessesByName("Pithos.Client.WPF").Length == 0 &&
Process.GetProcessesByName("Pithos.Client.WPF.vshost").Length == 0)
{
return ((System.Drawing.Bitmap)(obj));
}
}
+
+ internal static System.Drawing.Bitmap MenuProperties {
+ get {
+ object obj = ResourceManager.GetObject("MenuProperties", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
}
}
<data name="MenuHistory" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\MenuHistory.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
+ <data name="MenuProperties" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>..\Resources\MenuProperties.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+ </data>
</root>
\ No newline at end of file