Ejemplo n.º 1
0
        public async void Init()
        {
            if (!IsInternetAvailable())
            {
                return;
            }

            Messenger.Publish(new LoadingStatusMessage(this)
            {
                IsLoadingIndicatorActive = true
            });

            Contributors = await _userDataService.GetContributorsForRepository(GithubXamarinRepositoryId,
                                                                               GithubClientService.GetAuthorizedGithubClient());

            License = (await _fileDataService.GetFile(GithubXamarinRepositoryId, "LICENSE",
                                                      GithubClientService.GetAuthorizedGithubClient())).Content;

            //https://developer.github.com/v3/rate_limit/
            var rateLimits = await GithubClientService.GetAuthorizedGithubClient().Miscellaneous.GetRateLimits();

            CoreLimit       = $"Limit:  {rateLimits.Resources.Core.Limit}";
            CoreRemaining   = $"Remaining: {rateLimits.Resources.Core.Remaining}";
            CoreReset       = $"Reset:  {rateLimits.Resources.Core.Reset}";
            SearchLimit     = $"Limit:  {rateLimits.Resources.Search.Limit}";
            SearchRemaining = $"Remaining:  {rateLimits.Resources.Search.Remaining}";
            SearchReset     = $"Reset:  {rateLimits.Resources.Search.Reset}";

            Messenger.Publish(new LoadingStatusMessage(this)
            {
                IsLoadingIndicatorActive = false
            });
        }
Ejemplo n.º 2
0
        public async Task Refresh()
        {
            Messenger.Publish(new LoadingStatusMessage(this)
            {
                IsLoadingIndicatorActive = true
            });

            if (!IsInternetAvailable())
            {
                await DialogService.ShowDialogASync("", "Internet is not available");

                return;
            }
            if (string.IsNullOrWhiteSpace(_userName))
            {
                Messenger.Publish(new AppBarHeaderChangeMessage(this)
                {
                    HeaderTitle = $"Your Gists"
                });
                Gists = await _gistDataService.GetAllGistsForCurrentUser(GithubClientService.GetAuthorizedGithubClient());
            }
            else
            {
                Gists = await _gistDataService.GetAllPublicGistsForUser(_userName, GithubClientService.GetAuthorizedGithubClient());

                Messenger.Publish(new AppBarHeaderChangeMessage(this)
                {
                    HeaderTitle = $"Gists For {Gists[0].Owner.Name}"
                });
            }
            Messenger.Publish(new LoadingStatusMessage(this)
            {
                IsLoadingIndicatorActive = false
            });
        }
