private void ProcessControl(Control c, BusinessObject _obj) { IEditControl editControl = c as IEditControl; if (editControl != null) { string fieldName = editControl.FieldName; string ownFieldName = fieldName; string aggrFieldName = String.Empty; MetaField ownField = null; MetaField aggrField = null; if (ownFieldName.Contains(".")) { string[] mas = ownFieldName.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries); if (mas.Length > 1) { ownFieldName = mas[0]; aggrFieldName = mas[1]; string aggrClassName = _obj.Properties[ownFieldName].GetMetaType().Attributes[McDataTypeAttribute.AggregationMetaClassName].ToString(); aggrField = MetaDataWrapper.GetMetaFieldByName(aggrClassName, aggrFieldName); } } ownField = _obj.Properties[ownFieldName].GetMetaType(); object eValue = editControl.Value; bool makeChange = true; MetaField field = (aggrField == null) ? ownField : aggrField; if ((!field.IsNullable && eValue == null) || _obj.Properties[ownFieldName].IsReadOnly) { makeChange = false; } if (makeChange) { if (aggrField == null) { _obj[ownFieldName] = eValue; } else { //make aggregation MetaObject aggrObj = (MetaObject)_obj[ownFieldName]; aggrObj[aggrFieldName] = eValue; } } } BaseServiceEditControl bsc = c as BaseServiceEditControl; if (bsc != null) { bsc.Save(_obj); } }
protected void uniqValue_Required_ServerValidate(object source, ServerValidateEventArgs args) { args.IsValid = true; if (ViewState[FieldName + "FieldClassName"] != null) { MetaField field = MetaDataWrapper.GetMetaFieldByName(ViewState[FieldName + "FieldClassName"].ToString(), FieldName); if (!MetaObjectProperty.CheckUniqueValue(field, this.Value)) { args.IsValid = false; } } }
protected void uniqValue_Required_ServerValidate(object source, ServerValidateEventArgs args) { args.IsValid = true; if (ViewState[FieldName + "FieldClassName"] != null) { string realName = FieldName; if (FieldName.Contains(".")) { realName = FieldName.Substring(FieldName.IndexOf(".") + 1); } MetaField field = MetaDataWrapper.GetMetaFieldByName(ViewState[FieldName + "FieldClassName"].ToString(), realName); if (!MetaObjectProperty.CheckUniqueValue(field, ObjectId, this.Value)) { args.IsValid = false; } } }
/// <summary> /// Handles the RowCommand event of the grdMain control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewCommandEventArgs"/> instance containing the event data.</param> protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == deleteCommand && mc != null) { MetaField mf = MetaDataWrapper.GetMetaFieldByName(mc, e.CommandArgument.ToString()); //if (mf.GetMetaType().McDataType == Mediachase.Ibn.Data.Meta.Management.McDataType.Reference // && mf.Attributes.ContainsKey(McDataTypeAttribute.ReferenceUseSecurity) // && BusinessObjectServiceManager.IsServiceInstalled(mc, SecurityService.ServiceName) // && BusinessObjectServiceManager.IsServiceInstalled(MetaDataWrapper.GetAttributeValue(mf, McDataTypeAttribute.ReferenceMetaClassName).ToString(), SecurityService.ServiceName) // ) // Mediachase.Ibn.Data.Services.Security.RemoveObjectRolesFromReference(mf); mc.DeleteMetaField(mf); CHelper.RequireDataBind(); } }
private void ProcessControl(Control c, EntityObject _obj) { IEditControl editControl = c as IEditControl; if (editControl != null) { string fieldName = editControl.FieldName; #region MyRegion string ownFieldName = fieldName; string aggrFieldName = String.Empty; string aggrClassName = String.Empty; MetaField ownField = null; MetaField aggrField = null; MetaClass ownClass = MetaDataWrapper.GetMetaClassByName(ClassName); if (ownFieldName.Contains(".")) { string[] mas = ownFieldName.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries); if (mas.Length > 1) { ownFieldName = mas[0]; aggrFieldName = mas[1]; ownField = MetaDataWrapper.GetMetaFieldByName(ownClass, ownFieldName); aggrClassName = ownField.Attributes.GetValue <string>(McDataTypeAttribute.AggregationMetaClassName); aggrField = MetaDataWrapper.GetMetaFieldByName(aggrClassName, aggrFieldName); } } if (ownField == null) { ownField = ownClass.Fields[ownFieldName]; } #endregion object eValue = editControl.Value; bool makeChange = true; MetaField field = (aggrField == null) ? ownField : aggrField; if (!field.IsNullable && eValue == null) { makeChange = false; } if (makeChange) { if (aggrField == null) { _obj[ownFieldName] = eValue; } else { EntityObject aggrObj = null; if (_obj[ownFieldName] != null) { aggrObj = (EntityObject)_obj[ownFieldName]; } else { aggrObj = BusinessManager.InitializeEntity(ClassName); } aggrObj[aggrFieldName] = eValue; } } } }