/// <summary> /// Check Message Queue for Exchange if not there and check the MSMQ service is running /// if not running start it and create queue.else if service is already running create the queue simply. /// <Author>Vineetha Mathew</Author> /// <DateCreated>Date Created 11-Dec-2008</DateCreated> /// <param name=strMSMQExchangepath>string</param> /// <returns>true</returns> /// </summary> /// Method Revision History /// /// Author Date Description /// --------------------------------------------------- ///Vineetha Mathew 11-12-2008 Created public static bool CreateMSMQ(string strMSMQExchangepath) { bool bMSMQServiceStatus = false; DataTable dtMSMQServicesStatus = new DataTable(); BMCMonitoring objBMCMonitoring = new BMCMonitoring(); bool bReturn = false; try { dtMSMQServicesStatus = objBMCMonitoring.GetServiceStatus("MSMQ", BMCMonitoring.ServiceTypes.All); if (dtMSMQServicesStatus.Rows.Count > 0) { for (int i = 0; i < dtMSMQServicesStatus.Rows.Count; i++) { if (dtMSMQServicesStatus.Rows[i][0].ToString() == "MSMQ" && dtMSMQServicesStatus.Rows[i][1].ToString() == "Stopped") { bMSMQServiceStatus = objBMCMonitoring.StartService("MSMQ"); if (bMSMQServiceStatus == true) { System.Threading.Thread.Sleep(5000); MessageQueue.Create(strMSMQExchangepath, true); MessageQueue objMessagqQueue = new MessageQueue(strMSMQExchangepath); objMessagqQueue.SetPermissions("Everyone", MessageQueueAccessRights.FullControl); bReturn = true; break; } } else if (dtMSMQServicesStatus.Rows[i][0].ToString() == "MSMQ" && dtMSMQServicesStatus.Rows[i][1].ToString() == "Running") { MessageQueue.Create(strMSMQExchangepath, true); MessageQueue objMessagqQueue = new MessageQueue(strMSMQExchangepath); objMessagqQueue.SetPermissions("Everyone", MessageQueueAccessRights.FullControl); bReturn = true; break; } } } } catch (Exception ex) { LogManager.WriteLog("CreateMSMQ" + ex.Message.ToString() + ex.Source.ToString(), LogManager.enumLogLevel.Error); ExceptionManager.Publish(ex); bReturn = false; } return bReturn; }
/// <summary> /// To start the selected service /// <param name="strServicename">string</param> /// <returns name="service status">bool</returns> /// </summary> private bool StartService(string strServicename) { try { BMCMonitoring objBMCMonitoring = new BMCMonitoring(); return objBMCMonitoring.StartService(strServicename); } catch (Exception ex) { LogManager.WriteLog("StartService" + ex.Message.ToString() + ex.Source.ToString(), LogManager.enumLogLevel.Error); ExceptionManager.Publish(ex); return false; } }
public bool StartService(string strServiceName) { CheckSecurity(); try { var objMonitoring = new BMCMonitoring(); return objMonitoring.StartService(strServiceName); } catch { LogManager.WriteLog("Error in starting service " + strServiceName, LogManager.enumLogLevel.Error); return false; } }
/// <summary> /// To start the selected service /// <param name="strServicename">string</param> /// <returns name="service status">bool</returns> /// </summary> private bool StartService(string strServicename) { try { LogManager.WriteLog("Inside Method", LogManager.enumLogLevel.Info); BMCMonitoring objBMCMonitoring = new BMCMonitoring(); return objBMCMonitoring.StartService(strServicename, new TimeSpan(0, serviceTimeOut, 0)); } catch (Exception ex) { LogManager.WriteLog("StartService" + ex.Message.ToString() + ex.Source.ToString(), LogManager.enumLogLevel.Error); ExceptionManager.Publish(ex); MessageBox.ShowBox("MessageID74", BMC_Icon.Error); return false; } }