コード例 #1
0
        public int AddQuestion(QuestionRecord parRecord)
        {
            var res = QuestionTable.Count;

            parRecord.ID = res;
            QuestionTable.Add(parRecord);
            Casher.Save(this);
            return(res);
        }
コード例 #2
0
        private async Task <QuestionRecord> GetQuestionRecordAsync(Member member, PracticeTypeDto model)
        {
            QuestionRecord record = await GetQuestoinRecordAsync(member, model);

            if (record == null)
            {
                throw new Exception("Not Exist QuestionRecord where QuestionTypeId=" + model.QuestionTypeId + " & QuestionChapterId = " + model.QuestionChapterId);
            }
            return(record);
        }
コード例 #3
0
            public ResourceRecord(byte[] bytes, ref ushort offset)
            {
                question = new QuestionRecord(bytes, ref offset);
                this.ttl = GetLEUInt32(bytes, ref offset);
                UInt16 length;

                length    = GetLEUInt16(bytes, ref offset);
                this.data = new byte[length];
                Array.Copy(bytes, offset, data, 0, length);
                offset += length;
            }
 public void UpdateQuestion(QuestionRecord record)
 {
     if (string.IsNullOrWhiteSpace(record.GUIdentifier))
     {
         record.GUIdentifier = Guid.NewGuid().ToString("n");
     }
     if (record.Id == 0)
     {
         _repositoryQuestions.Create(record);
     }
     else
     {
         _repositoryQuestions.Update(record);
     }
 }
コード例 #5
0
        public async Task <QuestionRecord> SetQuestionRecordAsync(Member member, PracticeTypeDto model)
        {
            QuestionRecord record = (await GetQuestoinRecordAsync(member, model))
                                    ?? new QuestionRecord
            {
                MemberId          = member.Id,
                QuestionTypeId    = model.QuestionTypeId,
                QuestionChapterId = model.QuestionChapterId,
                ExamId            = model.ExamId,
                PracticeType      = model.PracticeType,
                CurrentIndex      = 0
            };

            record.UpdateTime = DateTime.Now;
            await SaveAsync(record);

            return(record);
        }
コード例 #6
0
            public static QuestionRecord ReadQuestionRecord(byte[] bBuffer, int startIndex)
            {
                QuestionRecord retval = new QuestionRecord();
                UInt16         i      = Convert.ToUInt16(bBuffer[startIndex]);
                int            offset = 0;

                if (i > 0xc000)
                {
                    retval.mQName = GetNameAtLocation(bBuffer, i - 0xc000);
                    offset        = 2;
                }
                else
                {
                    retval.mQName = GetNameAtLocation(bBuffer, startIndex);
                    offset        = retval.mQName.Length + 2;
                }

                retval.mQType  = GetUInt16(bBuffer, startIndex + offset);
                retval.mQClass = GetUInt16(bBuffer, startIndex + offset + 2);
                return(retval);
            }
コード例 #7
0
        private async Task <int> GetPageIndexAsync(Member member, PracticeTypeDto model, List <int> selectedQuestionIdList = null, List <int> exceptQuestionIdList = null)
        {
            QuestionRecord record = await SetQuestionRecordAsync(member, model);

            switch (model.PracticeType)
            {
            case PracticeType.Order:
            case PracticeType.Favorite:
            case PracticeType.Error:
            case PracticeType.Ignore:
                return(record.CurrentIndex + model.Different);

            case PracticeType.Random:
            case PracticeType.Exam:
                int intQuestionCount = await GetQuestionCount(member, model, selectedQuestionIdList, exceptQuestionIdList);

                return(new Random(Guid.NewGuid().GetHashCode()).Next(1, intQuestionCount + 1));

            default:
                return(1);
            }
        }
コード例 #8
0
        private async Task <int> GetQuestionRecordIdAsync(Member member, PracticeTypeDto model)
        {
            QuestionRecord record = await GetQuestoinRecordAsync(member, model);

            return(record.Id);
        }
コード例 #9
0
 public DnsTransaction(ushort _txnid, DnsFlags _flags, QuestionRecord _question)
     : this(_txnid, _flags, oneItemList <QuestionRecord>(_question))
 {
 }
コード例 #10
0
 public ResourceRecord(string n, QTYPE t, RCLASS c, uint _ttl, byte[] _data)
 {
     this.question = new QuestionRecord(n, t, c);
     this.ttl      = _ttl;
     this.data     = _data;
 }
コード例 #11
0
 public ResourceRecord(QuestionRecord question, UInt32 _ttl, byte[] _data)
 {
     this.question = question;
     this.ttl      = _ttl;
     this.data     = _data;
 }
コード例 #12
0
        public DNSPacket(byte[] bDatagram)
        {
            mID = DNSPacket.GetUInt16(bDatagram, 0);
            mQR = (bDatagram[2] & 0x80) == 0x80;
            mAuthorativeAnswer  = (bDatagram[2] & 0x04) == 0x04;
            mTruncated          = (bDatagram[2] & 0x02) == 0x02;
            mRecursionDesired   = (bDatagram[2] & 0x01) == 0x01;
            mRecursionAvailable = (bDatagram[3] & 0x80) == 0x80;
            mOpCode             = Convert.ToUInt16((bDatagram[2] & 0x78) / 0x08);
            mResponseCode       = Convert.ToUInt16(bDatagram[3] & 0x0F);
            mReservedBlock      = Convert.ToUInt16((bDatagram[3] & 0x70) / 0x10);
            if ((mReservedBlock & 0x02) == 0x02)
            {
                mAuthenticData = true;
            }
            if ((mReservedBlock & 0x01) == 0x01)
            {
                mCheckingDisabled = true;
            }

            UInt16 questionBlocks         = DNSPacket.GetUInt16(bDatagram, 4);
            UInt16 answerBlocks           = DNSPacket.GetUInt16(bDatagram, 6);
            UInt16 nameserverBlocks       = DNSPacket.GetUInt16(bDatagram, 8);
            UInt16 additionalRecordBlocks = DNSPacket.GetUInt16(bDatagram, 10);
            int    curLocation            = 12;

            mQuestionRecords = new List <QuestionRecord>();
            for (int i = 0; i < questionBlocks; i++)
            {
                QuestionRecord currentQuestionRecord = QuestionRecord.ReadQuestionRecord(bDatagram, curLocation);
                curLocation += currentQuestionRecord.Length;
                mQuestionRecords.Add(currentQuestionRecord);
            }
            mAnswerRecords = new List <AnswerRecord>();
            if (mResponseCode == 0 && curLocation < bDatagram.Length)
            {
                for (int i = 0; i < answerBlocks; i++)
                {
                    AnswerRecord currentAnswerRecord = AnswerRecord.ReadAnswerRecord(bDatagram, curLocation);
                    curLocation += currentAnswerRecord.Length;
                    mAnswerRecords.Add(currentAnswerRecord);
                }
            }
            mAuthorityRecords = new List <AnswerRecord>();
            if (mResponseCode == 0 && curLocation < bDatagram.Length)
            {
                for (int i = 0; i < nameserverBlocks; i++)
                {
                    AnswerRecord currentAnswerRecord = AnswerRecord.ReadAnswerRecord(bDatagram, curLocation);
                    curLocation += currentAnswerRecord.Length;
                    mAuthorityRecords.Add(currentAnswerRecord);
                }
            }
            mAdditionalRecords = new List <AnswerRecord>();
            if (mResponseCode == 0 && curLocation < bDatagram.Length)
            {
                for (int i = 0; i < additionalRecordBlocks; i++)
                {
                    AnswerRecord currentAnswerRecord = AnswerRecord.ReadAnswerRecord(bDatagram, curLocation);
                    curLocation += currentAnswerRecord.Length;
                    mAdditionalRecords.Add(currentAnswerRecord);
                }
            }
        }