Ejemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            string AccessKey= System.Configuration.ConfigurationManager.AppSettings["AccessKey"];
            string SecrectKey = System.Configuration.ConfigurationManager.AppSettings["SecrectKey"];
            Amazon.SimpleEmail.AmazonSimpleEmailServiceClient mailClient = new Amazon.SimpleEmail.AmazonSimpleEmailServiceClient(AccessKey,SecrectKey);
            //var obj = mailClient.GetSendQuota();
            SendEmailRequest request = new SendEmailRequest();
            List<string> toaddress = new List<string>();
            toaddress.Add("*****@*****.**");
            Destination des = new Destination(toaddress);
            request.Destination = des;
            request.Source = "*****@*****.**";
            Amazon.SimpleEmail.Model.Message mes = new Amazon.SimpleEmail.Model.Message();
            mes.Body = new Body(new Content( @"Hiện tại, Windows Phone mới hỗ trợ đến màn hình full HD, do đó để tương thích với màn hình 2K, hệ điều hành chắc chắn phải có bản cập nhật mới. Mặt khác, vi xử lý Snapdragon 805 của Qualcomm được biết sẽ phát hành đại trà vào nửa sau năm nay, nên thời điểm xuất hiện Lumia 1820 dùng vi xử lý này tại MWC 2014 vào tháng Hai sẽ là dấu hỏi lớn.

            Microsoft đã từng nói hãng đã chi tới 2,6 tỉ USD để phát triển cho hệ điều hành Windows Phone. Và năm nay, Microsoft đang có kế hoạch lớn dành cho Windows Phone lẫn Nokia. Do đó, chúng ta hãy cứ hy vọng Lumia 1525 và Lumia 1820 sẽ là bom tấn smartphone được kích hoạt trong 2014 này."));
            mes.Subject = new Content("Test send via amazon");

            request.Message = mes;

            SendEmailResponse response = mailClient.SendEmail(request);
            var messageId = response.SendEmailResult.MessageId;
            /*GetIdentityNotificationAttributesRequest notifyRequest = new GetIdentityNotificationAttributesRequest();
            List<string> iden = new List<string>();
            iden.Add("*****@*****.**"); //iden.Add(response.ResponseMetadata.RequestId);
            notifyRequest.Identities = iden;
            var notify = mailClient.GetIdentityNotificationAttributes(notifyRequest);
            //MessageBox.Show(notify.GetIdentityNotificationAttributesResult.NotificationAttributes["Bounces"].BounceTopic);

            var temp = mailClient.GetSendStatistics();
            MessageBox.Show("Total: "+temp.GetSendStatisticsResult.SendDataPoints.Count+"\nDeliveryAttempts: "+temp.GetSendStatisticsResult.SendDataPoints[265].DeliveryAttempts+"\n"
                + "Complaints: " + temp.GetSendStatisticsResult.SendDataPoints[265].Complaints + "\n"
                + "Bounces: " + temp.GetSendStatisticsResult.SendDataPoints[265].Bounces + "\n"
                + "Rejects: " + temp.GetSendStatisticsResult.SendDataPoints[265].Rejects + "\n");
               // MessageBox.Show("Max24HourSend:" + obj.GetSendQuotaResult.Max24HourSend + "\nMaxSendRate:" + obj.GetSendQuotaResult.MaxSendRate + "\nSentLast24Hours:" + obj.GetSendQuotaResult.SentLast24Hours);

            Amazon.SimpleNotificationService.Model.GetEndpointAttributesRequest endpointRequest = new Amazon.SimpleNotificationService.Model.GetEndpointAttributesRequest();
            Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient notifyClient = new Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient();
            //string result = notifyClient.GetEndpointAttributes(notify).GetEndpointAttributesResult.ToXML();
            //MessageBox.Show(result);
            */
            Amazon.SQS.AmazonSQSClient client = new Amazon.SQS.AmazonSQSClient(AccessKey, SecrectKey);
            Amazon.SQS.Model.ReceiveMessageRequest SQSrequest = new Amazon.SQS.Model.ReceiveMessageRequest();
            SQSrequest.MaxNumberOfMessages = 10;
            SQSrequest.QueueUrl = "https://sqs.us-east-1.amazonaws.com/063719400628/bounce-queue";
            AmazonQueues.ProcessQueuedBounce(client.ReceiveMessage(SQSrequest));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads more <see cref="Amazon.SQS.Model.Message"/>.
        /// </summary>
        /// <returns>A list of <see cref="Amazon.SQS.Model.Message"/>.</returns>
        protected override List <Amazon.SQS.Model.Message> Read()
        {
            using (var sqs = new Amazon.SQS.AmazonSQSClient())
            {
                var response = sqs.ReceiveMessage(new Amazon.SQS.Model.ReceiveMessageRequest()
                {
                    QueueUrl              = _options.QueueUrl,
                    MaxNumberOfMessages   = 10,
                    MessageAttributeNames = this._optionsMessageAttributeNames,
                    AttributeNames        = this._optionsAttributeNames,
                });

                Interlocked.Add(ref _readTotal, response.Messages.Count);

                if (Logger.IsDebugEnabled)
                {
                    Logger.Debug("Received messages. Count: {0}", response.Messages.Count);
                }

                return(response.Messages);
            }
        }
Ejemplo n.º 3
0
        public void TestMethod1()
        {
            try
            {
                Guid guid = Guid.NewGuid();

                string testMessageBody = "Test message from NLog.Targets.SQS {" + guid + "]";

                NLog.Targets.SQS.AwsSqsTarget target = (NLog.Targets.SQS.AwsSqsTarget)NLog.LogManager.Configuration.FindTargetByName("SQS Target");

                var region = Amazon.RegionEndpoint.GetBySystemName(target.RegionEndPoint);
                using (var sqs_client = new Amazon.SQS.AmazonSQSClient(target.AwsAccessKeyId, target.AwsSecretAccessKey, region))
                {
                    //Purge the target queue of existing messages
                    var att = sqs_client.GetQueueAttributes(target.QueueUrl, new System.Collections.Generic.List <string>()
                    {
                        "All"
                    });

                    if (att.ApproximateNumberOfMessages > 0 | att.ApproximateNumberOfMessagesDelayed > 0 | att.ApproximateNumberOfMessagesNotVisible > 0)
                    {
                        sqs_client.PurgeQueue(target.QueueUrl);
                    }



                    var logger = NLog.LogManager.GetCurrentClassLogger();


                    logger.Info(testMessageBody);


                    System.Threading.Thread.Sleep(1000);



                    Amazon.SQS.Model.ReceiveMessageRequest recReq = new Amazon.SQS.Model.ReceiveMessageRequest(target.QueueUrl);
                    recReq.MessageAttributeNames.Add("All");

                    var messages = sqs_client.ReceiveMessage(recReq);

                    Assert.AreEqual(System.Net.HttpStatusCode.OK, messages.HttpStatusCode);
                    Assert.AreEqual(1, messages.Messages.Count);
                    var message = messages.Messages[0];

                    try
                    {
                        Assert.AreEqual(testMessageBody, message.Body);
                        Assert.AreEqual("Info", message.MessageAttributes["Level"].StringValue);
                        Assert.AreEqual("NLog.Targets.SQS.Tests.UnitTests", message.MessageAttributes["Logger"].StringValue);
                        Assert.IsNotNull(message.MessageAttributes["SequenceID"].StringValue);
                    }
                    finally
                    {
                        sqs_client.DeleteMessage(target.QueueUrl, message.ReceiptHandle);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }