예제 #1
0
파일: Wetu_Service.cs 프로젝트: Ricium/Wetu
        protected override void OnStart(string[] args)
        {
            eventLog.WriteEntry(LogMessages.START_SERVICE, EventLogEntryType.Information, eventId++, EventCategories.SERVICE_EVENT);

            ServiceStatus serviceStatus = new ServiceStatus();
            serviceStatus.dwCurrentState = ServiceState.SERVICE_START_PENDING;
            serviceStatus.dwWaitHint = 100000;
            SetServiceStatus(this.ServiceHandle, ref serviceStatus);

            //SqlConnection sqlConn = new SqlConnection(conString);
            eventLog.WriteEntry("Before Try", EventLogEntryType.Information, eventId++, EventCategories.DATABASE_EVENT);

            /*try
            {
                eventLog.WriteEntry("In try", EventLogEntryType.Information, eventId++, EventCategories.DATABASE_EVENT);
                con.Open();
                eventLog.WriteEntry("Open Connection", EventLogEntryType.Information, eventId++, EventCategories.DATABASE_EVENT);
            }
            catch (Exception ex)
            {
                eventLog.WriteEntry("Exception", EventLogEntryType.Information, eventId++, EventCategories.DATABASE_EVENT);
                eventLog.WriteEntry(ex.Message, EventLogEntryType.Information, eventId++, EventCategories.DATABASE_EVENT);
            }*/

            InitializeTimer();

            serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING;
            SetServiceStatus(this.ServiceHandle, ref serviceStatus);
        }
예제 #2
0
파일: Wetu_Service.cs 프로젝트: Ricium/Wetu
 private static extern bool SetServiceStatus(IntPtr handle, ref ServiceStatus serviceStatus);