Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            ServiceThreadTPVCOFO obj = new ServiceThreadTPVCOFO();

            obj.Start("I");
            while (true)
            {
            }
            ;
            //This wont stop app
#if DEBUG_SERVICE_START
            System.Diagnostics.Debugger.Launch();
#endif

            //if (Environment.UserInteractive)
            //{
            //    Execute();


            //    SinParametro objSinParametros = new SinParametro();
            //    string json = objSinParametros.FuncionTestSP();

            //    Console.WriteLine(json);
            //    DeleteTempFiles();
            //}


            //Console.ReadLine();
        }
Ejemplo n.º 2
0
        protected override void OnStart(string[] args)
        {
            String strError = "";

            //RegistryKey objRegistro = null;
            try
            {
                ServiceLogTPVCOFO.Instance.WriteLine("***********Inicio de Servicio Windows***********", true);
                //_paused = false;
                EventLog.WriteEntry("TPVCOFO System Monitor Started.");

                //if (args != null)
                //{
                //    strServidorPrincipal = args[0];
                //    ServiceLogTPVCOFO.Instance.WriteLine("Inicio Setear Valor Registro de Windows - Servidor: " + strServidorPrincipal, true);
                //    objRegistro = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\ServiceTPVATG");
                //    objRegistro.SetValue("Servidor", strServidorPrincipal);
                //    objRegistro.Close();
                //    ServiceLogTPVCOFO.Instance.WriteLine("Fin Setear Valor Registro de Windows - Servidor: " + strServidorPrincipal, true);

                //}
                //else
                //{
                //    ServiceLogTPVCOFO.Instance.WriteLine("Inicio Obtener Valor Registro de Windows - Servidor", true);
                //    objRegistro = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\ServiceTPVATG");
                //    strServidorPrincipal = objRegistro.GetValue("Servidor").ToString();
                //    objRegistro.Close();
                //    ServiceLogTPVCOFO.Instance.WriteLine("Inicio Obtener Valor Registro de Windows - Servidor", true);
                //}

                _serviceThread = new ServiceThreadTPVCOFO();
                _serviceThread.Start("Started");

                ServiceLogTPVCOFO.Instance.GrabarLog();
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    strError = ex.InnerException.Message;
                }
                else
                {
                    strError = ex.Message;
                }

                EventLog.WriteEntry("Started Error :" + strError);
                ServiceLogTPVCOFO.Instance.WriteLine("Error al Iniciar: " + ex.Message, true);
                ServiceLogTPVCOFO.Instance.GrabarLog();
            }
        }
Ejemplo n.º 3
0
        //private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
        //{
        //    if (e.Mode == PowerModes.Suspend)
        //    {

        //        File.AppendAllLines(@"C:\prueba.txt", new string[] { "Supendido" }, Encoding.ASCII);
        //    }
        //    else
        //    {
        //        File.AppendAllLines(@"C:\prueba.txt", new string[] { "Reanudado" }, Encoding.ASCII);
        //    }

        //}

        protected override bool OnPowerEvent(PowerBroadcastStatus powerstatus)
        {
            _serviceThread = new ServiceThreadTPVCOFO();
            if (powerstatus == PowerBroadcastStatus.Suspend)
            {
                //Proceso p = Process.Start("shutdown.exe", "/ r");
                //p.WaitForExit();
                //File.AppendAllLines(@"C:\prueba.txt", new string[] { "Supendido - OnPowerEvent" }, Encoding.ASCII);
                EventLog.WriteEntry("Supensión de Equipo - Servicio de Windows");
                ServiceLogTPVCOFO.Instance.WriteLine("***********Supensión de Equipo - Servicio de Windows***********", true);
                _serviceThread.Stop("Stoped");
            }
            else if (powerstatus == PowerBroadcastStatus.ResumeSuspend)
            {
                //File.AppendAllLines(@"C:\prueba.txt", new string[] { "Reanudado - OnPowerEvent" }, Encoding.ASCII);
                EventLog.WriteEntry("Reanudado de Equipo - Servicio de Windows");
                ServiceLogTPVCOFO.Instance.WriteLine("***********Reanudado de Equipo - Servicio de Windows***********", true);
                _serviceThread.Start("Started");
            }
            return(base.OnPowerEvent(powerstatus));
        }
Ejemplo n.º 4
0
 protected override void OnContinue()
 {
     try
     {
         EventLog.WriteEntry("TPVCOFO System Monitor Resumed.");
         //_paused = false;
         _serviceThread = new ServiceThreadTPVCOFO();
         _serviceThread.Start("Resumed");
     }
     catch (Exception ex)
     {
         if (ex.InnerException != null)
         {
             EventLog.WriteEntry("Resumed Error :" + ex.InnerException.Message);
         }
         else
         {
             EventLog.WriteEntry("Resumed Error :" + ex.Message);
         }
     }
 }