コード例 #1
0
        public ActionResult MakeEdit([Bind(Include = "Id, Name, Phone, City")] PersonData data)
        {
            if (ModelState.IsValid)
            {
                StaticDataStorage.ReplacePerson(data);
                return(PartialView("PV_Person", data));
            }

            return(View("ListOfPeople", StaticDataStorage.personList));
        }
コード例 #2
0
        public ActionResult SortList(string pressedButton)
        {
            if (ModelState.IsValid)
            {
                StaticDataStorage.SortList(pressedButton);

                return(PartialView("PV_PersonTable", new PersonDataBundle {
                    TheList = StaticDataStorage.personList, TheListStart = StaticDataStorage.displayIndex
                }));
            }
            return(View(StaticDataStorage.personList));
        }
コード例 #3
0
        public ActionResult AddPerson(string name, string phone, string city)
        {
            if (ModelState.IsValid)
            {
                StaticDataStorage.AddPersonToList(name, phone, city);

                return(PartialView("PV_PersonTable", new PersonDataBundle {
                    TheList = StaticDataStorage.personList, TheListStart = StaticDataStorage.displayIndex
                }));
            }
            return(View(StaticDataStorage.personList));
        }
コード例 #4
0
        public ActionResult FilterList(string filter, bool caseSensitive)
        {
            if (ModelState.IsValid)
            {
                StaticDataStorage.FilterList(filter, caseSensitive);

                return(PartialView("PV_PersonTable", new PersonDataBundle {
                    TheList = StaticDataStorage.personList, TheListStart = StaticDataStorage.displayIndex
                }));
            }
            return(View(StaticDataStorage.personList));
        }
コード例 #5
0
        public ActionResult RemoveListEntry(string id)
        {
            if (ModelState.IsValid)
            {
                StaticDataStorage.RemovePersonFromList(id);


                return(PartialView("PV_Blank"));
            }


            return(View("ListOfPeople", StaticDataStorage.personList));
        }
コード例 #6
0
        public ActionResult ClearFilter()
        {
            if (ModelState.IsValid)
            {
                StaticDataStorage.ClearFilter();

                return(PartialView("PV_PersonTable", new PersonDataBundle {
                    TheList = StaticDataStorage.personList, TheListStart = StaticDataStorage.displayIndex
                }));
            }

            return(View(StaticDataStorage.personList));
        }
コード例 #7
0
        public Client(HicoreSocket socket)
        {
            if (_socket == null)
            {
                this._socket = socket;
                Token        = "";

                result = new Result();
                user   = new User();

                curTimeZone   = TimeZoneInfo.Local;
                currentOffset = curTimeZone.GetUtcOffset(DateTime.Now);

                MatchController = new MatchController(_socket);
                UpdateAccount   = new UpdateAccount(_socket);
                Friend          = new Friend(_socket);
                Matchmacker     = new Matchmacker(_socket);
                Communication   = new Communication(_socket);
                Storage         = new DataStorage(_socket);
                StaticStorage   = new StaticDataStorage(_socket);

                _socket.On(authenticateDeviceIdEvent, res =>
                {
                    JSONNode jsonRes = JSON.Parse(res.Text);

                    if (jsonRes["type"].Value.Equals(result.Success))
                    {
                        user.UserId             = jsonRes["userId"].Value;
                        user.Username           = jsonRes["username"].Value;
                        user.Token              = jsonRes["token"].Value;
                        user.GameInfo           = jsonRes["gameInfo"];
                        user.FriendRequest      = jsonRes["friendRequest"];
                        user.FriendList         = jsonRes["friendList"];
                        user.TotalFriendRequest = jsonRes["totalFriendRequest"];


                        result.Type    = jsonRes["type"].Value;
                        result.Message = jsonRes["msg"].Value;
                        result.Code    = jsonRes["code"].AsInt;


                        // save token to update account
                        Token = jsonRes["token"].Value;

                        // send user token to Game Server
                        ChildServer?.SendToken();

                        OnAuthenticateDeviceId(user, result);
                    }
                    else
                    {
                        result.Type    = jsonRes["type"].Value;
                        result.Message = jsonRes["msg"].Value;
                        result.Code    = jsonRes["code"].AsInt;
                        OnAuthenticateDeviceId(user, result);
                    }
                });

                _socket.On(authenticateEmailEvent, res =>
                {
                    JSONNode jsonRes = JSON.Parse(res.Text);

                    if (jsonRes["type"].Value.Equals(result.Success))
                    {
                        user.UserId             = jsonRes["userId"].Value;
                        user.Username           = jsonRes["username"].Value;
                        user.Token              = jsonRes["token"].Value;
                        user.GameInfo           = jsonRes["gameInfo"];
                        user.FriendRequest      = jsonRes["friendRequest"];
                        user.FriendList         = jsonRes["friendList"];
                        user.TotalFriendRequest = jsonRes["totalFriendRequest"];

                        result.Type    = jsonRes["type"].Value;
                        result.Message = jsonRes["msg"].Value;
                        result.Code    = jsonRes["code"].AsInt;


                        // save token to update account
                        Token = jsonRes["token"].Value;
                        // send user token to Game Server
                        ChildServer?.SendToken();


                        OnAuthenticateEmail(user, result);
                    }
                    else
                    {
                        result.Type    = jsonRes["type"].Value;
                        result.Message = jsonRes["msg"].Value;
                        result.Code    = jsonRes["code"].AsInt;
                        OnAuthenticateEmail(user, result);
                    }
                });
            }
            else
            {
                throw new ArgumentException("Socket is already in use");
            }
        }
