Beispiel #1
0
        public ActionResult AddOrUpdate(PeriodModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var isCreated = model.Id == Guid.Empty;
            var period    = new Periods();

            if (!isCreated)
            {
                period = PeriodRepository.GetById(model.Id);
            }

            period.Begin = model.Begin;
            period.End   = model.End;
            period.Years = YearRepository.GetById(model.YearId);

            if (isCreated)
            {
                PeriodRepository.Add(period);
            }
            PeriodRepository.Save();

            return(Redirect(Url.Action("Get", "Period", new { id = period.Id })));
        }
Beispiel #2
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var PeriodRepository = new PeriodRepository(new Entities.Entities());
            var period           = PeriodRepository.GetById(PeriodId);

            if (Date < period.Begin || Date > period.End)
            {
                yield return(new ValidationResult("La date doit être comprise dans la période", new string[] { "Date" }));
            }
        }
Beispiel #3
0
        public ActionResult AddOrUpdate(Guid?id)
        {
            var model = new PeriodModel();

            if (id.HasValue)
            {
                model = PeriodModel.ToModel(PeriodRepository.GetById(id.Value));
            }
            return(View(model));
        }
        public void Start(Calculation calculation)
        {
            Task.Factory.StartNew(() =>
            {
                publisher.RegisterHandler(new JobIndexPointPersister());
                using (var transaction = new TransactionScope())
                    using (var reuow = new NHUnitOfWork(RuleEngineSession.GetSession()))
                        using (var uow = new NHUnitOfWork(PMSSession.GetSession()))
                        {
                            var empRep    = new EmployeeRepository(uow);
                            var rebps     = new RuleBasedPolicyEngineService(new LocatorProvider("PMSDb"), publisher);
                            var policyRep = new MITD.PMS.Persistence.NH.PolicyRepository(uow,
                                                                                         new PolicyConfigurator(rebps));
                            var policy    = policyRep.GetById(calculation.PolicyId);
                            var periodRep = new PeriodRepository(uow);
                            var period    = periodRep.GetById(calculation.PeriodId);

                            var jiRep  = new JobIndexRepository(uow);
                            var jpRep  = new JobPositionRepository(uow);
                            var jipRep = new JobIndexPointRepository(uow);
                            var ji     = jiRep.GetAllJobIndex(period.Id).First();
                            var jp     = jpRep.GetJobPositions(period.Id).First();

                            var en = calculation.EmployeeIdList.Select(i => i.EmployeeNo).ToList();
                            IList <Employee> employees = empRep.Find(e => en.Contains(e.Id.EmployeeNo) && e.Id.PeriodId == calculation.PeriodId);
                            foreach (var employee in employees)
                            {
                                if (doStop)
                                {
                                    break;
                                }
                                //var indices = policy.CalculateFor(DateTime.Now, employee, period,calculation,
                                //    new CalculationDataProvider(empRep),publisher, );
                                //publisher.Publish(new JobIndexPointsReady(indices));
                            }

                            reuow.Commit();
                            uow.Commit();
                            transaction.Complete();
                        }
            });
        }
Beispiel #5
0
        private void refreshBalanceStatuskryptonButton_Click(object sender, EventArgs e)
        {
            vendorbalancekryptonDataGridView.Rows.Clear();
            if (m_customer.ID == 0)
            {
                return;
            }
            IList trs = r_sup.GetVendorBalances(m_customer.ID);

            foreach (VendorBalance ev in trs)
            {
                ev.CURRENCY = (Currency)r_ccy.GetById(ev.CURRENCY);
                ev.PERIOD   = (Period)r_per.GetById(ev.PERIOD);
                int r = vendorbalancekryptonDataGridView.Rows.Add();
                vendorbalancekryptonDataGridView[periodVBColumn.Index, r].Value       = ev.PERIOD.CODE;
                vendorbalancekryptonDataGridView[ccyVBColumn.Index, r].Value          = ev.CURRENCY.CODE;
                vendorbalancekryptonDataGridView[balanceVBColumn.Index, r].Value      = ev.BALANCE;
                vendorbalancekryptonDataGridView[periodstatusVBColumn.Index, r].Value = ev.PERIOD.PERIOD_STATUS.ToString();
            }
        }
Beispiel #6
0
        public Period Add(Period period)
        {
            if (period.StartDate.Date <= DateTime.Now.Date)
            {
                throw new ArgumentOutOfRangeException(
                          nameof(period.StartDate),
                          period.StartDate.Date,
                          "Cannot start a period that is less than or equal to the current date.");
            }

            if (period.EndDate.Date <= period.StartDate.Date)
            {
                throw new ArgumentOutOfRangeException(
                          nameof(period.EndDate),
                          period.StartDate.Date,
                          "Period cannot have an end date that is less than or equal to the start date.");
            }

            using (IUnitOfWork unitOfWork = context.CreateUnitOfWork())
            {
                int newPeriodId = periodRepo.Insert(period);
                if (newPeriodId <= 0)
                {
                    throw new FailedOperationException("Failed to insert Period.", period);
                }

                if (period.IsOpen)
                {
                    Period oldPeriod = periodRepo
                                       .Find(x => x.IsOpen)
                                       .FirstOrDefault(y => y.PeriodId != newPeriodId);

                    if (oldPeriod != null)
                    {
                        oldPeriod.IsOpen = false;
                        if (!periodRepo.Update(oldPeriod))
                        {
                            throw new FailedOperationException("Failed to update Period.", oldPeriod);
                        }
                    }

                    IEnumerable <Assignment> assignments = assignmentRepo.Get(null, null, oldPeriod.PeriodId);
                    foreach (Assignment assignment in assignments)
                    {
                        assignment.PeriodId          = newPeriodId;
                        assignment.AttemptCount      = 0;
                        assignment.LastAttemptedBy   = null;
                        assignment.LastAttemptedDate = DateTime.MinValue;
                        assignment.Status            = "Not Called";
                        assignment.Notes             = null;

                        if (assignmentRepo.Insert(assignment) <= 0)
                        {
                            throw new FailedOperationException("Failed to insert Assignment.", assignment);
                        }
                    }
                }

                unitOfWork.SaveChanges();
                return(periodRepo.GetById(newPeriodId));
            }
        }
Beispiel #7
0
 public ActionResult Get(Guid id)
 {
     return(View(PeriodModel.ToModel(PeriodRepository.GetById(id))));
 }