protected virtual void OnSelected(CrmDataSourceStatusEventArgs e) { EventHandler <CrmDataSourceStatusEventArgs> handler = base.Events[EventSelected] as EventHandler <CrmDataSourceStatusEventArgs>; if (handler != null) { handler(this, e); } }
protected override IEnumerable EndExecuteSelect(IAsyncResult asyncResult) { Tracing.FrameworkInformation("CrmDataSourceView", "EndExecuteSelect", "Begin"); if (_client == null) { Tracing.FrameworkInformation("CrmDataSourceView", "EndExecuteSelect", "End: _client=null"); return(null); } IEnumerable selectResult = null; int rowsAffected = 0; try { SynchronousAsyncSelectResult syncResult = asyncResult as SynchronousAsyncSelectResult; if (syncResult != null) { Tracing.FrameworkInformation("CrmDataSourceView", "EndExecuteSelect", "syncResult"); selectResult = syncResult.SelectResult; } else { Tracing.FrameworkInformation("CrmDataSourceView", "EndExecuteSelect", "EndExecute"); var response = _execute.EndInvoke(asyncResult); if (response != null) { var entities = response.Entities; rowsAffected = entities.Count; selectResult = ExecuteSelect(entities).ToList(); if (Owner.CacheParameters.Enabled) { var dependencies = GetCacheDependencies(Request.Query, selectResult); string cacheKey = GetCacheKey(Request.Query); // insert into cache ObjectCacheManager.GetInstance().Insert(cacheKey, selectResult, dependencies); } } } } catch (System.Web.Services.Protocols.SoapException ex) { Tracing.FrameworkError("CrmDataSourceView", "EndExecuteSelect", "{0}\n\n{1}", ex.Detail.InnerXml, ex); } catch (Exception e) { Tracing.FrameworkError("CrmDataSourceView", "EndExecuteSelect", "Exception: {0}", e); // raise post-event with exception CrmDataSourceStatusEventArgs selectedExceptionArgs = new CrmDataSourceStatusEventArgs(0, e); OnSelected(selectedExceptionArgs); if (!selectedExceptionArgs.ExceptionHandled) { throw; } return(selectResult); } finally { _client = null; } // raise post-event CrmDataSourceStatusEventArgs selectedArgs = new CrmDataSourceStatusEventArgs(rowsAffected, null); OnSelected(selectedArgs); Tracing.FrameworkInformation("CrmDataSourceView", "EndExecuteSelect", "End"); return(string.IsNullOrEmpty(Owner.StaticEntityWrapperTypeName) ? selectResult : CreateEntities(selectResult)); }