コード例 #1
0
ファイル: Default.aspx.cs プロジェクト: vmendi/UnusualEngine
        public static Player EnsurePlayerIsCreated(SoccerDataModelDataContext theContext, string facebookUserID, GetFBUserDelegate theFBUser)
        {
            var player = (from dbPlayer in theContext.Players
                          where dbPlayer.FacebookID == facebookUserID
                          select dbPlayer).FirstOrDefault();

            if (player == null)
            {
                // Tenemos un nuevo jugador (unico punto donde se crea)
                player = new Player();

                player.FacebookID = facebookUserID;
                player.CreationDate = DateTime.Now;		// En horario del servidor...
                player.Liked = false;

                if (theFBUser != null)
                {
                    // Probablemente llamada Rest
                    Facebook.Schema.user theFBUSer = theFBUser();

                    player.Name = theFBUSer.first_name;
                    player.Surname = theFBUSer.last_name;
                }
                else
                {
                    // Queremos evitar la llamada en los Test de debug
                    player.Name = "PlayerName";
                    player.Surname = "PlayerSurname";
                }

                theContext.Players.InsertOnSubmit(player);
            }

            return player;
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            mTeamID =  int.Parse(Request.QueryString["TeamID"]);
            mPlayer = (from p in mDC.Players where p.Team.TeamID == mTeamID select p).First();

            FillProfile();
        }
コード例 #3
0
ファイル: Default.aspx.cs プロジェクト: vmendi/UnusualEngine
        public static BDDModel.Session EnsureSessionIsCreated(SoccerDataModelDataContext theContext, Player thePlayer, string sessionKey)
        {
            var session = (from dbSession in theContext.Sessions
                           where dbSession.FacebookSession == sessionKey
                           select dbSession).FirstOrDefault();

            if (session == null)
            {
                session = new BDDModel.Session();
                session.Player = thePlayer;
                session.FacebookSession = sessionKey;
                session.CreationDate = DateTime.Now;    // En horario del servidor

                theContext.Sessions.InsertOnSubmit(session);
            }

            return session;
        }
コード例 #4
0
ファイル: MainService.cs プロジェクト: vmendi/UnusualEngine
        private SoccerDataModelDataContext CreateDataForRequest()
        {
            mContext = new SoccerDataModelDataContext();

            HttpContext theCurrentHttp = HttpContext.Current;

            if (!theCurrentHttp.Request.QueryString.AllKeys.Contains("SessionKey"))
                throw new Exception("SessionKey is missing");

            string sessionKey = theCurrentHttp.Request.QueryString["SessionKey"];

            mSession = (from s in mContext.Sessions
                        where s.FacebookSession == sessionKey
                        select s).FirstOrDefault();

            if (mSession == null)
                throw new Exception("Invalid SessionKey: " + sessionKey);

            mPlayer = mSession.Player;

            return mContext;
        }
コード例 #5
0
ファイル: MainService.cs プロジェクト: vmendi/UnusualEngine
 private static string PlayerToString(Player player)
 {
     return "Name: " + player.Name + " " + player.Surname + " FacebookID: " + player.FacebookID;
 }
コード例 #6
0
ファイル: Realtime.cs プロジェクト: vmendi/UnusualEngine
        private void CloseOldConnectionForPlayer(Player player)
        {
            IList<NetPlug> plugs = mNetServer.GetNetPlugs();

            foreach (NetPlug plug in plugs)
            {
                // Es posible que la conexión se haya desconectado o que no haya hecho login todavia...
                if (!plug.IsClosed && plug.UserData != null)
                {
                    if ((plug.UserData as RealtimePlayer).PlayerID == player.PlayerID)
                    {
                        plug.Invoke("PushedDisconnected", "Duplicated");
                        plug.CloseRequest();
                        break;
                    }
                }
            }
        }