Esempio n. 1
0
 private Task GetBuildsIndex()
 {
     return(Task.Run(() =>
     {
         try
         {
             var downloadEntry = new DownloadEntry(
                 Settings.GetRemoteBuildsIndexUrl(),
                 Settings.GetRemoteBuildsIndexUrl().Replace(Settings.RemoteUrl, string.Empty),
                 null,
                 null,
                 null
                 );
             BuildsIndex = Downloader.DownloadJson <BuildsIndex>(downloadEntry, Serializer);
         }
         catch (Exception e)
         {
             BuildsIndex = new BuildsIndex()
             {
                 AvailableBuilds = new List <IVersion>()
             };
             Logger.Warning("No builds index found. Problem: {BuildsIndexException}", e);
         }
     }));
 }
Esempio n. 2
0
        private void UpdateBuildIndex()
        {
            BuildsIndex index;

            if (FilesManager.Exists(_context.Settings.GetBuildsIndexPath()))
            {
                index = _context.Serializer.Deserialize <BuildsIndex>(File.ReadAllText(_context.Settings.GetBuildsIndexPath()));
            }
            else
            {
                index = new BuildsIndex();
                index.AvailableBuilds = new List <IVersion>();
            }

            index.AvailableBuilds.Add(_context.BuildVersion);

            File.WriteAllText(_context.Settings.GetBuildsIndexPath(), _context.Serializer.Serialize(index));
        }
Esempio n. 3
0
        private Task GetBuildDefinition()
        {
            return(Task.Run(() =>
            {
                if (CurrentVersion == null)
                {
                    CurrentVersion = BuildsIndex.GetLast();
                }

                if (CurrentVersion == null)
                {
                    Logger.Error(null, "Cannot retrieve any new version...");
                    throw new NoAvailableBuildsException();
                }

                if (!BuildsIndex.Contains(CurrentVersion) && CurrentVersion.IsLower(BuildsIndex.GetFirst()))
                {
                    CurrentVersion = BuildsIndex.GetLast();
                    SetRepairNeeded();
                }

                try
                {
                    var downloadEntry = new DownloadEntry(
                        Settings.GetRemoteBuildDefinitionUrl(CurrentVersion),
                        Settings.GetRemoteBuildDefinitionUrl(CurrentVersion).Replace(Settings.RemoteUrl, string.Empty),
                        null,
                        null,
                        null
                        );
                    CurrentBuildDefinition =
                        Downloader.DownloadJson <BuildDefinition>(downloadEntry, Serializer);
                    Logger.Info("Retrieved definition for {CurrentVersion}", CurrentVersion);
                }
                catch
                {
                    CurrentBuildDefinition = new BuildDefinition()
                    {
                        Entries = new BuildDefinitionEntry[0]
                    };
                    Logger.Warning("Cannot retrieve the build definition for {CurrentVersion}", CurrentVersion);
                }
            }));
        }