コード例 #1
0
ファイル: Service.cs プロジェクト: radtek/ClearView
        private void CheckServices()
        {
            DateTime now = DateTime.Now;

            string[] times  = strRestartTime.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            bool     timeOK = false;

            foreach (string time in times)
            {
                if (String.IsNullOrEmpty(time) == false)
                {
                    if (intLogging >= 3)
                    {
                        oEventLog.WriteEntry(String.Format("Checking Restart Time = " + time), EventLogEntryType.Information);
                    }

                    DateTime _tick = DateTime.Parse(time.Trim());
                    if (_tick.ToShortTimeString() == now.ToShortTimeString())
                    {
                        timeOK = true;
                        if (intLogging >= 2)
                        {
                            oEventLog.WriteEntry(String.Format("Time = " + time + " is Valid!"), EventLogEntryType.Information);
                        }
                        break;
                    }
                    else if (intLogging >= 3)
                    {
                        oEventLog.WriteEntry(String.Format("Time = " + time + " is not valid (" + now.ToShortTimeString() + ")"), EventLogEntryType.Warning);
                    }
                }
            }

            if (timeOK)
            {
                Servers      oServer      = new Servers(0, dsn);
                Workstations oWorkstation = new Workstations(0, dsn);

                List <ServiceData> Data         = new List <ServiceData>();
                string[]           strTypeSplit = { "," };
                Data.Add(new ServiceData("ClearView AP Physical", oServer.GetScheduler(PhysicalTypes), PhysicalSteps.Split(strTypeSplit, StringSplitOptions.RemoveEmptyEntries), "servername"));
                Data.Add(new ServiceData("ClearView AP VMware", oServer.GetScheduler(VirtualTypes), VirtualSteps.Split(strTypeSplit, StringSplitOptions.RemoveEmptyEntries), "servername"));
                Data.Add(new ServiceData("ClearView AP VMware Workstation", oWorkstation.GetScheduler(WorkstationType), WorkstationSteps.Split(strTypeSplit, StringSplitOptions.RemoveEmptyEntries), "workstationname"));
                foreach (ServiceData data in Data)
                {
                    CheckService oCheckService       = new CheckService(data.ServiceName, data.CurrentBuilds, data.ExcludeSteps, data.ColumnName, intRestartHours, intStartTimeout, dsn, intEnvironment, intLogging, oEventLog);
                    ThreadStart  oCheckServiceStart  = new ThreadStart(oCheckService.Begin);
                    Thread       oCheckServiceThread = new Thread(oCheckServiceStart);
                    oCheckServiceThread.Start();
                }
            }
        }