// public void MachineConfig() { if (nMachineThreadComplete != nMachineTotal) { LogManager.WriteLog("MachineConfig pending items to be processed.Returning to Main.", LogManager.enumLogLevel.Info); return; } nMachineThreadComplete = 0; string PROC = "|=> MachineConfig() : "; if (this.IsObjectInactive) { LogManager.WriteLog(PROC + "Service was instructed to stop.", LogManager.enumLogLevel.Info); return; } try { DataTable getMachineDetails; LogManager.WriteLog("Inside MachineConfig method", LogManager.enumLogLevel.Info); getMachineDetails = DBBuilder.GetAAMSDetails(3); if (getMachineDetails.Rows.Count <= 0) { return; } else { nMachineTotal = getMachineDetails.Rows.Count; } foreach (DataRow row in getMachineDetails.Rows) { if (this.IsObjectInactive) { LogManager.WriteLog(PROC + "Service was instructed to stop.", LogManager.enumLogLevel.Info); return; } MachineConfigThreadData threadData = new MachineConfigThreadData() { Installation_No = row["BAD_Reference_ID"] != DBNull.Value ? Convert.ToInt32(row["BAD_Reference_ID"].ToString()) : 0, Enable = false, badId = Convert.ToInt32(row["BAD_ID"]), datapakCurrentState = 0, entityType = 3, Installation_Float_Status = row["Installation_Float_Status"] != DBNull.Value ? Convert.ToInt32(row["Installation_Float_Status"]) : 0, enterprisestatus = row["BMC_Enterprise_Status"] != DBNull.Value ? Convert.ToBoolean(row["BMC_Enterprise_Status"].ToString()) : true, updateDate = Convert.ToDateTime(row["BAD_Updated_Date"]) }; #if DEBUG if (_machineDispatcher == null) { LogManager.WriteLog("|==> DANGER: _machineDispatcher is null.", LogManager.enumLogLevel.Info); } #endif _machineDispatcher.AddThreadData(threadData); } } catch (Exception Ex) { LogManager.WriteLog("MachineConfig Error " + Ex.Message, LogManager.enumLogLevel.Info); ExceptionManager.Publish(Ex); } }
public double EnableDisableVLTBasedonVerfication() { DataTable AAMSTable; bool IsVerified; LogManager.WriteLog("EnableDisableVLTBasedonVerfication - Started.", LogManager.enumLogLevel.Info); if (!Convert.ToBoolean(ConfigManager.Read("EnableDisableVLTBasedonVerfication"))) { return(60 * 1000); } double dTimerDelay = 60 * 1000; double dBlockTimeOut = 10; AAMSTable = DBBuilder.GetAAMSDetails(3); try { if (AAMSTable.Rows.Count > 0) { ConfigManager.Read("CommsRegistryPath"); // var key = BMCRegistryHelper.GetRegLocalMachine().OpenSubKey(ConfigManager.Read("CommsRegistryPath")); //if (key != null) // dBlockTimeOut = Convert.ToDouble(key.GetValue("BlockingCallTimeOut")); dBlockTimeOut = Convert.ToDouble(BMCRegistryHelper.GetRegKeyValue(ConfigManager.Read("CommsRegistryPath"), "BlockingCallTimeOut")); int nMaxThreads = 0; nMaxThreads = Convert.ToInt32(ConfigManager.Read("MaxThreadPoolSize")); LogManager.WriteLog("[EnableDisableVLTBasedonVerfication]- MaxThreads: " + nMaxThreads.ToString(), LogManager.enumLogLevel.Info); LogManager.WriteLog("[EnableDisableVLTBasedonVerfication]- BlockingCallTimeOutValue: " + dBlockTimeOut.ToString(), LogManager.enumLogLevel.Info); dTimerDelay = ((AAMSTable.Rows.Count / nMaxThreads) * dBlockTimeOut) + 10000; LogManager.WriteLog("[EnableDisableVLTBasedonVerfication]: RowCount: " + AAMSTable.Rows.Count.ToString(), LogManager.enumLogLevel.Info); foreach (DataRow row in AAMSTable.Rows) { try { MachineEnableDisable _autoEnableDisable; string EntityCommand = string.Empty; int iCurrentStatus = 0; int iInstallationNo = 0; string strSerialno = string.Empty; string strComment = string.Empty; bool enterpriseStatus = false; int Installation_Float_Status; iCurrentStatus = row["BAD_Entity_Current_Status"] != DBNull.Value ? Convert.ToInt32(row["BAD_Entity_Current_Status"].ToString()) : 0; strSerialno = row["BAD_Asset_Serial_No"] == DBNull.Value ? string.Empty : row["BAD_Asset_Serial_No"].ToString(); enterpriseStatus = row["BMC_Enterprise_Status"] != DBNull.Value ? Convert.ToBoolean(row["BMC_Enterprise_Status"].ToString()) : true; Installation_Float_Status = row["Installation_Float_Status"] != DBNull.Value ? Convert.ToInt32(row["Installation_Float_Status"]) : 0; iInstallationNo = row["BAD_Reference_ID"] != DBNull.Value ? Convert.ToInt32(row["BAD_Reference_ID"].ToString()) : 0; LogManager.WriteLog("-- Enable Disable Status for AssetSerialNumber - " + strSerialno + ", " + "- Enterprise Status :" + enterpriseStatus.ToString() + "Inside EnableDisableVLTBasedonVerfication - ", LogManager.enumLogLevel.Info); _autoEnableDisable = new MachineEnableDisable() { Installation_No = iInstallationNo, Enable = false, badId = Convert.ToInt32(row["BAD_ID"]), datapakCurrentState = 0, entityType = 3, updateDate = Convert.ToDateTime(row["BAD_Updated_Date"]) }; if (Installation_Float_Status == 1 && DBBuilder.GetSettingFromDB("DISABLE_MACHINE_ON_DROP", "FALSE").ToUpper() == "TRUE") { LogManager.WriteLog("Disabling the machine - " + strSerialno, LogManager.enumLogLevel.Info); _autoEnableDisable.Enable = false; _autoEnableDisable.datapakCurrentState = 0; ThreadPool.QueueUserWorkItem(new WaitCallback(EnableDisableMachine), _autoEnableDisable); strComment = "Machine Floated and Setting DISABLE_MACHINE_ON_DROP {True} hence disabling."; LogManager.WriteLog(strComment, LogManager.enumLogLevel.Info); DBBuilder.UpdateCommentsForAAMS(row["BAD_ID"].ToString(), strComment, 3, 0); } else { if (enterpriseStatus) { _autoEnableDisable.Enable = true; _autoEnableDisable.datapakCurrentState = 1; ThreadPool.QueueUserWorkItem(new WaitCallback(EnableDisableMachine), _autoEnableDisable); LogManager.WriteLog("Enabling the machine - " + strSerialno, LogManager.enumLogLevel.Info); } else { _autoEnableDisable.Enable = false; _autoEnableDisable.datapakCurrentState = 0; ThreadPool.QueueUserWorkItem(new WaitCallback(EnableDisableMachine), _autoEnableDisable); strComment = "Disabling the machine - " + strSerialno; LogManager.WriteLog(strComment, LogManager.enumLogLevel.Info); DBBuilder.UpdateCommentsForAAMS(row["BAD_ID"].ToString(), strComment, 2, 0); } } LogManager.WriteLog("EnableDisableVLTBasedonVerfication - Completed.", LogManager.enumLogLevel.Info); } catch (Exception ex) { ExceptionManager.Publish(ex); } } } else { LogManager.WriteLog("No Machine to be enabled or disabled.", LogManager.enumLogLevel.Info); } return(dTimerDelay); } catch (Exception Ex) { ExceptionManager.Publish(Ex); return(60 * 1000); } }
/// <summary> /// Entry Method for Enable/Disable Machines /// </summary> private void EnableDisableMachine() { if (mEvent.WaitOne(NetworkServiceSettings.RequestWaitTime)) { return; } DataTable dtInsatllationsToProcess; dtInsatllationsToProcess = DBBuilder.GetAAMSDetails(3); LogManager.WriteLog("EnableDisableMachine | Number of Installation to Process: " + dtInsatllationsToProcess.Rows.Count.ToString() , LogManager.enumLogLevel.Info); try { if (dtInsatllationsToProcess.Rows.Count > 0) { foreach (DataRow dRow in dtInsatllationsToProcess.Rows) { if (mEvent.WaitOne(NetworkServiceSettings.RequestWaitTime)) { break; } EnableDisableThreadData threadData = new EnableDisableThreadData() { InstallationNo = dRow["BAD_Reference_ID"] != DBNull.Value ? Convert.ToInt32(dRow["BAD_Reference_ID"].ToString()) : 0, Enable = false, badID = Convert.ToInt32(dRow["BAD_ID"]), datapakCurrentState = 0, entityType = 3, Installation_Float_Status = dRow["Installation_Float_Status"] != DBNull.Value ? Convert.ToInt32(dRow["Installation_Float_Status"]) : 0, enterprisestatus = dRow["BMC_Enterprise_Status"] != DBNull.Value ? Convert.ToBoolean(dRow["BMC_Enterprise_Status"].ToString()) : true, updateDate = Convert.ToDateTime(dRow["BAD_Updated_Date"]) }; #if DEBUG LogManager.WriteLog("EnableDisableMachine | InstallationNo:" + threadData.InstallationNo.ToString() + ", EnterpriseStatus:" + threadData.enterprisestatus.ToString(), LogManager.enumLogLevel.Info); #endif if (threadData.Installation_Float_Status == 1 && DBBuilder.GetSettingFromDB("DISABLE_MACHINE_ON_DROP", "FALSE").ToUpper() == "TRUE") { int messageID = DisableMachine(threadData.InstallationNo); if (!dEnableDisableRequest.ContainsKey(messageID)) { dEnableDisableRequest.Add(messageID, threadData); } threadData.Enable = false; threadData.datapakCurrentState = 0; threadData.command = eCommand.Disable; LogManager.WriteLog("EnableDisableMachine | Disable Request For Installation: " + threadData.InstallationNo.ToString() + ", MessageID:" + messageID.ToString() + " ,CASE:DISABLE_MACHINE_ON_DROP" , LogManager.enumLogLevel.Info); //var strComment = "Machine Floated and Setting DISABLE_MACHINE_ON_DROP {True} hence disabling."; //LogManager.WriteLog(strComment, LogManager.enumLogLevel.Info); //DBBuilder.UpdateCommentsForAAMS(dRow["BAD_ID"].ToString(), strComment, 3, 0); } else if (threadData.IsSiteLicensingEnabled && threadData.SiteLicensing_DisableGames) { int messageID = DisableMachine(threadData.InstallationNo); if (!dEnableDisableRequest.ContainsKey(messageID)) { dEnableDisableRequest.Add(messageID, threadData); } threadData.datapakCurrentState = 0; threadData.command = eCommand.Disable; LogManager.WriteLog("EnableDisableMachine | Disable Request For Installation: " + threadData.InstallationNo.ToString() + ", MessageID:" + messageID.ToString() + " ,CASE:SITELICENSING_DISABLEGAMES" , LogManager.enumLogLevel.Info); } else { if (threadData.enterprisestatus) { int messageID = EnableMachine(threadData.InstallationNo); if (!dEnableDisableRequest.ContainsKey(messageID)) { dEnableDisableRequest.Add(messageID, threadData); } threadData.Enable = true; threadData.datapakCurrentState = 1; threadData.command = eCommand.Enable; LogManager.WriteLog("EnableDisableMachine | Enable Request for Installation: " + threadData.InstallationNo.ToString() + ", MessageID:" + messageID.ToString() + " ,CASE:ENTERPRISESTATUS" , LogManager.enumLogLevel.Info); } else { int messageID = DisableMachine(threadData.InstallationNo); if (!dEnableDisableRequest.ContainsKey(messageID)) { dEnableDisableRequest.Add(messageID, threadData); } threadData.Enable = false; threadData.datapakCurrentState = 0; threadData.command = eCommand.Disable; LogManager.WriteLog("EnableDisableMachine | Disable Request for Installation: " + threadData.InstallationNo.ToString() + ", MessageID:" + messageID.ToString() + " ,CASE:ENTERPRISESTATUS" , LogManager.enumLogLevel.Info); //var strComment = "Disabling the Installation : " + threadData.InstallationNo.ToString(); //DBBuilder.UpdateCommentsForAAMS(dRow["BAD_ID"].ToString(), strComment, 2, 0); } } } } else { LogManager.WriteLog("No Machines to be enabled or disabled.", LogManager.enumLogLevel.Info); } } catch (Exception ex) { LogManager.WriteLog("EnableDisableMachine | Exception Occured.", LogManager.enumLogLevel.Info); ExceptionManager.Publish(ex); } }