Modified check for interrupted files to raise notification only if there are actual interrupted files. Closes #2081
var receiveCredentials = ListenForRedirectAsync(port);
+ var logoutUrl = loginUrl.Replace("login", "im/logout");
+ var logoutProcess=Process.Start(logoutUrl);
+ TaskEx.Delay(100).Wait();
var uriBuilder=new UriBuilder(loginUrl);
uriBuilder.Query="next=" + listenerUrl;
<TextBox Name="CurrentAccount_ServerUrl" Grid.Column="1" Grid.Row="0" Margin="5"/>
<Label Content="Account" Grid.Column="0" Grid.Row="1" Margin="0,5" HorizontalAlignment="Left"/>
<TextBox Name="CurrentAccount_AccountName" Grid.Column="1" Grid.Row="1" Margin="5"/>
- <Label Content="API Key" Grid.Column="0" Grid.Row="2" Margin="0,5" HorizontalAlignment="Left"/>
- <TextBox Name="CurrentAccount_ApiKey" Grid.Column="1" Grid.Row="2" Margin="5"/>
+ <Grid Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" >
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="Auto"/>
+ <ColumnDefinition Width="*"/>
+ <ColumnDefinition Width="Auto"/>
+ </Grid.ColumnDefinitions>
+ <Label Content="API Key" Grid.Column="0" Margin="0,5" HorizontalAlignment="Left"/>
+ <TextBox Name="CurrentAccount_ApiKey" Grid.Column="1" Margin="5" />
+ <Button Name="RefreshApiKey" Grid.Column="2" Content="Refresh" Margin="5"/>
+ </Grid>
<Label Content="Folder" Grid.Column="0" Grid.Row="3" Margin="0,5" HorizontalAlignment="Left"/>
<Grid Grid.Row="3" Grid.Column="1" >
<Grid.ColumnDefinitions>
using System.ComponentModel.Composition;
using System.IO;
using System.Net;
+using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
using Caliburn.Micro;
}
}
+
+ public async Task RefreshApiKey()
+ {
+ await Shell.TryAuthorize(CurrentAccount.AccountName, 3);
+ NotifyOfPropertyChange(()=>CurrentAccount);
+ }
public void SaveChanges()
{
}
- private async Task TryAuthorize(string userName, int retries)
+ public async Task TryAuthorize(string userName, int retries)
{
_events.Publish(new Notification { Title = "Authorization failed", Message = "Your API Key has probably expired. You will be directed to a page where you can renew it", Level = TraceLevel.Error });
public void RestartInterruptedFiles(AccountInfo accountInfo)
{
- StatusNotification.NotifyChange("Restart processing interrupted files", TraceLevel.Verbose);
using (log4net.ThreadContext.Stacks["Workflow"].Push("Restart"))
{
var account = accountInfo;
- var pendingEntries = from state in FileState.Queryable
+ var pendingEntries = (from state in FileState.Queryable
where state.FileStatus != FileStatus.Unchanged &&
!state.FilePath.StartsWith(cachePath) &&
!state.FilePath.EndsWith(".ignore") &&
state.FilePath.StartsWith(account.AccountPath)
- select state;
- var pendingStates = new List<WorkflowState>();
- foreach (var state in pendingEntries)
- {
- pendingStates.Add(new WorkflowState(account, state));
- }
+ select state).ToList();
+ if (pendingEntries.Count>0)
+ StatusNotification.NotifyChange("Restart processing interrupted files", TraceLevel.Verbose);
+
+ var pendingStates = pendingEntries
+ .Select(state => new WorkflowState(account, state))
+ .ToList();
+
if (Log.IsDebugEnabled)
Log.DebugFormat("Found {0} interrupted files", pendingStates.Count);
-
- foreach (var entry in pendingStates)
- {
- Post(entry);
- }
+ pendingStates.ForEach(Post);
}
}