public static void OnContractToBeCompleted(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 = "Vertrag vervollstaendigen";
                tempTask.TaskType = TaskTypes.VertragVervollstaendigen;
                tempTask.Contract = contract;
                tempTask.User = contract.Dispatcher;
                tempTask.IsDone = false;

                tempTask.DateCreated = DateTime.Now;

                //for Testing only - for Real App uncomment the Line after
                tempTask.Expiring = DateTime.Now.AddMinutes(Constants.LAUFZEIT_DISPATCHERTASK_MINUTEN_TEST);
                //tempTask.Expiring = DateTime.Now.AddDays(Constants.LAUFZEIT_DISPATCHERTASK_TAGE);

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

                //take care that the task gets removed
                tempTask.TriggerTaskCreatedEvent();

                System.Diagnostics.Debug.WriteLine("<Vertrag vervollstaendigen> Aufgabe erstellt");
            }
        }
Example #2
0
        public static void NotifyTaskOwner(ContractTask task)
        {
            dynamic email = new Email("NotificationMail");
            email.to = task.User.Email;
            email.from = applicationEmail;

            email.Send();
        }
Example #3
0
        public static void NotifyOnEscalation(ContractTask task, string contractOwnerEmail)
        {
            dynamic email = new Email("EscalationMail");
            email.to = contractOwnerEmail;
            email.from = applicationEmail;

            email.Send();
        }
Example #4
0
        //DAVID TaskTest *************************************************************************************
        public static void OnDispatcherNeeded(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 = "Dispatcher hinzufuegen";
                tempTask.TaskType = TaskTypes.DispatcherZuweisen;
                tempTask.Contract = contract;
                tempTask.User = contract.Owner;
                tempTask.IsDone = false;

                tempTask.DateCreated = DateTime.Now;

                tempTask.NotificationDate = DateTime.Now.AddSeconds(Constants.LAUFZEIT_DISPATCHERTASK_SEKUNDEN_TEST);
                tempTask.EscalationDate = DateTime.Now.AddSeconds(Constants.LAUFZEIT_DISPATCHERTASK_SEKUNDEN_TEST * 2);

                //for Testing only - for Real App uncomment the Line after
                tempTask.Expiring = DateTime.Now.AddMinutes(Constants.LAUFZEIT_DISPATCHERTASK_MINUTEN_TEST);
                //tempTask.Expiring = DateTime.Now.AddDays(Constants.LAUFZEIT_DISPATCHERTASK_TAGE);

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

                tempTask.TriggerTaskCreatedEvent();

                System.Diagnostics.Debug.WriteLine("<Dispatcher zuweisen> Aufgabe erstellt");
            }
        }
Example #5
0
        public static void OnFilesToBeAdded(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
            var contractForDbCheck = db.Contracts.Find(contract.Id);

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

                //The dispatcher has to be loaded here because the nav property is not set at this point yet
                ContractUser dispatcher = db.Users.Find(contract.DispatcherId);

                tempTask.Description = "Dokument hochladen";
                tempTask.TaskType = TaskTypes.DokumenteHochladen;
                tempTask.Contract = contractForDbCheck;
                tempTask.User = dispatcher;
                tempTask.IsDone = false;

                tempTask.DateCreated = DateTime.Now;

                tempTask.NotificationDate = DateTime.Now.AddSeconds(Constants.LAUFZEIT_DISPATCHERTASK_SEKUNDEN_TEST);
                tempTask.EscalationDate = DateTime.Now.AddSeconds(Constants.LAUFZEIT_DISPATCHERTASK_SEKUNDEN_TEST * 2);

                //for Testing only - for Real App uncomment the Line after
                tempTask.Expiring = DateTime.Now.AddMinutes(Constants.LAUFZEIT_DISPATCHERTASK_MINUTEN_TEST);
                //tempTask.Expiring = DateTime.Now.AddDays(Constants.LAUFZEIT_DISPATCHERTASK_TAGE);

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

                //take care that the task gets removed
                tempTask.TriggerTaskCreatedEvent();

                System.Diagnostics.Debug.WriteLine("<Datein hochladen> Aufgabe erstellt");
            }
        }