Exemplo n.º 1
0
 /// <summary>
 /// Searches for TLD.
 /// </summary>
 /// <param name="domainName"></param>
 /// <param name="type">QType</param>
 /// <param name="sendBy"></param>
 public Lookup(string domainName, QTypes type, SendBy sendBy)
 {
     this.domainName = domainName;
     this.type       = type;
     this.sendBy     = sendBy;
     send();
 }
Exemplo n.º 2
0
        /// <summary>
        /// 創建
        /// </summary>
        /// <param name="sendBy">透過誰來幫忙送信</param>
        /// <returns></returns>
        public ISendMail Create(SendBy sendBy)
        {
            ISendMail sendMailAsync = sendBy switch
            {
                SendBy.Normal => new NormalSendMail(_config),
                SendBy.SendGrid => new SendGridSendMail(_config, _serviceProvider),
                _ => null,
            };

            return(sendMailAsync);
        }
Exemplo n.º 3
0
 public BookInvoiceModel(long draftInvoiceNumber, SendBy sendBy)
 {
     DraftInvoice = new DraftInvoice
     {
         DraftInvoiceNumber = draftInvoiceNumber
     };
     if (sendBy == CreateModels.SendBy.Ean)
     {
         SendBy = "Ean";
     }
 }
Exemplo n.º 4
0
        private byte[] dataGram(string domainName, SendBy sendBy)
        {
            string[]    dName    = domainName.Split('.');
            uint        dgLength = (uint)sendBy * 2;
            uint        bodyLength;
            dGramHeader dHead = new dGramHeader();

            dHead.ID      = 0;
            dHead.QR      = 0;
            dHead.OpCode  = OpCodes.QUERY;
            dHead.AA      = 0;
            dHead.TC      = 0;
            dHead.RD      = 1;
            dHead.RA      = 0;
            dHead.Z       = 0;
            dHead.RCode   = RCodes.Success;
            dHead.QDCount = 1;
            dHead.ANCount = 0;
            dHead.NSCount = 0;
            dHead.ARCount = 0;

            byte[] header   = formHeader(dHead);
            byte[] question = formQuestion(dName);
            bodyLength = (uint)(header.Length + question.Length);

            byte[] dGram = new byte[dgLength + bodyLength];
            int    ptr   = 0;

            if (sendBy == SendBy.TCP)
            {
                dGram[0] = (byte)((bodyLength >> 8) & 0xFF);
                dGram[1] = (byte)(bodyLength & 0xFF);
                ptr      = 2;
            }
            for (int n = 0; n < header.Length; n++)
            {
                dGram[ptr] = header[n];
                ptr       += 1;
            }
            for (int m = 0; m < question.Length; m++)
            {
                dGram[ptr] = question[m];
                ptr       += 1;
            }
            return(dGram);
        }
Exemplo n.º 5
0
        public void Correct_Call_NotificationService(SendBy sendBy)
        {
            var busMock = new Mock <IServiceBus>();

            Container.RegisterInstance <IServiceBus>(busMock.Object);

            _playerCommands = Container.Resolve <PlayerCommands>();

            var player = FakePlayerRepository.Players.FirstOrDefault();

            Assert.That(player, Is.Not.Null);

            const string newPassword = "******";

            _playerCommands.SendNewPassword(new SendNewPasswordData {
                NewPassword = newPassword, PlayerId = player.Id, SendBy = sendBy
            });

            if (sendBy == SendBy.Email)
            {
                busMock.Verify(
                    n => n.PublishMessage(
                        It.IsAny <EmailCommandMessage>()),
                    Times.Once);
                busMock.Verify(
                    n => n.PublishMessage(
                        It.IsAny <SmsCommandMessage>()),
                    Times.Never);
            }
            else
            {
                busMock.Verify(
                    n => n.PublishMessage(
                        It.IsAny <SmsCommandMessage>()),
                    Times.Once);
                busMock.Verify(n => n.PublishMessage(
                                   It.IsAny <EmailCommandMessage>()),
                               Times.Never);
            }
        }
