本文整理汇总了C#中Amazon类的典型用法代码示例。如果您正苦于以下问题:C# Amazon类的具体用法?C# Amazon怎么用?C# Amazon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Amazon类属于命名空间,在下文中一共展示了Amazon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Get_Msg_From_Req_Q
public static bool Get_Msg_From_Req_Q(out Amazon.SQS.Model.Message msg, out bool msgFound)
{
msgFound = false;
msg = null;
try
{
ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
receiveMessageRequest.MaxNumberOfMessages = 1;
receiveMessageRequest.QueueUrl = requests_Q_url;
ReceiveMessageResponse receiveMessageResponse = sqs.ReceiveMessage(receiveMessageRequest);
if (receiveMessageResponse.IsSetReceiveMessageResult())
{
ReceiveMessageResult receiveMessageResult = receiveMessageResponse.ReceiveMessageResult;
List<Amazon.SQS.Model.Message> receivedMsges = receiveMessageResponse.ReceiveMessageResult.Message;
if (receivedMsges.Count == 0)
{
return true;
}
msgFound = true;
msg = receivedMsges[0];
}
}
catch (AmazonSQSException ex)
{
Console.WriteLine("Caught Exception: " + ex.Message);
Console.WriteLine("Response Status Code: " + ex.StatusCode);
Console.WriteLine("Error Code: " + ex.ErrorCode);
Console.WriteLine("Error Type: " + ex.ErrorType);
Console.WriteLine("Request ID: " + ex.RequestId);
Console.WriteLine("XML: " + ex.XML);
return false;
}
return true;
}
示例2: ZAwsElasticIp
public ZAwsElasticIp(ZAwsEc2Controller controller, Amazon.EC2.Model.Address res)
: base(controller)
{
Update(res);
//myController.HandleNewElasticIp(this);
}
示例3: DecodeAttribute
/// <summary>
/// Decodes the base64 encoded properties of the Attribute.
/// The Name and/or Value properties of an Attribute can be base64 encoded.
/// </summary>
/// <param name="inputAttribute">The properties of this Attribute will be decoded</param>
/// <seealso cref="P:Amazon.SimpleDB.Model.Attribute.NameEncoding" />
/// <seealso cref="P:Amazon.SimpleDB.Model.Attribute.ValueEncoding" />
public static void DecodeAttribute(Amazon.SimpleDB.Model.Attribute inputAttribute)
{
if (null == inputAttribute)
{
throw new ArgumentNullException("inputAttribute", "The Attribute passed in was null");
}
string encoding = inputAttribute.NameEncoding;
if (null != encoding)
{
if (String.Compare(encoding, base64Str, true) == 0)
{
// The Name is base64 encoded
inputAttribute.Name = AmazonSimpleDBUtil.DecodeBase64String(inputAttribute.Name);
inputAttribute.NameEncoding = "";
}
}
encoding = inputAttribute.ValueEncoding;
if (null != encoding)
{
if (String.Compare(encoding, base64Str, true) == 0)
{
// The Value is base64 encoded
inputAttribute.Value = AmazonSimpleDBUtil.DecodeBase64String(inputAttribute.Value);
inputAttribute.ValueEncoding = "";
}
}
}
示例4: EnqueueEventsForDelivery
/// <summary>
/// Enqueues the events for delivery. The event is stored in an instance of <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.IEventStore"/>.
/// </summary>
/// <param name="eventObject">Event object.<see cref="Amazon.MobileAnalytics.Model.Event"/></param>
public void EnqueueEventsForDelivery(Amazon.MobileAnalytics.Model.Event eventObject)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(delegate
{
EnqueueEventsHelper(eventObject);
}));
}
示例5: RenderAWSMetricDatum
private void RenderAWSMetricDatum(Amazon.CloudWatch.Model.MetricDatum metricDatum, TextWriter writer)
{
if (!String.IsNullOrEmpty(metricDatum.MetricName))
writer.Write("MetricName: {0}, ", metricDatum.MetricName);
if (!String.IsNullOrEmpty(metricDatum.Unit))
writer.Write("Unit: {0}, ", metricDatum.Unit);
if (metricDatum.StatisticValues == null)
writer.Write("Value: {0}, ", metricDatum.Value.ToString(CultureInfo.InvariantCulture));
if (metricDatum.Dimensions.Any())
{
writer.Write("Dimensions: {0}, ", String.Join(", ",
metricDatum.Dimensions.Select(
x =>
String.Format("{0}: {1}", x.Name, x.Value))));
}
if (metricDatum.Timestamp != default(DateTime))
writer.Write("Timestamp: {0}, ", metricDatum.Timestamp.ToString(CultureInfo.CurrentCulture));
if (metricDatum.StatisticValues != null)
{
if (metricDatum.StatisticValues.Maximum > 0)
writer.Write("Maximum: {0}, ", metricDatum.StatisticValues.Maximum.ToString(CultureInfo.InvariantCulture));
writer.Write("Minimum: {0}, ", metricDatum.StatisticValues.Minimum.ToString(CultureInfo.InvariantCulture));
if (metricDatum.StatisticValues.SampleCount > 1)
writer.Write("SampleCount: {0}, ", metricDatum.StatisticValues.SampleCount.ToString(CultureInfo.InvariantCulture));
if (metricDatum.StatisticValues.Sum > 0)
writer.Write("Sum: {0}, ", metricDatum.StatisticValues.Sum.ToString(CultureInfo.InvariantCulture));
}
}
示例6: Delete_Msg_From_Req_Q
public static bool Delete_Msg_From_Req_Q(Amazon.SQS.Model.Message msg)
{
try
{
String messageRecieptHandle = msg.ReceiptHandle;
//Deleting a message
Console.WriteLine("Deleting the message.\n");
DeleteMessageRequest deleteRequest = new DeleteMessageRequest();
deleteRequest.QueueUrl = requests_Q_url;
deleteRequest.ReceiptHandle = messageRecieptHandle;
Console.WriteLine("Before deleting incoming msg(" + messageRecieptHandle + ").");
sqs.DeleteMessage(deleteRequest);
Console.WriteLine("After deleting incoming msgs().");
}
catch (AmazonSQSException ex)
{
Console.WriteLine("Caught Exception: " + ex.Message);
Console.WriteLine("Response Status Code: " + ex.StatusCode);
Console.WriteLine("Error Code: " + ex.ErrorCode);
Console.WriteLine("Error Type: " + ex.ErrorType);
Console.WriteLine("Request ID: " + ex.RequestId);
Console.WriteLine("XML: " + ex.XML);
return false;
}
return true;
}
示例7: GlacierArchiveInfo
public GlacierArchiveInfo(Amazon.Glacier.Model.DescribeJobResult result)
{
Id = result.ArchiveId;
SizeInBytes = result.ArchiveSizeInBytes;
CreationDate = result.CreationDate;
Checksum = result.SHA256TreeHash;
}
示例8: ProcessCore
private void ProcessCore(long betScreenshotId, Amazon.S3.AmazonS3 amazonS3Client, SynchronizationContext synchronizationContext)
{
using (var unitOfWorkScope = _unitOfWorkScopeFactory.Create())
{
BetScreenshot betScreenshot = null;
try
{
betScreenshot = _repositoryOfBetScreenshot.Get(EntitySpecifications.IdIsEqualTo<BetScreenshot>(betScreenshotId)).Single();
var battleBet = _repositoryOfBet.Get(BetSpecifications.BetScreenshotOwner(betScreenshot.Id)).Single();
betScreenshot.StartedProcessingDateTime = DateTime.UtcNow;
ImageFormat imageFormat;
var screenshotEncodedStream = GetScreenshot(battleBet.Url, betScreenshot, synchronizationContext, out imageFormat);
PutScreenshot(amazonS3Client, screenshotEncodedStream, betScreenshot, imageFormat);
betScreenshot.FinishedProcessingDateTime = DateTime.UtcNow;
betScreenshot.StatusEnum = BetScreenshotStatus.Succeeded;
}
catch (Exception ex)
{
Logger.TraceException(String.Format("Failed to process betScreenshotId = {0}. Trying to save as failed", betScreenshotId), ex);
betScreenshot.StatusEnum = BetScreenshotStatus.Failed;
}
finally
{
unitOfWorkScope.SaveChanges();
}
}
}
示例9: Identify
public string Identify(Amazon.IdentityManagement.Model.User user)
{
if (null == user)
{
throw new ArgumentNullException(AnchoringByIdentifierBehavior.ArgumentNameUser);
}
return user.UserId;
}
示例10: Do
public override ActivityState Do(Amazon.SimpleWorkflow.Model.ActivityTask task)
{
return new ActivityState()
{
Key = "output",
Value = new string(task.Input.ToCharArray().Reverse().ToArray())
};
}
示例11: PutScreenshot
public void PutScreenshot(Amazon.S3.AmazonS3 amazonS3Client, string bucketName, string path, Stream stream)
{
var putObjectRequest = new PutObjectRequest();
putObjectRequest.WithInputStream(stream);
putObjectRequest.WithBucketName(bucketName);
putObjectRequest.WithKey(path);
amazonS3Client.PutObject(putObjectRequest);
}
示例12: Create
///// <summary>
///// Allows the use of a specific config in the creation of the client for a context
///// </summary>
///// <param name="context">The context the client should be used in</param>
///// <param name="config">The config object for the client</param>
//public static void UseConfigForClient(DynamoDBContext context, AmazonS3Config config)
//{
// var castedClient = ((AmazonDynamoDBClient)context.Client);
// var client = new AmazonS3Client(castedClient.GetCredentials(), config);
// S3ClientCache cache;
// if (!S3Link.Caches.TryGetValue(context, out cache))
// {
// cache = new S3ClientCache(castedClient.GetCredentials(),castedClient.CloneConfig<AmazonS3Config>());
// S3Link.Caches.Add(context, cache);
// }
// cache.UseClient(client, config.RegionEndpoint);
//}
/// <summary>
/// Creates an S3Link that can be used to managed an S3 connection
/// </summary>
/// <param name="context">The context that is handling the S3Link</param>
/// <param name="bucket">The bucket the S3Link should manage</param>
/// <param name="key">The key that S3Link should store and download from</param>
/// <param name="region">The region of the S3 resource</param>
/// <returns>A new S3Link object that can upload and download to the target bucket</returns>
public static S3Link Create(DynamoDBContext context, string bucket, string key, Amazon.RegionEndpoint region)
{
S3ClientCache cacheFromKey;
if (S3Link.Caches.TryGetValue(context, out cacheFromKey))
{
return new S3Link(cacheFromKey, bucket, key, region.SystemName);
}
S3ClientCache cache = CreatClientCacheFromContext(context);
return new S3Link(cache, bucket, key, region.SystemName);
}
示例13: DeliveryClient
/// <summary>
/// Constructor of <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.DeliveryClient"/> class.
/// </summary>
/// <param name="isDataAllowed">An instance of IDeliveryPolicyFactory <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.IDeliveryPolicyFactory"/></param>
/// <param name="clientContext">An instance of ClientContext <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.ClientContext"/></param>
/// <param name="credentials">An instance of Credentials <see cref="Amazon.Runtime.AWSCredentials"/></param>
/// <param name="regionEndPoint">Region end point <see cref="Amazon.RegionEndpoint"/></param>
public DeliveryClient(IDeliveryPolicyFactory policyFactory, Amazon.Runtime.Internal.ClientContext clientContext, AWSCredentials credentials, RegionEndpoint regionEndPoint)
{
_policyFactory = policyFactory;
_mobileAnalyticsLowLevelClient = new AmazonMobileAnalyticsClient(credentials, regionEndPoint);
_clientContext = clientContext;
_appId = clientContext.AppID;
_eventStore = new SQLiteEventStore(AWSConfigsMobileAnalytics.MaxDBSize, AWSConfigsMobileAnalytics.DBWarningThreshold);
_deliveryPolicies = new List<IDeliveryPolicy>();
_deliveryPolicies.Add(_policyFactory.NewConnectivityPolicy());
_deliveryPolicies.Add(_policyFactory.NewBackgroundSubmissionPolicy());
}
示例14: AWSSubnet
public AWSSubnet(Amazon.EC2.Model.Subnet subnet)
{
Name = "Unnamed";
if (subnet != null)
{
foreach (var tag in subnet.Tags.Where(tag => tag.Key == "Name"))
{
Name = tag.Value;
}
SubnetId = subnet.SubnetId;
CidrBlock = subnet.CidrBlock;
}
}
示例15: Process
public void Process(long betScreenshotId, Amazon.S3.AmazonS3 amazonS3Client, SynchronizationContext synchronizationContext)
{
using (var transactionScope = _transactionScopeFactory.Create())
{
try
{
ProcessCore(betScreenshotId, amazonS3Client, synchronizationContext);
transactionScope.Complete();
}
catch (Exception ex)
{
Logger.ErrorException(String.Format("Failed to process betScreenshotId = {0}. Was not saved", betScreenshotId), ex);
}
}
}