BaconographyPortable.Services.Impl.SmartOfflineRedditService.RunPeriodic C# (CSharp) Method

RunPeriodic() public method

public RunPeriodic ( ) : Task
return Task
        public async Task<bool> RunPeriodic()
        {
            try
            {
                if (_settingsService.IsOnline() && (await _userService.GetUser()).Username != null)
                {
                    var actionTpl = await _offlineService.DequeueAction();
                    try
                    {
                        if (actionTpl != null)
                        {
                            switch (actionTpl.Item1)
                            {
                                case "AddComment":
                                    {
                                        await AddComment(actionTpl.Item2["parentId"], actionTpl.Item2["content"]);
                                        break;
                                    }
                                case "EditComment":
                                    {
                                        await EditComment(actionTpl.Item2["thingId"], actionTpl.Item2["text"]);
                                        break;
                                    }
                                case "AddMessage":
                                    {
                                        await AddMessage(actionTpl.Item2["recipient"], actionTpl.Item2["subject"], actionTpl.Item2["message"]);
                                        break;
                                    }
                                case "AddPost":
                                    {
                                        await AddPost(actionTpl.Item2["kind"], actionTpl.Item2["url"], actionTpl.Item2["text"], actionTpl.Item2["subreddit"], actionTpl.Item2["title"]);
                                        break;
                                    }
                                case "EditPost":
                                    {
                                        await EditPost(actionTpl.Item2["text"], actionTpl.Item2["name"]);
                                        break;
                                    }
                                case "AddVote":
                                    {
                                        await AddVote(actionTpl.Item2["thingId"], int.Parse(actionTpl.Item2["direction"]));
                                        break;
                                    }
                                case "AddSubredditSubscription":
                                    {
                                        await AddSubredditSubscription(actionTpl.Item2["subreddit"], bool.Parse(actionTpl.Item2["direction"]));
                                        break;
                                    }
                                case "AddSavedThing":
                                    {
                                        await AddSavedThing(actionTpl.Item2["thingId"]);
                                        break;
                                    }
                                case "AddReportOnThing":
                                    {
                                        await AddReportOnThing(actionTpl.Item2["thingId"]);
                                        break;
                                    }
                                default:
                                    return false;
                            }
                            return true;
                        }
                    }
                    catch (Exception ex)
                    {
                        //fall through to the enqueue
                    }
                    await _offlineService.EnqueueAction(actionTpl.Item1, actionTpl.Item2);
                }
            }
            catch (TaskCanceledException)
            {
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.ToString());
            }
            return false;
        }