Exemplo n.º 6
0
        private int getResults(Byte[] receiveBytes, SendBy sendBy)
        {
            int ptr                 = ((int)sendBy * 2);
            int response            = (int)receiveBytes[ptr + 2] & 0x80;
            int authoritativeAnswer = (int)receiveBytes[ptr + 2] & 0x04;
            int truncation          = (int)receiveBytes[ptr + 2] & 0x02;
            int rcode               = (int)receiveBytes[ptr + 3] & 0x0f;
            int exists              = ((int)receiveBytes[ptr + 6] << 8) + (int)receiveBytes[ptr + 7];
            int result;

            if (response == 0)
            {
                result = -8;
            }
            else if (rcode == 1)
            {
                result = -1;
            }
            else if (rcode == 2)
            {
                result = -2;
            }
            else if (rcode == 3)
            {
                result = -3;
            }
            else if (rcode == 5)
            {
                result = -5;
            }
            else
            {
                result = exists;
            }
            return(result);
        }
Exemplo n.º 7
0
 public Message(string text, SendBy sendBy)
 {
     this.Text   = text;
     this.SendBy = sendBy;
 }
Exemplo n.º 8
0
 private int getResults(Byte[] receiveBytes, SendBy sendBy)
 {
     int ptr = ((int)sendBy * 2);
     int response = (int)receiveBytes[ptr + 2] & 0x80;
     int authoritativeAnswer = (int)receiveBytes[ptr + 2] & 0x04;
     int truncation = (int)receiveBytes[ptr + 2] & 0x02;
     int rcode = (int)receiveBytes[ptr + 3] & 0x0f;
     int exists = ((int)receiveBytes[ptr + 6] << 8) + (int)receiveBytes[ptr + 7];
     int result;
     if (response == 0)
     {
         result = -8;
     }
     else if (rcode == 1)
     {
         result = -1;
     }
     else if (rcode == 2)
     {
         result = -2;
     }
     else if (rcode == 3)
     {
         result = -3;
     }
     else if (rcode == 5)
     {
         result = -5;
     }
     else
     {
         result = exists;
     }
     return result;
 }
Exemplo n.º 9
0
        private byte[] dataGram(string domainName,SendBy sendBy)
        {
            string[] dName = domainName.Split('.');
            uint dgLength = (uint)sendBy * 2;
            uint bodyLength;
            dGramHeader dHead = new dGramHeader();
            dHead.ID = 0;
            dHead.QR = 0;
            dHead.OpCode = OpCodes.QUERY;
            dHead.AA = 0;
            dHead.TC = 0;
            dHead.RD = 1;
            dHead.RA = 0;
            dHead.Z = 0;
            dHead.RCode = RCodes.Success;
            dHead.QDCount = 1;
            dHead.ANCount = 0;
            dHead.NSCount = 0;
            dHead.ARCount = 0;

            byte[] header = formHeader(dHead);
            byte[] question = formQuestion(dName);
            bodyLength = (uint)(header.Length + question.Length);

            byte[] dGram = new byte[dgLength + bodyLength];
            int ptr = 0;
            if (sendBy == SendBy.TCP)
            {
                dGram[0] = (byte)((bodyLength >> 8) & 0xFF);
                dGram[1] = (byte)(bodyLength & 0xFF);
                ptr = 2;
            }
            for (int n = 0; n < header.Length; n++)
            {
                dGram[ptr] = header[n];
                ptr += 1;
            }
            for (int m = 0; m < question.Length; m++)
            {
                dGram[ptr] = question[m];
                ptr += 1;
            }
            return dGram;
        }
Exemplo n.º 10
0
 /// <summary>
 /// Searches for TLD.
 /// </summary>
 /// <param name="domainName"></param>
 /// <param name="sendBy">UDP or TCP</param>
 public Lookup(string domainName, SendBy sendBy)
 {
     this.domainName = domainName;
     this.sendBy = sendBy;
     send();
 }