Esempio n. 1
0
    private void OnMsgRegister(byte[] buffer)
    {
        AccountAnswer ret = Net.Deserialize <AccountAnswer>(buffer);

        if (!Net.CheckErrorCode(ret.errorCode, eCommand.REGISTER))
        {
            return;
        }

        // 注册成功
        ServerManager.Instance.Login();
    }
Esempio n. 2
0
        public static AccountAnswer Account(string username, string password)
        {
            var values = new Dictionary <string, string>
            {
                { "username", username },
                { "password", password },
                { "version", SOFTWARE_VERSION },
            };
            var json = CustomRequest("account", values, 5000);

            if (json != null)
            {
                AccountAnswer ret = JsonConvert.DeserializeObject <AccountAnswer>(json);
                return(ret);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 3
0
    private void OnMsgLogin(byte[] buffer)
    {
        AccountAnswer ret = Net.Deserialize <AccountAnswer>(buffer);

        if (!Net.CheckErrorCode(ret.errorCode, eCommand.LOGIN))
        {
            return;
        }

        // 账号信息
        ServerManager.Instance.AccountName = ret.name;
        ServerManager.Instance.AccountID   = ret.user_id;
        ServerManager.Instance.SessionKey  = ret.session_key;
        ServerManager.Instance.RegisteredGameServerList.Clear();
        ServerManager.Instance.RegisteredGameServerList.AddRange(ret.gmServerIds);

        // 游戏服务器列表
        ServerManager.Instance.GameServerList.Clear();
        foreach (var item in ret.servers)
        {
            ServerInfo info = new ServerInfo();
            info.id         = item.id;
            info.name       = item.name;
            info.ip         = item.ipv4;
            info.port       = item.port;
            info.statusType = (ServerStatusType)item.serverType;
            info.busyType   = (ServerBusyType)item.busy_degree;
            info.url        = item.domain_name;

            ServerManager.Instance.GameServerList.Add(info);
        }

        // TODO UI刷新游戏服务器列表
        Log.Info("登录成功");
        EventDispatcher.TriggerEvent(EventID.EVENT_UI_ACCOUNT_LOGIN_OK);
    }
Esempio n. 4
0
        public ActionResult SaveAnswer()
        {
            var       currentSurveyId = HttpContext.Request.Form["currentsurvey"];
            AllSurvey survey          = db.Surveys.Where(i => i.SurveyId.ToString() == currentSurveyId).FirstOrDefault();
            var       accountId       = User.Identity.GetUserId();

            foreach (var item in survey.Questions)
            {
                if (item.Type == 0)
                {
                    var           a      = HttpContext.Request.Form[item.Id.ToString()];
                    int           qId    = db.Question_answers.Where(q => q.QuestionId == item.Id).ToList().Where(d => d.Answer == a).FirstOrDefault().QuestionAnswerId;
                    AccountAnswer answer = new AccountAnswer
                    {
                        SurveyId         = survey.SurveyId,
                        Id               = accountId,
                        QuestionAnswerId = qId,
                        Status           = 1,
                        Description      = HttpContext.Request.Form[item.Id.ToString()]
                    };
                    db.Account_answers.Add(answer);
                }

                if (item.Type == 1)
                {
                    string        a      = HttpContext.Request.Form[item.Id.ToString()];
                    int           qId    = db.Question_answers.Where(q => q.QuestionId == item.Id).ToList().Where(d => d.Answer == a).FirstOrDefault().QuestionAnswerId;
                    AccountAnswer answer = new AccountAnswer
                    {
                        SurveyId         = survey.SurveyId,
                        Id               = accountId,
                        QuestionAnswerId = qId,
                        Status           = 1,
                        Description      = HttpContext.Request.Form[item.Id.ToString()]
                    };
                    db.Account_answers.Add(answer);
                }
                if (item.Type == 2)
                {
                    List <String> listAnswer = HttpContext.Request.Form[item.Id.ToString()].Split(',').ToList();

                    foreach (var a in listAnswer)
                    {
                        int           qId    = db.Question_answers.Where(q => q.QuestionId == item.Id).ToList().Where(d => d.Answer == a).FirstOrDefault().QuestionAnswerId;
                        AccountAnswer answer = new AccountAnswer
                        {
                            SurveyId         = survey.SurveyId,
                            Id               = accountId,
                            QuestionAnswerId = qId,
                            Status           = 1,
                            Description      = a
                        };
                        db.Account_answers.Add(answer);
                    }
                }
                if (item.Type == 3)
                {
                    List <String> listAnswer = HttpContext.Request.Form[item.Id.ToString()].Split(',').ToList();
                    if (listAnswer[0] == "Other")
                    {
                        int           qId    = db.Question_answers.Where(q => q.QuestionId == item.Id).ToList().Where(d => d.Answer == "Other").FirstOrDefault().QuestionAnswerId;
                        AccountAnswer answer = new AccountAnswer
                        {
                            SurveyId         = survey.SurveyId,
                            Id               = accountId,
                            QuestionAnswerId = qId,
                            Status           = 1,
                            Description      = listAnswer[1]
                        };
                        db.Account_answers.Add(answer);
                    }
                    if (listAnswer[0] != "Other")
                    {
                        var           des    = listAnswer[0];
                        int           qId    = db.Question_answers.Where(q => q.QuestionId == item.Id).ToList().Where(d => d.Answer == des).FirstOrDefault().QuestionAnswerId;
                        AccountAnswer answer = new AccountAnswer
                        {
                            SurveyId         = survey.SurveyId,
                            Id               = accountId,
                            QuestionAnswerId = qId,
                            Status           = 1,
                            Description      = des
                        };
                        db.Account_answers.Add(answer);
                    }
                }
                if (item.Type == 4)
                {
                    int           qId    = db.Question_answers.Where(q => q.QuestionId == item.Id).ToList().Where(d => d.Answer == "Essay").FirstOrDefault().QuestionAnswerId;
                    AccountAnswer answer = new AccountAnswer
                    {
                        SurveyId         = survey.SurveyId,
                        Id               = accountId,
                        QuestionAnswerId = qId,
                        Status           = 1,
                        Description      = HttpContext.Request.Form[item.Id.ToString()]
                    };
                    db.Account_answers.Add(answer);
                }
                db.SaveChanges();
            }
            return(Redirect("~/Home/Survey"));
        }