Ejemplo n.º 1
0
        public MainPage()
        {
            InitializeComponent();
            this.DataContext = this;

            SimpleDB.Client = AWSClientFactory.CreateAmazonSimpleDBClient();

            PropertyChanged += ((object sender, PropertyChangedEventArgs e) =>
            {
                if (string.Compare(e.PropertyName, "SelectedIndex", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    if (SelectedIndex >= 0)
                    {
                        //Update the bucket-name with the currently selected one.
                        this.DomainName = this.DomainNameList[SelectedIndex];
                    }
                }
                else if (string.Compare(e.PropertyName, "DomainName", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    if (string.IsNullOrEmpty(_domainName))
                    {
                        this.IsDomainNameSet = false;
                    }
                    else
                    {
                        this.IsDomainNameSet = true;
                    }
                }
            });
        }
Ejemplo n.º 2
0
        public void sendAmazonSimpleDbIndex(String XML)
        {
            AmazonSimpleDB sdb = AWSClientFactory.CreateAmazonSimpleDBClient(RegionEndpoint.USWest2);

            try
            {
                String domainName = "";

                CreateDomainRequest createDomain2 = (new CreateDomainRequest()).WithDomainName("index");
                sdb.CreateDomain(createDomain2);

                domainName = "index";
                String itemNameTwo = "1";
                PutAttributesRequest        putAttributesActionTwo = new PutAttributesRequest().WithDomainName(domainName).WithItemName(itemNameTwo);
                List <ReplaceableAttribute> attributesTwo          = putAttributesActionTwo.Attribute;
                attributesTwo.Add(new ReplaceableAttribute().WithName("indexID").WithValue(indexID));
                attributesTwo.Add(new ReplaceableAttribute().WithName("compID").WithValue(machineName));
                attributesTwo.Add(new ReplaceableAttribute().WithName("XML_Profile").WithValue(XML));

                sdb.PutAttributes(putAttributesActionTwo);
            }
            catch (AmazonSimpleDBException ex)
            {
                failCount++;
                log("Caught Exception: " + ex.Message);
                log("Response Status Code: " + ex.StatusCode);
                log("Error Code: " + ex.ErrorCode);
                log("Error Type: " + ex.ErrorType);
                log("Request ID: " + ex.RequestId);
                log("XML: " + ex.XML);
            }

            //Console.WriteLine("Press Enter to continue...");
            //Console.Read();
        }
Ejemplo n.º 3
0
        //Amazon
        public void sendAmazonSimpleMachineName()
        {
            AmazonSimpleDB sdb = AWSClientFactory.CreateAmazonSimpleDBClient(RegionEndpoint.USWest2);

            try
            {
                String domainName = "";

                CreateDomainRequest createDomain = (new CreateDomainRequest()).WithDomainName("Computer");
                sdb.CreateDomain(createDomain);

                // Putting data into a domain
                domainName = "Computer";

                String itemNameOne = "1";
                PutAttributesRequest        putAttributesActionOne = new PutAttributesRequest().WithDomainName(domainName).WithItemName(itemNameOne);
                List <ReplaceableAttribute> attributesOne          = putAttributesActionOne.Attribute;
                attributesOne.Add(new ReplaceableAttribute().WithName("compID").WithValue(machineName));
                attributesOne.Add(new ReplaceableAttribute().WithName("compName").WithValue(machineName));
                sdb.PutAttributes(putAttributesActionOne);
            }
            catch (AmazonSimpleDBException ex)
            {
                log(".........AmazonSimpleDBException.........");
                log("Caught Exception: " + ex.Message);
                log("Response Status Code: " + ex.StatusCode);
                log("Error Code: " + ex.ErrorCode);
                log("Error Type: " + ex.ErrorType);
                log("Request ID: " + ex.RequestId);
                log("XML: " + ex.XML);
            }
        }
        public static void InvokeListDomains()
        {
            NameValueCollection appConfig = ConfigurationManager.AppSettings;

            // Print the number of Amazon SimpleDB domains.
            IAmazonSimpleDB sdb = AWSClientFactory.CreateAmazonSimpleDBClient(RegionEndpoint.USWest2);

            try
            {
                ListDomainsResponse sdbResponse = sdb.ListDomains(new ListDomainsRequest());

                int numDomains = 0;
                numDomains = sdbResponse.DomainNames.Count;
                Console.WriteLine("You have " + numDomains + " Amazon SimpleDB domain(s).");
            }
            catch (AmazonSimpleDBException ex)
            {
                if (ex.ErrorCode.Equals("AuthFailure"))
                {
                    Console.WriteLine("Please check the provided AWS access credentials.");
                    Console.WriteLine("If you haven't signed up for Amazon SimpleDB yet, you can sign up at http://aws.amazon.com/simpledb.");
                }
                else
                {
                    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();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get a reference to an instance of AmazonSimpleDB
        /// </summary>
        /// <returns></returns>
        private AmazonSimpleDB GetSDB()
        {
            NameValueCollection appConfig = ConfigurationManager.AppSettings;
            AmazonSimpleDB      sdb       = AWSClientFactory.CreateAmazonSimpleDBClient(
                appConfig["AWSAccessKey"],
                appConfig["AWSSecretKey"]
                );

            return(sdb);
        }
Ejemplo n.º 6
0
        private void SetSimpleDBClient()
        {
            if (this.aSimpleDBClient != null)
            {
                this.aSimpleDBClient.Dispose();
                this.aSimpleDBClient = null;
            }

            this.aSimpleDBClient = AWSClientFactory.CreateAmazonSimpleDBClient(this.aAWSAccessKey, this.aAWSSecretAccessKey);
        }
Ejemplo n.º 7
0
        // Change the AWSProfileName to the profile you want to use in the App.config file.
        // See http://aws.amazon.com/credentials  for more details.
        //
        // This sample adds 50 items in a domain using the synchronized API and then
        // the asynchronized API.
        static void Main(string[] args)
        {
            sdb = AWSClientFactory.CreateAmazonSimpleDBClient(RegionEndpoint.USWest2);

            AddDataSynchronized();

            AddDataAsynchronized();

            Console.WriteLine("Press Enter to continue...");
            Console.Read();
        }
        private AmazonSimpleDB GetSimpleDbClient()
        {
            var accessKey  = Config.AwsKey;
            var privateKey = Config.AwsSecretKey;

            return(AWSClientFactory.CreateAmazonSimpleDBClient(
                       accessKey, privateKey, new AmazonSimpleDBConfig()
            {
                ServiceURL = "https://sdb.eu-west-1.amazonaws.com"
            }));
        }
Ejemplo n.º 9
0
        public bool sendAmazonSimpleDbImage(String filename, String partNo, String part)
        {
            AmazonSimpleDB sdb = AWSClientFactory.CreateAmazonSimpleDBClient(RegionEndpoint.USWest2);

            try
            {
                String domainName = "";

                CreateDomainRequest createDomain3 = (new CreateDomainRequest()).WithDomainName("Images");
                sdb.CreateDomain(createDomain3);

                domainName = "Images";
                String itemNameThree = itemNo.ToString();
                PutAttributesRequest        putAttributesActionThree = new PutAttributesRequest().WithDomainName(domainName).WithItemName(itemNameThree);
                List <ReplaceableAttribute> attributesThree          = putAttributesActionThree.Attribute;
                attributesThree.Add(new ReplaceableAttribute().WithName("ImgID").WithValue("TestImage01"));
                attributesThree.Add(new ReplaceableAttribute().WithName("indexID").WithValue("1"));
                attributesThree.Add(new ReplaceableAttribute().WithName("Extension").WithValue("jpg"));
                attributesThree.Add(new ReplaceableAttribute().WithName("location").WithValue(filename));
                attributesThree.Add(new ReplaceableAttribute().WithName("imgPart").WithValue(partNo.ToString()));
                attributesThree.Add(new ReplaceableAttribute().WithName("raw").WithValue(part));
                sdb.PutAttributes(putAttributesActionThree);
            }
            catch (AmazonSimpleDBException ex)
            {
                failCount++;
                log("Caught Exception: " + ex.Message);
                log("Response Status Code: " + ex.StatusCode);
                log("Error Code: " + ex.ErrorCode);
                log("Error Type: " + ex.ErrorType);
                log("Request ID: " + ex.RequestId);
                log("XML: " + ex.XML);

                return(false);
            }
            itemNo++;
            return(true);
        }
Ejemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder(1024);

            using (StringWriter sr = new StringWriter(sb))
            {
                try
                {
                    ec2 = AWSClientFactory.CreateAmazonEC2Client();
                    this.WriteEC2Info();
                }
                catch (AmazonEC2Exception ex)
                {
                    if (ex.ErrorCode != null && ex.ErrorCode.Equals("AuthFailure"))
                    {
                        sr.WriteLine("The account you are using is not signed up for Amazon EC2.");
                        sr.WriteLine("<br />");
                        sr.WriteLine("You can sign up for Amazon EC2 at http://aws.amazon.com/ec2");
                        sr.WriteLine("<br />");
                        sr.WriteLine("<br />");
                    }
                    else
                    {
                        sr.WriteLine("Caught Exception: " + ex.Message);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Response Status Code: " + ex.StatusCode);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Error Code: " + ex.ErrorCode);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Error Type: " + ex.ErrorType);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Request ID: " + ex.RequestId);
                        sr.WriteLine("<br />");
                        sr.WriteLine("<br />");
                    }
                    this.ec2Placeholder.Text = sr.ToString();
                }
            }

            sb = new StringBuilder(1024);
            using (StringWriter sr = new StringWriter(sb))
            {
                try
                {
                    s3 = AWSClientFactory.CreateAmazonS3Client();
                    this.WriteS3Info();
                }
                catch (AmazonS3Exception ex)
                {
                    if (ex.ErrorCode != null && (ex.ErrorCode.Equals("InvalidAccessKeyId") ||
                                                 ex.ErrorCode.Equals("InvalidSecurity")))
                    {
                        sr.WriteLine("The account you are using is not signed up for Amazon S3");
                        sr.WriteLine("<br />");
                        sr.WriteLine("You can sign up for Amazon S3 at http://aws.amazon.com/s3");
                        sr.WriteLine("<br/>");
                        sr.WriteLine("<br/>");
                    }
                    else
                    {
                        sr.WriteLine("Caught Exception: " + ex.Message);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Response Status Code: " + ex.StatusCode);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Error Code: " + ex.ErrorCode);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Request ID: " + ex.RequestId);
                        sr.WriteLine("<br />");
                        sr.WriteLine("<br />");
                    }
                    this.s3Placeholder.Text = sr.ToString();
                }
            }

            sb = new StringBuilder(1024);
            using (StringWriter sr = new StringWriter(sb))
            {
                try
                {
                    sdb = AWSClientFactory.CreateAmazonSimpleDBClient();
                    this.WriteSimpleDBInfo();
                }
                catch (AmazonSimpleDBException ex)
                {
                    if (ex.ErrorCode != null && ex.ErrorCode.Equals("InvalidClientTokenId"))
                    {
                        sr.WriteLine("The account you are using is not signed up for Amazon SimpleDB.");
                        sr.WriteLine("<br />");
                        sr.WriteLine("You can sign up for Amazon SimpleDB at http://aws.amazon.com/simpledb");
                        sr.WriteLine("<br />");
                        sr.WriteLine("<br />");
                    }
                    else
                    {
                        sr.WriteLine("Exception Message: " + ex.Message);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Response Status Code: " + ex.StatusCode);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Error Code: " + ex.ErrorCode);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Error Type: " + ex.ErrorType);
                        sr.WriteLine("<br />");
                        sr.WriteLine("Request ID: " + ex.RequestId);
                        sr.WriteLine("<br />");
                        sr.WriteLine("<br />");
                    }
                    this.sdbPlaceholder.Text = sr.ToString();
                }
            }
        }
