internal EntityDataSourceDesignerHelper(EntityDataSource entityDataSource, bool interactiveMode) { Debug.Assert(entityDataSource != null, "null entityDataSource"); _entityDataSource = entityDataSource; _interactiveMode = interactiveMode; _canLoadWebConfig = true; IServiceProvider serviceProvider = _entityDataSource.Site; if (serviceProvider != null) { // Get the designer instance associated with the specified data source control IDesignerHost designerHost = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost)); if (designerHost != null) { _owner = designerHost.GetDesigner(this.EntityDataSource) as EntityDataSourceDesigner; } // Get other services used to determine design-time information _webApplication = serviceProvider.GetService(typeof(IWebApplication)) as IWebApplication; } Debug.Assert(_owner != null, "expected non-null owner"); Debug.Assert(_webApplication != null, "expected non-null web application service"); }
internal WebControlParameterProxy(Parameter parameter, ParameterCollection parameterCollection, EntityDataSource entityDataSource) { Debug.Assert(null != entityDataSource); _parameter = parameter; _collection = parameterCollection; _entityDataSource = entityDataSource; VerifyUniqueType(_parameter); }
public static void Insert(this EntityDataSource origenDeDatos, IDictionary nuevaFila) { // Llamada: origen.Insert(objetoIDictionary) --> evento Inserting EntityDataSourceView vista = (origenDeDatos as IDataSource).GetView(string.Empty) as EntityDataSourceView; // Insertar la fila en alums_asigs vista.Insert(nuevaFila, Finalizacion); }
Parameter _parameter; // Can be null, that's why this class doesn't subclass Parameter internal WebControlParameterProxy(string propertyName, ParameterCollection parameterCollection, EntityDataSource entityDataSource) { Debug.Assert(null != entityDataSource); Debug.Assert(!String.IsNullOrEmpty(propertyName)); _parameter = EntityDataSourceUtil.GetParameter(propertyName, parameterCollection); _collection = parameterCollection; _entityDataSource = entityDataSource; VerifyUniqueType(_parameter); }
internal OrderByBuilder(string argsSortExpression, EntityDataSourceWrapperCollection wrapperCollection, string orderBy, bool autoGenerateOrderByClause, ParameterCollection orderByParameters, bool generateDefaultOrderByClause, EntityDataSource owner) { _argsSortExpression = argsSortExpression; _wrapperCollection = wrapperCollection; _orderBy = orderBy; _autoGenerateOrderByClause = autoGenerateOrderByClause; _orderByParameters = orderByParameters; _owner = owner; _generateDefaultOrderByClause = generateDefaultOrderByClause; }
/// <summary> /// Validates that the keys in the update parameters all match property names on the entityWrapper. /// </summary> /// <param name="entityWrapper"></param> /// <param name="parameters"></param> internal static void ValidateWebControlParameterNames(EntityDataSourceWrapper entityWrapper, ParameterCollection parameters, EntityDataSource owner) { Debug.Assert(null != entityWrapper, "entityWrapper should not be null"); if (null != parameters) { PropertyDescriptorCollection entityProperties = entityWrapper.GetProperties(); System.Collections.Specialized.IOrderedDictionary parmVals = parameters.GetValues(owner.HttpContext, owner); foreach (DictionaryEntry de in parmVals) { string key = de.Key as string; if (null == key || null == entityProperties.Find(key, false)) { throw new InvalidOperationException(Strings.EntityDataSourceUtil_InsertUpdateParametersDontMatchPropertyNameOnEntity(key, entityWrapper.WrappedEntity.GetType().ToString())); } } } }
/// <summary> /// Returns the value set onto the Parameter named by propertyName. /// If the Paramter does not have a value, it returns null. /// </summary> /// <param name="propertyName"></param> /// <param name="parameterCollection"></param> /// <param name="entityDataSource"></param> /// <returns></returns> internal static object GetParameterValue(string propertyName, ParameterCollection parameterCollection, EntityDataSource entityDataSource) { if (null == parameterCollection) // ParameterCollection undefined { return(null); } System.Collections.Specialized.IOrderedDictionary values = parameterCollection.GetValues(entityDataSource.HttpContext, entityDataSource); foreach (object key in values.Keys) { string parameterName = key as string; if (null != parameterName && String.Equals(propertyName, parameterName, StringComparison.Ordinal)) { return(values[parameterName]); } } return(null); }
// Configures and displays the editor dialog based on the specified property name private bool Initialize(EntityDataSourceDesigner designer, EntityDataSource entityDataSource, string propertyName, IServiceProvider serviceProvider, string statement) { string propertyParameters = GetOperationParameterProperty(propertyName); string autoGenProperty = GetOperationAutoGenerateProperty(propertyName); bool hasAutoGen = (autoGenProperty != null); bool autoGen = GetAutoGen(propertyName, designer); ParameterCollection parameters = GetParameters(propertyName, designer); string label = GetStatementLabel(propertyName, false); string accessibleName = GetStatementLabel(propertyName, true); string helpTopic = GetHelpTopic(propertyName); EntityDataSourceStatementEditorForm form = new EntityDataSourceStatementEditorForm(entityDataSource, serviceProvider, hasAutoGen, autoGen, propertyName, label, accessibleName, helpTopic, statement, parameters); DialogResult result = UIHelper.ShowDialog(serviceProvider, form); if (result == DialogResult.OK) { // We use the property descriptors to reset the values to // make sure we clear out any databindings or expressions that // may be set. PropertyDescriptor propDesc = null; if (autoGenProperty != null) { propDesc = TypeDescriptor.GetProperties(entityDataSource)[autoGenProperty]; propDesc.ResetValue(entityDataSource); propDesc.SetValue(entityDataSource, form.AutoGen); } if (propertyName != null) { propDesc = TypeDescriptor.GetProperties(entityDataSource)[propertyName]; propDesc.ResetValue(entityDataSource); propDesc.SetValue(entityDataSource, form.Statement); } if (propertyParameters != null) { SetParameters(propertyName, designer, form.Parameters); } return true; } else { return false; } }
/// ----------------------------------------------------------------------------- /// <summary> /// Page_Load runs when the control is loaded /// </summary> /// <remarks> /// </remarks> /// <history> /// </history> /// ----------------------------------------------------------------------------- protected void Page_Load(System.Object sender, System.EventArgs e) { base.Page_Load(sender, e); try { bool IsContactMode = false; if( (Settings["ConfigAsContact"] != null && Convert.ToBoolean(Settings["ConfigAsContact"])) ){ IsContactMode = true; adminTitle.InnerHtml = "Open Contact Requests"; } if (this.UserInfo.IsSuperUser) { aqufitEntities entities = new aqufitEntities(); atiAdminPanel.Visible = true; atiAjaxPanel.Visible = false; EntityDataSource eds = new EntityDataSource(); eds.ID = "aqufitEntities"; eds.ContextTypeName = "Affine.Data.aqufitEntities"; // eds.ConnectionString = "name=aqufitEntities"; eds.EntitySetName = "BugReports"; // eds.DefaultContainerName = "aqufitEntities"; eds.OrderBy = "it.[DateTime] DESC"; eds.EntityTypeFilter = "BugReport"; eds.EnableDelete = true; eds.EnableInsert = true; eds.EnableUpdate = true; if (Request["b"] != null) { eds.Where = "it.Id = " + Request["b"] + " && it.Status != 'Closed' && it.PortalId = " + this.PortalId + " && it.IsContactRequest = " + IsContactMode; } else { eds.Where = "it.Status != 'Closed' && it.PortalId = " + this.PortalId + " && it.IsContactRequest = " + IsContactMode; } RadGrid1.DataSource = eds; RadGrid1.MasterTableView.DataSource = eds; } if (!Page.IsPostBack && !Page.IsCallback) { if (Settings["ConfigAsContact"] != null && Convert.ToBoolean( Settings["ConfigAsContact"] )) { panelBugHead.Visible = false; panelContactHead.Visible = true; imgContact.ImageUrl = ResolveUrl("~/DesktopModules/ATI_Base/resources/images/iContact.png"); if (this.UserId < 0) { divEmail.Visible = true; } } else { panelBugHead.Visible = true; panelContactHead.Visible = false; imgBug.ImageUrl = ResolveUrl("~/DesktopModules/ATI_Base/resources/images/iBug.png"); if (this.UserId < 0) { divEmail.Visible = true; } } } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }
internal EntityDataSourceSelectingEventArgs(EntityDataSource dataSource, DataSourceSelectArguments selectArgs) { _dataSource = dataSource; _selectArguments = selectArgs; }
private DataTable GetCurrentSchema(bool preferSilent) { // Verify that we have values for a minimum set of properties that will be required to get schema if (String.IsNullOrEmpty(this.EntityDataSource.ConnectionString) || String.IsNullOrEmpty(this.EntityDataSource.DefaultContainerName) || String.IsNullOrEmpty(this.EntityDataSource.CommandText) && String.IsNullOrEmpty(this.EntityDataSource.EntitySetName)) { if (!preferSilent) { ShowError(Strings.Error_CannotRefreshSchema_MissingProperties); } return null; } bool originalMode = _interactiveMode; try { // Suppress error messages while loading metadata if we are in silent mode _interactiveMode = !preferSilent; // In interactive mode, always clear any cached information so we are sure to get the latest schema // This is necessary in case the metadata or entity classes in referenced assemblies has changed // or in case the metadata files have changed without changing any of the properties on the control if (_interactiveMode) { ReloadResources(); ClearMetadata(); } // Try to load metadata if we don't have it yet if (_entityConnection == null) { if (!LoadMetadata()) { return null; } // else metadata was successfully loaded, so continue refreshing schema } } finally { _interactiveMode = originalMode; } // Either _entityConnection was already set, or we should have successfully loaded it Debug.Assert(_entityConnection != null, "_entityConnection should have been initialized"); try { // Create a temporary data source based on the EntityConnection we have built with // the right metadata from the design-time environment EntityDataSource entityDataSource = new EntityDataSource(_entityConnection); // This is workaround for a bug in the SQL CE provider services. SQL CE uses two providers - one is supposed to be used at design time // while the other one is supposed to be used at runtime. When the Entiy Designer is used in a way that requires to talk to the database // SQL CE starts returning design time provider. However they don't reset an internal flag and continue to return design time provider even if // the Entity Designer is not used anymore. Calling GetProviderManifestToken() method will reset the flag according to the provider in the // connection. This fixes the problem for SQL CE provider without having to special case SQL CE because it will be a no-op for other providers. // For more details see bug 35675 in DevDiv database http://vstfdevdiv:8080/web/wi.aspx?pcguid=22f9acc9-569a-41ff-b6ac-fac1b6370209&id=35675 DbProviderServices.GetProviderServices(_entityConnection.StoreConnection).GetProviderManifestToken(_entityConnection.StoreConnection); // Copy only the properties that can affect the schema entityDataSource.CommandText = this.EntityDataSource.CommandText; CopyParameters(this.EntityDataSource.CommandParameters, entityDataSource.CommandParameters); entityDataSource.DefaultContainerName = this.EntityDataSource.DefaultContainerName; entityDataSource.EntitySetName = this.EntityDataSource.EntitySetName; entityDataSource.EntityTypeFilter = this.EntityDataSource.EntityTypeFilter; entityDataSource.GroupBy = this.EntityDataSource.GroupBy; entityDataSource.Select = this.EntityDataSource.Select; entityDataSource.EnableFlattening = this.EntityDataSource.EnableFlattening; CopyParameters(this.EntityDataSource.SelectParameters, entityDataSource.SelectParameters); EntityDataSourceView view = (EntityDataSourceView)(((IDataSource)entityDataSource).GetView(DefaultViewName)); DataTable viewTable = view.GetViewSchema(); viewTable.TableName = DefaultViewName; return viewTable; } catch (Exception ex) { if (!preferSilent) { StringBuilder errorMessage = new StringBuilder(); errorMessage.AppendLine(Strings.Error_CannotRefreshSchema_RuntimeException(ex.Message)); if (ex.InnerException != null) { errorMessage.AppendLine(Strings.Error_CannotRefreshSchema_RuntimeException_InnerException(ex.InnerException.Message)); } ShowError(errorMessage.ToString()); } } return null; }
private DataTable GetCurrentSchema(bool preferSilent) { // Verify that we have values for a minimum set of properties that will be required to get schema if (String.IsNullOrEmpty(this.EntityDataSource.ConnectionString) || String.IsNullOrEmpty(this.EntityDataSource.DefaultContainerName) || String.IsNullOrEmpty(this.EntityDataSource.CommandText) && String.IsNullOrEmpty(this.EntityDataSource.EntitySetName)) { if (!preferSilent) { ShowError(Strings.Error_CannotRefreshSchema_MissingProperties); } return null; } bool originalMode = _interactiveMode; try { // Suppress error messages while loading metadata if we are in silent mode _interactiveMode = !preferSilent; // In interactive mode, always clear any cached information so we are sure to get the latest schema // This is necessary in case the metadata or entity classes in referenced assemblies has changed // or in case the metadata files have changed without changing any of the properties on the control if (_interactiveMode) { ReloadResources(); ClearMetadata(); } // Try to load metadata if we don't have it yet if (_entityConnection == null) { if (!LoadMetadata()) { return null; } // else metadata was successfully loaded, so continue refreshing schema } } finally { _interactiveMode = originalMode; } // Either _entityConnection was already set, or we should have successfully loaded it Debug.Assert(_entityConnection != null, "_entityConnection should have been initialized"); try { // Create a temporary data source based on the EntityConnection we have built with // the right metadata from the design-time environment EntityDataSource entityDataSource = new EntityDataSource(_entityConnection); // This is workaround for a DbProviderServices.GetProviderServices(_entityConnection.StoreConnection).GetProviderManifestToken(_entityConnection.StoreConnection); // Copy only the properties that can affect the schema entityDataSource.CommandText = this.EntityDataSource.CommandText; CopyParameters(this.EntityDataSource.CommandParameters, entityDataSource.CommandParameters); entityDataSource.DefaultContainerName = this.EntityDataSource.DefaultContainerName; entityDataSource.EntitySetName = this.EntityDataSource.EntitySetName; entityDataSource.EntityTypeFilter = this.EntityDataSource.EntityTypeFilter; entityDataSource.GroupBy = this.EntityDataSource.GroupBy; entityDataSource.Select = this.EntityDataSource.Select; entityDataSource.EnableFlattening = this.EntityDataSource.EnableFlattening; CopyParameters(this.EntityDataSource.SelectParameters, entityDataSource.SelectParameters); EntityDataSourceView view = (EntityDataSourceView)(((IDataSource)entityDataSource).GetView(DefaultViewName)); DataTable viewTable = view.GetViewSchema(); viewTable.TableName = DefaultViewName; return viewTable; } catch (Exception ex) { if (!preferSilent) { StringBuilder errorMessage = new StringBuilder(); errorMessage.AppendLine(Strings.Error_CannotRefreshSchema_RuntimeException(ex.Message)); if (ex.InnerException != null) { errorMessage.AppendLine(Strings.Error_CannotRefreshSchema_RuntimeException_InnerException(ex.InnerException.Message)); } ShowError(errorMessage.ToString()); } } return null; }