コード例 #8
0
ファイル: Bundler.cs プロジェクト: sainabob/teamlab.v7.5
        private String GetStorePath(HttpContextBase context, String category, String uriString, ContentType contentType)
        {
            if (String.IsNullOrEmpty(category))
            {
                if (context.Request.Url != null)
                {
                    category = GetCategoryFromPath(context.Request.Url.AbsolutePath);
                }
                else if (String.IsNullOrEmpty(category))
                {
                    category = "common";
                }
            }

            var filePath = GetFullFileName(category, uriString, contentType);

            var cacheKey = String.Format("{0}-{1}", category, filePath);

            if (_cacheUri.ContainsKey(cacheKey))
            {
                return(_cacheUri[cacheKey]);
            }

            if (!StaticDataStorage.IsFile("common_static", filePath))
            {
                lock (_locker)
                {
                    if (_cacheUri.ContainsKey(cacheKey))
                    {
                        return(_cacheUri[cacheKey]);
                    }

                    var requestUri = uriString;

                    if (Uri.IsWellFormedUriString(uriString, UriKind.Relative))
                    {
                        var u          = context.Request.GetUrlRewriter();
                        var uriBuilder = new UriBuilder(u.Scheme, u.Host, u.Port, uriString);

                        requestUri = uriBuilder.ToString();
                    }

                    try
                    {
                        var req = (HttpWebRequest)WebRequest.Create(requestUri);

                        var currentTenant = CoreContext.TenantManager.GetCurrentTenant(false);

                        if (currentTenant != null && currentTenant.TenantId > -1)
                        {
                            req.CookieContainer = new CookieContainer();

                            var cookieDomain = CoreContext.TenantManager.GetCurrentTenant().TenantDomain;

                            if (req.RequestUri.Host.ToLower() == "localhost")
                            {
                                cookieDomain = "localhost";
                            }

                            req.CookieContainer.Add(new Cookie("asc_auth_key", CookiesManager.GetCookies(CookiesType.AuthKey), "/", cookieDomain));
                        }

                        using (var resp = (HttpWebResponse)req.GetResponse())
                            using (var stream = resp.GetResponseStream())
                            {
                                if (resp.StatusCode != HttpStatusCode.OK)
                                {
                                    throw new HttpException((int)resp.StatusCode, resp.StatusDescription);
                                }
                                if (ClientSettings.IsGZipEnabled)
                                {
                                    var compressedFileStream = new MemoryStream();

                                    using (var compressionStream = new GZipStream(compressedFileStream, CompressionMode.Compress, true))
                                    {
                                        stream.CopyTo(compressionStream);
                                    }

                                    Uri fileUri = StaticDataStorage.Save(String.Empty, filePath, compressedFileStream, "gzip", 365);
                                }
                                else
                                {
                                    StaticDataStorage.Save(filePath, stream);
                                }
                            }
                    }
                    catch (Exception exception)
                    {
                        _log.Error(exception);
                        _log.Error("Current Uri: " + context.Request.GetUrlRewriter().ToString());
                        _log.Error("Request Uri: " + requestUri);
                        throw;
                    }
                }
            }

            //HACK: support  for multi-cdn
            var result = WebPath.GetPath(filePath);

            if (!_cacheUri.ContainsKey(cacheKey))
            {
                _cacheUri.TryAdd(cacheKey, result);

                File.WriteAllText(_pathToCacheFile, JsonConvert.SerializeObject(_cacheUri));
            }

            return(result);
        }