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); } }
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; } }