Esempio n. 1
0
        private void RegisterSQLDependency()
        {
            try
            {
                LogManager.WriteLog("Inside RegisterSQLDependency", LogManager.enumLogLevel.Info);

                SqlConnection sqlConnection = new SqlConnection(DBCalls.GetConnRegSettings());

                SqlCommand sqlCommand = new SqlCommand();
                sqlCommand.Connection  = sqlConnection;
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = ProcGetSiteEnabledStatus;

                sqlCommand.Notification = null;

                //Set the SQLDepencdency to the SQLCommand object.
                SqlDependency sqlDependency = new SqlDependency(sqlCommand);
                sqlDependency.OnChange += new OnChangeEventHandler(sqlDependency_OnChange);

                //Execute the command.
                sqlConnection.Open();
                sqlCommand.ExecuteReader(CommandBehavior.CloseConnection);

                LogManager.WriteLog("SQLDependency registered Successfully", LogManager.enumLogLevel.Info);
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
Esempio n. 2
0
        private void GetSiteEnabledStatus()
        {
            try
            {
                LogManager.WriteLog("Inside GetCurrentSiteStatus", LogManager.enumLogLevel.Info);

                SqlConnection sqlConnection = new SqlConnection(DBCalls.GetConnRegSettings());

                SqlCommand sqlCommand = new SqlCommand();
                sqlCommand.Connection  = sqlConnection;
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = ProcGetSiteStatus;

                //Execute the command.
                sqlConnection.Open();
                SiteEnabledStatus = Convert.ToInt32(sqlCommand.ExecuteScalar());
                sqlConnection.Close();

                LogManager.WriteLog(string.Format("{0} - {1}", "Current Status of Site", SiteEnabledStatus.ToString()), LogManager.enumLogLevel.Info);
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
Esempio n. 3
0
        private void StartMonitoringSiteStatus()
        {
            try
            {
                LogManager.WriteLog("Starting Monitoring Site Status...", LogManager.enumLogLevel.Info);

                //Get the Exchange connection string
                string strConnectionString = DBCalls.GetConnRegSettings();

                // Get Current Status of Site
                GetSiteEnabledStatus();

                //Remove any existing dependency connection, then create a new one.
                SqlDependency.Stop(strConnectionString);
                SqlDependency.Start(strConnectionString);

                //Register SQL Dependency to trigger change Notifications to Site table
                RegisterSQLDependency();

                //Start Timer to monitor change Notifications to Site table, as backup if SQL Dependency fails
                StartCheckSiteStatusTimer();

                LogManager.WriteLog("Site Status Monitoring started successfully", LogManager.enumLogLevel.Info);
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
Esempio n. 4
0
        private void CheckSiteStatus()
        {
            try
            {
                LogManager.WriteLog("Inside CheckSiteStatus", LogManager.enumLogLevel.Info);

                SqlConnection sqlConnection = new SqlConnection(DBCalls.GetConnRegSettings());

                SqlCommand sqlCommand = new SqlCommand();
                sqlCommand.Connection  = sqlConnection;
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.CommandText = ProcGetSiteStatus;

                //Execute the command.
                sqlConnection.Open();
                int siteStatus = Convert.ToInt32(sqlCommand.ExecuteScalar());
                sqlConnection.Close();

                if (SiteEnabledStatus != siteStatus)
                {
                    BMCMonitoring objMonitoring = new BMCMonitoring();

                    string        strServiceNames = DBBuilder.DBCalls.GetServiceNames();
                    List <string> serviceNames    = new List <string>(strServiceNames.Split(','));

                    foreach (string service in serviceNames)
                    {
                        if (service.Trim().ToUpper() == BMCGuardianService)
                        {
                            continue;
                        }

                        if (siteStatus == 1)
                        {
                            objMonitoring.EnableService(service.Trim());
                        }
                        else
                        {
                            objMonitoring.DisableService(service.Trim());
                        }
                    }
                }
                else
                {
                    LogManager.WriteLog("Site Status not changed, hence skipping the Site Enable/Disable process.", LogManager.enumLogLevel.Info);
                }

                SiteEnabledStatus = siteStatus;
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
Esempio n. 5
0
        private void UpdateSiteServiceDetails(string sStatus)
        {
            try
            {
                SqlParameter[] sp_parames = null;

                sp_parames = new SqlParameter[1];

                sp_parames[0] = new SqlParameter("@Status", sStatus);

                SqlHelper.ExecuteScalar(DBCalls.GetConnRegSettings(), "usp_UpdateServiceStatus", sp_parames);
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
Esempio n. 6
0
        private void CheckDBConnectivity()
        {
            LogManager.WriteLog("Starting Guardian Service...", LogManager.enumLogLevel.Info);

            SqlConnection sqlConnection    = null;
            bool          isDBConnectionUp = false;

            while (!isDBConnectionUp)
            {
                try
                {
                    LogManager.WriteLog("Checking DB Connectivity...", LogManager.enumLogLevel.Info);

                    sqlConnection = new SqlConnection(DBCalls.GetConnRegSettings());
                    sqlConnection.Open();
                    isDBConnectionUp = true;
                }
                catch (Exception ex)
                {
                    ExceptionManager.Publish(ex);

                    LogManager.WriteLog("DB Connection is down.", LogManager.enumLogLevel.Error);

                    LogManager.WriteLog("Putting the Thread to Sleep for 10 Seconds...", LogManager.enumLogLevel.Info);

                    Thread.Sleep(10 * 1000);
                }
                finally
                {
                    if (sqlConnection != null)
                    {
                        sqlConnection = null;
                    }
                }
            }

            LogManager.WriteLog("DB Connection is Up.", LogManager.enumLogLevel.Info);

            StartService();
        }
Esempio n. 7
0
        public ActionResult Profile(int ID)
        {
            mockUser      = DBCalls.getUser(ID);
            mockQuestions = DBCalls.GetQuestions(ID);
            mockAnswers   = DBCalls.GetAnswers(ID);
            //mockRewards = getRewards();
            ViewBag.User     = mockUser;
            ViewBag.ID       = mockUser.Id;
            ViewBag.userName = mockUser.Name;
            ViewBag.email    = mockUser.Email;
            ViewBag.team     = mockUser.Team;

            ViewBag.score       = mockUser.Score;
            ViewBag.Preferences = mockUser.Tags;

            ViewBag.Questions = mockQuestions;
            ViewBag.Answers   = mockAnswers;

            ViewBag.Rewards = mockRewards;

            return(View());
        }
Esempio n. 8
0
        /// <summary>
        /// Get the settings for Client
        /// </summary>
        /// <param name="sqlparams"></param>
        /// <param name="strConnect"></param>
        /// <returns >string</returns>
        private string GetSettingFromDB(string strSetting)
        {
            string strReturnValue = string.Empty;

            try
            {
                SqlParameter[] sqlparams = GetSettingParameterDB(strSetting);
                SqlHelper.ExecuteNonQuery(DBCalls.GetConnRegSettings(), System.Data.CommandType.StoredProcedure, "rsp_getSetting", sqlparams);
                if (sqlparams[3].Value != null || sqlparams[3].Value.ToString() != string.Empty)
                {
                    strReturnValue = Convert.ToString(sqlparams[3].Value);
                }
                else
                {
                    strReturnValue = string.Empty;
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }

            return(strReturnValue);
        }
 // GET: Forum
 public ActionResult Index(int ID)
 {
     ViewBag.User      = DBCalls.getUser(ID);
     ViewBag.Questions = allQuestions;
     return(View());
 }
Esempio n. 10
0
 public ActionResult Questions(int ID)
 {
     ViewBag.User      = DBCalls.getUser(ID);
     ViewBag.Questions = DBCalls.GetQuestions(ID);
     return(View());
 }
Esempio n. 11
0
 public ActionResult Answers(int ID)
 {
     ViewBag.User    = DBCalls.getUser(ID);
     ViewBag.Answers = DBCalls.GetAnswers(ID);
     return(View());
 }