Ejemplo n.º 1
0
 async Task TryLoadVersionInfo()
 {
     try {
         VersionInfo = await GetToolsInfo(VersionInfoFile).ConfigureAwait(false);
     } catch (KeyNotFoundException) {
         VersionInfo = new VersionInfoDto();
     }
 }
Ejemplo n.º 2
0
        public VersionRegistry(Uri uri, IApiLocalObjectCacheManager cacheManager, ISystemInfo systemInfo)
        {
            _cacheManager = cacheManager;
            _systemInfo   = systemInfo;

            _versionInfoUrl  = Tools.Transfer.JoinUri(uri, VersionInfoFile);
            LocalVersionInfo = new VersionInfoDto();
            VersionInfo      = new VersionInfoDto();
        }
Ejemplo n.º 3
0
        public IActionResult CreateNewVersion(VersionInfoDto newVersion)
        {
            if (newVersion != null)
            {
                var created = logicHandler.CreateNewVersion(newVersion);
                return(Ok(created));
            }

            return(BadRequest());
        }
Ejemplo n.º 4
0
        public IActionResult GetVersionInfo()
        {
            var versionInfo = new VersionInfoDto();

            using (var reader = new StreamReader(_streamProvider.GetStream()))
            {
                var version = reader.ReadLine();
                versionInfo.Version = version;
            }
            versionInfo.VersionBase = versionInfo.Version.Substring(0, 4);

            _logger.LogInformation("Finished GetVersionInfo");
            return(Ok(versionInfo));
        }
Ejemplo n.º 5
0
        async Task TryDownloadVersionInfo()
        {
            VersionInfoDto versionInfo;

            try {
                var dl = await _cacheManager.Download(_versionInfoUrl, TimeSpan.FromSeconds(30));

                versionInfo = Encoding.UTF8.GetString(dl).FromJson <VersionInfoDto>();
            } catch (Exception) {
                versionInfo = new VersionInfoDto();
            }
            await Save(VersionInfoFile, versionInfo).ConfigureAwait(false);

            VersionInfo = versionInfo;
        }
Ejemplo n.º 6
0
        public VersionInfo CreateNewVersion(VersionInfoDto newVersion)
        {
            if (newVersion != null)
            {
                return(_VManager.CreateNewVersion(new VersionInfo
                {
                    Creator = newVersion.Creator,
                    VersionNumber = newVersion.VersionNumber,
                    VersionTitle = newVersion.VersionTitle,
                    ReleaseDate = newVersion.ReleaseDate,
                    ReleaseNote = newVersion.ReleaseNote,
                    Status = VersionStatus.unaudited,
                }));
            }

            return(null);
        }
        public static VersionInfoDto GetVersion(Assembly assembly, string environment)
        {
            Assembly thisAssembly          = assembly;
            string   assemblyConfiguration = string.Empty;
            string   sourceCodeVersion     = "(not detected)";

            var configurationAttribute = thisAssembly.GetCustomAttributes(typeof(AssemblyConfigurationAttribute)).OfType <AssemblyConfigurationAttribute>().ToList();

            if (configurationAttribute.Any())
            {
                assemblyConfiguration = configurationAttribute.First().Configuration;
            }

            var informalVersionAttribute = thisAssembly.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute)).OfType <AssemblyInformationalVersionAttribute>().ToList();

            if (informalVersionAttribute.Any())
            {
                var informalVersion = informalVersionAttribute.First().InformationalVersion;

                // This can be slitted into version and commit
                var splitted = informalVersion.Split(new[] { '+' }, 2, StringSplitOptions.RemoveEmptyEntries);

                if (splitted.Length == 2)
                {
                    sourceCodeVersion = splitted[1].Substring(0, 7);
                }
            }

            var assemblyDate = File.GetLastWriteTime(Assembly.GetExecutingAssembly().Location);

            var versionDto = new VersionInfoDto
            {
                ProductVersion        = thisAssembly.GetName().Version.ToString(),
                ApiVersion            = "1.0.4",
                BuildNumber           = thisAssembly.GetName().Version.Revision.ToString(CultureInfo.CurrentCulture),
                BuildDateTime         = string.Format("{0:yyyy-MM-dd HH:mm:ss}", assemblyDate),
                FullVersion           = string.Format("{0}-{1:yyyyMMddHHmmss}-{2}-{3}", thisAssembly.GetName().Version, assemblyDate, sourceCodeVersion, assemblyConfiguration),
                AssemblyConfiguration = assemblyConfiguration,
                Environment           = environment
            };

            return(versionDto);
        }
Ejemplo n.º 8
0
 async Task Save(string file, VersionInfoDto obj)
 {
     await _cacheManager.SetObject(file, obj.ToJson());
 }