예제 #1
0
        private void LogNewVersionInfo(UpdateChannel updateChannel, SemanticVersion latestVersion, string toolPath)
        {
            var toolPathArg = IsGlobalTool(toolPath) ? "-g" : $"--tool-path {toolPath}";

            Logger.LogWarning($"ABP CLI has a newer {updateChannel.ToString().ToLowerInvariant()} version {latestVersion}, please update to get the latest features and fixes.");
            Logger.LogWarning(string.Empty);
            Logger.LogWarning("Update Command: ");

            // Update command doesn't support prerelease versions https://github.com/dotnet/sdk/issues/2551 workaround is to uninstall & install
            switch (updateChannel)
            {
            case UpdateChannel.Stable:
                Logger.LogWarning($"dotnet tool update {toolPathArg} Volo.Abp.Cli");
                break;

            case UpdateChannel.Prerelease:
                Logger.LogWarning($"dotnet tool update {toolPathArg} Volo.Abp.Cli --version {latestVersion}");
                break;

            case UpdateChannel.Nightly:
            case UpdateChannel.Development:
                Logger.LogWarning($"dotnet tool uninstall {toolPathArg} Volo.Abp.Cli");
                Logger.LogWarning($"dotnet tool install {toolPathArg} Volo.Abp.Cli --add-source https://www.myget.org/F/abp-nightly/api/v3/index.json --version {latestVersion}");
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(updateChannel), updateChannel, null);
            }

            Logger.LogWarning(string.Empty);
        }
예제 #2
0
        /// <summary>
        /// Fetches the latest version of Virtual Paradise.
        /// </summary>
        /// <returns>Gets the version string of the latest stable Virtual Paradise.</returns>
        public async Task <SemVer> FetchLatest(UpdateChannel channel = UpdateChannel.Stable)
        {
            switch (channel)
            {
            case UpdateChannel.PreRelease:
                SyndicationItem item = this.GetLatestVirtualParadisePost(out Match match);

                if (!(item is null || match is null))
                {
                    // Return the version
                    return(new SemVer(match.Value));
                }

                // Return the latest stable instead
                return(await this.FetchLatest());

            case UpdateChannel.Stable:
            default:
                using (WebClient client = new WebClient())
                {
                    client.DownloadProgressChanged += this.WebClientProgressChanged;
                    this.webClient = client;

                    Uri    uri           = new Uri(VirtualParadise.Uri, @"version.txt");
                    string versionString = await client.DownloadStringTaskAsync(uri);

                    return(new SemVer(versionString));
                }
            }
        }
예제 #3
0
        private void LogNewVersionInfo(UpdateChannel updateChannel, SemanticVersion latestVersion, string toolPath)
        {
            Logger.LogWarning(
                $"ABP CLI has a newer {updateChannel.ToString().ToLowerInvariant()} version {latestVersion}, please update to get the latest features and fixes.");
            Logger.LogWarning("");
            Logger.LogWarning("Update Command: ");

            // Update command doesn't support prerelease versions https://github.com/dotnet/sdk/issues/2551 workaround is to uninstall & install
            switch (updateChannel)
            {
            case UpdateChannel.Stable:
                Logger.LogWarning($"    dotnet tool update --tool-path {toolPath} Volo.Abp.Cli");
                break;

            case UpdateChannel.Prerelease:
                Logger.LogWarning($"    dotnet tool uninstall --tool-path {toolPath} Volo.Abp.Cli");
                Logger.LogWarning($"    dotnet tool install --tool-path {toolPath} --version {latestVersion} Volo.Abp.Cli");
                break;

            case UpdateChannel.Nightly:
                Logger.LogWarning($"    dotnet tool uninstall --tool-path {toolPath} Volo.Abp.Cli");
                Logger.LogWarning(
                    $"    dotnet tool install --tool-path {toolPath} --add-source https://www.myget.org/F/abp-nightly/api/v3/index.json --version {latestVersion} Volo.Abp.Cli");
                break;
            }

            Logger.LogWarning("");
        }
예제 #4
0
        public async Task LogsInformationOnCall()
        {
            const int  CHANNEL   = 0;
            const bool DIRECTION = true;
            const bool ON        = true;

            var request = new UpdateChannel(CHANNEL, DIRECTION, ON);

            var loggerMock    = new Mock <ILogger>();
            var pinSetterMock = new Mock <IPinSetter>();

            var hardwareOptions = new HardwareOptions
            {
                Channels = new List <Channel>
                {
                    new Channel()
                }
            };

            var handler = new UpdateChannelHandler(loggerMock.Object, pinSetterMock.Object, hardwareOptions);
            await handler.Handle(request, CancellationToken.None);

            loggerMock.Verify(mock =>
                              mock.Information(It.IsAny <string>(), CHANNEL, DIRECTION, ON),
                              Times.Once
                              );
        }
