Esempio n. 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);
            }
        }
Esempio n. 2
0
        public DFLicenseResponse GetLicense(DFLicenseRequest objDFLicenseRequest)
        {
            var objDFLicenseResponse = new DFLicenseResponse();
            var objLicRequest        = new LicRequest();
            var objLicResponse       = new LicResponse();
            var objCAProxy           = new SigServTandbergService();

            //Start GetLicense;
            objEventLogger.WriteEntry("Start GetLicense");

            if (objDFLicenseRequest != null)
            {
                try
                {
                    //ASSIGNING ID'S
                    objDFLicenseResponse.RequestID  = objDFLicenseRequest.RequestID;
                    objDFLicenseResponse.ResponseID = objDFLicenseRequest.RequestID;

                    //Input Validation GetLicenses
                    if (objBL.ValidateRequest(objDFLicenseRequest, objDFLicenseResponse))
                    {
                        objBL.GetLicense(objDFLicenseRequest, objDFLicenseResponse);
                    }
                }
                catch (Exception ex)
                {
                    //Message for alg 17

                    if (ex.Message.EndsWith("alg 17 SKU") || ex.Message.EndsWith("alg 20 SKU") || ex.Message.EndsWith("Please enter valid no of years"))
                    {
                        //SET FAILURE STATUS
                        objDFLicenseResponse.ResponseStatus  = (int)Constants.ResponseStatus.InvalidParameter;
                        objDFLicenseResponse.ResponseMessage = ex.Message;
                        objDFLicenseResponse.LicenseKey      = "";
                    }
                    else
                    {
                        //SET FAILURE STATUS
                        objDFLicenseResponse.ResponseStatus  = (int)Constants.ResponseStatus.ServiceUnavailable;
                        objDFLicenseResponse.ResponseMessage = Constants.ResponseMessage[1000].ToString();
                        objDFLicenseResponse.LicenseKey      = "";
                    }

                    //LOG EXCEPTION
                    objEventLogger.WriteLog("GetLicense:" + ex.Message + Environment.NewLine + ex.StackTrace, objDFLicenseRequest.RequestingSystem, DateTime.UtcNow, objDFLicenseRequest.RequestID);
                }
                finally
                {
                    objDFLicenseResponse.ResponseDateTime = DateTime.UtcNow;

                    //SERIALIZE REQUEST/RESPONSE
                    string request  = "GetLicenseRequest";
                    string response = "GetLicenseResponse";

                    try
                    {
                        request  = Util.SerializeObject(objDFLicenseRequest);
                        response = Util.SerializeObject(objDFLicenseResponse);
                    }
                    catch (Exception ex)
                    {
                        objEventLogger.WriteLog("GetLicense:Request/Response Object Serialization Error: " + ex.Message + Environment.NewLine + ex.StackTrace, objDFLicenseRequest.RequestingSystem, DateTime.UtcNow, objDFLicenseRequest.RequestID);
                    }

                    if (!request.IsValidString())
                    {
                        request = "GetLicenseRequest";
                    }
                    if (!response.IsValidString())
                    {
                        response = "GetLicenseResponse";
                    }


                    //LOG REQUEST/RESPONSE
                    objTransactionLogger.LogTransaction(objDFLicenseRequest.RequestID, objDFLicenseRequest.RequestDateTime, objDFLicenseRequest.RequestingSystem,
                                                        request, objDFLicenseResponse.ResponseID, objDFLicenseResponse.ResponseDateTime, response,
                                                        objDFLicenseResponse.ResponseStatus, objDFLicenseResponse.ResponseMessage, 0);

                    //End Processing GetLicense
                }
            }

            return(objDFLicenseResponse);
        }