Ejemplo n.º 1
0
        // updating user activity
        private SearchNoticeMessage UpdateUserActivity(UserSearchInfo usi,
                                                       int userActivityMinSeconds,
                                                       HttpContext context,
                                                       SearchNoticeMessage noticemessage)
        {
            DateTime DateTimeNow = TimeZoneManager.DateTimeNow;

            Guid?searchId = ANOProfile.GetCookieValues(usi.UserIpAddress, context).SearchMatchID;

            SW_SearchWar getSearch =
                db.SW_SearchWar.SingleOrDefault <SW_SearchWar>(
                    s =>
                    s.SearchWarUserID == usi.UserID &&
                    (s.SearchWarId == searchId ||
                     s.SearchWarId == usi.SearchMatchID));

            if (getSearch != null)
            {
                if (getSearch.SearchWarEditDate.AddSeconds(userActivityMinSeconds) > DateTimeNow)
                {
                    getSearch.SearchWarEditDate = DateTimeNow.AddSeconds(5);
                    db.SaveChanges();

                    return(noticemessage);
                }
            }

            return(SearchNoticeMessage.NoConnection);
        }
Ejemplo n.º 2
0
        private InsertusiResult CreateUserSearch(UserSearchInfo usi)
        {
            TimeZoneManager mngInfo     = new TimeZoneManager(usi.UserIpAddress);
            DateTime        nowDatetime = TimeZoneManager.DateTimeNow;


            List <SW_SearchWar> getUserMatchs = (from s in db.SW_SearchWar
                                                 where s.SearchWarUserID == usi.UserID &&
                                                 s.SearchWarIsRunning == true
                                                 select s).ToList();

            foreach (SW_SearchWar s in getUserMatchs)
            {
                s.SearchWarIsRunning = false;
            }

            SW_SearchWar createusi = new SW_SearchWar
            {
                SearchWarId                = Guid.NewGuid(),
                SearchWarClanName          = usi.ClanName,
                SearchWarClanContinentId   = usi.ClanContinentID,
                SearchWarClanCountryId     = usi.ClanCountryID,
                SearchWarClanSkillId       = usi.SearchSkillID,
                SearchWarSearchGameId      = usi.SearchGameID,
                SearchWarSearchGameTypeId  = usi.SearchGameModeID,
                SearchWarSearchContinentId = usi.SearchContinentID,
                SearchWarSearchCountryId   = usi.SearchCountryID,
                SearchWarSearchMap         = usi.SearchMap,
                SearchWarIsRunning         = true,
                SearchWarSearchSkillId     = usi.SearchSkillID,
                SearchWarSearchvsX         = usi.SearchvsX,
                SearchWarSearchXvs         = usi.SearchXvs,
                SearchWarSearchMatchStart  = usi.SearchMatchStart,
                SearchWarUserIpAddress     = usi.UserIpAddress,
                SearchWarUserID            = usi.UserID,
                SearchWarAddedDate         = nowDatetime,
                SearchWarEditDate          = nowDatetime
            };

            db.SW_SearchWar.AddObject(createusi);
            db.SaveChanges();

            usi.SearchMatchID       = createusi.SearchWarId;
            _context.Session["usi"] = usi;

            return(InsertusiResult.Done);
        }
