Beispiel #1
0
        public int Add(Period period)
        {
            try
            {
                Period newPeriod = base.Add(period);
                if (newPeriod != null && newPeriod.Id > 0)
                {
                    CurrentPeriod currentPeriod = new CurrentPeriod();
                    currentPeriod.Period = newPeriod;
                    currentPeriodLogic.Modify(currentPeriod);
                }

                //int newPeriodId = periodDb.InsertPeriod(period.Name, period.Status.Id, period.Type, period.Span, period.StartDate, period.EndDate, transaction);
                //if (newPeriodId > 0)
                //{
                //    if (currentPeriodDbFacade.Add(newPeriodId, transaction))
                //    {
                //        return newPeriodId;
                //    }
                //}

                return(newPeriod.Id);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Starts next period
        /// </summary>
        /// <returns>this</returns>
        public Match StartPeriod()
        {
            if (!IsValid())
            {
                return(this);
            }

            ResetTimeouts();
            CurrentPeriod = CurrentPeriod.Increment(TotalPeriodsInMatch);
            State         = MatchState.PlayInProgress;
            IsBallInPlay  = true;
            return(this);
        }
Beispiel #3
0
 public void SetCurrent(CurrentPeriod period)
 {
     try
     {
         service = new ServiceClient();
         service.SetNewCurrentPeriodCompleted += new EventHandler <SetNewCurrentPeriodCompletedEventArgs>(service_SetNewCurrentPeriodCompleted);
         service.SetNewCurrentPeriodAsync(period);
         service.CloseAsync();
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #4
0
        public override string ToString()
        {
            var formatter = "{0,15}: {1,2}{5,2}{2,2} :{3,-15} {4}";
            var result    = "";

            if (Complete)
            {
                result += " Final";
            }
            else
            {
                result += " " + CurrentPeriod.DisplayWithSuffix();
            }

            return(string.Format(formatter, Home.Name, HomeScore, AwayScore, Away.Name, result, "-"));
        }
        private void OnSetCurrentPeriodCommand()
        {
            try
            {
                if (Period == null || Period.Id == 0)
                {
                    Utility.DisplayMessage("Please specify period!");
                    return;
                }

                //CurrentPeriod = Period;

                CurrentPeriod currentPeriod = new CurrentPeriod();
                currentPeriod.Period = Period;

                SetCurrentPeriodCompleted();
                currentPeriodService.SetCurrent(currentPeriod);
            }
            catch (Exception ex)
            {
                Utility.DisplayMessage(ex.Message);
            }
        }
Beispiel #6
0
 void _timer_Tick(object sender, EventArgs e)
 {
     CurrentPeriod.SaveTmpPeriod();
 }
    public void Process(int newValue)
    {
        switch (CurrentEngineStatus)
        {
        case EngineStatus.NoProfitPeriod:
        {
            if (CurrentPeriod.Process(newValue) == PeriodStatus.Closed)
            {
                //Refine further - Compare Before Override
                //PreviousPeriod = CurrentPeriod;
                historicalPeriods.Add(CurrentPeriod);
                CurrentEngineStatus = EngineStatus.OneProfitPeriod;
                PreviousBestPeriod  = new ProfitPeriod()
                {
                    PeriodLow = CurrentPeriod.PeriodLow, PeriodHigh = CurrentPeriod.PeriodHigh
                };
                CurrentPeriod = new ProfitPeriod();
                CurrentPeriod.Process(newValue);
            }
            ;

            break;
        }

        case EngineStatus.OneProfitPeriod:
        {
            if (CurrentPeriod.Process(newValue) == PeriodStatus.Closed)
            {
                //Refine further - Compare Before Override
                if (PreviousBestPeriod.Gain < CurrentPeriod.Gain)
                {
                    //replace previous best period
                    PreviousBestPeriod = new ProfitPeriod()
                    {
                        PeriodLow = CurrentPeriod.PeriodLow, PeriodHigh = CurrentPeriod.PeriodHigh
                    };
                }
                ;
                historicalPeriods.Add(CurrentPeriod);
                CurrentEngineStatus = EngineStatus.MoreThanOnePeriod;
                CurrentPeriod       = new ProfitPeriod();
                CurrentPeriod.Process(newValue);
            }
            ;
            break;
        }

        case EngineStatus.MoreThanOnePeriod:
        {
            if (CurrentPeriod.Process(newValue) == PeriodStatus.Closed)
            {
                //Compare Before Override
                //potentially keep a SecondBestPeriod
                if (PreviousBestPeriod.Gain < CurrentPeriod.Gain)
                {
                    //replace previous best period
                    PreviousBestPeriod = new ProfitPeriod()
                    {
                        PeriodLow = CurrentPeriod.PeriodLow, PeriodHigh = CurrentPeriod.PeriodHigh
                    };
                }
                ;
                historicalPeriods.Add(CurrentPeriod);
                CurrentPeriod = new ProfitPeriod();
                CurrentPeriod.Process(newValue);
            }
            ;
            break;
        }
        }
    }
Beispiel #8
0
 /// <summary>
 /// Starts next period
 /// </summary>
 /// <returns>this</returns>
 public Match StartPeriod()
 {
     CurrentPeriod = CurrentPeriod.Increment(4);
     IsBallInPlay  = true;
     return(this);
 }