//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 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(); }
public override void Initialize(string name, NameValueCollection config) { base.Initialize(name, config); accessKey = config["accessKey"]; secretKey = config["secretKey"]; if (string.IsNullOrEmpty(accessKey)) { throw new ConfigurationErrorsException("AWS Access Key is required."); } if (string.IsNullOrEmpty(secretKey)) { throw new ConfigurationErrorsException("AWS Secret Key is required."); } // Set any domain prefix if (!string.IsNullOrEmpty(config["domainPrefix"])) { domainPrefix = config["domainPrefix"]; } client = new AmazonSimpleDBClient(accessKey, secretKey); if (config["domains"] != null) { // Make sure domains exist string[] domains = config["domains"].ToString().Split(new char[] { ',' }); foreach (string domain in domains) { string _domain = SetDomain(domain); CreateDomainRequest request = new CreateDomainRequest().WithDomainName(_domain); client.CreateDomain(request); } } }
public override void Initialize(string name, NameValueCollection config) { if (config == null) { throw new ArgumentNullException("config"); } if (name == null || name.Length == 0) { name = "SDBProfileProvider"; } // Initialize the abstract base class. base.Initialize(name, config); accessKey = GetConfigValue(config["accessKey"], ""); secretKey = GetConfigValue(config["secretKey"], ""); domain = GetConfigValue(config["domain"], "Profiles"); client = new AmazonSimpleDBClient(accessKey, secretKey); // Make sure the domain for user profiles exists CreateDomainRequest cdRequest = new CreateDomainRequest(); cdRequest.DomainName = domain; client.CreateDomain(cdRequest); }
protected override void OnSetup() { var settings = (IDictionary<string, object>) Settings; object providedClient; if (settings.TryGetValue("Client", out providedClient)) { this.client = (AmazonSimpleDB) providedClient; return; } object accessKey; object secret; if (!settings.TryGetValue("AccessKey", out accessKey) || !settings.TryGetValue("Secret", out secret)) { throw new InvalidOperationException( "The SimpleDB adapter requires the AccessKey and Secret properties to be set."); } var config = new AmazonSimpleDBConfig(); object serviceUrl; if (settings.TryGetValue("ServiceUrl", out serviceUrl)) { config.WithServiceURL(serviceUrl.ToString()); } client = Amazon.AWSClientFactory.CreateAmazonSimpleDBClient(accessKey.ToString(), secret.ToString(), config); }
void Init() { client = new AmazonSimpleDBClient(accessKey, secretKey); foreach (string domain in domains) { string _domain = SetDomain(domain); CreateDomainRequest request = new CreateDomainRequest().WithDomainName(_domain); client.CreateDomain(request); } }
private void SetSimpleDBClient() { if (this.aSimpleDBClient != null) { this.aSimpleDBClient.Dispose(); this.aSimpleDBClient = null; } this.aSimpleDBClient = AWSClientFactory.CreateAmazonSimpleDBClient(this.aAWSAccessKey, this.aAWSSecretAccessKey); }
/// <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); }
/// <summary> /// Constructor with only the Amazon credentials /// </summary> /// <param name="amazonAccessKey"></param> /// <param name="amazonSecretKey"></param> public SimpleDBProvider(string amazonAccessKey, string amazonSecretKey) : this() { var entityMapper = new EntityMapper(); _deleteFactory = new BatchDeleteAttributeRequestFactory(new DeleteableItemAdapter()); _putFactory = new BatchPutAttributeRequestFactory(new ReplaceableItemAdapter(entityMapper)); _selectRequestFactory = new SelectRequestFactory(); _itemAdapter = new ItemAdapter(entityMapper); _domainRequestFactory = new DomainRequestFactory(); _simpleDB = new AmazonSimpleDBClient(amazonAccessKey, amazonSecretKey); }
public static bool DoesDomainExist(string domainName, AmazonSimpleDB sdbClient) { ListDomainsRequest listDomainsRequest = new ListDomainsRequest(); ListDomainsResult result = sdbClient.ListDomains(listDomainsRequest).ListDomainsResult; if (result != null) { return result.DomainName.Contains(domainName); } return false; }
public SimpleDBAdapter() { // initialize Amazon SimpleDBClient AmazonSimpleDBConfig simpleDBConfig = new AmazonSimpleDBConfig(); simpleDBConfig.ServiceURL = ConfigurationManager.AppSettings["SimpleDBServiceURL"]; m_simpleDBClient = AWSClientFactory.CreateAmazonSimpleDBClient(simpleDBConfig); m_BroadcastMessagesDomain = ConfigurationManager.AppSettings["BroadcastMessagesSDBDomain"]; m_GroupMessagesDomain = ConfigurationManager.AppSettings["GroupMessagesSDBDomain"]; m_PrivateMessagesDomain = ConfigurationManager.AppSettings["PrivateMessagesSDBDomain"]; m_UserStateDomain = ConfigurationManager.AppSettings["UserStateSDBDomain"]; }
public static void CheckForDomain(string domainName, AmazonSimpleDB sdbClient) { VerifyKeys(); ListDomainsRequest listDomainsRequest = new ListDomainsRequest(); ListDomainsResponse listDomainsResponse = sdbClient.ListDomains(listDomainsRequest); if (!listDomainsResponse.ListDomainsResult.DomainName.Contains(domainName)) { CreateDomainRequest createDomainRequest = new CreateDomainRequest().WithDomainName(domainName); sdbClient.CreateDomain(createDomainRequest); } }
/// <summary> /// Constructor with all dependencies injected /// </summary> /// <param name="deleteFactory">Factory for creating delete requests</param> /// <param name="putFactory">Factory for creating put requests</param> /// <param name="selectRequestFactory">Factory for creating select requests</param> /// <param name="itemAdapter">Factory for converting select response items to the given POCO of type T</param> /// <param name="simpleDb">Amazon SimpleDB instance</param> /// <param name="domainRequestFactory">Factory for domain requests</param> public SimpleDBProvider(BatchDeleteAttributeRequestFactory deleteFactory, BatchPutAttributeRequestFactory putFactory, SelectRequestFactory selectRequestFactory, ItemAdapter itemAdapter, AmazonSimpleDB simpleDb, DomainRequestFactory domainRequestFactory) : this() { _deleteFactory = deleteFactory; _putFactory = putFactory; _selectRequestFactory = selectRequestFactory; _itemAdapter = itemAdapter; _simpleDB = simpleDb; _domainRequestFactory = domainRequestFactory; }
public override void Initialize(string name, NameValueCollection config) { // // Initialize values from web.config. // if (config == null) { throw new ArgumentNullException("config"); } if (name == null || name.Length == 0) { name = "SDBRoleProvider"; } if (String.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", "Amazon Simple DB Role provider"); } // Initialize the abstract base class. base.Initialize(name, config); accessKey = GetConfigValue(config["accessKey"], ""); secretKey = GetConfigValue(config["secretKey"], ""); domain = GetConfigValue(config["domain"], "Roles"); if (config["writeExceptionsToEventLog"] != null) { if (config["writeExceptionsToEventLog"].ToUpper() == "TRUE") { pWriteExceptionsToEventLog = true; } } // // Initialize the SimpleDB Client. // client = new AmazonSimpleDBClient(accessKey, secretKey); // Make sure the domain for users exists CreateDomainRequest cdRequest = new CreateDomainRequest(); cdRequest.DomainName = domain; client.CreateDomain(cdRequest); }
public void setup() { var streamReader = new StreamReader(@"C:\SpecialSuperSecret\[email protected]"); var dictionary = new Dictionary<string, string>(); while (!streamReader.EndOfStream) { var line = streamReader.ReadLine(); var keyValue = line.Split(':'); dictionary.Add(keyValue[0], keyValue[1]); } _key = dictionary["UserName"]; _secret = dictionary["Password"]; _client = Amazon.AWSClientFactory.CreateAmazonSimpleDBClient(_key, _secret); _manager = new UserManager(new AuthenticationServiceConfig() {StoreName = "TEST_AUTHENTICATION"}, _client); }
private void GivenAFeatureUsageService() { _simpleDbClient = MockRepository.GenerateStub<AmazonSimpleDB>(); _simpleDbClient .Stub(s => s.PutAttributes(Arg<PutAttributesRequest>.Is.Anything)) .Return(null); _exceptionToThrow = new Exception("Something really bad happened"); _simpleDbClient .Stub(s => s.CreateDomain(Arg<CreateDomainRequest>.Is.Anything)) .Throw(_exceptionToThrow); _domainName = "My Domain"; Action<Exception> exceptionAction = exception => _exceptions.Add(exception); _service = new SimpleDbFeatureUsageService(exceptionAction, _domainName, _simpleDbClient); }
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); }
/// <summary> /// Put the user's reco into the ZigMeRecos domain in SimpleDB /// </summary> /// <returns></returns> private bool SaveRecoToSimpleDB(string myFBId) { AmazonSimpleDB sdb = GetSDB(); // Creating a domain String domainName = "ZigMeRecos"; CreateDomainRequest createDomain = (new CreateDomainRequest()).WithDomainName(domainName); sdb.CreateDomain(createDomain); // Check to see how many recos this FB user id has stored in our domain String selectExpression = "Select * From ZigMeRecos Where FBId = '" + myFBId + "'"; SelectRequest selectRequestAction = new SelectRequest().WithSelectExpression(selectExpression); SelectResponse selectResponse = sdb.Select(selectRequestAction); int cRecos = 0; // Now store the actual recommendation item if (selectResponse.IsSetSelectResult()) { SelectResult selectResult = selectResponse.SelectResult; cRecos = selectResult.Item.Count; } cRecos++; String recoItem = "Reco_" + myFBId + "_" + cRecos; PutAttributesRequest putAttributesRecoItem = new PutAttributesRequest().WithDomainName(domainName).WithItemName(recoItem); List <ReplaceableAttribute> attributesRecoItem = putAttributesRecoItem.Attribute; attributesRecoItem.Add(new ReplaceableAttribute().WithName("FBId").WithValue(myFBId)); attributesRecoItem.Add(new ReplaceableAttribute().WithName("Name").WithValue(RecoName.Text)); attributesRecoItem.Add(new ReplaceableAttribute().WithName("Email").WithValue(ContactEmail.Text)); attributesRecoItem.Add(new ReplaceableAttribute().WithName("City").WithValue(RecoCity.Text)); attributesRecoItem.Add(new ReplaceableAttribute().WithName("Service").WithValue(RecoService.SelectedValue)); PutAttributesResponse putAttributesResponse = sdb.PutAttributes(putAttributesRecoItem); return(putAttributesResponse.IsSetResponseMetadata()); }
protected void Page_Load(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(1024); using (StringWriter sr = new StringWriter(sb)) { try { ec2 = AWSClientFactory.CreateAmazonEC2Client(RegionEndpoint.USWest2); 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("XML: " + ex.XML); 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(RegionEndpoint.USWest2); 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("XML: " + ex.XML); 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(RegionEndpoint.USWest2); 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("XML: " + ex.XML); sr.WriteLine("<br />"); sr.WriteLine("<br />"); } this.sdbPlaceholder.Text = sr.ToString(); } } }
// // System.Configuration.Provider.ProviderBase.Initialize Method // public override void Initialize(string name, NameValueCollection config) { // // Initialize values from web.config. // if (config == null) { throw new ArgumentNullException("config"); } if (name == null || name.Length == 0) { name = "SDBMembershipProvider"; } // Initialize the abstract base class. base.Initialize(name, config); accessKey = GetConfigValue(config["accessKey"], ""); secretKey = GetConfigValue(config["secretKey"], ""); domain = GetConfigValue(config["domain"], "Users"); pWriteExceptionsToEventLog = Convert.ToBoolean(GetConfigValue(config["writeExceptionsToEventLog"], "true")); string temp_format = config["passwordFormat"]; if (temp_format == null) { temp_format = "Hashed"; } switch (temp_format) { case "Hashed": pPasswordFormat = MembershipPasswordFormat.Hashed; break; case "Encrypted": pPasswordFormat = MembershipPasswordFormat.Encrypted; break; case "Clear": pPasswordFormat = MembershipPasswordFormat.Clear; break; default: throw new ProviderException("Password format not supported."); } // // Initialize the SimpleDB Client. // client = new AmazonSimpleDBClient(accessKey, secretKey); // Make sure the domain for users exists CreateDomainRequest cdRequest = new CreateDomainRequest(); cdRequest.DomainName = domain; client.CreateDomain(cdRequest); // Get encryption and decryption key information from the configuration. Configuration cfg = WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath); machineKey = (MachineKeySection)cfg.GetSection("system.web/machineKey"); if (machineKey.ValidationKey.Contains("AutoGenerate")) { if (PasswordFormat != MembershipPasswordFormat.Clear) { throw new ProviderException("Hashed or Encrypted passwords " + "are not supported with auto-generated keys."); } } }
public override void Initialize(string name, NameValueCollection config) { if (config == null) throw new ArgumentNullException("config"); if (name == null || name.Length == 0) name = "SDBProfileProvider"; // Initialize the abstract base class. base.Initialize(name, config); accessKey = GetConfigValue(config["accessKey"], ""); secretKey = GetConfigValue(config["secretKey"], ""); domain = GetConfigValue(config["domain"], "Profiles"); client = new AmazonSimpleDBClient(accessKey, secretKey); // Make sure the domain for user profiles exists CreateDomainRequest cdRequest = new CreateDomainRequest(); cdRequest.DomainName = domain; client.CreateDomain(cdRequest); }
public WorkItemFactoryAWS(string awsAccessKey, string awsSecretKey) { sdb = AWSClientFactory.CreateAmazonSimpleDBClient(awsAccessKey, awsSecretKey); }
// // System.Configuration.Provider.ProviderBase.Initialize Method // public override void Initialize(string name, NameValueCollection config) { // // Initialize values from web.config. // if (config == null) throw new ArgumentNullException("config"); if (name == null || name.Length == 0) name = "SDBMembershipProvider"; // Initialize the abstract base class. base.Initialize(name, config); accessKey = GetConfigValue(config["accessKey"], ""); secretKey = GetConfigValue(config["secretKey"], ""); domain = GetConfigValue(config["domain"], "Users"); pWriteExceptionsToEventLog = Convert.ToBoolean(GetConfigValue(config["writeExceptionsToEventLog"], "true")); string temp_format = config["passwordFormat"]; if (temp_format == null) { temp_format = "Hashed"; } switch (temp_format) { case "Hashed": pPasswordFormat = MembershipPasswordFormat.Hashed; break; case "Encrypted": pPasswordFormat = MembershipPasswordFormat.Encrypted; break; case "Clear": pPasswordFormat = MembershipPasswordFormat.Clear; break; default: throw new ProviderException("Password format not supported."); } // // Initialize the SimpleDB Client. // client = new AmazonSimpleDBClient(accessKey, secretKey); // Make sure the domain for users exists CreateDomainRequest cdRequest = new CreateDomainRequest(); cdRequest.DomainName = domain; client.CreateDomain(cdRequest); // Get encryption and decryption key information from the configuration. Configuration cfg = WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath); machineKey = (MachineKeySection)cfg.GetSection("system.web/machineKey"); if (machineKey.ValidationKey.Contains("AutoGenerate")) if (PasswordFormat != MembershipPasswordFormat.Clear) throw new ProviderException("Hashed or Encrypted passwords " + "are not supported with auto-generated keys."); }
public UserManager(AuthenticationServiceConfig config, AmazonSimpleDB client) { _config = config; _client = client; EnsureDomain(); }
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 static Database OpenSimpleDb(this IDatabaseOpener opener, AmazonSimpleDB client) { return opener.Open("SimpleDb", new {Client = client}); }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { CheckIfFacebookAppIsSetupCorrectly(); var auth = new CanvasAuthorizer { Permissions = new[] { "user_about_me" } }; if (auth.Authorize()) { ShowFacebookContent(); } } else { AmazonSimpleDB sdb = GetSDB(); // Should I clean out the AWS domain state? if (Page.Request.Params["delaws"] == "1") { //Deleting a domain DeleteDomainRequest deleteDomainAction = new DeleteDomainRequest().WithDomainName("ZigMeRecos"); sdb.DeleteDomain(deleteDomainAction); } // Now read from the AWS domain and populate the dropdown list // First check to see if a domain contain service types exists. if not then create it and populate it // Listing domains /*ListDomainsResponse sdbListDomainsResponse = sdb.ListDomains(new ListDomainsRequest()); * if (sdbListDomainsResponse.IsSetListDomainsResult()) * { * ListDomainsResult listDomainsResult = sdbListDomainsResponse.ListDomainsResult; * * if (!listDomainsResult.DomainName.Contains("ZigMeServiceTypes")) * { * } * else * { * String selectExpression = "Select * From ZigMeServiceTypes"; * SelectRequest selectRequestAction = new SelectRequest().WithSelectExpression(selectExpression); * SelectResponse selectResponse = sdb.Select(selectRequestAction); * if (selectResponse.IsSetSelectResult()) * { * SelectResult selectResult = selectResponse.SelectResult; * foreach (Item item in selectResult.Item) * { * foreach (Amazon.SimpleDB.Model.Attribute attribute in item.Attribute) * { * if (attribute.IsSetName() && attribute.IsSetValue()) * { * } * } * } * } * } * }*/ } }
public SimpleDBDataStore() { _simpleDb = AwsFacade.GetSimpleDBClient(); }
public SimpleDBHelper(AmazonSimpleDB amazonSimpleDBClient) { Client = amazonSimpleDBClient; }
public SimpleDBQueryProvider(AmazonSimpleDB service, string domainName, SetterDelegate setter) { m_service = service; m_domainName = domainName; m_setter = setter; }
private void UploadEvent(LoggingEvent loggingEvent, AmazonSimpleDB client) { var request = new PutAttributesRequest(); request.Attribute.Add( new ReplaceableAttribute { Name = "UserName", Replace = true, Value = loggingEvent.UserName }); request.Attribute.Add( new ReplaceableAttribute { Value = loggingEvent.TimeStamp.ToString(CultureInfo.InvariantCulture), Name = "TimeStamp", Replace = true }); request.Attribute.Add( new ReplaceableAttribute { Value = loggingEvent.ThreadName, Name = "ThreadName", Replace = true }); request.Attribute.Add( new ReplaceableAttribute { Value = loggingEvent.RenderedMessage, Name = "Message", Replace = true }); request.Attribute.Add( new ReplaceableAttribute { Value = loggingEvent.LoggerName, Name = "LoggerName", Replace = true }); request.Attribute.Add( new ReplaceableAttribute { Value = loggingEvent.Level.ToString(), Name = "Level", Replace = true }); request.Attribute.Add( new ReplaceableAttribute { Value = loggingEvent.Identity, Name = "Identity", Replace = true }); request.Attribute.Add( new ReplaceableAttribute { Value = loggingEvent.Domain, Name = "Domain", Replace = true }); request.Attribute.Add( new ReplaceableAttribute { Value = DateTime.UtcNow.ToString(CultureInfo.InvariantCulture), Name = "CreatedOn", Replace = true }); request.DomainName = _dbName; request.ItemName = Guid.NewGuid().ToString(); client.PutAttributes(request); }
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("XML: " + ex.XML); 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("XML: " + ex.XML); 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("XML: " + ex.XML); sr.WriteLine("<br />"); sr.WriteLine("<br />"); } this.sdbPlaceholder.Text = sr.ToString(); } } }
public SimpleDBWorkStepRepository(string domain, string accessKey, string secretKey) { _domain = domain; _client = AWSClientFactory.CreateAmazonSimpleDBClient(accessKey, secretKey); EnsureDomain(_domain); }
public SimpleDbDomainConfiguration(ISimpleDbConfiguration config) { _config = config; _service = AWSClientFactory.CreateAmazonSimpleDBClient (config.SimpleDbAccessKey, config.SimpleDbSecretKey, config.AmazonSimpleDbConfig); }
public void SetUp() { _client = AWSClientFactory.CreateAmazonSimpleDBClient(Access_Key_ID, Secret_Access_Key); //A pre-requisite for testing SimpleDB Objects. Ensure that we create one Domain to test the Objects. //Create the Domain. bool hasCallbackArrived = false; SimpleDBResponseEventHandler<object, ResponseEventArgs> handler = null; handler = delegate(object sender, ResponseEventArgs args) { //Unhook from event. _client.OnSimpleDBResponse -= handler; hasCallbackArrived = true; }; _client.OnSimpleDBResponse += handler; _client.BeginCreateDomain(new Amazon.SimpleDB.Model.CreateDomainRequest { DomainName = _domainName_UnitTesting }); EnqueueConditional(() => hasCallbackArrived); EnqueueTestComplete(); }
/// <summary> /// Constructor with arguments /// </summary> /// <param name="onFailure">What to do in the catch clause when an exception occurs in the NotifyFeatureUsageSafe method</param> /// <param name="domainName">Domain to log feature usage to</param> /// <param name="simpleDbClient">SimpleDb client to use for persistence</param> public SimpleDbFeatureSubscriptionService(Action<Exception> onFailure, string domainName, AmazonSimpleDB simpleDbClient) { _onFailure = onFailure; _domainName = domainName; _simpleDbClient = simpleDbClient; }
public override void Initialize(string name, NameValueCollection config) { base.Initialize(name, config); accessKey = config["accessKey"]; secretKey = config["secretKey"]; if (string.IsNullOrEmpty(accessKey)) throw new ConfigurationErrorsException("AWS Access Key is required."); if (string.IsNullOrEmpty(secretKey)) throw new ConfigurationErrorsException("AWS Secret Key is required."); // Set any domain prefix if (!string.IsNullOrEmpty(config["domainPrefix"])) domainPrefix = config["domainPrefix"]; client = new AmazonSimpleDBClient(accessKey, secretKey); if (config["domains"] != null) { // Make sure domains exist string[] domains = config["domains"].ToString().Split(new char[] { ',' }); foreach (string domain in domains) { string _domain = SetDomain(domain); CreateDomainRequest request = new CreateDomainRequest().WithDomainName(_domain); client.CreateDomain(request); } } }
protected override void SafeManagedResourcesDisposing() { m_simpleDBClient.Dispose(); m_simpleDBClient = null; }
public override void Initialize(string name, NameValueCollection config) { // // Initialize values from web.config. // if (config == null) throw new ArgumentNullException("config"); if (name == null || name.Length == 0) name = "SDBRoleProvider"; if (String.IsNullOrEmpty(config["description"])) { config.Remove("description"); config.Add("description", "Amazon Simple DB Role provider"); } // Initialize the abstract base class. base.Initialize(name, config); accessKey = GetConfigValue(config["accessKey"], ""); secretKey = GetConfigValue(config["secretKey"], ""); domain = GetConfigValue(config["domain"], "Roles"); if (config["writeExceptionsToEventLog"] != null) { if (config["writeExceptionsToEventLog"].ToUpper() == "TRUE") { pWriteExceptionsToEventLog = true; } } // // Initialize the SimpleDB Client. // client = new AmazonSimpleDBClient(accessKey, secretKey); // Make sure the domain for users exists CreateDomainRequest cdRequest = new CreateDomainRequest(); cdRequest.DomainName = domain; client.CreateDomain(cdRequest); }
// Change the accessKeyID and the secretAccessKeyID to your credentials 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(); }
public SimpleDbProxy() { _simpleDbClient = AWSClientFactory.CreateAmazonSimpleDBClient(new AmazonSimpleDBConfig()); }