Exemplo n.º 1
0
        public static void OnTaskCreated(object source, EventArgs e)
        {
            //make sure that task is removed on expiration date
            ContractTask tempTask = (ContractTask)source;

            //Call the Scheduler Singleton and Instantiate the job
            IScheduler scheduler = Scheduler.Instance();
            IJobDetail job       = JobBuilder.Create <RemoveTask>().Build();

            //Pass the Id of the task to the job for deleting it
            job.JobDataMap["TaskId"] = tempTask.Id;

            scheduler.ScheduleJob(job, Triggers.GetTriggerAtDate((DateTime)tempTask.Expiring));
        }
Exemplo n.º 2
0
        public void Execute(IJobExecutionContext context)
        {
            System.Diagnostics.Debug.WriteLine("Aufgabe wird geloescht ");

            JobDataMap dataMap = context.JobDetail.JobDataMap;

            int taskKey = dataMap.GetInt("TaskId");

            MyDbContext db = new MyDbContext();

            ContractTask task = db.ContractTasks.Find(taskKey);

            db.ContractTasks.Remove(task);
            db.SaveChanges();

            System.Diagnostics.Debug.WriteLine("Aufgabe wurde geloescht ");
        }
Exemplo n.º 3
0
        //------------------------------- General Events ---------------------------------------

        public static void OnTaskDone(object source, EventArgs e)
        {
            //when task is marked as done schedule the remove process some time after
            ContractTask tempTask = (ContractTask)source;

            System.Diagnostics.Debug.WriteLine("Aufgabe " + tempTask.TaskType.ToString() + " wird bald geloescht");

            //Call the Scheduler Singleton and Instantiate the job
            IScheduler scheduler = Scheduler.Instance();
            IJobDetail job       = JobBuilder.Create <RemoveTask>().Build();

            //Pass the Id of the task to the job for deleting it
            job.JobDataMap["TaskId"] = tempTask.Id;

            //for Testing only - for Real App uncomment the Line after
            scheduler.ScheduleJob(job, Triggers.GetTriggerWithSecondOffset(Constants.LAUFZEIT_ERLEDIGTER_VERTRAG_SICHTBAR_SEKUNDEN_TEST));
            //scheduler.ScheduleJob(job, Triggers.GetTriggerWithSecondOffset(Constants.LAUFZEIT_ERLEDIGTER_VERTRAG_SICHTBAR_TAGE));
        }
Exemplo n.º 4
0
        //DAVID TaskTest *************************************************************************************
        public static void OnTestEvent(object source, EventArgs e)
        {
            MyDbContext db = new MyDbContext();

            var contract = (Contract)source;

            //Get contract from db to check wheter the saving worked and the status is set
            contract = db.Contracts.Find(contract.Id);

            if (contract != null && contract.ContractStatus.Id == 1)
            {
                var tempTask = new ContractTask();

                tempTask.Description = "tolle Aufgabe";
                tempTask.TaskType    = TaskTypes.DispatcherZuweisen;
                tempTask.Contract    = contract;
                tempTask.User        = contract.Owner;

                tempTask.DateCreated = DateTime.Now;
                tempTask.Expiring    = DateTime.Now.AddSeconds(30);

                db.ContractTasks.Add(tempTask);
                db.SaveChanges();

                System.Diagnostics.Debug.WriteLine("Aufgabe erstellt");

                //Call the Scheduler Singleton and Instantiate the job
                IScheduler scheduler = Scheduler.Instance();
                IJobDetail job       = JobBuilder.Create <TestJob>().Build();

                //Pass the Id of the task to the job for deleting it
                job.JobDataMap["TaskId"] = tempTask.Id;

                scheduler.ScheduleJob(job, Triggers.GetTriggerAtDate((DateTime)tempTask.Expiring));
            }
        }