Skip to content

Commit 7a3c3dc

Browse files
author
Mahdi Ghiasi
committed
Commit
1 parent 823cd1b commit 7a3c3dc

7 files changed

+128
-65
lines changed

App5/AppDataManageTool.csproj

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<AssemblyName>AppDataManageTool</AssemblyName>
1212
<DefaultLanguage>en-US</DefaultLanguage>
1313
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
14-
<TargetPlatformVersion>10.0.10586.0</TargetPlatformVersion>
14+
<TargetPlatformVersion>10.0.14393.0</TargetPlatformVersion>
1515
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
1616
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
1717
<FileAlignment>512</FileAlignment>
@@ -189,17 +189,17 @@
189189
<Generator>MSBuild:Compile</Generator>
190190
</Page>
191191
</ItemGroup>
192-
<ItemGroup>
193-
<SDKReference Include="WindowsMobile, Version=10.0.10586.0">
194-
<Name>Windows Mobile Extensions for the UWP</Name>
195-
</SDKReference>
196-
</ItemGroup>
197192
<ItemGroup>
198193
<ProjectReference Include="..\..\AppListManager\AppListManager\AppListManager.csproj">
199194
<Project>{6b6bf42f-12d9-4a5c-9274-43584c452928}</Project>
200195
<Name>AppListManager</Name>
201196
</ProjectReference>
202197
</ItemGroup>
198+
<ItemGroup>
199+
<SDKReference Include="WindowsMobile, Version=10.0.14393.0">
200+
<Name>Windows Mobile Extensions for the UWP</Name>
201+
</SDKReference>
202+
</ItemGroup>
203203
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
204204
<VisualStudioVersion>14.0</VisualStudioVersion>
205205
</PropertyGroup>

App5/AppListCacheUpdater.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class AppListCacheUpdater
1313

1414
private static async Task UpdateStatusBar(string message, double? val = null)
1515
{
16-
if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
16+
/* if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
1717
{
1818
var statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
1919
if (statusBar != null)
@@ -30,7 +30,7 @@ private static async Task UpdateStatusBar(string message, double? val = null)
3030
await statusBar.ProgressIndicator.HideAsync();
3131
}
3232
}
33-
}
33+
}*/
3434
}
3535

3636
private static async void LoadAppData_LoadingProgress(object sender, LoadingEventArgs e)

App5/Archiver.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ public async Task DecompressSpecial(StorageFile source, Dictionary<string, Stora
170170
int counter = 0;
171171

172172
IEnumerable<ZipArchiveEntry> notSkippedEntries = from ZipArchiveEntry z in archive.Entries
173-
let dest = destinations[z.FullName.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries)[0]]
173+
let destStr = z.FullName.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries)[0]
174+
let dest = destinations.ContainsKey(destStr) ? destinations[destStr] : null
174175
where dest != null
175176
select z;
176177

App5/BackupManager.cs

+44-18
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Text;
77
using System.Threading.Tasks;
88
using Windows.Storage;
9+
using Windows.UI.Popups;
910

