/// <summary> /// This calls the Akamai service and passes all the properties to it. Calling this will remove items from the cache. /// </summary> public void Remove() { if (_PurgeType == PurgeType.ARL) { if ((!_ItemsToPurge[0].Trim().ToLower().Contains("http://")) || (!_ItemsToPurge[0].Trim().ToLower().Contains("https://"))) { throw new Exception("If the PurgeType is set to 'ARL', then the items in the ItemsToPurge array must be complete URLs"); } } if (_PurgeType == PurgeType.CPCode) { double Num; bool isNum = double.TryParse(_ItemsToPurge[0], out Num); if (!isNum) { throw new Exception("If the PurgeType is set to 'CPCode', the the ItemsToPurge array must only contain one item, and that item must be a number"); } } string email = "email-notification=" + _AkamaiNotificationEmail; string[] fileToPurge = _ItemsToPurge; string action = ""; if (_Action == Action.Purge) { action = "action=remove"; } else if (_Action == Action.Invalidate) { action = "action=invalidate"; } ///get the domain string domain = ""; if (_Domain == Domain.Staging) { domain = "domain=staging"; } else if (_Domain == Domain.Production) { domain = "domain=production"; } string purgeType = ""; if (_PurgeType == PurgeType.CPCode) { purgeType = "type=cpcode"; } else if (_PurgeType == PurgeType.ARL) { purgeType = "type=arl"; } //type: type=cpcode or type=arl >> arl: akamai resource locator. //url: uniform resource locator. //To use the type cpcode option, your administrator must enable //purge-by-cpcode access for your username //through Akamai EdgeControl. string[] options = new string[] { action, domain, email, purgeType }; AkamaiCache.AkamaiServiceRef.PurgeApi purgeAPI = new AkamaiCache.AkamaiServiceRef.PurgeApi(); AkamaiCache.AkamaiServiceRef.PurgeResult purgeResult = purgeAPI.purgeRequest(_AkamaiAccountName, _AkamaiAccountPassword, string.Empty, options, fileToPurge); if (purgeResult.resultCode >= 300) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.AppendFormat(" Error Code: {0}", purgeResult.resultCode); sb.AppendFormat(" Error Message: {0}", purgeResult.resultMsg); sb.AppendFormat(" Session ID: {0}", purgeResult.sessionID); sb.AppendFormat(" URI Index: {0}", purgeResult.uriIndex); throw new Exception(sb.ToString()); } }
/// <summary> /// This calls the Akamai service and passes all the properties to it. Calling this will remove items from the cache. /// </summary> public void Remove() { if (_PurgeType == PurgeType.ARL) { if ((!_ItemsToPurge[0].Trim().ToLower().Contains("http://")) || (!_ItemsToPurge[0].Trim().ToLower().Contains("https://"))) { throw new Exception("If the PurgeType is set to 'ARL', then the items in the ItemsToPurge array must be complete URLs"); } } if (_PurgeType == PurgeType.CPCode) { double Num; bool isNum = double.TryParse(_ItemsToPurge[0], out Num); if (!isNum) { throw new Exception("If the PurgeType is set to 'CPCode', the the ItemsToPurge array must only contain one item, and that item must be a number"); } } string email = "email-notification=" + _AkamaiNotificationEmail; string[] fileToPurge = _ItemsToPurge; string action = ""; if (_Action == Action.Purge) { action = "action=remove"; } else if (_Action == Action.Invalidate) { action = "action=invalidate"; } ///get the domain string domain = ""; if (_Domain == Domain.Staging) { domain = "domain=staging"; } else if (_Domain == Domain.Production) { domain = "domain=production"; } string purgeType = ""; if (_PurgeType == PurgeType.CPCode) { purgeType = "type=cpcode"; } else if (_PurgeType == PurgeType.ARL) { purgeType = "type=arl"; } //type: type=cpcode or type=arl >> arl: akamai resource locator. //url: uniform resource locator. //To use the type cpcode option, your administrator must enable //purge-by-cpcode access for your username //through Akamai EdgeControl. string[] options = new string[] { action, domain, email, purgeType }; AkamaiCache.AkamaiServiceRef.PurgeApi purgeAPI = new AkamaiCache.AkamaiServiceRef.PurgeApi(); AkamaiCache.AkamaiServiceRef.PurgeResult purgeResult = purgeAPI.purgeRequest(_AkamaiAccountName, _AkamaiAccountPassword, string.Empty, options, fileToPurge); if (purgeResult.resultCode >= 300) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.AppendFormat(" Error Code: {0}", purgeResult.resultCode); sb.AppendFormat(" Error Message: {0}", purgeResult.resultMsg); sb.AppendFormat(" Session ID: {0}", purgeResult.sessionID); sb.AppendFormat(" URI Index: {0}", purgeResult.uriIndex); throw new Exception(sb.ToString()); } }