public override void SetPropertyValues(SettingsContext sc, SettingsPropertyValueCollection properties) { string username = (string)sc["UserName"]; bool userIsAuthenticated = (bool)sc["IsAuthenticated"]; MCItem item = new MCItem(username, domain); item.Attributes.Add("Anon", ""); item.Attributes.Add("LastUpdated", DateTime.Now.ToShortDateString()); foreach (SettingsPropertyValue property in properties) { if (property.PropertyValue != null) { item.Attributes.Add(property.Name, property.PropertyValue.ToString()); } } PutAttributesRequest request = new PutAttributesRequest().WithDomainName(item.Domain).WithItemName(item.ItemName); List <ReplaceableAttribute> attributes = new List <ReplaceableAttribute>(); foreach (string key in item.Attributes.Keys) { attributes.Add(new ReplaceableAttribute().WithName(key).WithValue(item.Attributes[key].ToString()).WithReplace(true)); } request.Attribute = attributes; client.PutAttributes(request); }
/// <summary> /// Returns a user's profile /// Currently assumes a single user will match the token. /// </summary> /// <param name="authenticationOption"></param> /// <param name="usernameToMatch"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="totalRecords"></param> /// <returns></returns> public override ProfileInfoCollection FindProfilesByUserName(ProfileAuthenticationOption authenticationOption, string usernameToMatch, int pageIndex, int pageSize, out int totalRecords) { // TODO: Take paging into account // TODO: Take auth option into account totalRecords = 0; ProfileInfoCollection profiles = new ProfileInfoCollection(); GetAttributesRequest request = new GetAttributesRequest().WithDomainName(domain).WithItemName(usernameToMatch); GetAttributesResponse response = client.GetAttributes(request); if (response.GetAttributesResult.Attribute.Count > 0) { ProfileInfo profile = null; List <Attribute> attributes = response.GetAttributesResult.Attribute; MCItem item = new MCItem(); item.Domain = domain; item.ItemName = usernameToMatch; item.Attributes = new Hashtable(); foreach (Attribute attribute in attributes) { item.Attributes.Add(attribute.Name, attribute.Value); } bool Anon = bool.Parse(item.Get("Anon").Replace("", "false")); DateTime LastActivity = DateTime.Parse(item.Get("LastActivity")); DateTime LastUpdated = DateTime.Parse(item.Get("LastUpdated")); profile = new ProfileInfo(item.Id, Anon, LastActivity, LastUpdated, 0); profiles.Add(profile); } totalRecords = profiles.Count; return(profiles); }
public override void SaveItem(MCItem item) { item.Domain = SetDomain(item.Domain); PutAttributesRequest request = new PutAttributesRequest().WithDomainName(item.Domain).WithItemName(item.ItemName); List <ReplaceableAttribute> attributes = new List <ReplaceableAttribute>(); foreach (string key in item.Attributes.Keys) { attributes.Add(new ReplaceableAttribute().WithName(key).WithValue(item.Attributes[key].ToString()).WithReplace(true)); } request.Attribute = attributes; client.PutAttributes(request); }
/// <summary> /// Returns a SIMPLEDB object with ALL attributes. /// </summary> /// <param name="ItemName">Same as the item ID.</param> /// <param name="Domain"></param> /// <returns></returns> public override MCItem GetItem(string ItemName, string Domain) { string sdbDomain = SetDomain(Domain); GetAttributesRequest request = new GetAttributesRequest().WithDomainName(sdbDomain).WithItemName(ItemName); GetAttributesResponse response = client.GetAttributes(request); MCItem item = new MCItem(); item.Domain = Domain; item.ItemName = ItemName; item.Attributes = new Hashtable(); foreach (Attribute attribute in response.GetAttributesResult.Attribute) { item.Attributes.Add(attribute.Name, attribute.Value); } return item; }
/// <summary> /// Returns a SIMPLEDB object with ALL attributes. /// </summary> /// <param name="ItemName">Same as the item ID.</param> /// <param name="Domain"></param> /// <returns></returns> public override MCItem GetItem(string ItemName, string Domain) { string sdbDomain = SetDomain(Domain); GetAttributesRequest request = new GetAttributesRequest().WithDomainName(sdbDomain).WithItemName(ItemName); GetAttributesResponse response = client.GetAttributes(request); MCItem item = new MCItem(); item.Domain = Domain; item.ItemName = ItemName; item.Attributes = new Hashtable(); foreach (Attribute attribute in response.GetAttributesResult.Attribute) { item.Attributes.Add(attribute.Name, attribute.Value); } return(item); }
public override List <MCItem> Select(string Query, string Domain) { string sdbDomain = SetDomain(Domain); SelectRequest request = new SelectRequest().WithSelectExpression(Query); SelectResponse response = client.Select(request); List <MCItem> items = new List <MCItem>(); foreach (Item sdb in response.SelectResult.Item) { MCItem newItem = new MCItem(sdb.Name, Domain); foreach (Attribute attribute in sdb.Attribute) { newItem.Attributes.Add(attribute.Name, attribute.Value); } items.Add(newItem); } return(items); }
public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext sc, SettingsPropertyCollection collection) { string username = (string)sc["UserName"]; SettingsPropertyValueCollection properties = new SettingsPropertyValueCollection(); GetAttributesRequest request = new GetAttributesRequest().WithDomainName(domain).WithItemName(username); GetAttributesResponse response = client.GetAttributes(request); // Setup defaults ... foreach (SettingsProperty prop in collection) { SettingsPropertyValue value = new SettingsPropertyValue(prop); value.PropertyValue = prop.DefaultValue; properties.Add(value); } if (response.GetAttributesResult.Attribute.Count > 0) { List <Attribute> attributes = response.GetAttributesResult.Attribute; MCItem item = new MCItem(); item.Domain = domain; item.ItemName = username; item.Attributes = new Hashtable(); foreach (Attribute attribute in attributes) { item.Attributes.Add(attribute.Name, attribute.Value); } foreach (SettingsProperty prop in collection) { SettingsPropertyValue value = properties[prop.Name]; value.PropertyValue = item.Attributes[prop.Name]; //value.Deserialized = true; } } return(properties); }
public override ProfileInfoCollection GetAllProfiles(ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords) { // TODO: Take paging into account // TODO: Take auth option into account totalRecords = 0; ProfileInfoCollection profiles = new ProfileInfoCollection(); SelectRequest request = new SelectRequest().WithSelectExpression("select * from " + domain); SelectResponse response = client.Select(request); if (response.SelectResult.Item.Count > 0) { foreach (Item _item in response.SelectResult.Item) { ProfileInfo profile = null; List <Attribute> attributes = _item.Attribute; MCItem item = new MCItem(); item.Domain = domain; item.ItemName = _item.Name; item.Attributes = new Hashtable(); foreach (Attribute attribute in attributes) { item.Attributes.Add(attribute.Name, attribute.Value); } bool Anon = bool.Parse(item.Get("Anon").Replace("", "false")); DateTime LastActivity = DateTime.Parse(item.Get("LastActivity")); DateTime LastUpdated = DateTime.Parse(item.Get("LastUpdated")); profile = new ProfileInfo(item.Id, Anon, LastActivity, LastUpdated, 0); profiles.Add(profile); } } totalRecords = profiles.Count; return(profiles); }
/// <summary> /// This was kept in place but refactored to support Select. /// </summary> /// <param name="Domain"></param> /// <returns></returns> public override List<MCItem> GetItems(string Domain) { string sdbDomain = SetDomain(Domain); SelectRequest request = new SelectRequest().WithSelectExpression("Select * from " + sdbDomain); SelectResponse response = client.Select(request); List<MCItem> items = new List<MCItem>(); foreach (Item sdb in response.SelectResult.Item) { MCItem newItem = new MCItem(sdb.Name, Domain); foreach (Attribute attribute in sdb.Attribute) newItem.Attributes.Add(attribute.Name, attribute.Value); items.Add(newItem); } return items; }
public abstract void SaveItem(MCItem item, string Domain);
public abstract void SaveItem(MCItem item);
public override void SaveItem(MCItem item, string Domain) { item.Domain = Domain; SaveItem(item); }
public override void SetPropertyValues(SettingsContext sc, SettingsPropertyValueCollection properties) { string username = (string)sc["UserName"]; bool userIsAuthenticated = (bool)sc["IsAuthenticated"]; MCItem item = new MCItem(username, domain); item.Attributes.Add("Anon", ""); item.Attributes.Add("LastUpdated", DateTime.Now.ToShortDateString()); foreach (SettingsPropertyValue property in properties) { if (property.PropertyValue != null) { item.Attributes.Add(property.Name, property.PropertyValue.ToString()); } } PutAttributesRequest request = new PutAttributesRequest().WithDomainName(item.Domain).WithItemName(item.ItemName); List<ReplaceableAttribute> attributes = new List<ReplaceableAttribute>(); foreach (string key in item.Attributes.Keys) { attributes.Add(new ReplaceableAttribute().WithName(key).WithValue(item.Attributes[key].ToString()).WithReplace(true)); } request.Attribute = attributes; client.PutAttributes(request); }
public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext sc, SettingsPropertyCollection collection) { string username = (string)sc["UserName"]; SettingsPropertyValueCollection properties = new SettingsPropertyValueCollection(); GetAttributesRequest request = new GetAttributesRequest().WithDomainName(domain).WithItemName(username); GetAttributesResponse response = client.GetAttributes(request); // Setup defaults ... foreach (SettingsProperty prop in collection) { SettingsPropertyValue value = new SettingsPropertyValue(prop); value.PropertyValue = prop.DefaultValue; properties.Add(value); } if (response.GetAttributesResult.Attribute.Count > 0) { List<Attribute> attributes = response.GetAttributesResult.Attribute; MCItem item = new MCItem(); item.Domain = domain; item.ItemName = username; item.Attributes = new Hashtable(); foreach (Attribute attribute in attributes) { item.Attributes.Add(attribute.Name, attribute.Value); } foreach (SettingsProperty prop in collection) { SettingsPropertyValue value = properties[prop.Name]; value.PropertyValue = item.Attributes[prop.Name]; //value.Deserialized = true; } } return properties; }
public override ProfileInfoCollection GetAllProfiles(ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords) { // TODO: Take paging into account // TODO: Take auth option into account totalRecords = 0; ProfileInfoCollection profiles = new ProfileInfoCollection(); SelectRequest request = new SelectRequest().WithSelectExpression("select * from " + domain); SelectResponse response = client.Select(request); if (response.SelectResult.Item.Count > 0) { foreach (Item _item in response.SelectResult.Item) { ProfileInfo profile = null; List<Attribute> attributes = _item.Attribute; MCItem item = new MCItem(); item.Domain = domain; item.ItemName = _item.Name; item.Attributes = new Hashtable(); foreach (Attribute attribute in attributes) { item.Attributes.Add(attribute.Name, attribute.Value); } bool Anon = bool.Parse(item.Get("Anon").Replace("", "false")); DateTime LastActivity = DateTime.Parse(item.Get("LastActivity")); DateTime LastUpdated = DateTime.Parse(item.Get("LastUpdated")); profile = new ProfileInfo(item.Id, Anon, LastActivity, LastUpdated, 0); profiles.Add(profile); } } totalRecords = profiles.Count; return profiles; }
/// <summary> /// Returns a user's profile /// Currently assumes a single user will match the token. /// </summary> /// <param name="authenticationOption"></param> /// <param name="usernameToMatch"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <param name="totalRecords"></param> /// <returns></returns> public override ProfileInfoCollection FindProfilesByUserName(ProfileAuthenticationOption authenticationOption, string usernameToMatch, int pageIndex, int pageSize, out int totalRecords) { // TODO: Take paging into account // TODO: Take auth option into account totalRecords = 0; ProfileInfoCollection profiles = new ProfileInfoCollection(); GetAttributesRequest request = new GetAttributesRequest().WithDomainName(domain).WithItemName(usernameToMatch); GetAttributesResponse response = client.GetAttributes(request); if (response.GetAttributesResult.Attribute.Count > 0) { ProfileInfo profile = null; List<Attribute> attributes = response.GetAttributesResult.Attribute; MCItem item = new MCItem(); item.Domain = domain; item.ItemName = usernameToMatch; item.Attributes = new Hashtable(); foreach (Attribute attribute in attributes) { item.Attributes.Add(attribute.Name, attribute.Value); } bool Anon = bool.Parse(item.Get("Anon").Replace("", "false")); DateTime LastActivity = DateTime.Parse(item.Get("LastActivity")); DateTime LastUpdated = DateTime.Parse(item.Get("LastUpdated")); profile = new ProfileInfo(item.Id, Anon, LastActivity, LastUpdated, 0); profiles.Add(profile); } totalRecords = profiles.Count; return profiles; }
public abstract void SaveItem(MCItem item);
public override void SaveItem(MCItem item, string Domain) { item.Domain = Domain; SaveItem(item); }
public override void SaveItem(MCItem item) { item.Domain = SetDomain(item.Domain); PutAttributesRequest request = new PutAttributesRequest().WithDomainName(item.Domain).WithItemName(item.ItemName); List<ReplaceableAttribute> attributes = new List<ReplaceableAttribute>(); foreach (string key in item.Attributes.Keys) { attributes.Add(new ReplaceableAttribute().WithName(key).WithValue(item.Attributes[key].ToString()).WithReplace(true)); } request.Attribute = attributes; client.PutAttributes(request); }
public abstract void SaveItem(MCItem item, string Domain);