private static string GetThirdRowLampStates(TimeDto time) { var minutesSinceMidnight = time.Minutes; int fiveMinutesCount = minutesSinceMidnight / LampWeight; var states = new List <string>(); for (int index = 1; index <= ThirdRowLampsCount; index++) { var lampState = index <= fiveMinutesCount ? YellowLight : NoLight; if ((index == 3 || index == 6 || index == 9) && lampState == YellowLight) { lampState = RedLight; } states.Add(lampState); } var lampStates = string.Join(string.Empty, states); var lampStatesWithYellowColor = GetLampStates(fiveMinutesCount, ThirdRowLampsCount, YellowLight); var lampStatesWithYellowAndRedColor = AddRedColorToYellowLampStates(lampStatesWithYellowColor, ThirdRowLampsCount); return(lampStatesWithYellowAndRedColor); }
public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> viewModelState) { if (e.Parameter == null) { Time = new TimeDto(); } }
public IActionResult Create(TimeDto dto) { using var db = new ModelContext(); var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; var date = DateTime.Now; var time = new Time { UserId = userId, TaskId = dto.TaskId, WorkDate = dto.WorkDate, Hours = dto.Hours, Comment = dto.Comment, Location = dto.Location, BillableTypeId = dto.BillableTypeId, CreatedById = userId, DateCreated = date, LastModifiedById = userId, DateLastModified = date, Deleted = false }; db.Time.Add(time); return(Ok(db.SaveChanges())); }
public async Task <bool> CriarTime(TimeDto time) { var json = JsonConvert.SerializeObject(time); var httpContent = new StringContent(json, Encoding.UTF8, "application/json"); var result = await _httpClient.PostAsync(Api.BASE_URL + Api.TIMES_URL, httpContent); return(result.IsSuccessStatusCode); }
private static string GetTopLampState(TimeDto time) { var secondsSinceMidnight = time.Seconds; var lampState = (secondsSinceMidnight % 2 == 0) ? YellowLight : NoLight; return(lampState); }
/// <summary> /// 开始计时广播处理 /// </summary> /// <param name="timeDto"></param> private void startTimingBro(TimeDto timeDto) { //计算经服务器延迟之后还有多长时间 long time = timeDto.time - (DateTime.Now.Ticks - timeDto.timeStamp); Debug.Log(time); timeDto.Change(timeDto.Id, time, timeDto.timeStamp); Dispatch(AreaCode.UI, UIEvent.SHOW_TIMER_PANEL, timeDto); }
private static string GetSecondRowLampStates(TimeDto time) { var hoursSinceMidnight = time.Hours; int oneHoursCount = hoursSinceMidnight % LampWeight; var lampStates = GetLampStates(oneHoursCount, SecondRowLampsCount, RedLight); return(lampStates); }
private static string GetForthRowLampStates(TimeDto time) { var minutesSinceMidnight = time.Minutes; int oneMinutesCount = minutesSinceMidnight % LampWeight; var lampStates = GetLampStates(oneMinutesCount, FourthRowLampsCount, YellowLight); return(lampStates); }
private static string GetFirstRowLampStates(TimeDto time) { var hoursSinceMidnight = time.Hours; int fiveHoursCount = hoursSinceMidnight / LampWeight; var lampStates = GetLampStates(fiveHoursCount, FirstRowLampsCount, RedLight); return(lampStates); }
public TimeDto ParseTime(string time) { var timeFractions = time.Split(FractionsSeparator); var timeDto = new TimeDto { Hours = ConvertTimeFractionToInt(timeFractions[0]), Minutes = ConvertTimeFractionToInt(timeFractions[1]), Seconds = ConvertTimeFractionToInt(timeFractions[2]) }; return(timeDto); }
// [AuthFilter]//身份认证,不带token或者token错误会被拦截器拦截进不来这个接口 public IActionResult GetMongoDB(DateTime StartTime, DateTime EndTime, int Skip, int limit) { DBRequestLogs _logs = new DBRequestLogs(); var list = _logs.Get(StartTime, EndTime, Skip, limit).GroupBy(x => x.ApiName.Split("?")[0]); Dictionary <string, Dictionary <DateTime, int> > Time = new Dictionary <string, Dictionary <DateTime, int> >(); foreach (var item in list) { foreach (var Citem in item.GroupBy(x => x.CreateTime.Day)) { TimeDto timeDto = new TimeDto() { DateTime = Citem.Key, Count = Citem.Count() }; List <TimeDto> ChangeTiem = new List <TimeDto>(); ChangeTiem.Add(timeDto); Time.Add(item.Key + Citem.Key, SequenceID.CompletionTime(StartTime, EndTime, ChangeTiem)); } } return(Ok(new ApiResponse(Time, Time.Count()))); }
public IActionResult Edit(TimeDto dto) { using var db = new ModelContext(); var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; var date = DateTime.Now; var time = db.Time.Find(dto.Id); time.TaskId = dto.TaskId; time.WorkDate = dto.WorkDate; time.Hours = dto.Hours; time.Comment = dto.Comment; time.Location = dto.Location; time.BillableTypeId = dto.BillableTypeId; time.LastModifiedById = userId; time.DateLastModified = date; return(Ok(db.SaveChanges())); }
public string GetClockState(TimeDto timeDto) { var topLampState = GetTopLampState(timeDto); var firstRowLampStates = GetFirstRowLampStates(timeDto); var secondRowLampStates = GetSecondRowLampStates(timeDto); var thirdRowLampStates = GetThirdRowLampStates(timeDto); var forthRowLampStates = GetForthRowLampStates(timeDto); var clockState = $"{topLampState}{LineBreak}" + $"{firstRowLampStates}{LineBreak}" + $"{secondRowLampStates}{LineBreak}" + $"{thirdRowLampStates}{LineBreak}" + $"{forthRowLampStates}"; return(clockState); }
public async Task Edit(TimeDto dto) { await http.PostAsJsonAsync("api/time/edit", dto); }
public async Task Create(TimeDto dto) { await http.PostAsJsonAsync("api/time/create", dto); }
public async Task <IActionResult> Add(TimeDto time) { var result = await _dataBase.AddTimeAsync(time); return(Ok(result)); }
public override void Execute(int eventCode, object message) { switch (eventCode) { case UIEvent.PLAYER_HIDE_STATE: { txtReady.gameObject.SetActive(false); } break; case UIEvent.PLAYER_READY: { if (userDto == null) { break; } int userId = (int)message; //如果是自身角色 就显示 if (userDto.Id == userId) { ReadyState(); } break; } case UIEvent.PLAYER_LEAVE: { if (userDto == null) { break; } int userId = (int)message; if (userDto.Id == userId) { setPanelActive(false); } break; } case UIEvent.PLAYER_ENTER: { if (userDto == null) { break; } int userId = (int)message; if (userDto.Id == userId) { setPanelActive(true); SetName(userDto.Name); //Debug.Log("statePanelEnter"); } break; } case UIEvent.PLAYER_CHAT: { if (userDto == null) { break; } ChatMsg msg = message as ChatMsg; if (userDto.Id == msg.UserId) { showChat(msg.Text); } break; } case UIEvent.PLAY_CHANGE_IDENTITY: { if (userDto == null) { break; } int userId = (int)message; if (userDto.Id == userId) { setIdentity(1); } break; } case UIEvent.SHOW_TIMER_PANEL: { if (userDto == null) { break; } TimeDto timeDto = message as TimeDto; if (userDto.Id == timeDto.Id) { ShowTimer(timeDto.time); } break; } case UIEvent.HIDE_TIMER_PANEL: { if (userDto == null) { break; } int userId = (int)message; if (userDto.Id == userId) { setTimerActive(false); } break; } default: break; } }
private void HandleTimeMessage(TimeDto time) { CurrentTrack.Duration = time.Total; CurrentTrack.CurrentTime = time.Current; TimeUpdated?.Invoke(this, new TimeUpdatedEventArgs(CurrentTrack.Duration, CurrentTrack.CurrentTime)); }