Esempio n. 1
0
 private async void StartDeleteDefaultAccount()
 {
     try
     {
         await AccountsManager.Delete(DefaultAccountToDelete.LocalAccountId);
     }
     catch
     {
         // We don't really care if delete fails
     }
 }
 private void btnDelete_ItemClick(object sender, ItemClickEventArgs e)
 {
     try
     {
         if (txtAccLevel.Text == "1")
         {
             MessageBox.Show("You Can't Delete This Account ");
             return;
         }
         DALLayer.Accounts ac = acc.Get(txtAccCode.Text);
         acc.Delete(ac);
         MessageBox.Show("Success");
         AccountTree.Nodes.Remove(node);
         AccountTree_AfterSelect(null, null);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 3
0
        private static async System.Threading.Tasks.Task UpgradeAccount(LoginWin login)
        {
            await Store.LoadData(login);

            AccountWin account = login.Account;

            AccountDataItem accountUWP = new AccountDataItem(login.LocalAccountId)
            {
                AccountId               = login.AccountId,
                AutoLogin               = login.AutoLogin,
                CurrentChangeNumber     = account.CurrentChangeNumber,
                CurrentSemesterId       = account.School.ActiveSemesterIdentifier,
                DeviceId                = login.DeviceId,
                LocalAccountId          = login.LocalAccountId,
                LocalToken              = login.Password,
                PremiumAccountExpiresOn = account.PremiumAccountExpiresOn,
                RememberPassword        = login.RememberPassword,
                RememberUsername        = login.RememberUsername,
                Username                = login.Username,
                WeekOneStartsOn         = account.WeekOneStartsOn,
                Version = account.Version
            };

            // Save account (need to do this so there's a folder for everything else)
            await AccountsManager.Save(accountUWP);

            try
            {
                AccountDataStore dataStoreUWP = await AccountDataStore.Get(login.LocalAccountId);

                // Transfer the Changes
                PartialChanges existingChanges = await account.GetPartialChanges();

                await AccountDataStore.ChangedItems.ImportChangesAsync(login.LocalAccountId, existingChanges.Changes.Keys.ToArray(), existingChanges.Deletes.Keys.ToArray());

                try
                {
                    // Transfer images to upload
                    string[] imagesToUpload = (await account.GetAllImagesToUpload()).ToArray();
                    await dataStoreUWP.AddImagesToUploadAsync(imagesToUpload);

                    // Transfer stored images
                    StorageFolder oldImagesFolder = await login.GetImagesFolder();

                    IFolder newImagesFolderPortable = await PowerPlannerAppDataLibrary.DataLayer.FileHelper.GetOrCreateImagesFolder(login.LocalAccountId);

                    StorageFolder newImagesFolder = await StorageFolder.GetFolderFromPathAsync(newImagesFolderPortable.Path);

                    foreach (StorageFile existingImage in await oldImagesFolder.GetFilesAsync())
                    {
                        await existingImage.MoveAsync(newImagesFolder);
                    }
                }

                catch { }

                // Get all the existing items
                BaseItem[] syncItems = account.GetAllItemsInSendingFormat();

                // Translate them to the universal sync language
                BaseDataItem[] uwpItems = PowerPlannerAppDataLibrary.SyncLayer.Sync.GetSyncItemsAsDataItems(syncItems);

                // And then input those into the new database
                await dataStoreUWP.ImportItemsAsync(uwpItems);
            }

            catch (Exception ex)
            {
                try
                {
                    TelemetryExtension.Current?.TrackException(ex);
                }

                catch { }

                await AccountsManager.Delete(login.LocalAccountId);
            }
        }
        private async void deleteAndFinish()
        {
            await AccountsManager.Delete(Account.LocalAccountId);

            RemoveViewModel();
        }
        private static async System.Threading.Tasks.Task UpgradeAccount(string dir)
        {
            try
            {
                var accountSection = AccountSection.Get(Guid.Parse(dir)).Value;

                // Null means that data deserialization failed for some reason
                if (accountSection == null)
                {
                    return;
                }

                AccountDataItem accountUWP = new AccountDataItem(accountSection.LocalId)
                {
                    AccountId               = accountSection.AccountId,
                    AutoLogin               = accountSection.AutoLogin,
                    CurrentChangeNumber     = accountSection.CurrentChangeNumber,
                    CurrentSemesterId       = accountSection.School.ActiveSemesterIdentifier,
                    DeviceId                = accountSection.DeviceId,
                    LocalToken              = accountSection.Password,
                    PremiumAccountExpiresOn = accountSection.PremiumAccountExpiresOn,
                    RememberPassword        = accountSection.RememberPassword,
                    RememberUsername        = accountSection.RememberUsername,
                    Username                = accountSection.Username,
                    WeekOneStartsOn         = accountSection.WeekOneStartsOn,
                    Version             = accountSection.Version,
                    ImageUploadOption   = ConvertImageUploadOption(accountSection.ImageUploadOption),
                    IsPushDisabled      = !accountSection.IsPushEnabled,
                    NeedsToSyncSettings = accountSection.NeedsToSyncSettings,
                    RemindersDayBefore  = accountSection.RemindersDayBefore,
                    RemindersDayOf      = accountSection.RemindersDayOf
                };

                accountUWP.MainTileSettings.ShowEvents         = accountSection.ShowExamsOnTiles;
                accountUWP.MainTileSettings.ShowTasks          = accountSection.ShowHomeworkOnTiles;
                accountUWP.MainTileSettings.SkipItemsOlderThan = accountSection.IgnoreItemsOlderThan;

                // Save account (need to do this so there's a folder for everything else)
                await AccountsManager.Save(accountUWP);

                try
                {
                    AccountDataStore dataStoreUWP = await AccountDataStore.Get(accountUWP.LocalAccountId);

                    // Transfer the changes
                    await AccountDataStore.ChangedItems.ImportChangesAsync(accountUWP.LocalAccountId, accountSection.PartialChanges.Changes.Keys.ToArray(), accountSection.PartialChanges.Deletes.Keys.ToArray());

                    try
                    {
                        // Transfer images to upload
                        string[] imagesToUpload = accountSection.StoredImagesToUpload.ToArray();
                        await dataStoreUWP.AddImagesToUploadAsync(imagesToUpload);


                        // Transfer stored imagesDataContract
                        IFolder newImagesFolder = await PowerPlannerAppDataLibrary.DataLayer.FileHelper.GetOrCreateImagesFolder(accountUWP.LocalAccountId);


                        foreach (string imageName in accountSection.StoredImagesToUpload)
                        {
                            string path = Files.IMAGE_FILE_NAME(imageName, accountUWP.LocalAccountId);

                            // Try transfering the image
                            try
                            {
                                using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
                                {
                                    using (IsolatedStorageFileStream existingStream = store.OpenFile(path, System.IO.FileMode.Open, System.IO.FileAccess.Read, FileShare.Read))
                                    {
                                        var newFile = await newImagesFolder.CreateFileAsync(imageName, StorageEverywhere.CreationCollisionOption.ReplaceExisting);

                                        using (Stream newStream = await newFile.OpenAsync(StorageEverywhere.FileAccess.ReadAndWrite))
                                        {
                                            existingStream.CopyTo(newStream);
                                        }
                                    }
                                }
                            }

                            catch (Exception ex)
                            {
                                TelemetryExtension.Current?.TrackException(ex);
                            }
                        }
                    }

                    catch { }


                    // Get all the existing items in universal sync language
                    BaseItem[] syncItems = accountSection.GetAllItemsInSendingFormat().ToArray();

                    // Convert them to the UWP data format
                    BaseDataItem[] uwpItems = PowerPlannerAppDataLibrary.SyncLayer.Sync.GetSyncItemsAsDataItems(syncItems);

                    // And then input those into the new database
                    await dataStoreUWP.ImportItemsAsync(uwpItems);
                }

                catch (Exception ex)
                {
                    try
                    {
                        TelemetryExtension.Current?.TrackException(ex);
                    }

                    catch { }

                    await AccountsManager.Delete(accountUWP.LocalAccountId);
                }
            }

            catch (Exception ex)
            {
                TelemetryExtension.Current?.TrackException(ex);
                Debug.WriteLine("Failed upgrading Silverlight account");
            }
        }
 private async void deleteAndFinish(AccountDataItem account)
 {
     await AccountsManager.Delete(account.LocalAccountId);
 }
Esempio n. 7
0
 public ActionResult Delete(int id)
 {
     accsMng.Delete(id);
     return(RedirectToAction("Index"));
 }