예제 #5
0
        public static bool CheckForUpdate(UpdateChannel channel, DateTime LastUpdate, string url)
        {
            Manifest mn = GetChannelManifest(channel, url);

            return mn.LastUpdate > LastUpdate;           

        }
예제 #6
0
        private async ValueTask RenameChannel(ChannelViewModel existing, FFmpegProfileViewModel ffmpegProfile)
        {
            int newFFmpegProfileId = string.IsNullOrWhiteSpace(FFmpegProfileName)
                ? existing.FfmpegProfileId
                : ffmpegProfile.Id;

            if (existing.Name != Name || existing.FfmpegProfileId != newFFmpegProfileId ||
                existing.StreamingMode != StreamingMode)
            {
                var updateChannel = new UpdateChannel(
                    existing.Id,
                    Name,
                    existing.Number,
                    newFFmpegProfileId,
                    existing.Logo,
                    StreamingMode);

                await _channelsApi.ApiChannelsPatchAsync(updateChannel);
            }

            _logger.LogInformation(
                "Successfully synchronized channel {ChannelNumber} - {ChannelName}",
                Number,
                Name);
        }
예제 #7
0
        public async Task UsesPinSetterToSetOnePinToDirection()
        {
            const int  CHANNEL   = 0;
            const bool DIRECTION = true;
            const bool ON        = true;

            const int ENABLE = 20;
            const int ONE    = 30;
            const int TWO    = 40;

            var request = new UpdateChannel(CHANNEL, DIRECTION, ON);

            var loggerMock    = new Mock <ILogger>();
            var pinSetterMock = new Mock <IPinSetter>();

            var hardwareOptions = new HardwareOptions
            {
                Channels = new List <Channel>
                {
                    new Channel {
                        Enable = ENABLE, One = ONE, Two = TWO
                    }
                }
            };

            var handler = new UpdateChannelHandler(loggerMock.Object, pinSetterMock.Object, hardwareOptions);
            await handler.Handle(request, CancellationToken.None);

            pinSetterMock.Verify(mock =>
                                 mock.SetPinAsync(ONE, DIRECTION),
                                 Times.Once
                                 );
        }
예제 #8
0
 private void Start()
 {
     _updateChannels = new UpdateChannel[System.Enum.GetValues(typeof(UpdateChannelType)).Length];
     for (int i = 0; i < _updateChannels.Length; ++i)
     {
         _updateChannels[i] = new UpdateChannel();
     }
 }
예제 #9
0
        public static IEnumerable <Build> GetBuildsForChannel(UpdateChannel channel, string url)
        {
            Manifest mn = GetChannelManifest(channel, url);

            Build[] Builds = JsonConvert.DeserializeObject <Build[]>(QuickDownloadJson(mn.BuildListURL));

            return(Builds);
        }
예제 #10
0
        public static Manifest GetChannelManifest(UpdateChannel channel, string url)
        {
            Manifest[] Manifests = JsonConvert.DeserializeObject <Manifest[]>(QuickDownloadJson(url));

            Manifest chn = Manifests.FirstOrDefault(x => x.Channel == channel.ToString());

            return(chn);
        }
예제 #11
0
        public static Manifest GetChannelManifest(UpdateChannel channel, string url)
        {
            Manifest[] Manifests = JsonConvert.DeserializeObject<Manifest[]>(QuickDownloadJson(url));

            Manifest chn = Manifests.FirstOrDefault(x => x.Channel == channel.ToString());

            return chn;
        }