Ejemplo n.º 11
0
        public static string GetServiceOutput()
        {
            StringBuilder sb = new StringBuilder(1024);

            using (StringWriter sr = new StringWriter(sb))
            {
                sr.WriteLine("===========================================");
                sr.WriteLine("Welcome to the AWS .NET SDK!");
                sr.WriteLine("===========================================");

                // Print the number of Amazon EC2 instances.
                AmazonEC2 ec2 = AWSClientFactory.CreateAmazonEC2Client();
                DescribeInstancesRequest ec2Request = new DescribeInstancesRequest();

                try
                {
                    DescribeInstancesResponse ec2Response = ec2.DescribeInstances(ec2Request);
                    int numInstances = 0;
                    numInstances = ec2Response.DescribeInstancesResult.Reservation.Count;
                    sr.WriteLine("You have " + numInstances + " Amazon EC2 instance(s) running in the US-East (Northern Virginia) region.");
                }
                catch (AmazonEC2Exception ex)
                {
                    if (ex.ErrorCode != null && ex.ErrorCode.Equals("AuthFailure"))
                    {
                        sr.WriteLine("The account you are using is not signed up for Amazon EC2.");
                        sr.WriteLine("You can sign up for Amazon EC2 at http://aws.amazon.com/ec2");
                    }
                    else
                    {
                        sr.WriteLine("Caught Exception: " + ex.Message);
                        sr.WriteLine("Response Status Code: " + ex.StatusCode);
                        sr.WriteLine("Error Code: " + ex.ErrorCode);
                        sr.WriteLine("Error Type: " + ex.ErrorType);
                        sr.WriteLine("Request ID: " + ex.RequestId);
                        sr.WriteLine("XML: " + ex.XML);
                    }
                }
                sr.WriteLine();

                // Print the number of Amazon SimpleDB domains.
                AmazonSimpleDB     sdb        = AWSClientFactory.CreateAmazonSimpleDBClient();
                ListDomainsRequest sdbRequest = new ListDomainsRequest();

                try
                {
                    ListDomainsResponse sdbResponse = sdb.ListDomains(sdbRequest);

                    if (sdbResponse.IsSetListDomainsResult())
                    {
                        int numDomains = 0;
                        numDomains = sdbResponse.ListDomainsResult.DomainName.Count;
                        sr.WriteLine("You have " + numDomains + " Amazon SimpleDB domain(s) in the US-East (Northern Virginia) region.");
                    }
                }
                catch (AmazonSimpleDBException ex)
                {
                    if (ex.ErrorCode != null && ex.ErrorCode.Equals("AuthFailure"))
                    {
                        sr.WriteLine("The account you are using is not signed up for Amazon SimpleDB.");
                        sr.WriteLine("You can sign up for Amazon SimpleDB at http://aws.amazon.com/simpledb");
                    }
                    else
                    {
                        sr.WriteLine("Caught Exception: " + ex.Message);
                        sr.WriteLine("Response Status Code: " + ex.StatusCode);
                        sr.WriteLine("Error Code: " + ex.ErrorCode);
                        sr.WriteLine("Error Type: " + ex.ErrorType);
                        sr.WriteLine("Request ID: " + ex.RequestId);
                        sr.WriteLine("XML: " + ex.XML);
                    }
                }
                sr.WriteLine();

                // Print the number of Amazon S3 Buckets.
                AmazonS3 s3Client = AWSClientFactory.CreateAmazonS3Client();

                try
                {
                    ListBucketsResponse response = s3Client.ListBuckets();
                    int numBuckets = 0;
                    if (response.Buckets != null &&
                        response.Buckets.Count > 0)
                    {
                        numBuckets = response.Buckets.Count;
                    }
                    sr.WriteLine("You have " + numBuckets + " Amazon S3 bucket(s) in the US Standard region.");
                }
                catch (AmazonS3Exception ex)
                {
                    if (ex.ErrorCode != null && (ex.ErrorCode.Equals("InvalidAccessKeyId") ||
                                                 ex.ErrorCode.Equals("InvalidSecurity")))
                    {
                        sr.WriteLine("Please check the provided AWS Credentials.");
                        sr.WriteLine("If you haven't signed up for Amazon S3, please visit http://aws.amazon.com/s3");
                    }
                    else
                    {
                        sr.WriteLine("Caught Exception: " + ex.Message);
                        sr.WriteLine("Response Status Code: " + ex.StatusCode);
                        sr.WriteLine("Error Code: " + ex.ErrorCode);
                        sr.WriteLine("Request ID: " + ex.RequestId);
                        sr.WriteLine("XML: " + ex.XML);
                    }
                }
                sr.WriteLine("Press any key to continue...");
            }
            return(sb.ToString());
        }
 public SimpleDBWorkStepRepository(string domain, string accessKey, string secretKey)
 {
     _domain = domain;
     _client = AWSClientFactory.CreateAmazonSimpleDBClient(accessKey, secretKey);
     EnsureDomain(_domain);
 }
Ejemplo n.º 13
0
 public static AmazonSimpleDB GetSimpleDBClient()
 {
     return(AWSClientFactory.CreateAmazonSimpleDBClient(AccessKey, SecretKey));
 }
Ejemplo n.º 14
0
 public SimpleDBHelper(AwsClientDetails clientDetails)
 {
     Client = AWSClientFactory.CreateAmazonSimpleDBClient(clientDetails.AwsAccessKeyId, clientDetails.AwsSecretAccessKey);
 }
Ejemplo n.º 15
0
 public SimpleDBHelper(string awsAccessKeyId, string awsSecretAccessKey)
 {
     Client = AWSClientFactory.CreateAmazonSimpleDBClient(awsAccessKeyId, awsSecretAccessKey);
 }