public static Dictionary<string, string> GetMultiplePersonalizationSetting(PersonalizationType type, string id, string keys) { try { Dictionary<string, string> PersonalizationSettings = new Dictionary<string, string>(); RedisCache Redis = new RedisCache(_PersonalizationHost); switch (type) { case PersonalizationType.Org: PersonalizationSettings = Redis.GetMultipleValuesFromOrgCache(id, keys); break; default: throw new NotImplementedException(); break; } return PersonalizationSettings; } catch (NotImplementedException ex) { } catch (Exception ex) { // throw; } return null; }
public static string GetPersonalizationList(PersonalizationType type, string id, string key, string filter) { try { RedisCache Redis = new RedisCache(_PersonalizationHost); string Value = null; switch (type) { case PersonalizationType.Org: Value = Redis.GetListFromOrgCache(id, key, filter); break; default: throw new NotImplementedException(); break; } } catch (NotImplementedException ex) { } catch (Exception ex) { } return null; }
/// <summary> /// Gets the personalized message content as sent to a specific member as part of the specified mailing. /// </summary> /// <returns>Message content from a mailing, personalized for a member. The response will contain all parts of the mailing content by default, or just the type of content specified by type..</returns> /// <param name="mailingId">Mailing identifier.</param> /// <param name="memberId">Member identifier.</param> /// <param name="type">Accepts: ‘all’, ‘html’, ‘plaintext’, ‘subject’. Defaults to ‘all’, if not provided.</param> /// <remarks>Http404 if no mailing is found.</remarks> public MailingPersonalization GetMailingMembersPersonalization(string mailingId, string memberId, PersonalizationType? type = null) { var request = new RestRequest(); request.Resource = "/{accountId}/mailings/{mailingId}/messages/{memberId}"; request.AddUrlSegment("mailingId", mailingId); request.AddUrlSegment("memberId", memberId); if (type != null) request.AddParameter("type", type); return Execute<MailingPersonalization>(request); }
public static bool RemovePersonalizationSetting(PersonalizationType type, string id, string key) { try { RedisCache Redis = new RedisCache(_PersonalizationHost); bool IsRemoved; switch (type) { case PersonalizationType.Global: IsRemoved = Redis.RemoveValueFromGlobalCache(key); break; case PersonalizationType.Org: IsRemoved = Redis.RemoveValueFromOrgCache(id, key); break; default: IsRemoved = Redis.RemoveValueFromUserCache(id, key); break; } return true; } catch (Exception ex) { // throw; } return false; }
public static bool RemoveMultiplePersonalizationSettings(PersonalizationType type, string id, string key, int retryCount = 0, int timeOutInSeconds = 2) { try { int AttemptsToSave = 0; bool IsSaveSuccess = false; RedisCache Redis = new RedisCache(_PersonalizationHost); while (!IsSaveSuccess && AttemptsToSave <= retryCount) { try { switch (type) { case PersonalizationType.Global: IsSaveSuccess = Redis.RemoveMultipleValuesFromGlobalCache(key); break; case PersonalizationType.Org: IsSaveSuccess = Redis.RemoveMultipleValuesFromOrgCache(id, key); break; default: IsSaveSuccess = Redis.RemoveMultipleValuesFromUserCache(id, key); break; } } catch (Exception ex) { if (AttemptsToSave == retryCount) { throw; } } AttemptsToSave++; System.Threading.Thread.Sleep(_WaitTimeBetWeenAttempts); } } catch (Exception ex) { // throw; } return false; }
public static bool PutPersonalizationSetting(PersonalizationType type, string id, string key, object value, int timeOutInSeconds = 2, int? expireInHours = null) { try { RedisCache Redis = new RedisCache(_PersonalizationHost); string ValueForKey = value != null ? value.ToString() : null; switch (type) { case PersonalizationType.Global: Redis.AddValueToGlobalCache(key, ValueForKey, expireInHours); break; case PersonalizationType.Org: Redis.AddValueToOrgCache(id, key, ValueForKey, expireInHours); break; default: Redis.AddValueToUserCache(id, key, ValueForKey, expireInHours); break; } return true; } catch (Exception ex) { } return false; }
public static bool PutPersonalizationList(PersonalizationType type, string id, string key, object value, int timeOutInSeconds = 5) { try { RedisCache Redis = new RedisCache(_PersonalizationHost); string ValueForKey = value != null ? value.ToString() : null; switch (type) { case PersonalizationType.Org: Redis.AddListToOrgCache(id, key, ValueForKey); break; default: throw new NotImplementedException("Put List is only allowed for `Org` PersonalizationType!"); break; } } catch (NotImplementedException ex) { } catch (Exception ex) { } return false; }
public static string GetPersonalizationSetting(PersonalizationType type, string id, string key, int timeOutInSeconds = 2) { try { RedisCache Redis = new RedisCache(_PersonalizationHost); string Value = null; switch (type) { case PersonalizationType.Global: Value = Redis.GetValueFromGlobalCache(key); break; case PersonalizationType.Org: Value = Redis.GetValueFromOrgCache(id, key); break; default: Value = Redis.GetValueFromUserCache(id, key); break; } return Value; } catch (Exception ex) { // throw; NOT Thorwing error to avoid checking exception everywhere } return null; }