Beispiel #1
0
        public static bool CheckAgentLic(string hwId, int licAgentCount)
        {
            lock (CheckAgentLicLock)
            {
                DataSet ds = SqlWorks.ExecSql($"select LicId from LicAgent where ComputerId = {MainSettings.MainSqlSettings.ComputerId}");
                if (ds != null &&
                    ds.Tables != null &&
                    ds.Tables.Count == 1 &&
                    ds.Tables[0].Rows != null &&
                    ds.Tables[0].Rows.Count == 1)
                {
                    string licRequest  = LicRequest.GetRequest(hwId, licAgentCount);
                    bool   checkResult = licRequest == Convert.ToString(ds.Tables[0].Rows[0]["LicId"]);
                    if (checkResult)
                    {
                        SqlWorks.ExecSql($"update LicAgent set LicStatus = 0 where ComputerId = {MainSettings.MainSqlSettings.ComputerId}");
                    }
                    else
                    {
                        SqlWorks.ExecSql($"update LicAgent set LicStatus = -1 where ComputerId = {MainSettings.MainSqlSettings.ComputerId}");
                    }

                    return(checkResult);
                }

                return(false);
            }
        }
Beispiel #2
0
        public static int GetLicAgentRealCount()
        {
            lock (GetLicAgentRealCountLock)
            {
                DataSet ds = SqlWorks.ExecSql("select count(*) as ccc from LicAgent");
                if (ds != null &&
                    ds.Tables != null &&
                    ds.Tables.Count == 1 &&
                    ds.Tables[0].Rows != null &&
                    ds.Tables[0].Rows.Count == 1)
                {
                    string valStr = Convert.ToString(ds.Tables[0].Rows[0]["ccc"]);
                    int    valInt;
                    if (!int.TryParse(valStr, out valInt))
                    {
                        valInt = 0;
                    }

                    return(valInt);
                }

                return(0);
            }
        }
Beispiel #3
0
        public static int GetLicAgentCountFromGlobalSettings()
        {
            lock (GetLicAgentCountFromGlobalSettingsLock)
            {
                DataSet ds = SqlWorks.ExecSql("select Value from CommonGlobalSettings where Name = 'LicAgentsCount'");
                if (ds != null &&
                    ds.Tables != null &&
                    ds.Tables.Count == 1 &&
                    ds.Tables[0].Rows != null &&
                    ds.Tables[0].Rows.Count == 1)
                {
                    string valStr = Convert.ToString(ds.Tables[0].Rows[0]["Value"]);
                    int    valInt;
                    if (!int.TryParse(valStr, out valInt))
                    {
                        valInt = 0;
                    }

                    return(valInt);
                }

                return(0);
            }
        }