Exemple #1
0
        public static void LoadRegistry()
        {
#if !NETCORE
            LoadingRegistryElementsForWindows();
#else
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                LoadingRegistryElementsForWindows();
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                if (!File.Exists(NCInfoFileOnLinux))
                {
                    return;
                }

                LicenseProperties = XMLManager.ReadConfiguration <LicenseProperties>(NCInfoFileOnLinux);

                if (LicenseProperties == null)
                {
                    return;
                }
            }
            else
            {
                throw new NotImplementedException();
            }
#endif
        }
Exemple #2
0
        public static void LoadRegistry()
        {
            if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                LoadingRegistryElementsForWindows();
            }
            else if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                var path = GetRegPathForLinux();

                if (loaded || !File.Exists(path))
                {
                    return;
                }

                LicenseProperties = XMLManager.ReadConfiguration <LicenseProperties>(path);
                return;

                if (LicenseProperties.Product != null)
                {
                    LicenseProperties.Product.ProductName = "NCache";
                }
            }
            else
            {
                throw new NotImplementedException();
            }
            loaded = true;
        }
Exemple #3
0
        private static void LoadingRegistryElementsForWindows()
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            if (LicenseProperties == null)
            {
                LicenseProperties = new LicenseProperties();
            }
            if (LicenseProperties.Product == null)
            {
                LicenseProperties.Product = new Product();
            }
            if (LicenseProperties.UserInfo == null)
            {
                LicenseProperties.UserInfo = new UserInfo();
            }
            LicenseProperties.Product.ProductName = "NCache";
            //FOR PRODUCT
            using (RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@ForProductInfo, false))
            {
                if (regKey == null)
                {
                    return;
                }
                foreach (var item in regKey.GetValueNames())
                {
                    dictionary.Add(item.ToString(), regKey.GetValue(item.ToString()) as string);
                }
            }

            if (dictionary.ContainsKey("DotNetInstallMode"))
            {
                LicenseProperties.Product.DotNetInstallMode = dictionary["DotNetInstallMode"];
            }
            if (dictionary.ContainsKey("Http.Port"))
            {
                LicenseProperties.Product.HttpPort = dictionary["Http.Port"];
            }
            if (dictionary.ContainsKey("InstallCode"))
            {
                LicenseProperties.Product.InstallCode = dictionary["InstallCode"];
            }
            if (dictionary.ContainsKey("InstallDir"))
            {
                LicenseProperties.Product.InstallDir = dictionary["InstallDir"];
            }
            if (dictionary.ContainsKey("LastReportTime"))
            {
                LicenseProperties.Product.LastReportTime = dictionary["LastReportTime"];
            }
            //if (dictionary.ContainsKey("NCacheTcp.Port")) LicenseProperties.Product.NCacheTcpPort = dictionary["NCacheTcp.Port"];
            if (dictionary.ContainsKey("Platform"))
            {
                LicenseProperties.Product.Platform = dictionary["Platform"];
            }
            if (dictionary.ContainsKey("SPVersion"))
            {
                LicenseProperties.Product.SPVersion = dictionary["SPVersion"];
            }
            if (dictionary.ContainsKey("Tcp.Port"))
            {
                LicenseProperties.Product.TcpPort = dictionary["Tcp.Port"];
            }
            if (dictionary.ContainsKey("act-voil"))
            {
                LicenseProperties.Product.ActVoil = dictionary["act-voil"];
            }

            //FOR USERINFO
            using (RegistryKey regKey = Registry.LocalMachine.OpenSubKey(@ForUserInfo, false))
            {
                if (regKey == null)
                {
                    return;
                }
                foreach (var item in regKey.GetValueNames())
                {
                    dictionary.Add(item.ToString(), regKey.GetValue(item.ToString()) as string);
                }
            }

            if (dictionary.ContainsKey("address"))
            {
                LicenseProperties.UserInfo.Address = dictionary["address"];
            }
            if (dictionary.ContainsKey("AuthCode"))
            {
                LicenseProperties.UserInfo.AuthCode = dictionary["AuthCode"];
            }
            if (dictionary.ContainsKey("city"))
            {
                LicenseProperties.UserInfo.City = dictionary["city"];
            }
            if (dictionary.ContainsKey("company"))
            {
                LicenseProperties.UserInfo.Company = dictionary["company"];
            }
            if (dictionary.ContainsKey("country"))
            {
                LicenseProperties.UserInfo.Country = dictionary["country"];
            }
            if (dictionary.ContainsKey("DeactivateCode"))
            {
                LicenseProperties.UserInfo.DeactivateCode = dictionary["DeactivateCode"];
            }
            if (dictionary.ContainsKey("email"))
            {
                LicenseProperties.UserInfo.Email = dictionary["email"];
            }
            if (dictionary.ContainsKey("ExtCode"))
            {
                LicenseProperties.UserInfo.ExtCode = dictionary["ExtCode"] ?? string.Empty;
            }
            if (dictionary.ContainsKey("firstname"))
            {
                LicenseProperties.UserInfo.FirstName = dictionary["firstname"];
            }
            if (dictionary.ContainsKey("lastname"))
            {
                LicenseProperties.UserInfo.LastName = dictionary["lastname"];
            }
            if (dictionary.ContainsKey("licenseKey"))
            {
                LicenseProperties.UserInfo.LicenseKey = dictionary["licenseKey"];
            }
            if (dictionary.ContainsKey("phone"))
            {
                LicenseProperties.UserInfo.Phone = dictionary["phone"];
            }
            if (dictionary.ContainsKey("state"))
            {
                LicenseProperties.UserInfo.State = dictionary["state"];
            }
            if (dictionary.ContainsKey("zip"))
            {
                LicenseProperties.UserInfo.Zip = dictionary["zip"];
            }
        }