예제 #1
0
파일: Program.cs 프로젝트: breshch/AIS
        private static void Main(string[] args)
        {
            if (args.Any())
            {
                string serviceName = "AIS_Enterprise_Gas";
                switch (args[0])
                {
                case "-c":
                    var gas = new GasProcessing();
                    gas.GetBalance();
                    Console.ReadKey();
                    break;

                case "-i":
                    if (GetServiceStatus(serviceName) != "notInstalled")
                    {
                        if (GetServiceStatus(serviceName) == "started")
                        {
                            StopService(serviceName);
                            DeleteService(serviceName);
                        }
                        else if (GetServiceStatus(serviceName) == "stopped")
                        {
                            DeleteService(serviceName);
                        }
                    }

                    InstallService();

                    StatrtService(serviceName);

                    break;

                case "-u":
                    DeleteService(serviceName);
                    break;

                default:
                    throw new Exception();
                }
            }
            else
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new Service1()
                };
                ServiceBase.Run(ServicesToRun);
            }
        }
예제 #2
0
파일: Service1.cs 프로젝트: breshch/AIS
        protected override void OnStart(string[] args)
        {
            var gas = new GasProcessing();

            Task.Factory.StartNew(gas.GetBalance);
        }