Esempio n. 1
0
        private void _startTimer_Elapsed(object sender, timer.ElapsedEventArgs e)
        {
            foreach (var connectionString in _connectionStrings)
            {
                Log.WriteErrorLog("Processing connection :");

                List <ProcessJob> jobs = null;

                try
                {
                    //get new or pending extraction template
                    jobs = _dataManager.GetNewOrPendingProcessJobs(connectionString);

                    Log.WriteErrorLog("Job found :" + jobs.Count().ToString());

                    foreach (var job in jobs)
                    {
                        Log.WriteErrorLog("Processing job :" + job.Code);

                        var service = ServiceExist(job.Code);

                        if (job.Status == PackageStatus.New)
                        {
                            if (service == null)
                            {
                                string svcName     = job.Code;
                                string svcDispName = "Fintrak " + job.Code + " " + " Service";

                                //get username and password
                                string userName = null;
                                string password = null;

                                if (Account == ServiceAccount.User)
                                {
                                    userName = UserName;
                                    password = Password;
                                }

                                CustomServiceInstaller c = new CustomServiceInstaller();
                                c.InstallService(_servicePath, svcName, svcDispName, userName, password, connectionString);

                                //Update job to running
                                job.Status = PackageStatus.Running;
                                job.Remark = "Job running...";
                                _dataManager.UpdateProcessJob(connectionString, job);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteErrorLog(ex);
                }
            }
        }
Esempio n. 2
0
        public static bool Install()
        {
            CustomServiceInstaller si = new CustomServiceInstaller();

            if (si.InstallService(Assembly.GetExecutingAssembly().Location + " -service", UO98Service.UniqueServiceName, "UO:98 Ultima Online Server", true))
            {
                Console.WriteLine("The {0} service has been installed.", UO98Service.UniqueServiceName);
                return(true);
            }
            else
            {
                Console.WriteLine("An error occurred during service installation.");
                return(false);
            }
        }
        /// <summary>
        /// This method is used to actually install the service.  The service is installed with the 
        /// specified dependency included.  If the dependency parameter is null, no dependency is
        /// created.
        /// </summary>
        /// <param name="customInstaller">The installer object.</param>
        /// <param name="dependencies">The specified dependency.</param>
        static void Install(CustomServiceInstaller customInstaller, string dependencies)
        {
            //	Make sure that the service does not already exist as an installed service
            //if (customInstaller.DoesServiceExists(WindowsServiceConstants.SERVICE_NAME) == false)
            if (customInstaller.DoesServiceExists(ServiceName) == false)
            {
                //	Build the path to the executable
                var sServiceExe = Environment.CurrentDirectory + "\\" + WindowsServiceConstants.SERVICE_EXECUTABLE;

                //	Attempts to install the service.
                var bSuccess = customInstaller.InstallService(sServiceExe, ServiceName, DisplayName, ServiceDescription,
                    CustomServiceInstaller.SERVICE_START_TYPE.SERVICE_AUTO_START,
                    dependencies);

                if (bSuccess == false)
                    throw new Exception("Unable to install the service successfully.");
            }
            else
                throw new Exception("The service already exists as an installed service.");
        }