Ejemplo n.º 3
0
        public Boolean GetUserMatchInfo(UserSearchInfo usi)
        {
            SW_SearchWar getSearch = null;

            if (usi.SearchMatchID.HasValue && usi.UserID != null)
            {
                GetUserMatchInfoColumnNoPosition parameters = new GetUserMatchInfoColumnNoPosition
                {
                    SearchWarId     = usi.SearchMatchID.Value,
                    SearchWarUserId = usi.UserID
                };

                getSearch = GetUserSearchInfoFast(db, parameters);
            }

            if (getSearch != null)
            {
                usi.SearchGameID     = getSearch.SearchWarSearchGameId;
                usi.SearchMatchStart = getSearch.SearchWarSearchMatchStart;
                usi.ClanSkillID      = getSearch.SearchWarClanSkillId;
                usi.ClanName         = getSearch.SearchWarClanName;
                if (getSearch.SearchWarClanSkillId.HasValue)
                {
                    usi.ClanCountryID = getSearch.SearchWarClanCountryId.Value;
                }
                usi.ClanContinentID = getSearch.SearchWarClanContinentId.Value;
                if (getSearch.SearchWarSearchContinentId.HasValue)
                {
                    usi.SearchContinentID = getSearch.SearchWarSearchContinentId.Value;
                }
                usi.SearchCountryID  = getSearch.SearchWarSearchCountryId;
                usi.SearchGameModeID = getSearch.SearchWarSearchGameTypeId;
                usi.SearchMap        = getSearch.SearchWarSearchMap;
                usi.SearchSkillID    = getSearch.SearchWarSearchSkillId;
                usi.SearchvsX        = getSearch.SearchWarSearchvsX;
                usi.SearchXvs        = getSearch.SearchWarSearchXvs;

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        // check max idle time
        private SearchNoticeMessage CheckUserIdleActivity(UserSearchInfo usi,
                                                          int maxIdleSearch_Seconds,
                                                          HttpContext context,
                                                          SearchNoticeMessage noticemessage)
        {
            Guid?searchID = ANOProfile.GetCookieValues(usi.UserIpAddress, context).SearchMatchID;

            SW_SearchWar obj =
                db.SW_SearchWar.SingleOrDefault <SW_SearchWar>(s => s.SearchWarUserID == usi.UserID && (s.SearchWarId == searchID));

            DateTime getAddedDateTime;

            if (obj != null)
            {
                getAddedDateTime = obj.SearchWarAddedDate;
            }
            else
            {
                return(SearchNoticeMessage.NoResults);
            }

            return(getAddedDateTime.AddSeconds(maxIdleSearch_Seconds) > TimeZoneManager.DateTimeNow ? noticemessage : SearchNoticeMessage.NoResults);
        }
        public void ProcessRequest(HttpContext context)
        {
            // Set defaults values
            string            data          = null;
            string            currentUserIp = "62.107.21.129";
            HttpRequest       currentR      = context.Request;
            HttpServerUtility currentS      = context.Server;
            int      currentLangId;
            bool     isValid      = true;
            string   errorMessage = "succes";
            ANO_User getUser      = ANOProfile.GetCookieValues(currentUserIp, context);



            string userAction = context.Request.QueryString["a"];

            if (string.IsNullOrEmpty(userAction))
            {
                isValid      = false;
                errorMessage = "You forgot action (querystring a)";
            }


            // Create documet and root element called "c" for "chat"
            XDocument createXml = new XDocument(
                new XDeclaration("1.0", "iso-8859-1", "true"),
                new XElement("chat"));

            // Get root element "c"
            XElement getRootElement = createXml.Descendants("chat").Single();

            if (userAction == ChatCmds.SendMessage.ToString())
            {
                string userText = context.Request["t"];
                if (string.IsNullOrEmpty(userText))
                {
                    isValid      = false;
                    errorMessage = "You forgot the message (post/querystring t)";
                }

                string chatIdQuery = context.Request["c"];
                Guid?  chatId      = null;
                if (string.IsNullOrEmpty(chatIdQuery))
                {
                    isValid      = false;
                    errorMessage = "You forgot the chat window id (post/querystring c";
                }

                // Convert chatid querystring to Guid
                try
                {
                    chatId = new Guid(chatIdQuery);
                }
                catch
                {
                    isValid      = false;
                    errorMessage = "Problem with converting chat window id (querystring c)";
                }

                if (isValid == true && chatId.HasValue)
                {
                    string getUsername = null;
                    if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
                    {
                        getUsername = Membership.GetUser(getUser.UserID).UserName;
                    }

                    if (string.IsNullOrEmpty(getUsername))
                    {
                        Searchwar_netEntities db          = new Searchwar_netEntities();
                        SW_SearchWar          matchSearch = db.SW_SearchWar.SingleOrDefault(w => w.SearchWarId == getUser.SearchMatchID);

                        if (matchSearch != null)
                        {
                            getUsername = matchSearch.SearchWarClanName;
                        }
                    }

                    if (!string.IsNullOrEmpty(getUsername))
                    {
                        ChatSystem mngChat = new ChatSystem(context, currentUserIp);
                        mngChat.CreateMsg(userText, chatId, getUser.UserID, getUsername);
                    }
                    else
                    {
                        isValid      = false;
                        errorMessage = "You muct be logged in or searching for a match";
                    }
                }
            }

            // write status for result
            getRootElement.Add(new XElement("status", new XAttribute("bool", isValid.ToString()), errorMessage));

            // Write/save data
            StringWriter sw = new StringWriter();
            XmlWriter    xw = XmlWriter.Create(sw);

            createXml.Save(xw);

            xw.Close();

            data = sw.ToString();

            context.Response.ContentType     = "text/xml";
            context.Response.ContentEncoding = Encoding.UTF8;
            context.Response.Write(XmlWhiteSpaceModule.RemoveWhitespace(data));
        }