private void ProcessPlayLog(ConnectionInfo connectionInfo, PlayLog playLog) { string ipAdd = ((IPEndPoint)connectionInfo.RemoteEndPoint).Address.MapToIPv4().ToString(); InternalClientStatus iClientStatus = _internalClientStatus.Where(x => x.ClientIP == ipAdd).FirstOrDefault(); if (iClientStatus != null) { int tileID = 0; int.TryParse(playLog.TileID, out tileID); using (VRArcadeDataAccessModel m = new VRArcadeDataAccessModel()) { VRTileconfig vtc = m.VRTileconfigs.Where(x => x.ID == tileID && !x.IsDeleted).FirstOrDefault(); VRClienthistory vrh = new VRClienthistory(); vrh.VRClientID = iClientStatus.ClientID; if (tileID == -1) { vrh.TileConfigID = -1; } else { vrh.TileConfigID = (vtc != null) ? vtc.ID : 0; } if (playLog.SignalType == VRGameSelectorDTO.Enums.PlayLogSignalType.Start) { // start game if (tileID > 0) { string imagePath = (vtc.ImageData.Length > 0) ? vtc.ID.ToString() + ".bmp" : ""; // full path will be decided on client end VRGameSelectorDTO.ImageInfo ii = new VRGameSelectorDTO.ImageInfo(vtc.ImageData); VRGameSelectorDTO.Tile tileConfig = new Tile(vtc.TileHeight, vtc.TileWidth, vtc.TileRowNumber, vtc.ID.ToString(), vtc.TileTitle, imagePath, vtc.TileDesc, vtc.Command, vtc.Arguments, vtc.WorkingPath, ii, vtc.AgeRequire, vtc.VideoURL); iClientStatus.ClientRunningModeSetup.TileConfig = tileConfig; } iClientStatus.ClientRunningModeSetup.CurrentRunningTileID = tileID; vrh.StartTime = DateTime.Now; } else { // end game iClientStatus.ClientRunningModeSetup.CurrentRunningTileID = 0; iClientStatus.ClientRunningModeSetup.TileConfig = null; vrh.EndTime = DateTime.Now; } m.Add(vrh); m.SaveChanges(); //m.Cache.Release(m.VRClienthistories); } } }
// send play log public void SendPlayLog() { PlayLog playLog = new PlayLog("A2", Enums.PlayLogSignalType.Start); VRCommand cmd = new VRCommand(playLog); SendCommandToServer(cmd); }
private void SendPlayLogToServer(string tileID, Enums.PlayLogSignalType signalType) { PlayLog playLog = new PlayLog(tileID, signalType); VRCommand cmd = new VRCommand(playLog); SendCommandToServer(cmd); }
public static bool RemoveEntry(PlayLog __instance, LogEntry entry) { lock (entries(__instance)) { entries(__instance).Remove(entry); } return(false); }
/// <summary> /// send play log to server /// </summary> public void SendPlayLog(Tile tile, Transform trans) { string tileID = tile.TileID; Debug.Log("send PLAY_LOG message to server."); PlayLog playLog = new PlayLog(tileID, Enums.PlayLogSignalType.Start); VRCommand cmd = new VRCommand(playLog); SendCommandToServer(cmd); }
public static bool RemoveEntry(PlayLog __instance, LogEntry entry) { lock (__instance) { List <LogEntry> newEntries = new List <LogEntry>(__instance.entries); newEntries.Remove(entry); __instance.entries = newEntries; } return(false); }
public static bool Add(PlayLog __instance, LogEntry entry) { lock (__instance) { List <LogEntry> newEntries = new List <LogEntry>(__instance.entries); newEntries.Insert(0, entry); while (newEntries.Count > 150) { newEntries.RemoveAt(newEntries.Count - 1); } __instance.entries = newEntries; } return(false); }
// GET api/values/5 public int?Get(string session) { using (BlackJackContext dbContext = new BlackJackContext()) { var model = dbContext.PlayLog.Where(pl => pl.SessionID == session)?.FirstOrDefault(); if (model == null) { PlayLog data = new PlayLog(); data.Cash = 500; data.CreatedDate = DateTime.Now; data.PutCache = 0; data.SessionID = session; data.Win = true; dbContext.PlayLog.Add(data); dbContext.SaveChanges(); } return(model != null ? model.Cash : 500); } }