예제 #12
0
        private void OnMessage(object sender, MessageEventArgs eventArgs)
        {
            if (!eventArgs.IsText)
            {
                return;
            }

            var container = JsonConvert.DeserializeObject <Container>(eventArgs.Data);

            switch (container.Identifier)
            {
            case DispatchType.Login:
                if (((JObject)container.Payload).ToObject(typeof(LoginResponseContainer)) is LoginResponseContainer loginResponse)
                {
                    var eventLog = new EventLogMessage()
                    {
                        IsSuccessfully = true,
                        SenderName     = _login,
                        Text           = "Login",
                        Time           = DateTime.Now,
                        Type           = DispatchType.Login
                    };
                    if (loginResponse.Content.Result == ResponseType.Failure)
                    {
                        eventLog.IsSuccessfully = false;
                        eventLog.Text           = loginResponse.Content.Reason;
                    }

                    LoginEvent?.Invoke(
                        this,
                        new LoginEventArgs(
                            _login,
                            eventLog.IsSuccessfully,
                            eventLog,
                            loginResponse.General,
                            loginResponse.OnlineList,
                            loginResponse.OfflineList,
                            loginResponse.EventLogMessageList));
                }

                break;

            case DispatchType.Message:
                MessageReceived?.Invoke(this, MessageSorter.GetSortedMessage((JObject)container.Payload));
                break;

            case DispatchType.Channel:
                UpdateChannel?.Invoke(this, MessageSorter.GetSortedChannel((JObject)container.Payload));
                break;

            case DispatchType.EventLog:
                LogEvent?.Invoke(this, MessageSorter.GetSortedEventMessage((JObject)container.Payload));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #13
0
        public static IEnumerable<Build> GetBuildsForChannel(UpdateChannel channel, string url)
        {
            Manifest mn = GetChannelManifest(channel, url);

            Build[] Builds = JsonConvert.DeserializeObject<Build[]>(QuickDownloadJson(mn.BuildListURL));

            return Builds;

        }
예제 #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DownloadForm"/> class.
        /// </summary>
        /// <param name="args">Command-line arguments to pass to Virtual Paradise.</param>
        /// <param name="virtualParadise">The instance of <see cref="VirtualParadise"/> to use.</param>
        /// <param name="channel">The update channel to use.</param>
        private DownloadForm(string[] args, VirtualParadise virtualParadise, UpdateChannel channel)
        {
            this.InitializeComponent();

            this.commandLineArgs = args;
            this.virtualParadise = virtualParadise;
            this.updateChannel   = channel;
            this.updater         = new Updater(virtualParadise);
        }
예제 #15
0
    public async Task <Either <BaseError, ChannelViewModel> > Handle(
        UpdateChannel request,
        CancellationToken cancellationToken)
    {
        await using TvContext dbContext = await _dbContextFactory.CreateDbContextAsync(cancellationToken);

        Validation <BaseError, Channel> validation = await Validate(dbContext, request);

        return(await LanguageExtensions.Apply(validation, c => ApplyUpdateRequest(dbContext, c, request)));
    }
예제 #16
0
 /// <summary>
 /// Creates an instance of the <see cref="Package"/> class
 /// when provided with the Plex user's registry key and the user's token.
 /// </summary>
 /// <param name="localAppDataFolder">
 /// The local application data folder for Plex.
 /// </param>
 /// <param name="updateChannel">
 /// The update channel used to update Plex.
 /// </param>
 /// <param name="token">
 /// The Plex user's token.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// An argument provided is <c>null</c>.
 /// </exception>
 public Package(
     string updatesFolder,
     UpdateChannel updateChannel,
     string token)
 {
     _updatesFolder =
         updatesFolder ?? throw new ArgumentNullException(nameof(updatesFolder));
     _updateChannel = updateChannel;
     _token         = token ?? throw new ArgumentNullException(nameof(token));
 }
예제 #17
0
        private void UpdateCustomChannels()
        {
            var channels = new UpdateChannel[]
            {
                new UpdateChannel("Custom", UpdateUrl)
                {
                    IsPrerelease = true
                }
            };

            _updateService.Initialize(channels, channels[0], true);
        }
예제 #18
0
파일: Updater.cs 프로젝트: ermau/Gablarski
		public static async Task<Update> CheckAsync (UpdateChannel channel, CancellationToken cancelToken)
		{
			if (!Enum.IsDefined (typeof (UpdateChannel), channel))
				throw new ArgumentException ("channel is an invalid value for UpdateChannel", "channel");

			string versionUrl = "http://files.gablarski.org/" + channel.ToString().ToLower() + "_version.txt";

			HttpClient client = new HttpClient();
			HttpResponseMessage response = await client.GetAsync (versionUrl, cancelToken).ConfigureAwait (false);
			string content = await response.Content.ReadAsStringAsync().ConfigureAwait (false);

			return new Update (new Version (content), "http://files.gablarski.org/" + channel.ToString().ToLower() + ".exe");
		}
예제 #19
0
        private void HandlePacket(byte[] packet)
        {
            string serializedMessages = GetStringPacket(packet);
            var    container          = JsonConvert.DeserializeObject <Container>(serializedMessages);

            switch (container.Identifier)
            {
            case DispatchType.Login:
                if (((JObject)container.Payload).ToObject(typeof(LoginResponseContainer)) is LoginResponseContainer loginResponse)
                {
                    var eventLog = new EventLogMessage
                    {
                        IsSuccessfully = loginResponse.Content.Result == ResponseType.Ok,
                        SenderName     = _login,
                        Text           = loginResponse.Content.Reason,
                        Time           = DateTime.Now,
                        Type           = DispatchType.Login
                    };
                    _isLogin = eventLog.IsSuccessfully;
                    LoginEvent?.Invoke(
                        this,
                        new LoginEventArgs(
                            _login,
                            eventLog.IsSuccessfully,
                            eventLog,
                            loginResponse.General,
                            loginResponse.OnlineList,
                            loginResponse.OfflineList,
                            loginResponse.EventLogMessageList));
                }

                break;

            case DispatchType.Message:
                MessageReceived?.Invoke(this, MessageSorter.GetSortedMessage((JObject)container.Payload));
                break;

            case DispatchType.Channel:
                UpdateChannel?.Invoke(this, MessageSorter.GetSortedChannel((JObject)container.Payload));
                break;

            case DispatchType.EventLog:
                LogEvent?.Invoke(this, MessageSorter.GetSortedEventMessage((JObject)container.Payload));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        private List <UpdateChannel> GenerateReleaseHistory(string xmlFilePath)
        {
            var updateChannels = new List <UpdateChannel>();

            var xmlDoc = new XmlDocument();

            xmlDoc.Load(xmlFilePath);

            var xmlUpdateChannels = xmlDoc.SelectNodes("/ReleaseHistory/UpdateChannel");

            foreach (XmlNode xmlUpdateChannel in xmlUpdateChannels)
            {
                var name = xmlUpdateChannel.GetAttributeValue("Name");

                var updateChannel = new UpdateChannel
                {
                    Name    = name,
                    Updates = new List <Update>()
                };

                var updates = xmlUpdateChannel.SelectNodes("./Update");
                foreach (XmlNode xmlUpdate in updates)
                {
                    var latest        = Convert.ToBoolean(xmlUpdate.GetAttributeValue("Latest"));
                    var version       = xmlUpdate.GetAttributeValue("Version");
                    var legacyVersion = xmlUpdate.GetAttributeValue("LegacyVersion");
                    var build         = xmlUpdate.GetAttributeValue("Build");
                    var pubTime       = xmlUpdate.GetAttributeValue("PubTime");

                    var publishTime = XmlConvert.ToDateTime(pubTime, XmlDateTimeSerializationMode.Utc);

                    var update = new Update()
                    {
                        Build         = build,
                        Latest        = latest,
                        LegacyVersion = legacyVersion,
                        Version       = version,
                        PublishTime   = publishTime
                    };

                    updateChannel.Updates.Add(update);
                }

                updateChannels.Add(updateChannel);
            }

            return(updateChannels);
        }
예제 #21
0
파일: Updater.cs 프로젝트: ermau/Gablarski
        public static async Task <Update> CheckAsync(UpdateChannel channel, CancellationToken cancelToken)
        {
            if (!Enum.IsDefined(typeof(UpdateChannel), channel))
            {
                throw new ArgumentException("channel is an invalid value for UpdateChannel", "channel");
            }

            string versionUrl = "http://files.gablarski.org/" + channel.ToString().ToLower() + "_version.txt";

            HttpClient          client   = new HttpClient();
            HttpResponseMessage response = await client.GetAsync(versionUrl, cancelToken).ConfigureAwait(false);

            string content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            return(new Update(new Version(content), "http://files.gablarski.org/" + channel.ToString().ToLower() + ".exe"));
        }
예제 #22
0
 private void Update()
 {
     for (int i = 0; i < _updateChannels.Length; ++i)
     {
         UpdateChannel channel = _updateChannels[i];
         if (channel.UpdateIndex < channel.UpdateList.Count)
         {
             channel.UpdateList[channel.UpdateIndex].LazyUpdate();
             ++channel.UpdateIndex;
         }
         else
         {
             channel.UpdateIndex = 0;
         }
     }
 }
예제 #23
0
        private async Task <SemanticVersion> GetLatestVersion(UpdateChannel updateChannel)
        {
            switch (updateChannel)
            {
            case UpdateChannel.Stable:
                return(await NuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Cli"));

            case UpdateChannel.Prerelease:
                return(await NuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Cli", includeReleaseCandidates : true));

            case UpdateChannel.Nightly:
                return(await NuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Cli", includeNightly : true));

            default:
                return(default);
            }
        }
예제 #24
0
        private void RegenerateUpdateChannels(ModelViewHierarchyUpdater hierarchy, List <AnimationBlender.Channel> channels)
        {
            var newUpdateChannels = new List <UpdateChannel>();

            // TODO: Temporary implementation due to lack of time before first release.
            foreach (var channel in channels)
            {
                string nodeName = channel.NodeName;
                if (nodeName == null)
                {
                    continue;
                }

                var updateChannel = new UpdateChannel();
                updateChannel.Index = -1;

                var hierarchyNodes = hierarchy.Nodes;
                for (int i = 0; i < hierarchyNodes.Length; ++i)
                {
                    var node = hierarchyNodes[i];
                    if (node.Name == nodeName)
                    {
                        updateChannel.Index = i;
                        break;
                    }
                }

                if (updateChannel.Index == -1)
                {
                    // TODO: Warning?
                    //throw new InvalidOperationException(string.Format("Could not find matching node in animation for {0}", nodeName));
                    continue;
                }

                updateChannel.Offset = channel.Offset;
                updateChannel.Type   = channel.Type;

                newUpdateChannels.Add(updateChannel);
            }

            updateChannels = newUpdateChannels.ToArray();
        }
예제 #25
0
        public void Store()
        {
            UpdateService.AutoCheckForUpdates = !radioNever.Active;
            UpdateService.UpdateSpanValue     = 1;

            if (radioHour.Active)
            {
                UpdateService.UpdateSpanUnit = UpdateSpanUnit.Hour;
            }
            else if (radioDay.Active)
            {
                UpdateService.UpdateSpanUnit = UpdateSpanUnit.Day;
            }
            else if (radioMonth.Active)
            {
                UpdateService.UpdateSpanUnit = UpdateSpanUnit.Month;
            }

            if (checkUnstable.Active)
            {
                if (radioBeta.Active)
                {
                    UpdateService.UpdateChannel = UpdateChannel.FromUpdateLevel(UpdateLevel.Beta);
                }
                else if (radioAlpha.Active)
                {
                    UpdateService.UpdateChannel = UpdateChannel.FromUpdateLevel(UpdateLevel.Alpha);
                }
                else if (radioTest.Active)
                {
                    UpdateService.UpdateChannel = UpdateChannel.FromUpdateLevel(UpdateLevel.Test);
                }
            }
            else
            {
                UpdateService.UpdateChannel = UpdateChannel.FromUpdateLevel(UpdateLevel.Stable);
            }
        }
예제 #26
0
        /// <summary>
        /// Builds a <see cref="DownloadForm"/>.
        /// </summary>
        /// <param name="args">Command-line arguments to pass to Virtual Paradise.</param>
        /// <returns>Returns a new instance of <see cref="DownloadForm"/>.</returns>
        public static async Task <DownloadForm> Build(string[] args)
        {
            UpdaterConfig config = await UpdaterConfig.Load();

            await config.LoadDefaults();

            UpdateChannel channel = (int)config["stable_only", 1] == 1
                ? UpdateChannel.Stable
                : UpdateChannel.PreRelease;

            try
            {
                VirtualParadise virtualParadise = VirtualParadise.GetCurrent();
                if (channel == UpdateChannel.PreRelease)
                {
                    VirtualParadise preVirtualParadise = VirtualParadise.GetPreRelease();
                    if (!(preVirtualParadise is null))
                    {
                        virtualParadise = preVirtualParadise;
                    }
                }

                return(new DownloadForm(args, virtualParadise, channel));
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format(Resources.VpObjectBuildError, ex.Message),
                                Resources.Error,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);

                // There's nothing we can do from here
                Environment.Exit(0);
                return(null);
            }
        }
예제 #27
0
    private async Task <ChannelViewModel> ApplyUpdateRequest(TvContext dbContext, Channel c, UpdateChannel update)
    {
        c.Name                          = update.Name;
        c.Number                        = update.Number;
        c.Group                         = update.Group;
        c.Categories                    = update.Categories;
        c.FFmpegProfileId               = update.FFmpegProfileId;
        c.PreferredAudioLanguageCode    = update.PreferredAudioLanguageCode;
        c.PreferredSubtitleLanguageCode = update.PreferredSubtitleLanguageCode;
        c.SubtitleMode                  = update.SubtitleMode;
        c.Artwork ??= new List <Artwork>();

        if (!string.IsNullOrWhiteSpace(update.Logo))
        {
            Option <Artwork> maybeLogo =
                Optional(c.Artwork).Flatten().FirstOrDefault(a => a.ArtworkKind == ArtworkKind.Logo);

            maybeLogo.Match(
                artwork =>
            {
                artwork.Path        = update.Logo;
                artwork.DateUpdated = DateTime.UtcNow;
            },
                () =>
            {
                var artwork = new Artwork
                {
                    Path        = update.Logo,
                    DateAdded   = DateTime.UtcNow,
                    DateUpdated = DateTime.UtcNow,
                    ArtworkKind = ArtworkKind.Logo
                };
                c.Artwork.Add(artwork);
            });
        }

        c.StreamingMode    = update.StreamingMode;
        c.WatermarkId      = update.WatermarkId;
        c.FallbackFillerId = update.FallbackFillerId;
        await dbContext.SaveChangesAsync();

        if (c.SubtitleMode != ChannelSubtitleMode.None)
        {
            Option <Playout> maybePlayout = await dbContext.Playouts
                                            .SelectOneAsync(p => p.ChannelId, p => p.ChannelId == c.Id);

            foreach (Playout playout in maybePlayout)
            {
                await _ffmpegWorkerChannel.WriteAsync(new ExtractEmbeddedSubtitles(playout.Id));
            }
        }

        return(ProjectToViewModel(c));
    }
        public async Task <List <UpdateChannel> > DownloadVersionsFromWebSite()
        {
            var lstReturn       = new List <UpdateChannel>();
            var ccUpdateChannel = new UpdateChannel()
            {
                Name    = "Current",
                Updates = new List <Update>()
            };
            var dcUpdateChannel = new UpdateChannel()
            {
                Name    = "Deferred",
                Updates = new List <Update>()
            };
            var frdcUpdateChannel = new UpdateChannel()
            {
                Name    = "FirstReleaseDeferred",
                Updates = new List <Update>()
            };

            lstReturn.Add(ccUpdateChannel);
            lstReturn.Add(dcUpdateChannel);
            lstReturn.Add(frdcUpdateChannel);

            var webClient = new WebClient();
            var page      = await webClient.DownloadStringTaskAsync(OfficeVersionWebSite);

            var doc = new HtmlAgilityPack.HtmlDocument();

            doc.LoadHtml(page);

            var tables = doc.DocumentNode.SelectNodes("//table").ToList();

            foreach (var table in tables)
            {
                var headerRow = table
                                .Descendants("tr")
                                .Where(tr => tr.Elements("th").Count() > 1)
                                .Select(tr => tr.Elements("th").Select(td => td.InnerText.Trim()).ToList())
                                .FirstOrDefault();
                if (headerRow == null)
                {
                    continue;
                }
                if (headerRow[0].ToLower() != "version")
                {
                    continue;
                }

                var rows = table
                           .Descendants("tr")
                           .Where(tr => tr.Elements("td").Count() > 1)
                           .Select(tr => tr.Elements("td").Select(td => td.InnerText.Trim()).ToList())
                           .ToList();
                if (rows.Count == 0)
                {
                    continue;
                }

                var ccIndex   = 1;
                var frdcIndex = 2;
                var dcIndex   = 3;
                for (var i = 1; i <= 3; i++)
                {
                    var rowHeader = headerRow[i];
                    if (rowHeader.ToLower().Contains("current"))
                    {
                        ccIndex = i;
                    }
                    if (rowHeader.ToLower().Contains("deferred") &&
                        rowHeader.ToLower().Contains("first release"))
                    {
                        frdcIndex = i;
                    }
                    if (rowHeader.ToLower().Contains("deferred") &&
                        !rowHeader.ToLower().Contains("first release"))
                    {
                        dcIndex = i;
                    }
                }

                foreach (var row in rows)
                {
                    var version = row[0];
                    if (!Regex.Match(version, @"\d{4}").Success)
                    {
                        continue;
                    }

                    var currentChannel = row[ccIndex];
                    var ccVersions     = Regex.Matches(currentChannel, @"\d{4}\.\d{4}\s");
                    if (ccVersions.Count == 0)
                    {
                        continue;
                    }

                    var frdc         = row[frdcIndex];
                    var frdcVersions = Regex.Matches(frdc, @"\d{4}\.\d{4}");
                    if (frdcVersions.Count == 0)
                    {
                        continue;
                    }

                    var dc         = row[dcIndex];
                    var dcVersions = Regex.Matches(dc, @"\d{4}\.\d{4}");
                    if (dcVersions.Count == 0)
                    {
                        continue;
                    }

                    foreach (Match build in ccVersions)
                    {
                        ccUpdateChannel?.Updates.Add(new Update()
                        {
                            Build         = build.Value,
                            LegacyVersion = "16.0." + build.Value,
                            Version       = version
                        });
                    }

                    foreach (Match build in dcVersions)
                    {
                        dcUpdateChannel?.Updates.Add(new Update()
                        {
                            Build         = build.Value,
                            LegacyVersion = "16.0." + build.Value,
                            Version       = version
                        });
                    }

                    foreach (Match build in dcVersions)
                    {
                        frdcUpdateChannel?.Updates.Add(new Update()
                        {
                            Build         = build.Value,
                            LegacyVersion = "16.0." + build.Value,
                            Version       = version
                        });
                    }
                }
            }

            return(lstReturn);
        }
예제 #29
0
 private void HandleUpdateChannel(object sender, UpdateChannelEventArgs eventArgs)
 {
     UpdateChannel?.Invoke(sender, eventArgs);
 }
예제 #30
0
        private void RegenerateUpdateChannels(ModelViewHierarchyUpdater hierarchy, List<AnimationBlender.Channel> channels)
        {
            var newUpdateChannels = new List<UpdateChannel>();

            // TODO: Temporary implementation due to lack of time before first release.
            foreach (var channel in channels)
            {
                string nodeName = channel.NodeName;
                if (nodeName == null)
                    continue;

                var updateChannel = new UpdateChannel();
                updateChannel.Index = -1;

                var hierarchyNodes = hierarchy.Nodes;
                for (int i = 0; i < hierarchyNodes.Length; ++i)
                {
                    var node = hierarchyNodes[i];
                    if (node.Name == nodeName)
                    {
                        updateChannel.Index = i;
                        break;
                    }
                }

                if (updateChannel.Index == -1)
                {
                    // TODO: Warning?
                    //throw new InvalidOperationException(string.Format("Could not find matching node in animation for {0}", nodeName));
                    continue;
                }

                updateChannel.Offset = channel.Offset;
                updateChannel.Type = channel.Type;

                newUpdateChannels.Add(updateChannel);
            }

            updateChannels = newUpdateChannels.ToArray();
        }
        internal bool SaveSettings()
        {
            if (!ValidateSettings())
            {
                return(false);
            }

            Sys.Settings.Subscriptions = GetUpdatedSubscriptions();
            Sys.Settings.ExtraFolders  = ExtraFolderList.Distinct().ToList();

            // ensure required folders are always in ExtraFolders list
            if (!Sys.Settings.ExtraFolders.Contains("direct", StringComparer.InvariantCultureIgnoreCase))
            {
                Sys.Settings.ExtraFolders.Add("direct");
            }

            if (!Sys.Settings.ExtraFolders.Contains("music", StringComparer.InvariantCultureIgnoreCase))
            {
                Sys.Settings.ExtraFolders.Add("music");
            }

            if (!Sys.Settings.ExtraFolders.Contains("sfx", StringComparer.InvariantCultureIgnoreCase))
            {
                Sys.Settings.ExtraFolders.Add("sfx");
            }

            if (!Sys.Settings.ExtraFolders.Contains("voice", StringComparer.InvariantCultureIgnoreCase))
            {
                Sys.Settings.ExtraFolders.Add("voice");
            }

            if (!Sys.Settings.ExtraFolders.Contains("ambient", StringComparer.InvariantCultureIgnoreCase))
            {
                Sys.Settings.ExtraFolders.Add("ambient");
            }

            Sys.Settings.FF7Exe            = FF7ExePathInput;
            Sys.Settings.LibraryLocation   = LibraryPathInput;
            Sys.Settings.MovieFolder       = MoviesPathInput;
            Sys.Settings.AaliFolder        = TexturesPathInput;
            Sys.Settings.FFNxUpdateChannel = FFNxUpdateChannel;
            Sys.Settings.UpdateChannel     = UpdateChannel;

            Sys.Settings.Options = GetUpdatedOptions();

            ApplyOptions();

            Directory.CreateDirectory(Sys.Settings.LibraryLocation);

            Sys.Message(new WMessage(ResourceHelper.Get(StringKey.GeneralSettingsHaveBeenUpdated)));

            if (reload && UpdateChannel != Updater.GitHub.Releases.Channel.Locked)
            {
                MessageDialogWindow.Show("You have just changed the release version, just going to update and restart.", "Change of Release Version");
                Sys.Message(new WMessage()
                {
                    Text = "Sarting updater application"
                });
                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.UseShellExecute  = false;
                startInfo.WorkingDirectory = Environment.CurrentDirectory;
                startInfo.FileName         = "updater.exe";
                startInfo.Arguments        = "\"" + System.AppDomain.CurrentDomain.BaseDirectory + "\\\" " + UpdateChannel.ToString();
                Process proc = Process.Start(startInfo);
                IntPtr  hWnd = proc.MainWindowHandle;
                if (hWnd != IntPtr.Zero)
                {
                    SetForegroundWindow(hWnd);
                    ShowWindow(hWnd, int.Parse("9"));
                }
                App.ShutdownApp();
            }

            return(true);
        }
예제 #32
0
파일: Updater.cs 프로젝트: ermau/Gablarski
 public static Task <Update> CheckAsync(UpdateChannel channel)
 {
     return(CheckAsync(channel, CancellationToken.None));
 }
예제 #33
0
 /// <summary>
 /// Checks for a Virtual Paradise update.
 /// </summary>
 /// <param name="channel">The update channel to use.</param>
 /// <returns>Returns <see langword="true"/> if the there is an updated and the user accepted, <see langword="false"/> otherwise.</returns>
 private async Task <Version> CheckForUpdates(UpdateChannel channel)
 {
     return(await this.updater.FetchLatest(channel));
 }
예제 #34
0
        /// <summary>
        /// Fetches the Uri of the latest download from the Virtual Paradise download page.
        /// </summary>
        /// <param name="channel">The update channel to use.</param>
        /// <returns>Returns a <see cref="Uri"/> containing the download link.</returns>
        public async Task <Uri> FetchDownloadLink(UpdateChannel channel = UpdateChannel.Stable)
        {
            IConfiguration   config  = Configuration.Default.WithDefaultLoader();
            IBrowsingContext context = BrowsingContext.New(config);

            switch (channel)
            {
            case UpdateChannel.PreRelease:

                // The RSS feed for the blog does not use <content> as a tag, but instead
                // uses <content:encoded> - as such, we'll have to parse the XML manually
                string rssUri = new Uri(VirtualParadise.Uri, @"edwin/feed").ToString();
                using (XmlReader rssReader = XmlReader.Create(rssUri))
                {
                    XmlDocument xmlDocument = new XmlDocument();
                    xmlDocument.Load(rssReader);

                    XmlNodeList items   = xmlDocument.GetElementsByTagName("item");
                    XmlNode     useNode = null;

                    foreach (XmlNode node in items)
                    {
                        string title = node["title"]?.InnerText ?? "";
                        bool   match = Regex.Match(title, @"Virtual Paradise").Success&&
                                       Regex.Match(title, SemVerRegex).Success;

                        if (match)
                        {
                            useNode = node;
                            break;
                        }
                    }

                    if (useNode is null)
                    {
                        return(null);
                    }

                    using (IDocument document = await context.OpenAsync(req => req.Content(useNode.InnerText)))
                    {
                        const string selector   = @"a:last-child";
                        string       systemArch = Helper.GetMachineArch().ToString();

                        IHtmlCollection <IElement> cells = document.QuerySelectorAll(selector);
                        IElement a =
                            cells.FirstOrDefault(c =>
                                                 Regex.Match(c.GetAttribute("href"),
                                                             $"windows_{Regex.Escape(systemArch)}")
                                                 .Success);

                        string href = a?.GetAttribute("href") ?? "";
                        return(new Uri(href));
                    }
                }

            case UpdateChannel.Stable:
            default:
                Uri downloadPageUri = new Uri(VirtualParadise.Uri, @"Download");

                using (IDocument document = await context.OpenAsync(downloadPageUri.ToString()))
                {
                    const string selector   = @".download a.btn";
                    string       systemArch = Helper.GetMachineArch().ToString();

                    IHtmlCollection <IElement> cells = document.QuerySelectorAll(selector);
                    IElement a =
                        cells.FirstOrDefault(c =>
                                             Regex.Match(c.GetAttribute("href"),
                                                         $"windows_{Regex.Escape(systemArch)}")
                                             .Success);

                    string href = a?.GetAttribute("href") ?? "";
                    return(new Uri(href));
                }
            }
        }
예제 #35
0
 private async Task <Validation <BaseError, Channel> > Validate(TvContext dbContext, UpdateChannel request) =>
 (await ChannelMustExist(dbContext, request), ValidateName(request),
예제 #36
0
파일: Updater.cs 프로젝트: ermau/Gablarski
		public static Task<Update> CheckAsync (UpdateChannel channel)
		{
			return CheckAsync (channel, CancellationToken.None);
		}