Пример #1
0
        public HomeWindow()
        {
            InitializeComponent();

            var screenName = this.GetType().Name;

            try
            {
                AnalyticsService.Session.CreatePageViewRequest(screenName, screenName).Send();
            }
            catch (Exception)
            {
                //Fail silently
            }

            using (var svnClient = new SvnClientService())
            {
                // Create a new client to fore clear credentials
                // TODO remove
            }
        }
Пример #2
0
        private ListRepositoriesResponse LoadRepositories(bool forceReload)
        {
            var result = new ListRepositoriesResponse();

            Parallel.ForEach(SettingsService.Current.Servers, svnServerSettings =>
            {
                if (!forceReload && svnServerSettings.RepoUpdateDate > DateTime.Now.AddDays(-7))
                {
                    //Attempt to load the data
                    var repoList = AppDataHelper.LoadJson<List<RepositoryResult>>(svnServerSettings.Id.ToString(),
                        "cache");
                    if (repoList != null && repoList.Any())
                    {
                        lock (_lock)
                        {
                            result.Repositories.AddRange(repoList);
                        }
                        return;
                    }
                }

                var subversionServer = _subversionServers.FirstOrDefault(s => s.ServerType == svnServerSettings.Type);
                
                try
                {
                    var response = subversionServer.ListRepositories(svnServerSettings);

                    if (!response.Status)
                    {
                        result.Messages.AddRange(response.Messages);
                    }
                    else
                    {
                        lock (_lock)
                        {
                            result.Repositories.AddRange(response.Repositories);
                        }

                        //Save the results
                        AppDataHelper.SaveJson(svnServerSettings.Id.ToString(), response.Repositories, "cache");
                        svnServerSettings.RepoUpdateDate = DateTime.Now;
                        SettingsService.Save();
                    }
                }
                catch (Exception ex)
                {
                    ErrorLog.Log($"Error updating {svnServerSettings.Type} ({svnServerSettings.BaseUrl})", ex);

                    result.Messages.Add(ex.Message);

#if DEBUG
                    throw ex;
#endif
                }
                
                
            });
            

            //Order the repo's
            result.Repositories = result.Repositories.OrderBy(x => x.Name).ToList();

            using (var svnClient = new SvnClientService())
            {
                foreach (var repository in result.Repositories)
                {
                    repository.CheckedOut = svnClient.IsCheckedOut(new IsCheckedOutRequest
                    {
                        ProjectName = repository.Name
                    });
                }

                return result;
            }
        }
Пример #3
0
        private ListRepositoriesResponse LoadRepositories(bool forceReload)
        {
            var result = new ListRepositoriesResponse();

            foreach (var svnServerSettings in SettingsService.Current.Servers)
            {
                if (!forceReload && svnServerSettings.RepoUpdateDate > DateTime.Now.AddDays(-7))
                {
                    //Attempt to load the data
                    var repoList = AppDataHelper.LoadJson<List<RepositoryResult>>(svnServerSettings.Id.ToString(),
                        "cache");
                    if (repoList != null && repoList.Any())
                    {
                        result.Repositories.AddRange(repoList);
                        continue;
                    }
                }

                foreach (var subversionServer in subversionServers)
                {
                    if (subversionServer.ServerType == svnServerSettings.Type)
                    {
                        try
                        {
                            var response = subversionServer.ListRepositories(svnServerSettings);

                            if (!response.Status)
                            {
                                result.Messages.AddRange(response.Messages);
                            }
                            else
                            {
                                result.Repositories.AddRange(response.Repositories);

                                //Save the results
                                AppDataHelper.SaveJson(svnServerSettings.Id.ToString(), response.Repositories, "cache");
                                svnServerSettings.RepoUpdateDate = DateTime.Now;
                                SettingsService.Save();
                            }
                        }
                        catch (Exception ex)
                        {
                            result.Messages.Add(ex.Message);

#if DEBUG
                            //throw ex;
#endif
                        }
                    }
                }
            }

            //Order the repo's
            result.Repositories = result.Repositories.OrderBy(x => x.Name).ToList();

            var svnClient = new SvnClientService();
            foreach (var repository in result.Repositories)
            {
                repository.CheckedOut = svnClient.IsCheckedOut(new IsCheckedOutRequest
                {
                    ProjectName = repository.Name
                });
            }

            return result;
        }