public async Task <IActionResult> CreateFitting([FromBody] Fitting fitting)
        {
            try
            {
                if (fitting != null)
                {
                    var response = await SchedulerHandler.InsertFitting(fitting);

                    if (response != null)
                    {
                        return(Ok(response));
                    }
                    else
                    {
                        return(StatusCode(505, new ErrorResponse()
                        {
                            Message = "Error occurred while saving fitting to database, please try again."
                        }));
                    }
                }
                return(StatusCode(408, new ErrorResponse()
                {
                    Message = "Bad Request - Fitting data is null"
                }));
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.ToString());
                return(StatusCode(505, ex.Message));
            }
        }
Beispiel #2
0
        public bool HasScheduler(SchedulerHandler handler)
        {
            bool result = false;

            for (int i = 0; i < _listSchedulerEntity.Count; i++)
            {
                if (_listSchedulerEntity [i].handler == handler)
                {
                    result = true;
                    break;
                }
            }
            if (_isUpdating)
            {
                int count = result ? 1 : 0;
                for (int i = 0; i < _listOperateEntity.Count; i++)
                {
                    if (_listOperateEntity [i].handler == handler)
                    {
                        if (_listOperateEntity [i].state == SchedulerEntityState.ToAdd)
                        {
                            count++;
                        }
                        else if (_listOperateEntity [i].state == SchedulerEntityState.ToRemove)
                        {
                            count--;
                        }
                    }
                }
                result = count > 0;
            }
            return(result);
        }
Beispiel #3
0
        public static void RemoveScheduler(int gameId, SchedulerHandler handler)
        {
            GameRunner runner;

            if (TryGameRunner(gameId, out runner))
            {
                runner.STContainer.Scheduler.RemoveScheduler(handler);
            }
        }
Beispiel #4
0
        public static bool AddScheduler(int gameId, SchedulerHandler handler, float delay, int times = 0)
        {
            GameRunner runner;

            if (TryGameRunner(gameId, out runner))
            {
                return(runner.STContainer.Scheduler.AddScheduler(handler, delay, times));
            }
            return(false);
        }
		public void Init(SchedulerHandler handler,float delay,int times)
		{
			this.Init (handler);
			this.curDelay = 0;
			this.startDelay = 0;
			this.curTimes = 0;
			this.delay = delay;
			this.times = times;
			state = SchedulerEntityState.Init;
		}
Beispiel #6
0
 private void RealRemoveSchedule(SchedulerHandler handler)
 {
     for (int i = _listSchedulerEntity.Count - 1; i >= 0; i--)
     {
         if (_listSchedulerEntity [i].handler == handler)
         {
             SchedulerEntity entity = _listSchedulerEntity [i];
             _listSchedulerEntity.RemoveAt(i);
             _pool.SaveObject(entity);
             break;
         }
     }
 }
Beispiel #7
0
        public bool AddScheduler(SchedulerHandler handler, float delay, int times = 0)
        {
            if (HasScheduler(handler))
            {
                return(false);
            }
            SchedulerEntity entity = _pool.GetObject();

            entity.Init(handler, delay, times);
            if (_isUpdating)
            {
                entity.state = SchedulerEntityState.ToAdd;
                _listOperateEntity.Add(entity);
            }
            else
            {
                entity.state = SchedulerEntityState.ToDoAction;
                _listSchedulerEntity.Add(entity);
            }
            return(true);
        }
Beispiel #8
0
 public void RemoveScheduler(SchedulerHandler handler)
 {
     if (_isUpdating)
     {
         SchedulerEntity entity = _pool.GetObject();
         entity.Init(handler);
         entity.state = SchedulerEntityState.ToRemove;
         _listOperateEntity.Add(entity);
         //有可能当前的scheduleEntity.handler里移除了一个即将调用的scheduleEntity(被移掉的不再执行)
         for (int i = 0; i < _listSchedulerEntity.Count; i++)
         {
             if (_listSchedulerEntity [i].handler == handler)
             {
                 _listSchedulerEntity [i].state = SchedulerEntityState.ToRemove;
             }
         }
     }
     else
     {
         RealRemoveSchedule(handler);
     }
 }
		public void Init(SchedulerHandler handler)
		{
			this.handler = handler;
		}