예제 #1
0
        public static void BuildQuestionnaire(GameServer srv)
        {
            BC <QuestionnaireMgr>();       // 问卷调查
            BC <QuestionnaireResultMgr>(); // 问卷调查

            var qrc = new QuestionnaireResultContainer(new MySqlDbPersistence <QuestionnaireResult, string>(
                                                           "scm_qr", "127.0.0.1", "root", "123456",
                                                           @"Qa", "CREATE TABLE Qa(ID VARCHAR(100) BINARY, Data MediumBlob,"
                                                           + "PRIMARY KEY(ID ASC));", null, (da) =>
            {
                var buff = new WriteBuffer();
                da.Serialize(buff);
                return(buff.Data);
            }, (data) =>
            {
                var rb = new RingBuffer(data);
                var qr = new QuestionnaireResult();
                qr.Deserialize(rb);
                return(qr);
            }, null));

            srv.Add("QuestionnaireResultContainer", qrc);
        }
예제 #2
0
        void OnSubmitQuestionnaireResult(Session s, IReadableBuffer data)
        {
            var qr = new QuestionnaireResult();

            qr.Info.Usr = s.Usr.ID;

            qr.Info.Id = data.ReadString();
            while (data.Available > 0)
            {
                qr.Info.Answers.Add(data.ReadString());
            }

            qr.ID = qr.Info.Id + qr.Info.Usr;

            QRC.Retrieve(qr.ID, (questionnaire) =>
            {
                if (questionnaire != null)
                {
                    return;
                }

                QRC.AddNew(qr);
            });
        }