// Constructor
        public CubesEnvironmentInfo(string rootFolder)
        {
            var assembly = Assembly.GetExecutingAssembly();
            var fvi      = FileVersionInfo.GetVersionInfo(assembly.Location);

            RootFolder = rootFolder;
            Hostname   = Dns.GetHostName();
            LiveSince  = DateTime.Now;
            Version    = fvi.FileVersion;
#if DEBUG
            IsDebug = true;
#else
            IsDebug = false;
#endif
            FullVersion = Assembly
                          .GetExecutingAssembly()
                          .GetCustomAttribute <AssemblyInformationalVersionAttribute>()
                          .InformationalVersion;
            BuildVersion = FullVersion;
            if (BuildVersion.Contains("-"))
            {
                GitHash      = BuildVersion.Substring(BuildVersion.IndexOf('-') + 1);
                BuildVersion = BuildVersion.Substring(0, BuildVersion.IndexOf('-'));
            }

            using var buildDate = assembly.GetManifestResourceStream("Cubes.Core.BuildDate.txt");
            using var reader    = new StreamReader(buildDate);
            string value = reader.ReadToEnd().Trim();
            BuildDateTime = DateTime.ParseExact(value, "yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture);
        }
Beispiel #2
0
        private bool IsOldVersion()
        {
            if (string.IsNullOrEmpty(BuildVersion))
            {
                return(false);
            }
            if (BuildVersion.Contains("2018"))
            {
                return(true);
            }
            string year     = "2019";
            int    maxMonth = 7;
            int    maxDay   = 23;

            if (BuildVersion.Contains(year))
            {
                try
                {
                    int start = BuildVersion.IndexOf(year);
                    int month = int.Parse(BuildVersion.Substring(start + year.Length, 2));
                    int day   = int.Parse(BuildVersion.Substring(start + year.Length + 2, 2));
                    if (month < maxMonth)
                    {
                        return(true);
                    }
                    else if (month == maxMonth && day <= maxDay)
                    {
                        return(true);
                    }
                }
                catch (System.Exception err)
                {
                    Debug.LogError("Build version check failed: " + err.ToString());
                }
            }
            return(false);
        }