Ejemplo n.º 3
0
        private async Task Refresh()
        {
            if (!IsInternetAvailable())
            {
                return;
            }
            Messenger.Publish(new LoadingStatusMessage(this)
            {
                IsLoadingIndicatorActive = true
            });

            try
            {
                Repository = await _repoDataService.GetRepository(_repositoryId,
                                                                  GithubClientService.GetAuthorizedGithubClient());

                Messenger.Publish(new AppBarHeaderChangeMessage(this)
                {
                    HeaderTitle = $"{Repository.FullName}"
                });
            }
            catch (HttpRequestException)
            {
                await DialogService.ShowDialogASync("The internet seems to be working but the code threw an HttpRequestException. Try again.", "Hmm, this is weird!");
            }
            await CheckRepositoryStats();

            Messenger.Publish(new LoadingStatusMessage(this)
            {
                IsLoadingIndicatorActive = false
            });
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Checks for repository stats which are not directly available in
        /// </summary>
        /// <returns></returns>
        private async Task CheckRepositoryStats()
        {
            //Check if repository is starred
            var starredClient = new StarredClient(new ApiConnection(GithubClientService.GetAuthorizedGithubClient().Connection));

            IsRepositoryStarred = await starredClient.CheckStarred(Repository.Owner.Login.ToString(), Repository.Name);
        }
Ejemplo n.º 5
0
        private async Task Search(string searchTerm, SearchTypeEnumeration searchType)
        {
            if (!IsInternetAvailable())
            {
                await DialogService.ShowDialogASync("Or is it?", "Internet is not available");

                return;
            }
            switch (searchType)
            {
            case SearchTypeEnumeration.Issues:
                Issues = await _issueDataService.SearchIssues(searchTerm,
                                                              GithubClientService.GetAuthorizedGithubClient());

                break;

            case SearchTypeEnumeration.Repositories:
                Repositories = await _repoDataService.SearchRepositories(searchTerm,
                                                                         GithubClientService.GetAuthorizedGithubClient());

                break;

            case SearchTypeEnumeration.Users:
                Users = await _userDataService.SearchUsers(searchTerm,
                                                           GithubClientService.GetAuthorizedGithubClient());

                break;

            case SearchTypeEnumeration.Code:
                break;

            default:
                break;
            }
        }
        private async Task MarkAllNotificationsAsRead()
        {
            var notificationsClient = new NotificationsClient(new ApiConnection(GithubClientService.GetAuthorizedGithubClient().Connection));

            await notificationsClient.MarkAsRead();

            await Refresh();
        }
Ejemplo n.º 7
0
        public async Task Refresh()
        {
            if (!IsInternetAvailable())
            {
                await DialogService.ShowDialogASync("Use this moment to look up from your screen and enjoy life.", "No Internet Connection!");

                return;
            }

            Messenger.Publish(new LoadingStatusMessage(this)
            {
                IsLoadingIndicatorActive = true
            });

            try
            {
                if (_repositoryId.HasValue)
                {
                    Events = await _eventDataService.GetAllEventsOfRepository(_repositoryId.Value,
                                                                              GithubClientService.GetAuthorizedGithubClient());

                    Messenger.Publish(new AppBarHeaderChangeMessage(this)
                    {
                        HeaderTitle = $"Events for {Events[0]?.Repo.FullName}"
                    });
                }
                else if (!string.IsNullOrWhiteSpace(_userLogin))
                {
                    Messenger.Publish(new AppBarHeaderChangeMessage(this)
                    {
                        HeaderTitle = $"Public Events for {_userLogin}"
                    });
                    Events = await _eventDataService.GetAllPublicEventsForUser(_userLogin,
                                                                               GithubClientService.GetAuthorizedGithubClient());
                }
                else
                {
                    Messenger.Publish(new AppBarHeaderChangeMessage(this)
                    {
                        HeaderTitle = "Your Events"
                    });
                    Events =
                        await _eventDataService.GetAllEventsForCurrentUser(
                            GithubClientService.GetAuthorizedGithubClient());
                }
            }
            catch (HttpRequestException)
            {
                await DialogService.ShowDialogASync("The internet seems to be working but the code threw an HttpRequestException. Try again.", "Hmm, this is weird!");
            }

            Messenger.Publish(new LoadingStatusMessage(this)
            {
                IsLoadingIndicatorActive = false
            });
        }
        private async Task MarkNotificationAsRead(Notification notification)
        {
            if (MarkedNotification == null)
            {
                return;
            }
            var notificationsClient = new NotificationsClient(new ApiConnection(GithubClientService.GetAuthorizedGithubClient().Connection));

            await notificationsClient.MarkAsRead(int.Parse(MarkedNotification.Id));
        }
Ejemplo n.º 9
0
        private async Task Refresh()
        {
            if (!IsInternetAvailable() || string.IsNullOrWhiteSpace(_gistId))
            {
                return;
            }
            Gist = await _gistDataService.GetGist(_gistId, GithubClientService.GetAuthorizedGithubClient());

            Messenger.Publish(new AppBarHeaderChangeMessage(this)
            {
                HeaderTitle = $"Files in {Gist.Description}"
            });
        }
Ejemplo n.º 10
0
 private async Task StarOrUnstarRepository()
 {
     if (IsRepositoryStarred)
     {
         await _repoDataService.UnStarRepository(Repository.Owner.Login, Repository.Name,
                                                 GithubClientService.GetAuthorizedGithubClient());
     }
     else
     {
         await _repoDataService.StarRepository(Repository.Owner.Login, Repository.Name,
                                               GithubClientService.GetAuthorizedGithubClient());
     }
     await Refresh();
 }
Ejemplo n.º 11
0
        public override async void Start()
        {
            if (await IsInternetAvailable())
            {
                await Task.Delay(500);

                var privacyPolicy = await _fileDataService.GetFile(73414278, "PRIVACY_POLICY.md",
                                                                   GithubClientService.GetUnAuthorizedGithubClient());

                await DialogService.ShowMarkdownDialogAsync(privacyPolicy.Content, "Privacy Policy");
            }

            while (!CrossSecureStorage.Current.HasKey("OAuthToken"))
            {
                await Task.Delay(5000);
            }
            ShowViewModel <EventsViewModel>();
        }
Ejemplo n.º 12
0
        public async Task Refresh()
        {
            if (!IsInternetAvailable())
            {
                await DialogService.ShowDialogASync("Or is it?", "Internet is not available");

                return;
            }
            Messenger.Publish(new LoadingStatusMessage(this)
            {
                IsLoadingIndicatorActive = true
            });
            try
            {
                if (_repositoryId.HasValue)
                {
                    Issues = await _issueDataService.GetAllIssuesForRepository(_repositoryId.Value,
                                                                               GithubClientService.GetAuthorizedGithubClient());

                    Messenger.Publish(new AppBarHeaderChangeMessage(this)
                    {
                        HeaderTitle = $"Issues for {Issues[0]?.Repository.FullName}"
                    });
                }
                else
                {
                    Messenger.Publish(new AppBarHeaderChangeMessage(this)
                    {
                        HeaderTitle = "Your Issues"
                    });
                    Issues =
                        await _issueDataService.GetAllIssuesForCurrentUser(
                            GithubClientService.GetAuthorizedGithubClient());
                }
            }
            catch (HttpRequestException)
            {
                await DialogService.ShowDialogASync("The internet seems to be working but the code threw an HttpRequestException. Try again.", "Hmm, this is weird!");
            }
            Messenger.Publish(new LoadingStatusMessage(this)
            {
                IsLoadingIndicatorActive = false
            });
        }
Ejemplo n.º 13
0
        public async Task Refresh()
        {
            if (!IsInternetAvailable())
            {
                await DialogService.ShowDialogASync("What is better ? To be born good or to overcome your evil nature through great effort ?", "No Internet Connection!");

                return;
            }
            Messenger.Publish(new LoadingStatusMessage(this)
            {
                IsLoadingIndicatorActive = true
            });
            try
            {
                if (_repositoryId.HasValue)
                {
                    Messenger.Publish(new AppBarHeaderChangeMessage(this)
                    {
                        HeaderTitle = "Notifications"
                    });
                    Notifications = await _notificationDataService.GetAllNotificationsForRepository(_repositoryId.Value,
                                                                                                    GithubClientService.GetAuthorizedGithubClient());
                }
                else
                {
                    Messenger.Publish(new AppBarHeaderChangeMessage(this)
                    {
                        HeaderTitle = "Your Notifications"
                    });
                    Notifications =
                        await _notificationDataService.GetAllNotificationsForCurrentUser(
                            GithubClientService.GetAuthorizedGithubClient());
                }
            }
            catch (HttpRequestException)
            {
                await DialogService.ShowDialogASync("The internet seems to be working but the code threw an HttpRequestException. Try again.", "Hmm, this is weird!");
            }
            Messenger.Publish(new LoadingStatusMessage(this)
            {
                IsLoadingIndicatorActive = false
            });
        }
Ejemplo n.º 14
0
        public async Task Refresh()
        {
            if (!IsInternetAvailable())
            {
                await DialogService.ShowDialogASync("What is better ? To be born good or to overcome your evil nature through great effort ?", "No Internet Connection!");

                return;
            }
            Messenger.Publish(new LoadingStatusMessage(this)
            {
                IsLoadingIndicatorActive = true
            });
            try
            {
                if (string.IsNullOrWhiteSpace(_userLogin))
                {
                    Messenger.Publish(new AppBarHeaderChangeMessage(this)
                    {
                        HeaderTitle = $"Your Repositories"
                    });
                    Repositories =
                        await _repoDataService.GetAllRepositoriesForCurrentUser(
                            GithubClientService.GetAuthorizedGithubClient());
                }
                else
                {
                    Messenger.Publish(new AppBarHeaderChangeMessage(this)
                    {
                        HeaderTitle = $"Repositories of {_userLogin}"
                    });
                    Repositories = await _repoDataService.GetAllRepositoriesForUser(_userLogin,
                                                                                    GithubClientService.GetAuthorizedGithubClient());
                }
            }
            catch (HttpRequestException)
            {
                await DialogService.ShowDialogASync("The internet seems to be working but the code threw an HttpRequestException. Try again.", "Hmm, this is weird!");
            }
            Messenger.Publish(new LoadingStatusMessage(this)
            {
                IsLoadingIndicatorActive = false
            });
        }
Ejemplo n.º 15
0
        public override async void Start()
        {
            //HACK: Delay is added so that the MainViewModel can completely load first before showing other ViewModels.
            //Without the delay the ViewModels were not loading inside of the Frame in MainViewModel
            await Task.Delay(1000);

            if (CrossSecureStorage.Current.HasKey("OAuthToken"))
            {
                ShowViewModel <EventsViewModel>();
            }
            else
            {
                ShowViewModel <LoginViewModel>();
            }

            if (CrossSecureStorage.Current.HasKey("OAuthToken") && IsInternetAvailable())
            {
                User = await GithubClientService.GetAuthorizedGithubClient().User.Current();
            }
        }
Ejemplo n.º 16
0
        private async Task Refresh()
        {
            if (!IsInternetAvailable())
            {
                return;
            }

            switch (_fileType)
            {
            case FileTypeEnumeration.Readme:

                var readme = await _fileDataService.GetReadme(_repositoryId,
                                                              GithubClientService.GetAuthorizedGithubClient());

                FileContent = readme.Content;
                Messenger.Publish(new AppBarHeaderChangeMessage(this)
                {
                    HeaderTitle = $"{readme.Name}"
                });

                break;

            case FileTypeEnumeration.Encoded:

                break;

            case FileTypeEnumeration.Nonencoded:
                Messenger.Publish(new AppBarHeaderChangeMessage(this)
                {
                    HeaderTitle = $"{_filePath}"
                });
                FileContent = (await _fileDataService.GetFile(_repositoryId, _filePath,
                                                              GithubClientService.GetAuthorizedGithubClient())).Content;

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 17
0
        private async Task Refresh()
        {
            if (!IsInternetAvailable())
            {
                await DialogService.ShowDialogASync("What is better ? To be born good or to overcome your evil nature through great effort ?", "No Internet Connection!");

                return;
            }
            Messenger.Publish(new LoadingStatusMessage(this)
            {
                IsLoadingIndicatorActive = true
            });

            try
            {
                if (string.IsNullOrWhiteSpace(_owner) || string.IsNullOrWhiteSpace(_repoName))
                {
                    Issue = await _issueDataService.GetIssueForRepository(_repositoryId, _issueNumber,
                                                                          GithubClientService.GetAuthorizedGithubClient());
                }
                else
                {
                    Issue = await _issueDataService.GetIssueForRepository(_owner, _repoName, _issueNumber,
                                                                          GithubClientService.GetAuthorizedGithubClient());
                }
                Messenger.Publish(new AppBarHeaderChangeMessage(this)
                {
                    HeaderTitle = $"{Issue.Title}"
                });
            }
            catch (HttpRequestException)
            {
                await DialogService.ShowDialogASync("The internet seems to be working but the code threw an HttpRequestException. Try again.", "Hmm, this is weird!");
            }
            Messenger.Publish(new LoadingStatusMessage(this)
            {
                IsLoadingIndicatorActive = false
            });
        }
Ejemplo n.º 18
0
        private ActionManager GetActionManager()
        {
            IGithubClientService githubClientService = new GithubClientService();
            IProcessService      processService      = new ProcessService();
            IGitClientService    gitClientService    = new GitClientService(processService);
            IDotnetService       dotnetService       = new DotnetService(processService);
            IDDService           dDService           = new DDService(processService);

            var actionManager = new ActionManager(_cryptoService);

            actionManager.RegisterAction(new InitializeProject(
                                             _fileService,
                                             githubClientService,
                                             gitClientService,
                                             dotnetService,
                                             dDService));
            actionManager.RegisterAction(new AddDomain());
            actionManager.RegisterAction(new DeleteDomain());
            actionManager.RegisterAction(new DeleteSchema());
            actionManager.RegisterAction(new AddSchema());
            actionManager.RegisterAction(new ModifySchema());
            actionManager.RegisterAction(new AddSchemaProperty());
            actionManager.RegisterAction(new AddAzurePipelinesSetting(_cryptoService));
            actionManager.RegisterAction(new DeleteAzurePipelinesSetting());
            actionManager.RegisterAction(new AddGithubSetting(_cryptoService));
            actionManager.RegisterAction(new DeleteGithubSetting());
            actionManager.RegisterAction(new AddSchemaIntersection());
            actionManager.RegisterAction(new AddUseCase());
            actionManager.RegisterAction(new DeleteUseCase());
            //actionManager.RegisterAction(new AddSchemaToDomain());
            //actionManager.RegisterAction(new AddDomainInMicroService(_fileService, dotnetService));
            //actionManager.RegisterAction(new AddMicroService(_fileService, githubClientService, gitClientService, dotnetService));
            actionManager.RegisterAction(new AddEnvironment());
            actionManager.RegisterAction(new DeleteEnvironment());
            actionManager.RegisterAction(new AddSetting());
            actionManager.RegisterAction(new AddSchemaView());

            return(actionManager);
        }
Ejemplo n.º 19
0
 private async Task Refresh()
 {
     if (!IsInternetAvailable())
     {
         return;
     }
     try
     {
         Messenger.Publish(new LoadingStatusMessage(this)
         {
             IsLoadingIndicatorActive = true
         });
         if (string.IsNullOrWhiteSpace(_userLogin))
         {
             Messenger.Publish(new AppBarHeaderChangeMessage(this)
             {
                 HeaderTitle = "Your Profile"
             });
             User = await _userDataService.GetCurrentUser(GithubClientService.GetAuthorizedGithubClient());
         }
         else
         {
             Messenger.Publish(new AppBarHeaderChangeMessage(this)
             {
                 HeaderTitle = $"Profile of {_userLogin}"
             });
             User = await _userDataService.GetUser(_userLogin, GithubClientService.GetAuthorizedGithubClient());
         }
     }
     catch (HttpRequestException)
     {
         await DialogService.ShowDialogASync("The internet seems to be working but the code threw an HttpRequestException. Try again.", "Hmm, this is weird!");
     }
     Messenger.Publish(new LoadingStatusMessage(this)
     {
         IsLoadingIndicatorActive = false
     });
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Create a fork of the current repository
        /// </summary>
        private void ForkRepository()
        {
            var forkClient = new RepositoryForksClient(new ApiConnection(GithubClientService.GetAuthorizedGithubClient().Connection));

            forkClient.Create(Repository.Id, new NewRepositoryFork());
        }
Ejemplo n.º 21
0
        public async Task Refresh()
        {
            if (!IsInternetAvailable())
            {
                await DialogService.ShowDialogASync("So for the time being, here is an interesting fact: If each dead person became a ghost, there’d be more than 100 billion of them haunting us all. Creepy, but cool!", "No Internet Connection!");

                return;
            }
            Messenger.Publish(new LoadingStatusMessage(this)
            {
                IsLoadingIndicatorActive = true
            });
            try
            {
                if (_usersType != null)
                {
                    switch (_usersType)
                    {
                    case UsersTypeEnumeration.Stargazers:
                        Users = await _userDataService.GetStargazersForRepository(_repositoryId,
                                                                                  GithubClientService.GetAuthorizedGithubClient());

                        Messenger.Publish(new AppBarHeaderChangeMessage(this)
                        {
                            HeaderTitle = $"Stargazers"
                        });
                        break;

                    case UsersTypeEnumeration.Collaborators:
                        Messenger.Publish(new AppBarHeaderChangeMessage(this)
                        {
                            HeaderTitle = "Collaborators"
                        });
                        Users = await _userDataService.GetCollaboratorsForRepository(_repositoryId,
                                                                                     GithubClientService.GetAuthorizedGithubClient());

                        break;

                    default:
                        Users = await _userDataService.GetCollaboratorsForRepository(_repositoryId,
                                                                                     GithubClientService.GetAuthorizedGithubClient());

                        break;
                    }
                }
                else
                {
                    Messenger.Publish(new AppBarHeaderChangeMessage(this)
                    {
                        HeaderTitle = "Collaborators"
                    });
                    Users = await _userDataService.GetCollaboratorsForRepository(_repositoryId,
                                                                                 GithubClientService.GetAuthorizedGithubClient());
                }
            }
            catch (HttpRequestException)
            {
                await DialogService.ShowDialogASync("The internet seems to be working but the code threw an HttpRequestException. Try again.", "Hmm, this is weird!");
            }
            Messenger.Publish(new LoadingStatusMessage(this)
            {
                IsLoadingIndicatorActive = false
            });
        }