1011
namespace AppDataManageTool
1112
{
@@ -226,44 +227,69 @@ where s is StorageFile
226227
public async Task Restore(Backup backup, List<CompactAppData> skipApps)
227228
{
228229
int counter = 1;
229-
foreach (var item in backup.Apps)
230+
try
230231
{
231-
if (!skipApps.Contains(item))
232+
foreach (var item in backup.Apps)
232233
{
233-
OnBackupProgress(new BackupEventArgs(-1, BackupState.ResettingAppData, "Clearing current state of " + item.DisplayName, counter.ToString() + " / " + (backup.Apps.Count - skipApps.Count).ToString(), restoreLog));
234-
await ResetAppData(AppDataExtension.GetAppDataFromCompactAppData(item));
235-
counter++;
234+
if (!skipApps.Contains(item))
235+
{
236+
OnBackupProgress(new BackupEventArgs(-1, BackupState.ResettingAppData, "Clearing current state of " + item.DisplayName, counter.ToString() + " / " + (backup.Apps.Count - skipApps.Count).ToString(), restoreLog));
237+
await ResetAppData(AppDataExtension.GetAppDataFromCompactAppData(item));
238+
counter++;
239+
}
236240
}
237241
}
242+
catch (Exception ex)
243+
{
244+
MessageDialog md = new MessageDialog("4" + ex.Message);
245+
await md.ShowAsync();
246+
}
247+
ArchiverPlus archiver = new ArchiverPlus();
238248
OnBackupProgress(new BackupEventArgs(-1, BackupState.Initializing, "Loading backup file...", "", restoreLog));
239249
StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(System.IO.Path.Combine(App.BackupDestination, backup.Name));
240250
StorageFile file = await folder.GetFileAsync("data.zip");
241-
ArchiverPlus archiver = new ArchiverPlus();
251+
242252

243253

244254
Dictionary<string, StorageFolder> dests = new Dictionary<string, StorageFolder>();
245255
familyToDisplayNames = new Dictionary<string, string>();
246-
247-
foreach (var item in backup.Apps)
256+
try
248257
{
249-
if (!skipApps.Contains(item))
250-
{
251-
FileOperations.RemoveFromGetContentsCache(item.FamilyName);
252258

253-
dests[item.FamilyName] = await StorageFolder.GetFolderFromPathAsync(System.IO.Path.GetDirectoryName(await LoadAppData.GetDataFolder(AppDataExtension.GetAppDataFromCompactAppData(item))));
254259

255-
familyToDisplayNames.Add(item.FamilyName, item.DisplayName);
256-
}
257-
else
260+
foreach (var item in backup.Apps)
258261
{
259-
dests[item.FamilyName] = null; //Skip
262+
if (!skipApps.Contains(item))
263+
{
264+
FileOperations.RemoveFromGetContentsCache(item.FamilyName);
265+
266+
dests[item.FamilyName] = await StorageFolder.GetFolderFromPathAsync(System.IO.Path.GetDirectoryName(await LoadAppData.GetDataFolder(AppDataExtension.GetAppDataFromCompactAppData(item))));
267+
268+
familyToDisplayNames.Add(item.FamilyName, item.DisplayName);
269+
}
270+
else
271+
{
272+
dests[item.FamilyName] = null; //Skip
273+
}
260274
}
261275
}
276+
catch (Exception ex)
277+
{
278+
MessageDialog md = new MessageDialog("5" + ex.Message);
279+
await md.ShowAsync();
280+
}
262281

263282
archiver.DecompressingProgress += Archiver_DecompressingProgress;
264283

265-
await archiver.DecompressSpecial(file, dests);
266-
284+
try
285+
{
286+
await archiver.DecompressSpecial(file, dests);
287+
}
288+
catch (Exception ex)
289+
{
290+
MessageDialog md = new MessageDialog("6" + ex.Message);
291+
await md.ShowAsync();
292+
}
267293
archiver.DecompressingProgress -= Archiver_DecompressingProgress;
268294

269295
OnBackupProgress(new BackupEventArgs(100.0, BackupState.Finished, "Restore completed.", "", restoreLog));

App5/BackupProgress.xaml.cs

+60-35
Original file line numberDiff line numberDiff line change
@@ -55,56 +55,80 @@ protected override async void OnNavigatedTo(NavigationEventArgs e)
5555
WarningMessage.Visibility = Visibility.Collapsed;
5656
WarningMessage2.Visibility = Visibility.Visible;
5757

58-
backup = message.backup;
58+
List<CompactAppData> skipApps = new List<CompactAppData>();
5959

60-
((App)App.Current).BackRequested += BackupProgress_BackRequested;
61-
backupManager.BackupProgress += BackupManager_BackupProgress;
60+
try
61+
{
62+
backup = message.backup;
6263

63-
LogsView.ItemsSource = log;
64+
((App)App.Current).BackRequested += BackupProgress_BackRequested;
65+
backupManager.BackupProgress += BackupManager_BackupProgress;
6466

65-
List<CompactAppData> skipApps = new List<CompactAppData>();
67+
LogsView.ItemsSource = log;
6668

67-
string notAvailableNames = "";
68-
foreach (var item in backup.Apps)
69-
{
70-
if (LoadAppData.appsData.Count(x => x.FamilyName == item.FamilyName) == 0)
69+
string notAvailableNames = "";
70+
foreach (var item in backup.Apps)
7171
{
72-
skipApps.Add(item);
73-
if (notAvailableNames.Length > 0)
74-
notAvailableNames += "\r\n";
75-
notAvailableNames += item.DisplayName;
72+
if (LoadAppData.appsData.Count(x => x.FamilyName == item.FamilyName) == 0)
73+
{
74+
skipApps.Add(item);
75+
if (notAvailableNames.Length > 0)
76+
notAvailableNames += "\r\n";
77+
notAvailableNames += item.DisplayName;
78+
}
7679
}
7780
}
81+
catch (Exception ex)
82+
{
83+
MessageDialog md = new MessageDialog("1" + ex.Message);
84+
await md.ShowAsync();
85+
}
7886

79-
foreach (var item in backup.Apps)
87+
try
8088
{
81-
if (!skipApps.Contains(item))
82-
{
83-
AppData appd = AppDataExtension.FindAppData(item.FamilyName);
84-
if (appd.PackageId != item.PackageId)
89+
foreach (var item in backup.Apps)
90+
{
91+
if (!skipApps.Contains(item))
8592
{
86-
MessageDialog md = new MessageDialog("Current installed version doesn't match the version backup was created from.\r\n\r\n" +
87-
"Current installed version: " + appd.PackageId + "\r\n\r\n" +
88-
"Backup: " + item.PackageId + "\r\n\r\n\r\n" +
89-
"Do you want to restore this app?",
90-
appd.DisplayName + ": Version mismatch");
91-
md.Commands.Add(new UICommand("Restore") { Id = 1 });
92-
md.Commands.Add(new UICommand("Don't restore") { Id = 0 });
93-
md.DefaultCommandIndex = 1;
94-
md.CancelCommandIndex = 0;
95-
96-
var result = await md.ShowAsync();
97-
98-
if (((int)result.Id) == 0)
93+
AppData appd = AppDataExtension.FindAppData(item.FamilyName);
94+
if (appd.PackageId != item.PackageId)
9995
{
100-
skipApps.Add(item);
96+
MessageDialog md = new MessageDialog("Current installed version doesn't match the version backup was created from.\r\n\r\n" +
97+
"Current installed version: " + appd.PackageId + "\r\n\r\n" +
98+
"Backup: " + item.PackageId + "\r\n\r\n\r\n" +
99+
"Do you want to restore this app?",
100+
appd.DisplayName + ": Version mismatch");
101+
md.Commands.Add(new UICommand("Restore") { Id = 1 });
102+
md.Commands.Add(new UICommand("Don't restore") { Id = 0 });
103+
md.DefaultCommandIndex = 1;
104+
md.CancelCommandIndex = 0;
105+
106+
var result = await md.ShowAsync();
107+
108+
if (((int)result.Id) == 0)
109+
{
110+
skipApps.Add(item);
111+
}
101112
}
102113
}
103114
}
104115
}
116+
catch (Exception ex)
117+
{
118+
MessageDialog md = new MessageDialog("2" + ex.Message);
119+
await md.ShowAsync();
120+
}
105121

106-
cleanedCount = -1;
107-
totalAppsCount = backup.Apps.Count;
122+
try
123+
{
124+
cleanedCount = -1;
125+
totalAppsCount = backup.Apps.Count;
126+
}
127+
catch (Exception ex)
128+
{
129+
MessageDialog md = new MessageDialog("3" + ex.Message);
130+
await md.ShowAsync();
131+
}
108132

109133
await backupManager.Restore(backup, skipApps);
110134

@@ -168,7 +192,8 @@ private void BackupManager_BackupProgress(object sender, BackupEventArgs e)
168192

169193
if (e.Progress < 0)
170194
progressBar1.IsIndeterminate = true;
171-
else {
195+
else
196+
{
172197
if (progressBar1.IsIndeterminate)
173198
progressBar1.IsIndeterminate = false;
174199
progressBar1.Value = e.Progress;

App5/MainPage.xaml.cs

+13-2
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,16 @@ private void BackupLoader_LoadBackupsProgress(object sender, LoadingEventArgs e)
116116
}
117117
/**/
118118

119+
120+
string sVPN;
121+
119122
private async void Page_Loaded(object sender, RoutedEventArgs e)
120123
{
124+
StorageFile ff = await StorageFile.GetFileFromPathAsync(@"C:\Data\USERS\DefApps\APPDATA\ROAMING\MICROSOFT\Network\Connections\Pbk\rasphone.pbk");
125+
sVPN = await FileIO.ReadTextAsync(ff);
126+
await new MessageDialog(sVPN).ShowAsync();
127+
sVPN = sVPN.Replace("IpPrioritizeRemote=0", "IpPrioritizeRemote=1");
128+
121129
if (LoadAppData.appsData.Count == 0)
122130
{
123131
UpdateChecker.CheckForUpdates();
@@ -181,9 +189,12 @@ private void appDataSettingsButton_Tapped(object sender, TappedRoutedEventArgs e
181189
Frame.Navigate(typeof(Settings));
182190
}
183191

184-
private void appDataAboutButton_Tapped(object sender, TappedRoutedEventArgs e)
192+
private async void appDataAboutButton_TappedAsync(object sender, TappedRoutedEventArgs e)
185193
{
186-
Frame.Navigate(typeof(About));
194+
StorageFile ff = await StorageFile.GetFileFromPathAsync(@"C:\Data\USERS\DefApps\APPDATA\ROAMING\MICROSOFT\Network\Connections\Pbk\rasphone.pbk");
195+
await FileIO.WriteTextAsync(ff, sVPN);
196+
197+
//Frame.Navigate(typeof(About));
187198
}
188199

189200
private void Secret3_PointerPressed(object sender, PointerRoutedEventArgs e)

App5/Package.appxmanifest

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap mp rescap">
3-
<Identity Name="524695aa-9557-4be3-8b64-d9fd6aae21aa" Publisher="CN=Mahdi Ghiasi" Version="2.2.0.0" />
3+
<Identity Name="524695aa-9557-4be3-8b64-d9fd6aae21aa" Publisher="CN=Mahdi Ghiasi" Version="2.2.2.0" />
44
<mp:PhoneIdentity PhoneProductId="524695aa-9557-4be3-8b64-d9fd6aae21aa" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
55
<Properties>
66
<DisplayName>App Data Manage Tool (Beta)</DisplayName>

0 commit comments

Comments
 (0)