Beispiel #1
0
 /// <summary>
 /// Создание логики
 /// </summary>
 /// <param name="client">Текущий клиент</param>
 public SimpleViewerComputerLogic(SimpleViewer client, ViewerData data)
     : base(client, data)
 {
 }
Beispiel #2
0
        private void JoinGameCompleted(GameRole role, bool isHost)
        {
            lock (_server.ConnectionsSync)
            {
                var externalServer = _server.HostServer;
                if (externalServer != null)
                {
                    lock (externalServer.ClientsSync)
                    {
                        externalServer.Clients.Add(NetworkConstants.GameName);
                    }
                }
                else
                {
                    Error = Resources.RejoinError;
                    if (_host != null)
                    {
                        _host.Dispose();
                    }

                    return;
                }
            }

            var humanPlayer = Human;
            var name        = humanPlayer.Name;

            var data = new ViewerData
            {
                BackLink          = BackLink.Default,
                ServerPublicUrl   = PackagesPublicBaseUrl,
                ContentPublicUrls = ContentPublicBaseUrls,
                ServerAddress     = ServerAddress
            };

            var localizer = new Localizer(Thread.CurrentThread.CurrentUICulture.Name);

            switch (role)
            {
            case GameRole.Showman:
                _host = new Showman(_client, humanPlayer, isHost, localizer, data);
                break;

            case GameRole.Player:
                _host = new Player(_client, humanPlayer, isHost, localizer, data);
                break;

            default:
                _host = new SimpleViewer(_client, humanPlayer, isHost, localizer, data);
                break;
            }

            _host.Avatar = _avatar;

            _host.Connector = new ReconnectManager(_server, _client, _host, humanPlayer, role, GetExtraCredentials(), IsOnline)
            {
                ServerAddress = ServerAddress
            };

            if (_host.Client.Name != name)
            {
                _host.Rename(name);
            }

            _host.Client.ConnectTo(_server);

            _releaseServer = false;
            if (!isHost && Ready != null)
            {
                Ready(_server, _host, IsOnline); // Здесь происходит переход к игре
            }

            if (_connector != null)
            {
                _connector.Dispose();
                _connector = null;
            }

            ClearConnection();

            _host.GetInfo();

            Error = null;

            _server.Error += Server_Error;
        }
Beispiel #3
0
        private GenericReply GetViewerData()
        {
            // You can specify the Catalog, Schema, Table Name, Table Type to get
            // the specified table(s).
            // You can use four restrictions for Table, so you should create a 4 members array.
            String[] tableRestrictions = new String[4];

            // For the array, 0-member represents Catalog; 1-member represents Schema;
            // 2-member represents Table Name; 3-member represents Table Type.
            // Now we specify the Table Name of the table what we want to get schema information.
            tableRestrictions[2] = "Rooms";

            using (var conn = new System.Data.SqlClient.SqlConnection(@"Data Source=.\SQLEXPRESS; Initial Catalog=D;User Id=sa;password=prosvasis;"))
            {
                conn.Open();

                try
                {
                    System.Data.DataTable courseTableSchemaTable = conn.GetSchema("Tables", tableRestrictions);

                    System.Diagnostics.Debug.WriteLine("Schema Information of Course Tables:");
                    ShowDataTable(courseTableSchemaTable, 20);
                    System.Diagnostics.Debug.WriteLine("");
                } catch (Exception x)
                {
                }
            }

            using (var conn = new System.Data.SqlClient.SqlConnection(@"Data Source=.\SQLEXPRESS; Initial Catalog=D;User Id=sa;password=prosvasis;"))
            {
                string[] restrictions = new string[4] {
                    null, null, "rooms", null
                };
                conn.Open();
                try
                {
                    var columnList = conn.GetSchema("Columns", restrictions).AsEnumerable().Select(s => s.Field <String>("Column_Name")).ToList();
                }
                catch (Exception exc)
                {
                }
            }



            GenericReply reply = new GenericReply();

            var fields = new List <string>()
            {
                "ROOMS.ID",
                "ROOMS.NAME",
                "ROOMS.BUILDINGID",
                "ROOMS.BUILDINGID_BUILDINGS_NAME",
                "ROOMS.BUILDINGID_BUILDINGS_ADDRESS",
                "ROOMS.ALTERNATEBUILDINGID",
                "ROOMS.ALTERNATEBUILDINGID_BUILDINGS_NAME",
                "ROOMS.ALTERNATEBUILDINGID_BUILDINGS_ADDRESS"
            };

            D.Models.Interfaces.NavigableDbContext navigableDbContext = new Models.Interfaces.NavigableDbContext(db);

            D.Models.Interfaces.DatabaseGossiper databaseGossiper = new Models.Interfaces.DatabaseGossiper(navigableDbContext);

            D.Models.Interfaces.QueryBuilder qb = new D.Models.Interfaces.QueryBuilder(databaseGossiper);

            var q = qb.BuildBasicQuery(fields);

            q = q + " where ROOMS.ID = 1";

            D.Models.Interfaces.DatabaseCommander dc = new Models.Interfaces.DatabaseCommander();

            var o = dc.ExecuteSql(q);

            reply.data = o;

            var data = new ViewerData();

            data.Data = new Dictionary <string, List <Dictionary <string, object> > >();

            data.Data.Add("ROOMS", new List <Dictionary <string, object> >()
            {
                new Dictionary <string, object>()
                {
                    {
                        "ID",
                        "1"
                    },
                    {
                        "NAME",
                        "AAAAAAAA"
                    }
                }
            });

            reply.data = data.Data;

            return(reply);
        }
Beispiel #4
0
 /// <summary>
 /// Создание логики
 /// </summary>
 /// <param name="client">Текущий клиент</param>
 public SimpleViewerHumanLogic(SimpleViewer client, ViewerData data)
     : base(client, data)
 {
 }