Exemple #1
0
        public void AssociateChangeHandle()
        {
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    var fields = _scheduleParamsHandler.ConvertToObject();
                    ViewModel.ScheduledTaskViewModel previousTask = null;
                    foreach (var item in fields)
                    {
                        //if (ValidateAssociateScheduleField(item.Field))
                        //{
                        //    _associateRepository.UpdateScheduleField(item.AssId, item.Field, item.Value);
                        //}
                        //else
                        //{
                        //    throw new SchedulerException(item.Field + "is not scheduling property, please make sure field has SchedulerEnabled attribute.");
                        //}
                        _associateRepository.UpdateScheduleField(item.AssId, item.Field, item.Value);
                        ViewModel.ScheduledTaskViewModel task = null;

                        if (previousTask == null)
                        {
                            task         = this._associateRepository.GetTask(item.TaskId);
                            previousTask = task;
                        }
                        else if (previousTask.TaskId != item.TaskId)
                        {
                            task         = this._associateRepository.GetTask(item.TaskId);
                            previousTask = task;
                        }
                        if (previousTask.StartDate.AddMinutes(5) < DateTime.Now)
                        {
                            this._associateRepository.BackDateAssociateChanges(item.AssId, item.Field, item.Value, item.TaskId);
                        }
                    }

                    scope.Complete();
                    Result = true;
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }