public int AddQuestion(QuestionRecord parRecord) { var res = QuestionTable.Count; parRecord.ID = res; QuestionTable.Add(parRecord); Casher.Save(this); return(res); }
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); }
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); } }
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); }
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); }
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); } }
private async Task <int> GetQuestionRecordIdAsync(Member member, PracticeTypeDto model) { QuestionRecord record = await GetQuestoinRecordAsync(member, model); return(record.Id); }
public DnsTransaction(ushort _txnid, DnsFlags _flags, QuestionRecord _question) : this(_txnid, _flags, oneItemList <QuestionRecord>(_question)) { }
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; }
public ResourceRecord(QuestionRecord question, UInt32 _ttl, byte[] _data) { this.question = question; this.ttl = _ttl; this.data = _data; }
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); } } }