Exemple #1
0
        private void AddTileConfig(ConnectionInfo connectionInfo, VRGameSelectorServerDTO.TileConfig tileConfig)
        {
            using (VRArcadeDataAccessModel m = new VRArcadeDataAccessModel())
            {
                VRTileconfig vtc = new VRTileconfig()
                {
                    TileGUID        = tileConfig.TileGUID,
                    TileTitle       = tileConfig.TileTitle,
                    TileHeight      = tileConfig.TileHeight,
                    TileWidth       = tileConfig.TileWidth,
                    TileDesc        = tileConfig.TileDesc,
                    Command         = tileConfig.Command,
                    Arguments       = tileConfig.Arguments,
                    WorkingPath     = tileConfig.WorkingPath,
                    Order           = tileConfig.Order,
                    TileRowNumber   = tileConfig.TileRowNumber,
                    TileConfigSetID = tileConfig.TileConfigSetID,
                    VRTileconfigID  = tileConfig.TileconfigID,
                    ImageData       = tileConfig.TileImage.ImageData,
                    AgeRequire      = tileConfig.AgeRequire,
                    VideoURL        = tileConfig.VideoURL,
                    IsDeleted       = false
                };

                m.Add(vtc);
                m.SaveChanges();
                //m.Cache.Release(m.VRTileconfigs);
            }

            GetTileConfigList(connectionInfo, tileConfig.TileConfigSetID);
        }
Exemple #2
0
        private void ModifyTileConfig(ConnectionInfo connectionInfo, VRGameSelectorServerDTO.TileConfig tileConfig)
        {
            using (VRArcadeDataAccessModel m = new VRArcadeDataAccessModel())
            {
                VRTileconfig vtc = m.VRTileconfigs.Where(x => x.ID == tileConfig.ID).FirstOrDefault();

                if (vtc != null)
                {
                    vtc.TileGUID       = tileConfig.TileGUID;
                    vtc.TileTitle      = tileConfig.TileTitle;
                    vtc.TileHeight     = tileConfig.TileHeight;
                    vtc.TileWidth      = tileConfig.TileWidth;
                    vtc.TileDesc       = tileConfig.TileDesc;
                    vtc.Command        = tileConfig.Command;
                    vtc.Arguments      = tileConfig.Arguments;
                    vtc.WorkingPath    = tileConfig.WorkingPath;
                    vtc.Order          = tileConfig.Order;
                    vtc.TileRowNumber  = tileConfig.TileRowNumber;
                    vtc.VRTileconfigID = tileConfig.TileconfigID;
                    vtc.ImageData      = tileConfig.TileImage.ImageData;
                    vtc.AgeRequire     = tileConfig.AgeRequire;
                    vtc.VideoURL       = tileConfig.VideoURL;

                    m.SaveChanges();
                    //m.Cache.Release(m.VRTileconfigs);
                }
            }

            GetTileConfigList(connectionInfo, tileConfig.TileConfigSetID);
        }
        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);
                }
            }
        }
Exemple #4
0
        private void DeleteTileConfig(ConnectionInfo connectionInfo, VRGameSelectorServerDTO.TileConfig tileConfig)
        {
            using (VRArcadeDataAccessModel m = new VRArcadeDataAccessModel())
            {
                VRTileconfig vtc = m.VRTileconfigs.Where(x => x.ID == tileConfig.ID).FirstOrDefault();

                if (vtc != null)
                {
                    vtc.IsDeleted = true;
                    m.SaveChanges();
                    //m.Cache.Release(m.VRTileconfigs);
                }
            }

            GetTileConfigList(connectionInfo, tileConfig.TileConfigSetID);
        }
