/// <summary> /// Write incidents to the incident history log. /// </summary> /// <param name="message">The message to write to the log</param> public void WriteToHistory(string message) { using (DisposableProxy <IIncidentManagement> client = GetClient()) { client.Proxy.WriteToHistory(message); } }
/// <summary> /// Gets an incident with specified incidentid from the LOB Services. /// </summary> /// <param name="incidentId">The Id of the incident to retrieve.</param> /// <returns>The incident. </returns> public Incident GetIncident(string incidentId) { // Impersonate as the AppPool account: // As part of the trusted facade, we want to ensure that only the SharePoint server can access // the WCF LOB services. In order to check that, we have added a PrincipalPermissionAttribute that demands // that the calling account is part of a specific group. The app pool account is also part of that group // so we need to impersonate as the app pool account. using (HostingEnvironment.Impersonate()) { using (DisposableProxy <IIncidentManagement> client = GetClient()) { return(TransformProxyIncidentToIncident(client.Proxy.GetIncident(incidentId))); } } }
/// <summary> /// Retrieve the price for a particular SKU that applies to the currently logged on user. This price includes all the discounts that have been /// applied to it for the current partner. /// </summary> /// <param name="sku">The SKU to retrieve pricing for.</param> /// <returns>The price.</returns> public Price GetPriceBySku(string sku) { Price price = null; //prices are stored per sku and partner IPartnerSiteDirectory partnerSiteDirectory = SharePointServiceLocator.Current.GetInstance <IPartnerSiteDirectory>(); string key = string.Format(CultureInfo.InvariantCulture, "{0}:{1}:{2}", typeof(Price).FullName, sku, partnerSiteDirectory.GetCurrentPartnerId()); if (cache[key] == null) { // Impersonate as the AppPool account: // As part of the trusted facade, we want to ensure that only the SharePoint server can access // the WCF LOB services. In order to check that, we have added a PrincipalPermissionAttribute that demands // that the calling account is part of a specific group. The app pool account is also part of that group // so we need to impersonate as the app pool account. using (HostingEnvironment.Impersonate()) { // Dispose of the proxy after usage, to ensure the resources are cleaned up: // Creating proxy classes can potentially be a heavy operation, so you might consider // creating a pool of proxy objects. using (DisposableProxy <IPricing> client = GetClient()) { price = TransformProxyPriceToPrice(client.Proxy.GetPriceBySku(sku)); } } if (price != null) { cache.Add(key, price, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(5f), CacheItemPriority.Normal, null); } } else { price = cache[key] as Price; } return(price); }