Exemplo n.º 1
0
/* moved to InternalMethods
 *              private SqlConnection GetNewConnection(string Server, string Database)
 *              {
 *                      SqlConnection con = new SqlConnection("Server="+Server+";Database="+Database+";Integrated Security=SSPI;POOLING=FALSE");
 *                      con.Open();
 *                      try
 *                      {
 *                              string ls_pref;
 *                              string ls_approlecred;
 *                              string ls_sql;
 *
 *                              SqlCommand cmd = new SqlCommand("SELECT dbo.fn_get_global_preference('SYSTEM', 'system_bitmap') FROM c_1_Record",con);
 *                              object dbValue = cmd.ExecuteScalar();
 *                              if(null==dbValue)
 *                              {
 *                                      ls_approlecred = "applesauce28";
 *                              }
 *                              else
 *                              {
 *                                      ls_pref = dbValue.ToString();
 *                                      ls_approlecred = InternalMethods.DecryptString(ls_pref);
 *                              }
 *
 *                              ls_sql = "sp_setapprole 'cprsystem', '" + ls_approlecred + "'";
 *                              SqlCommand com = new SqlCommand(ls_sql, con);
 *                              com.ExecuteNonQuery();
 *                      }
 *                      catch(Exception exc)
 *                      {
 *                              EPSEventLog.WriteEntry("Error executing sp_setapprole:"+Environment.NewLine+exc.ToString(),EventLogEntryType.Error);
 *                      }
 *                      return con;
 *              }
 */
        private void monitorMyHealth()
        {
            try
            {
                int myPID = Process.GetCurrentProcess().Id;
                while (running)
                {
                    uint workingSet = ProcUtils.GetProcessMemoryUsage(myPID).WorkingSetSize;
                    if (workingSet > masterMemMax)
                    {
                        // If over limit for memory usage, stop and start self
                        EPSEventLog.WriteEntry("MasterMemMaxMB=" + MasterMemMaxMB.ToString() + Environment.NewLine +
                                               "Current Memory Usage (MB)=" + (workingSet / Math.Pow(2d, 20d)).ToString() +
                                               Environment.NewLine + "Shutting down all processes.", EventLogEntryType.Warning);
                        ServiceManager.StopServices();
                        GC.Collect();
                        EPSEventLog.WriteEntry("Restarting processes.", EventLogEntryType.Warning);
                        ServiceManager.StartServices(Args);
                        return;
                    }
                    Thread.Sleep(5000);
                    GC.Collect();                     // Perform garbage collection
                }
            }
            catch (ThreadAbortException) {}
            catch (Exception exc)
            {
                EPSEventLog.WriteEntry("Error in monitorHealth() " + Environment.NewLine + exc.ToString(), EventLogEntryType.Error);
            }
        }
Exemplo n.º 2
0
        public void Stop()
        {
            try
            {
                OnStopping();

                // Forcefully kill the application
                if (IsRunning)
                {
                    ProcUtils.Kill(ProcessId);
                    p.WaitForExit();
                }
            }
            catch (Exception exc)
            {
                EPSEventLog.WriteEntry("Error in Stop()" + Environment.NewLine +
                                       exc.ToString(), System.Diagnostics.EventLogEntryType.Error);
                throw exc;
            }
        }
Exemplo n.º 3
0
 private void KillActiveEproServerProcs()
 {
     ProcUtils.KillAll("eproserver.exe");
 }