Exemple #5
0
        private void GetGamePlayHistory(ConnectionInfo connection, List <ClientParm> clientParm)
        {
            ClientParm cp = clientParm.FirstOrDefault();

            System.IO.StringWriter output = new System.IO.StringWriter();

            if (cp != null)
            {
                using (VRArcadeDataAccessModel m = new VRArcadeDataAccessModel())
                {
                    List <VRClienthistory> lvch = m.VRClienthistories.Where(x => x.VRClientID == cp.ClientID).OrderByDescending(y => y.ID).Take(500).ToList();

                    List <GamePlayHistory> lgph = new List <GamePlayHistory>();

                    foreach (VRClienthistory vch in lvch)
                    {
                        GamePlayHistory gph = new GamePlayHistory();

                        gph.TileID    = vch.TileConfigID;
                        gph.StartTime = vch.StartTime ?? DateTime.MinValue;
                        gph.EndTime   = vch.EndTime ?? DateTime.MinValue;

                        if (vch.TileConfigID != -1)
                        {
                            VRTileconfig vtc = m.VRTileconfigs.Where(x => x.ID == vch.TileConfigID).FirstOrDefault();

                            gph.TileName = (vtc != null) ? vtc.TileTitle : "ERROR!";
                        }
                        else
                        {
                            gph.TileName = "VR Game Selector Interface";
                        }

                        lgph.Add(gph);
                    }

                    VRCommandServer vrc = new VRCommandServer(VRGameSelectorServerDTO.Enums.ControlMessage.GET_GAME_PLAY_HISTORY, lgph);

                    SendCommandToPeer(connection, vrc);
                }
            }
        }
Exemple #6
0
        private void ReorderTileConfig(bool isMovingUp, VRGameSelectorServerDTO.TileConfig tileConfig)
        {
            using (VRArcadeDataAccessModel m = new VRArcadeDataAccessModel())
            {
                VRTileconfig currentVrtc = m.VRTileconfigs.Where(x => x.ID == tileConfig.ID && !x.IsDeleted).ToList().FirstOrDefault();

                List <VRTileconfig> rootLevelVrtcs;
                List <VRTileconfig> sortedRootLevelVrtcs;
                VRTileconfig        targetRootLevelVrtc;

                List <VRTileconfig> sortedSubVrtcs;
                VRTileconfig        targetSubVrtc;

                if (currentVrtc != null)
                {
                    if (tileConfig.TileconfigID == 0)
                    {
                        // root level tile

                        rootLevelVrtcs       = m.VRTileconfigs.Where(x => x.VRTileconfigID == 0 && x.TileConfigSetID == tileConfig.TileConfigSetID && !x.IsDeleted).ToList();
                        sortedRootLevelVrtcs = rootLevelVrtcs.OrderBy(x => x.Order).ToList();

                        if (sortedRootLevelVrtcs.Count > 1)
                        {
                            int posCurrentVrtc = sortedRootLevelVrtcs.IndexOf(currentVrtc);

                            if (posCurrentVrtc > 0 && isMovingUp)
                            {
                                targetRootLevelVrtc = sortedRootLevelVrtcs[posCurrentVrtc - 1];
                                targetRootLevelVrtc.Order++;
                                currentVrtc.Order--;
                            }
                            else if (posCurrentVrtc < sortedRootLevelVrtcs.Count - 1 && !isMovingUp)
                            {
                                targetRootLevelVrtc = sortedRootLevelVrtcs[posCurrentVrtc + 1];
                                targetRootLevelVrtc.Order--;
                                currentVrtc.Order++;
                            }
                        }
                    }
                    else
                    {
                        // sub level tile

                        VRTileconfig parentVrtc = m.VRTileconfigs.Where(x => x.ID == tileConfig.TileconfigID && !x.IsDeleted).ToList().FirstOrDefault();

                        if (parentVrtc != null && parentVrtc.VRTileconfigs.Count > 1)
                        {
                            sortedSubVrtcs = parentVrtc.VRTileconfigs.OrderBy(x => x.Order).ToList();

                            if (sortedSubVrtcs.Count > 1)
                            {
                                int posCurrentVrtc = sortedSubVrtcs.IndexOf(currentVrtc);

                                if (posCurrentVrtc > 0 && isMovingUp)
                                {
                                    targetSubVrtc = sortedSubVrtcs[posCurrentVrtc - 1];
                                    targetSubVrtc.Order++;
                                    currentVrtc.Order--;
                                }
                                else if (posCurrentVrtc < sortedSubVrtcs.Count - 1 && !isMovingUp)
                                {
                                    targetSubVrtc = sortedSubVrtcs[posCurrentVrtc + 1];
                                    targetSubVrtc.Order--;
                                    currentVrtc.Order++;
                                }
                            }
                        }
                    }

                    m.SaveChanges();
                    //m.Cache.Release(m.VRTileconfigs);
                }
            }
        }