Ejemplo n.º 1
0
        public void CreateAllJobs(QuartzServer server)
        {
            try
            {
                #region INSERT NF DB
                var dictionary = new Dictionary <String, DateTime>();
                dictionary.Add("DataVenda", DateTime.Today);

                var jobContaWifi = Quartz.JobBuilder.Create()
                                   .OfType(typeof(XMLRead))
                                   .StoreDurably(true)
                                   .WithDescription("Job NFe Insert DB ")
                                   .WithIdentity(new JobKey("Job NFe Insert DB", "main"))
                                   .Build();

                //executa a cada 4 minutos
                var triggerContasWifi = TriggerBuilder.Create()
                                        .ForJob(jobContaWifi)
                                        .UsingJobData(new JobDataMap(dictionary))
                                        .UsingJobData("SyncCompleto", false)
                                        .UsingJobData("QtdeItensEnvio", 10000)
                                        .UsingJobData("SyncPeriodo", false)
                                        .WithCronSchedule("	0 0/4 * 1/1 * ? *")
                                        .StartNow()
                                        .Build();

                server.AddTrigger(jobContaWifi, triggerContasWifi);

                #endregion
            }
            catch (Exception ex)
            {
                System.IO.File.WriteAllText(@"c:\temp\Service.txt", string.Format("Falha ao iniciar servidor Quartz. {0}.", ex.ToString()));
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            server.QuartzServer quartzServer;

            try
            {
                quartzServer = new server.QuartzServer();
                quartzServer.StartServer();
                new server.JobCreator().CreateAllJobs(quartzServer);

                System.IO.File.AppendAllText(@"c:\temp\Service.txt", string.Format(@"Serviço de sincronizãção iniciado em {0}.", DateTime.Now.ToString("dd/MM hh:mm:ss")));
            }
            catch (Exception ex)
            {
                System.IO.File.AppendAllText(@"c:\temp\Service.txt", string.Format("Falha ao iniciar o serviço. {0}.", ex.ToString()));
                Console.WriteLine("Falha ao iniciar o serviço. {0}.", ex.ToString());
            }

            //new XMLRead().DeserializeXML();
        }