Ejemplo n.º 1
0
        private async Task <IList <HistoryAction> > GetActions(bool lockFolder)
        {
            IList <HistoryAction> actions = new List <HistoryAction>();

            StorageFolder folder = await GetFolder(BackgroundActionsFolder);

            if (lockFolder)
            {
                await CreateEventMarker(folder);
            }
            StorageFolder parentFolder = await folder.GetParentAsync();

            IReadOnlyList <StorageFolder> folders = await parentFolder.GetFoldersAsync();

            foreach (StorageFolder storageFolder in folders)
            {
                try
                {
                    IReadOnlyList <StorageFile> files = await storageFolder.GetFilesAsync();

                    StorageFile first = null;
                    foreach (var f in files)
                    {
                        if (f.Name == ActionsFileName)
                        {
                            first = f;
                            break;
                        }
                    }
                    if (first != null)
                    {
                        List <HistoryAction> fileActions = FileStorageHelper.ActionsFromStrings(await FileIO.ReadLinesAsync(first));
                        if (fileActions != null)
                        {
                            foreach (HistoryAction historyAction in fileActions)
                            {
                                actions.Add(historyAction);
                            }
                        }
                    }
                }
                catch (SEHException)
                {
                }
                catch (FileNotFoundException)
                {
                }
            }
            if (ForegroundHistoryActionWriter != null)
            {
                List <HistoryAction> foreGroundfileActions = FileStorageHelper.ActionsFromStrings(await ForegroundHistoryActionWriter.ReadLines());
                if (foreGroundfileActions != null)
                {
                    foreach (HistoryAction historyAction in foreGroundfileActions)
                    {
                        actions.Add(historyAction);
                    }
                }
            }

            return(actions);
        }