public static void UpdateTimeEvent(TimeEventModel timeEvent) { string sql = @"UPDATE OR IGNORE TimeEvents SET EventType=@EventType, ArrivalTime=@ArrivalTime, WaitTime=@WaitTime, ServiceTemplateId=@ServiceTemplateId, LocationId=@LocationId, [Order]=@Order WHERE Id=@Id"; SQLiteData.SaveData <dynamic>(sql, new { timeEvent.EventType, timeEvent.ArrivalTime, timeEvent.WaitTime, timeEvent.ServiceTemplateId, timeEvent.LocationId, timeEvent.Order, timeEvent.Id }, SQLiteData.GetConnectionString()); }
public void SaveTimeEvent() { TimeEventModel newTimeEvent = new TimeEventModel(); newTimeEvent.EventType = TimeType; newTimeEvent.ArrivalTime = ArrivalTime; newTimeEvent.WaitTime = WaitTime; newTimeEvent.LocationId = Location.Id; newTimeEvent.Order = Order; newTimeEvent.ServiceTemplateId = ServiceId; if (TimeEventId <= 0) { TimeEventDataAccess.InsertTimeEventForServiceTemplate(newTimeEvent); } else { newTimeEvent.Id = TimeEventId; TimeEventDataAccess.UpdateTimeEvent(newTimeEvent); } var temp = FullTimeEventDataAccess.GetAllFullTimeEventsPerServiceTemplate(ServiceId) .OrderBy(p => p.Order) .ToList(); TimeEvents.FilteredFullTimeEventList = new BindableCollection <FullTimeEventModel>(temp); UpdateCalculatedDuration(); NotifyOfPropertyChange(() => TimeEvents); ClearTimeEvent(); }
public void Init(BaseToken[] tokens) { state = FightRoomState.Init; //添加字典 foreach (var item in tokens) { string name = UserCache.Ins.GetDALByToken(item).name; tokenToUserDTO.Add(item, LoginManager.Ins.GetDTO(name)); } string[] pos_str = AppSetting.Ins.GetValue("pos").Split(';', StringSplitOptions.RemoveEmptyEntries); //初始化 模型数据(只有玩家) for (int i = 0; i < tokens.Length; i++) { BaseToken t = tokens[i]; BaseModelData data = BaseModelDataFactory.GetDataByID(1); string[] p = pos_str[i].Split('_'); Vector3Ex pos = new Vector3Ex(int.Parse(p[0]), int.Parse(p[1]), int.Parse(p[2])); BaseModel model = new BaseModel(i + 1, 1, tokenToUserDTO[t].name, data, pos, Vector3Ex.Zero);//位置什么的都应该读表 tokenToModelID.Add(t, model.id); baseModelDic.Add(model.id, model); } updateModel = new TimeEventModel(deltaTime, -1, Update); //TimeEventHandler.Ins.AddEvent(new TimeEventModel(300, 1, CreateDragon)); TimeEventHandler.Ins.AddEvent(updateModel); state = FightRoomState.Ready; //发送房间数据 Broadcast(tokenToUserDTO.Keys.ToList(), 1003002, 0, GetDTO()); }
public void SaveTimeEvents() { foreach (var item in FullTimeEventsList) { if (item.EventType?.Length > 0) { var timeEvent = new TimeEventModel(); timeEvent.Id = item.Id; timeEvent.EventType = item.EventType; timeEvent.ArrivalTime = item.ArrivalTime; timeEvent.WaitTime = item.WaitTime; timeEvent.LocationId = item.LocationId; timeEvent.ServiceTemplateId = item.ServiceTemplateId; timeEvent.Order = item.Order; if (item.Id > 0) { timeEvent.Id = item.Id; TimeEventDataAccess.UpdateTimeEvent(timeEvent); } else { TimeEventDataAccess.InsertTimeEventForServiceTemplate(timeEvent); } } } int duration = FullTimeEventsList.Sum(x => x.ArrivalTime + x.WaitTime); SelectedServiceTemplate.CalculatedDuration = duration; ServiceTemplateDataAccess.UpdateServiceCalculatedDuration(duration, SelectedServiceTemplate.Id); ServiceTemplateUI.ServiceTemplateList.Refresh(); FullTimeEventsList = new BindableCollection <FullTimeEventModel>(FullTimeEventDataAccess.GetAllFullTimeEventsPerServiceTemplate(SelectedServiceTemplate.Id)); Log.Trace($"Time events for service {SelectedServiceTemplate.ServiceTemplateAbbreviation} saved", LogEventType.Event); }
public static int InsertTimeEventForServiceTemplate(TimeEventModel timeEvent) { string sql = @"INSERT OR IGNORE INTO TimeEvents (EventType, ArrivalTime, WaitTime, ServiceTemplateId, LocationId, [Order]) VALUES(@EventType, @ArrivalTime, @WaitTime, @ServiceTemplateId, @LocationId, @Order)"; return(SQLiteData.SaveData <dynamic>(sql, new { timeEvent.EventType, timeEvent.ArrivalTime , timeEvent.WaitTime, timeEvent.ServiceTemplateId, timeEvent.LocationId, timeEvent.Order } , SQLiteData.GetConnectionString())); }
// TODO check if this works, maybe markup must be more configurable // his intial setup uses a two line approach. public static string TimeEventToString(int startTime, TimeEventModel timeEvent) { var output = $"{MinutesToString(startTime+timeEvent.ArrivalTime)}"; if (timeEvent.WaitTime > 0) { output += $" A\n{MinutesToString(startTime+timeEvent.ArrivalTime+timeEvent.WaitTime)} D"; } return(output); }
private void ImportTimeEvents(string[] fields) { var timeEvent = new TimeEventModel(); timeEvent.Id = int.Parse(fields[1]); timeEvent.EventType = fields[2]; timeEvent.ArrivalTime = int.Parse(fields[3]); timeEvent.WaitTime = int.Parse(fields[4]); var oldServiceId = int.Parse(fields[5]); timeEvent.ServiceTemplateId = ServiceTemplateKeys.GetValueOrDefault(oldServiceId, 0); var oldLocationid = int.Parse(fields[6]); timeEvent.LocationId = LocationKeys.GetValueOrDefault(oldLocationid, 0); timeEvent.Order = int.Parse(fields[7]); TimeEventDataAccess.InsertTimeEventForServiceTemplate(timeEvent); }
async void Handle() { running = true; if (getKLineData == null) { getKLineData = new TimeEventModel(1.25f, -1, () => { #if DEBUG GetKLineValue(true); #else GetKLineValue(false); #endif }); } TimeEventHandler.Ins.RemoveEvent(getKLineData); TimeEventHandler.Ins.AddEvent(getKLineData); }