예제 #1
0
 public bool StartWorkPeriod(string description)
 {
     using (var w = WorkspaceFactory.Create())
     {
         using (var tran = w.BeginTransaction())
         {
             try
             {
                 _workPeriodDao.StartWorkPeriod(description, w);
                 foreach (var workPeriodProcessor in WorkPeriodProcessors)
                 {
                     workPeriodProcessor.ProcessWorkPeriodStart(CurrentWorkPeriod);
                 }
                 if (tran != null)
                 {
                     tran.Commit();
                 }
             }
             catch (Exception e)
             {
                 if (tran != null)
                 {
                     tran.Rollback();
                 }
                 _logService.LogError(e);
                 return(false);
             }
         }
     }
     _applicationStateSetter.ResetWorkPeriods();
     return(true);
 }
예제 #2
0
        public void StartWorkPeriod(string description, decimal cashAmount, decimal creditCardAmount, decimal ticketAmount)
        {
            using (var workspace = WorkspaceFactory.Create())
            {
                _applicationStateSetter.ResetWorkPeriods();

                var latestWorkPeriod = workspace.Last <WorkPeriod>();
                if (latestWorkPeriod != null && latestWorkPeriod.StartDate == latestWorkPeriod.EndDate)
                {
                    return;
                }

                var now       = DateTime.Now;
                var newPeriod = new WorkPeriod
                {
                    StartDate        = now,
                    EndDate          = now,
                    StartDescription = description,
                    CashAmount       = cashAmount,
                    CreditCardAmount = creditCardAmount,
                    TicketAmount     = ticketAmount
                };

                workspace.Add(newPeriod);
                workspace.CommitChanges();
                _applicationStateSetter.ResetWorkPeriods();
            }
        }
예제 #3
0
 public void StartWorkPeriod(string description)
 {
     _applicationStateSetter.ResetWorkPeriods();
     _workPeriodDao.StartWorkPeriod(description);
     _applicationStateSetter.ResetWorkPeriods();
 }