コード例 #1
0
        /// <summary>
        ///     Gets the asset with the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns>
        ///     The asset.
        /// </returns>
        public async Task <ApiAsset> GetAsset(string id)
        {
            try
            {
                _log.WriteLine($"Fetching information from the PN API for asset {id}.");
                var url = _website.ResolveUrl("api/assets/" + id + "?include=image,user,resource,dependencies");

                using (var client = _webClientFactory.CreateWebClient())
                    using (var stream = await client.OpenRead(url))
                        using (var reader = new StreamReader(stream))
                        {
                            var data = await reader.ReadToEndAsync();

                            var deserialized = JsonConvert.DeserializeObject <ApiDataContainer <ApiAsset> >(data);

                            return(deserialized.Data);
                        }
            }
            catch (Exception e)
            {
                _log.WriteLine($"Failed to fetch information for asset {id}!", LogLevel.Error);
                _log.WriteException(e);

                return(null);
            }
        }
コード例 #2
0
ファイル: UpdateManager.cs プロジェクト: calintx3/calin
        protected virtual string GetUpdateVersionUrl()
        {
            switch (OperatingSystem.Detect())
            {
            case SupportedOperatingSystem.Windows:
                return(_website.ResolveUrl("update.json", "client"));

            case SupportedOperatingSystem.MacOSX:
                return(_website.ResolveUrl("update-osx.json", "client"));

            case SupportedOperatingSystem.Linux:
                throw new NotImplementedException();

            default:
                throw new Exception("unknown operating system");
            }
        }
コード例 #3
0
        protected override void PopulateViewBoxWithButtons(VBox vBox, IAsset asset)
        {
            var mod = asset as IModAsset;

            var viewOnWebsiteButton = new Button("View on ParkitectNexus")
            {
                Sensitive = !mod.Information.IsDevelopment
            };

            if (!mod.Information.IsDevelopment)
            {
                viewOnWebsiteButton.Clicked +=
                    (sender, args) => { Process.Start(_website.ResolveUrl($"redirect/{mod.Repository}", "client")); }
            }
            ;

            var recompileButton = new Button("Recompile");

            recompileButton.Clicked += (sender, args) =>
            {
                _queueableTaskManager.With(mod).Add <CompileModTask>();
                MainView.SwitchToTab <TasksPageView>();
            };

            var updateButton = new Button("Update")
            {
                Sensitive = !mod.Information.IsDevelopment
            };

            if (!mod.Information.IsDevelopment)
            {
                updateButton.Clicked += (sender, args) =>
                {
                    _queueableTaskManager.With(mod).Add <UpdateModTask>();
                }
            }
            ;

            var utils = new HBox();

            utils.PackStart(recompileButton, true);
            utils.PackStart(updateButton, true);

            vBox.PackStart(viewOnWebsiteButton);
            vBox.PackStart(utils);

            base.PopulateViewBoxWithButtons(vBox, asset);
        }

        #endregion
    }
}
コード例 #4
0
        public void Report(string action, Exception exception)
        {
            if (exception == null)
            {
                return;
            }

            try
            {
                var data = JsonConvert.SerializeObject(Generate(action, _parkitect, exception));

                using (var client = _webClientFactory.CreateWebClient())
                {
                    _log.WriteLine("Crash report is being sent.");
                    client.UploadString(_website.ResolveUrl("report/crash", "client"), data);
                    _log.WriteLine("Crash report was sent.");
                }
            }
            catch
            {
            }
        }