/// <summary> /// Lists the specified folder. /// </summary> /// <param name="folder">ListFolder.</param> /// <returns></returns> public static ListInfo[] List(MetaObject folder) { if (folder == null) throw new ArgumentNullException("folder"); return List(folder.PrimaryKeyId.Value); }
protected static IEnumerable<SqlDataRecord> GenerateMetaPropertyTable(MetaObject o) { var metaFields = new List<SqlDataRecord>(); try { SqlMetaData[] metaData = new SqlMetaData[2]; metaData[0] = new SqlMetaData("FieldName", SqlDbType.VarChar, 30); metaData[1] = new SqlMetaData("FieldValue", SqlDbType.VarChar, -1); foreach (KeyValuePair<string, JToken> prop in o.MetaPropertiesObject) { SqlDataRecord record = new SqlDataRecord(metaData); record.SetString(0, prop.Key); // coming from the DB the value will be an object representing the field, with a "Value" key // coming from the client the value will be a single value var value = prop.Value.SelectToken("Value") ?? prop.Value; if (value.Type == JTokenType.Null) { record.SetDBNull(1); } else { record.SetString(1, value.ToString()); } metaFields.Add(record); } } catch (Exception e) { } return metaFields; }
/// <summary> /// Lists the specified folder. /// </summary> /// <param name="folder">ListFolder.</param> /// <returns></returns> public static ListPublication[] List(MetaObject folder) { if (folder == null) throw new ArgumentNullException("folder"); return List(FilterElement.EqualElement("FolderId", folder.PrimaryKeyId.Value)); }
public override MetaObject GetMember(GetMemberAction action, MetaObject[] args) { return new MetaObject( Expression.Call( Expression.Convert(Expression, LimitType), typeof(Duck).GetMethod("GetMember", new Type[] { typeof(GetMemberAction) }), Expression.Constant(action) ), Restrictions.TypeRestriction(Expression, LimitType) ); }
public static string GetEventControlVirtualPath(string virtualStructureDir, MetaObject eventObject, string className) { string structureDir = HostingEnvironment.MapPath(virtualStructureDir); string controlPath = GetEventControlPath(eventObject, className); if (controlPath != null) { controlPath = controlPath.Replace(structureDir, virtualStructureDir); controlPath = controlPath.Replace(Path.DirectorySeparatorChar, '/'); } return controlPath; }
public static string GetEventControlPath(MetaObject eventObject, string className) { string result = null; string eventTypeName = (string)eventObject.Properties[_eventType].Value; FileDescriptor[] files = FileResolver.GetFiles("EventControls", "*.ascx", new Selector(eventTypeName, className)); if (files.Length > 0) { result = files[files.Length - 1].FilePath; } return result; }
internal static void UpdateAddressName(MetaObject address) { if (address == null) return; if (address.GetMetaType().Name != AddressEntity.GetAssignedMetaClassName()) throw new ArgumentOutOfRangeException("The address object has wrong meta object type. Should be 'Address'."); address["Name"] = string.Join(";", new string[] { address.Properties["Line2"].GetValue<string>(string.Empty), address.Properties["Line1"].GetValue<string>(string.Empty), address.Properties["City"].GetValue<string>(string.Empty), address.Properties["Region"].GetValue<string>(string.Empty), address.Properties["PostalCode"].GetValue<string>(string.Empty), address.Properties["Country"].GetValue<string>(string.Empty) }); }
protected override void CopyEntityObjectToMetaObject(EntityObject target, MetaObject metaObject) { // Base Copy base.CopyEntityObjectToMetaObject(target, metaObject); // Process not updatable field DocumentContentVersionEntity srcVersion = (DocumentContentVersionEntity)target; #region Index // Only if new object if (metaObject.ObjectState == MetaObjectState.Created) { // Calculate max index int maxIndex = 0; SqlScript selectMaxIndex = new SqlScript(); selectMaxIndex.Append("SELECT MAX([Index]) AS [Index] FROM [dbo].[cls_DocumentContentVersion] WHERE [OwnerDocumentId] = @OwnerDocumentId"); selectMaxIndex.AddParameter("@OwnerDocumentId", (Guid)srcVersion.OwnerDocumentId); using (IDataReader reader = SqlHelper.ExecuteReader(SqlContext.Current, CommandType.Text, selectMaxIndex.ToString(), selectMaxIndex.Parameters.ToArray())) { if (reader.Read()) { object value = reader["Index"]; if (value is int) { maxIndex = (int)value; } } } // update index metaObject["Index"] = maxIndex + 1; } #endregion // Update State via Custom Method = UpdateState }
/// <summary> /// Internals the bind. /// </summary> private void internalBind() { MainGrid.Columns.Clear(); McMetaViewPreference mvPref = GetMetaViewPreference(); MainGrid.AllowPaging = true; if (mvPref.Attributes["PageSize"] != null) { int pageSize = Convert.ToInt32(mvPref.Attributes.GetValue("PageSize").ToString()); if (pageSize != -1) { MainGrid.PageSize = pageSize; } else { MainGrid.PageSize = 10000; //MainGrid.AllowPaging = false; } //CHelper.SafeSelect(ddPaging, mvPref.Attributes.Get("PageSize").ToString()); } else { MainGrid.PageSize = 10; mvPref.Attributes.Set("PageSize", 10); Mediachase.Ibn.Core.UserMetaViewPreference.Save((int)DataContext.Current.CurrentUserId, mvPref); } int width = 0; if (this.ShowCheckboxes) width += 22 + 7; #region Check Additional columns from xml foreach (MetaGridCustomColumnInfo customColumn in this.CustomColumns) { MainGrid.Columns.Add(customColumn.Column); width += customColumn.Width + 7; } #endregion int counter = 0; foreach (MetaField field in this.VisibleMetaFields) { int cellWidth = 0; if (PlaceName == String.Empty) MainGrid.Columns.Add((new ListColumnFactory(this.ViewName)).GetColumn(this.Page, field)); else MainGrid.Columns.Add((new ListColumnFactory(this.ViewName)).GetColumn(this.Page, field, PlaceName)); cellWidth = mvPref.GetMetaFieldWidth(counter, 100); if (cellWidth == 0) cellWidth = 100; width += cellWidth; counter++; } width += this.VisibleMetaFields.Length * 7; MainGrid.Width = width; #region Adding PrimaryKeyColumn MainGrid.Columns.Add((new ListColumnFactory(this.ViewName)).GetCssColumn(this.Page, CurrentView.MetaClass.Name)); #endregion internalBindHeader(); FilterElement fe = null; if (this.SearchKeyword != string.Empty) { fe = ListManager.CreateFilterByKeyword(mvPref.MetaView.MetaClass, this.SearchKeyword); mvPref.Filters.Add(fe); } MetaObject[] list = CurrentView.List(mvPref); if (fe != null) mvPref.Filters.Remove(fe); if (CurrentView.PrimaryGroupBy == null && CurrentView.SecondaryGroupBy == null) { MainGridExt.IsEmpty = (list.Length == 0); if (list.Length == 0) { list = new MetaObject[] { new MetaObject(CurrentView.MetaClass) }; } MainGrid.DataSource = list; } else { if (CurrentView.SecondaryGroupBy != null) list = MetaViewGroupUtil.ExcludeCollapsed(MetaViewGroupByType.Secondary, CurrentView.SecondaryGroupBy, CurrentView.PrimaryGroupBy, mvPref, list); list = MetaViewGroupUtil.ExcludeCollapsed(MetaViewGroupByType.Primary, CurrentView.PrimaryGroupBy, null, mvPref, list); MainGridExt.IsEmpty = (list.Length == 0); if (list.Length == 0) { list = new MetaObject[] { new MetaObject(CurrentView.MetaClass) }; } MainGrid.DataSource = list; } this.Count = list.Length; if (MainGridExt.IsEmpty) this.Count = 0; MainGrid.DataBind(); internalBindPaging(); if (list.Length == 0) MainGrid.CssClass = "serverGridBodyEmpty"; }
protected virtual void CreateUserRow(MetaObject metaObject, Rule rule, params object[] items) { for (int Index = 0; Index < this.UserColumnInfos.Length; Index++) { RuleItem mapping = rule[this.UserColumnInfos[Index].Field.Name]; if (mapping == null || mapping.FillType != FillTypes.Default) { metaObject[this.UserColumnInfos[Index].Field.Name] = items[Index]; } } }
private void AddMetaObject(ArrayList Array, string Name, Object NewObject) { MetaObject NewMetaObject = new MetaObject(); NewMetaObject.Name = Name; NewMetaObject.TypeStr = null; NewMetaObject.Data = NewObject; NewMetaObject.Offset = Offset; Array.Add(NewMetaObject); }
public static int GetTotalCount(params FilterElement[] filters) { return(MetaObject.GetTotalCount(ListPublication.GetAssignedMetaClass(), filters)); }
/// <summary> /// Helper method for generating a MetaObject which calls a specific method on Dynamic w/ the /// meta object array as the params. /// </summary> private MetaObject CallMethodNAry(MetaAction action, MetaObject[] args, string methodName) { return new MetaObject( Expression.Call( GetLimitedSelf(), typeof(DynamicObject).GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance), ReplaceSelfWithAction(action, args) ), GetRestrictions() ); }
public static CalendarFolderLink[] List(Mediachase.Ibn.Data.FilterElementCollection filters, Mediachase.Ibn.Data.SortingElementCollection sorting, int start, int count) { return(MetaObject.List <CalendarFolderLink>(CalendarFolderLink.GetAssignedMetaClass(), filters, sorting, start, count)); }
public override MetaObject Operation(OperationAction action, MetaObject[] args) { if (ImplementsActions(StandardActionKinds.Operation)) { return CallMethodNAry(action, args, "Operation"); } return base.Operation(action, args); }
public static CalendarFolderLink[] List(params Mediachase.Ibn.Data.FilterElement[] filters) { return(MetaObject.List <CalendarFolderLink>(CalendarFolderLink.GetAssignedMetaClass(), filters)); }
public static CalendarFolderLink[] List(params Mediachase.Ibn.Data.SortingElement[] sorting) { return(MetaObject.List <CalendarFolderLink>(CalendarFolderLink.GetAssignedMetaClass(), sorting)); }
public static CalendarFolderLink[] List() { return(MetaObject.List <CalendarFolderLink>(CalendarFolderLink.GetAssignedMetaClass())); }
public int GetCount(int tenantId, MetaObject metaObject, FilterDefinition <BsonDocument> condition) { return(Convert.ToInt32(db.GetCollectionBson(metaObject.Code).CountDocuments(CombineTenantId(tenantId, condition)))); }
public Result Add(int tenantId, MetaObject metaObject, BsonDocument bsons) { //错误信息返回值 HashSet <string> ErrorInfo = new HashSet <string>(); //获取到字段列表 var metaFields = metaFieldService.GetMetaFieldUpperKeyDicUnDeleted(metaObject.Id); for (int i = bsons.ElementCount - 1; i >= 0; i--) { var item = bsons.GetElement(i); string upperKey = item.Name.ToUpperInvariant(); if (metaFields.ContainsKey(upperKey)) { //检查字段的值是否符合字段类型 var checkResult = metaFieldService.CheckAndGetFieldValueByFieldType(metaFields[upperKey], item.Value); if (checkResult.IsSuccess) { //如果大小写不匹配,则都转化成配置的字段Code形式 if (!item.Name.Equals(metaFields[upperKey].Code)) { bsons.RemoveElement(item); bsons.Add(new BsonElement(metaFields[upperKey].Code, BsonValue.Create(checkResult.Data))); } else { //重置字段的真实类型的值 bsons.SetElement(new BsonElement(metaFields[upperKey].Code, BsonValue.Create(checkResult.Data))); } } else { return(Result.Error($"字段[{item.Name}]传递的值[{item.Value}]不符合字段定义的类型")); } } else { //如果字段不在配置字段中,则不进行添加 bsons.RemoveElement(item); ErrorInfo.Add($"字段[{item.Name}]不属于对象[{metaObject.Code}({metaObject.Name})]定义的字段"); } } //预置字段及其默认值 foreach (var item in metaFieldService.GetPresetFieldBsonElements()) { //如果传入的字段已经有了,那么这里就不预置了 if (!bsons.Contains(item.Name)) { bsons.Add(item); } } //补充字段 bsons.SetElement(new BsonElement(MetaDataConst.TenantId, tenantId)); bsons.SetElement(new BsonElement("MetaObjectCode", metaObject.Code)); db.GetCollectionBson(metaObject.Code).InsertOne(bsons); return(Result.Success($"插入成功,日志:{string.Join(",", ErrorInfo)}")); }
public override MetaObject Convert(ConvertAction action, MetaObject[] args) { if (ImplementsActions(StandardActionKinds.Convert)) { return CallMethodUnary(action, "Convert"); } return base.Convert(action, args); }
public static int GetTotalCount(params FilterElement[] filters) { return(MetaObject.GetTotalCount(CalendarFolderLink.GetAssignedMetaClass(), filters)); }
public override MetaObject GetMember(GetMemberAction action, MetaObject[] args) { if (ImplementsActions(StandardActionKinds.GetMember)) { return CallMethodUnary(action, "GetMember"); } return base.GetMember(action, args); }
/// <summary> /// Draw an object to the PDF file /// </summary> /// <param name="page">MetaPage conatining the object</param> /// <param name="obj">Object to be drawn</param> public void DrawObject(MetaPage page, MetaObject obj) { if (CalculateOnly) { return; } int X, Y, W, H, S; int Width, Height, posx, posy; Rectangle rec; int aalign; MemoryStream stream; string astring; posx = obj.Left; posy = obj.Top; switch (obj.MetaType) { case MetaObjectType.Text: MetaObjectText objt = (MetaObjectText)obj; FPDFFile.Canvas.Font.WFontName = page.GetWFontNameText(objt); FPDFFile.Canvas.Font.FontName = FPDFFile.Canvas.Font.WFontName.Replace(" ", ""); FPDFFile.Canvas.Font.LFontName = page.GetLFontNameText(objt); FPDFFile.Canvas.Font.Style = objt.FontStyle; // Transparent ? FPDFFile.Canvas.Font.Name = (PDFFontType)objt.Type1Font; FPDFFile.Canvas.Font.Size = objt.FontSize; FPDFFile.Canvas.Font.Color = objt.FontColor; FPDFFile.Canvas.Font.Bold = (objt.FontStyle & 1) > 0; FPDFFile.Canvas.Font.Italic = (objt.FontStyle & 2) > 0; FPDFFile.Canvas.Font.Underline = (objt.FontStyle & 4) > 0; FPDFFile.Canvas.Font.StrikeOut = (objt.FontStyle & 8) > 0; FPDFFile.Canvas.Font.BackColor = objt.BackColor; FPDFFile.Canvas.Font.Transparent = objt.Transparent; FPDFFile.Canvas.UpdateFonts(); aalign = objt.Alignment; rec = new Rectangle(posx, posy, posx + objt.Width, posy + objt.Height); astring = page.GetText(objt); FPDFFile.Canvas.TextRect(rec, astring, aalign, objt.CutText, objt.WordWrap, objt.FontRotation, objt.RightToLeft); break; case MetaObjectType.Draw: MetaObjectDraw objd = (MetaObjectDraw)obj; Width = objd.Width; Height = objd.Height; FPDFFile.Canvas.BrushStyle = objd.BrushStyle; FPDFFile.Canvas.PenStyle = objd.PenStyle; FPDFFile.Canvas.PenColor = objd.PenColor; FPDFFile.Canvas.BrushColor = objd.BrushColor; FPDFFile.Canvas.PenWidth = objd.PenWidth; X = (int)FPDFFile.Canvas.PenWidth / 2; Y = X; W = Width - FPDFFile.Canvas.PenWidth + 1; H = Height - FPDFFile.Canvas.PenWidth + 1; if (FPDFFile.Canvas.PenWidth == 0) { W--; H--; } if (W < H) { S = W; } else { S = H; } ShapeType shape = (ShapeType)objd.DrawStyle; if ((shape == ShapeType.Square) || (shape == ShapeType.RoundSquare) || (shape == ShapeType.Circle)) { X = X + (int)((W - S) / 2); Y = Y + (int)((H - S) / 2); W = S; H = S; } switch (shape) { case ShapeType.Rectangle: case ShapeType.Square: FPDFFile.Canvas.Rectangle(X + posx, Y + posy, X + posx + W, Y + posy + H); break; case ShapeType.RoundRect: case ShapeType.RoundSquare: FPDFFile.Canvas.RoundedRectangle(X + posx, Y + posy, X + posx + W, Y + posy + H, Rectangle_Radius); break; case ShapeType.Ellipse: case ShapeType.Circle: FPDFFile.Canvas.Ellipse(X + posx, Y + posy, X + posx + W, Y + posy + H); break; case ShapeType.HorzLine: FPDFFile.Canvas.Line(X + posx, Y + posy, X + posx + W, Y + posy); // if (objd.PenStyle >= 3 && objd.PenStyle <= 4) // { // FPDFFile.Canvas.PenStyle = 6; // FPDFFile.Canvas.Line(X + posx, Y + posy, X + posx, Y + posx + H); // } break; case ShapeType.VertLine: FPDFFile.Canvas.Line(X + posx, Y + posy, X + posx, Y + posy + H); break; case ShapeType.Oblique1: FPDFFile.Canvas.Line(X + posx, Y + posy, X + posx + W, Y + posy + H); break; case ShapeType.Oblique2: FPDFFile.Canvas.Line(X + posx, Y + posy + H, X + posx + W, Y + posy); break; } break; case MetaObjectType.Image: MetaObjectImage obji = (MetaObjectImage)obj; // In pdf draw also preview only images //if (!obji.PreviewOnly) { Width = obji.Width; Height = obji.Height; rec = new Rectangle(posx, posy, Width, Height); stream = page.GetStream(obji); ImageDrawStyleType dstyle = (ImageDrawStyleType)obji.DrawImageStyle; long intimageindex = -1; if (obji.SharedImage) { intimageindex = obji.StreamPos; } bool adaptsize = false; if (dstyle == ImageDrawStyleType.Full) { adaptsize = true; dstyle = ImageDrawStyleType.Crop; } switch (dstyle) { case ImageDrawStyleType.Full: FPDFFile.Canvas.DrawImage(rec, stream, obji.DPIRes, false, false, intimageindex); break; case ImageDrawStyleType.Stretch: FPDFFile.Canvas.DrawImage(rec, stream, 0, false, false, intimageindex); break; case ImageDrawStyleType.Crop: int bitmapwidth = 0; int bitmapheight = 0; using (Image nimage = Image.FromStream(stream)) { bitmapwidth = nimage.Width; bitmapheight = nimage.Height; } if (adaptsize) { double nwidth = bitmapwidth * Twips.TWIPS_PER_INCH / obji.DPIRes; double nheight = bitmapheight * Twips.TWIPS_PER_INCH / obji.DPIRes; if (nwidth > rec.Width) { rec = new Rectangle(rec.Left, rec.Top, Convert.ToInt32(nwidth), Height); } if (nheight > rec.Height) { rec = new Rectangle(rec.Left, rec.Top, rec.Width, Convert.ToInt32(nheight)); } } double propx = (double)rec.Width / bitmapwidth; double propy = (double)rec.Height / bitmapheight; H = 0; W = 0; if (propy > propx) { H = Convert.ToInt32(Math.Round(rec.Height * propx / propy)); rec = new Rectangle(rec.Left, Convert.ToInt32(rec.Top + (rec.Height - H) / 2), rec.Width, H); } else { W = Convert.ToInt32(rec.Width * propy / propx); rec = new Rectangle(rec.Left + (rec.Width - W) / 2, rec.Top, W, rec.Height); } FPDFFile.Canvas.DrawImage(rec, stream, 0, false, false, intimageindex); break; case ImageDrawStyleType.Tile: case ImageDrawStyleType.Tiledpi: FPDFFile.Canvas.DrawImage(rec, stream, PDFFile.CONS_PDFRES, true, true, intimageindex); break; } } break; } }
/// <summary> /// Helper which returns an Expression array corresponding to the arguments minus /// the DynamicObject instance (arg0) plus the MetaAction constant. /// </summary> private static Expression[] ReplaceSelfWithAction(MetaAction action, MetaObject[] args) { Expression[] paramArgs = new Expression[args.Length - 1]; for (int i = 0; i < paramArgs.Length; i++) { paramArgs[i] = Expression.ConvertHelper(args[i + 1].Expression, typeof(object)); } return new Expression[] { Expression.Constant(action), Expression.NewArrayInit(typeof(object), paramArgs) }; }
private void BindGrid() { // DataTable structure DataTable dt = new DataTable(); dt.Locale = CultureInfo.InvariantCulture; dt.Columns.Add(idColumn, typeof(string)); dt.Columns.Add(principalColumn, typeof(string)); dt.Columns.Add(isInheritedColumn, typeof(bool)); foreach (SecurityRight right in Mediachase.Ibn.Data.Services.Security.GetMetaClassRights(mc.Name)) { dt.Columns.Add(right.RightName, typeof(string)); } dt.Columns.Add(editColumn, typeof(string)); dt.Columns.Add(resetColumn, typeof(string)); // Fill data DataRow dr; foreach (MetaObject mo in Mediachase.Ibn.Data.Services.Security.GetGlobalAcl(mc.Name)) { int principalId = (PrimaryKeyId)mo.Properties["PrincipalId"].Value; dr = dt.NewRow(); dr[idColumn] = mo.PrimaryKeyId.Value; dr[principalColumn] = CHelper.GetUserName(principalId); bool isInhereted = false; MetaObject obj = StateMachineUtil.GetGlobalAclStateItem(mc.Name, mo.PrimaryKeyId.Value, int.Parse(StateMachineList.SelectedValue), int.Parse(StateList.SelectedValue)); if (obj == null) { obj = mo; isInhereted = true; } dr[isInheritedColumn] = isInhereted; for (int i = 1; i < MainGrid.Columns.Count - 2; i++) { BoundField rightsField = MainGrid.Columns[i] as BoundField; if (rightsField != null) { string fieldName = rightsField.DataField; dr[fieldName] = CHelper.GetPermissionImage((int)obj.Properties[fieldName].Value, isInhereted); } } string url = String.Format(CultureInfo.InvariantCulture, "javascript:ShowWizard("{7}?ClassName={0}&btn={1}&PrincipalId={2}&SmId={3}&StateId={4}", {5}, {6});", mc.Name, Page.ClientScript.GetPostBackEventReference(RefreshButton, ""), principalId, StateMachineList.SelectedValue, StateList.SelectedValue, dialogWidth, dialogHeight, ResolveClientUrl("~/Apps/Security/Pages/Admin/GlobalRoleAclStateEdit.aspx")); dr[editColumn] = String.Format(CultureInfo.InvariantCulture, "<a href=\"{0}\"><img src=\"{1}\" title=\"{2}\" width=\"16\" height=\"16\" border=\"0\" /></a>", url, ResolveUrl("~/Images/IbnFramework/edit.gif"), GetGlobalResourceObject("IbnFramework.GlobalMetaInfo", "Edit").ToString()); dt.Rows.Add(dr); } MainGrid.DataSource = dt; MainGrid.DataBind(); }
public Result Delete(int tenantId, MetaObject metaObject, FilterDefinition <BsonDocument> condition) { db.GetCollectionBson(metaObject.Code).DeleteMany(CombineTenantId(tenantId, condition)); return(Result.Success($"删除成功")); }
/// <summary> /// Creates the child controls internal. /// </summary> private void CreateChildControlsInternal() { //if (this.ObjectId > 0) { MetaControls.EnableViewState = false; if (MetaControls.Controls.Count > 0) { return; } MetaControls.Controls.Clear(); MetaClass mc = MetaClass.Load(this.MDContext, MetaClassId); if (mc == null) { return; } Dictionary <string, MetaObject> metaObjects = new Dictionary <string, MetaObject>(); if (_metaObjects != null) { metaObjects = _metaObjects; } else { // cycle through each language and get meta objects MDContext.UseCurrentUICulture = false; foreach (string language in Languages) { MDContext.UseCurrentUICulture = false; MDContext.Language = language; MetaObject metaObj = null; if (ObjectId > 0) { metaObj = MetaObject.Load(MDContext, ObjectId, mc); if (metaObj == null) { metaObj = MetaObject.NewObject(MDContext, ObjectId, MetaClassId, FrameworkContext.Current.Profile.UserName); metaObj.AcceptChanges(MDContext); } } metaObjects[language] = metaObj; } MDContext.UseCurrentUICulture = true; } MetaFieldCollection metaFieldsColl = MetaField.GetList(MDContext, MetaClassId); foreach (MetaField mf in metaFieldsColl) { if (mf.IsUser) { int index = 0; foreach (string language in Languages) { string controlName = ResolveMetaControl(mc, mf); Control ctrl = MetaControls.FindControl(mf.Name); if (ctrl == null) { ctrl = Page.LoadControl(controlName); MetaControls.Controls.Add(ctrl); } CoreBaseUserControl coreCtrl = ctrl as CoreBaseUserControl; if (coreCtrl != null) { coreCtrl.MDContext = this.MDContext; } //ctrl.ID = String.Format("{0}-{1}", mf.Name, index.ToString()); ((IMetaControl)ctrl).MetaField = mf; if (metaObjects[language] != null && metaObjects[language][mf] != null) { ((IMetaControl)ctrl).MetaObject = metaObjects[language]; } ((IMetaControl)ctrl).LanguageCode = language; ((IMetaControl)ctrl).ValidationGroup = ValidationGroup; ctrl.DataBind(); if (!mf.MultiLanguageValue) { break; } index++; } } } } }
private void ProcessControl(Control c, MetaObject mo) { IEditControl fc = c as IEditControl; if (fc != null && !fc.ReadOnly) { string fieldName = fc.FieldName; if (fieldName.ToLower() == "title" && mo.Properties[fieldName] == null) { fieldName = mo.GetMetaType().TitleFieldName; } mo.Properties[fieldName].Value = fc.Value; } }
/// <summary> /// Saves the changes. /// </summary> /// <param name="context">The context.</param> public void SaveChanges(IDictionary context) { if (ObjectId != 0) { // set username here, because calling FrameworkContext.Current.Profile causes MeteDataContext.Current to change (it's bug in ProfileContext class). string userName = FrameworkContext.Current.Profile.UserName; MDContext.UseCurrentUICulture = false; // make sure all the values are saved using transaction //using (TransactionScope scope = new TransactionScope()) { MetaObjectSerialized serialized = new MetaObjectSerialized(); //bool saveSerialized = false; //string foreach (string language in Languages) { MDContext.Language = language; MetaObject metaObj = null; bool saveChanges = true; // Check if meta object contect exists if (context != null && context.Contains(_MetaObjectContextKey + language)) { saveChanges = false; metaObj = (MetaObject)context[_MetaObjectContextKey + language]; } //if (context != null) //{ // if (context.Contains(_MetaObjectContextKey + language)) // { // saveChanges = false; // saveSerialized = true; // metaObj = (MetaObject)context[_MetaObjectContextKey + language]; // } // else if (context.Contains(_OrderMetaObjectContextKey + language)) // { // metaObj = (MetaObject)context[_OrderMetaObjectContextKey + language]; // } //} if (metaObj == null) { metaObj = MetaObject.Load(MDContext, ObjectId, MetaClassId); } if (metaObj == null) { metaObj = MetaObject.NewObject(MDContext, ObjectId, MetaClassId, userName); //DataBind(); return; } else { metaObj.ModifierId = userName; metaObj.Modified = DateTime.UtcNow; } foreach (Control ctrl in MetaControls.Controls) { // Only update controls that belong to current language if (String.Compare(((IMetaControl)ctrl).LanguageCode, language, true) == 0) { ((IMetaControl)ctrl).MetaObject = metaObj; //((IMetaControl)ctrl).MetaField = metaObj; ((IMetaControl)ctrl).Update(); } } // Only save changes when new object has been created if (saveChanges) { metaObj.AcceptChanges(MDContext); } //else if (context != null) { serialized.AddMetaObject(language, metaObj); } } if (context != null) //&& saveSerialized) { context.Add("MetaObjectSerialized", serialized); } //scope.Complete(); } MDContext.UseCurrentUICulture = true; } //DataBind(); }
public static ListPublication[] List(params Mediachase.Ibn.Data.FilterElement[] filters) { return(MetaObject.List <ListPublication>(ListPublication.GetAssignedMetaClass(), filters)); }
/// <summary> /// Binds a data source to the invoked server control and all its child controls. /// </summary> public override void DataBind() { ListInfo li = ListManager.GetListInfoByMetaClass(mc); if (!li.IsTemplate) { ListDataLink.Text = li.Title; ListDataLink.NavigateUrl = String.Format(CultureInfo.InvariantCulture, "~/Apps/MetaUIEntity/Pages/EntityList.aspx?ClassName={0}", mc.Name); ListTemplate.Visible = false; } else { ListTemplate.Text = li.Title; ListDataLink.Visible = false; } RecordCountLabel.Text = MetaObject.GetTotalCount(mc).ToString(); CreatedByLabel.Text = CommonHelper.GetUserStatus(li.CreatorId); CreatedLabel.Text = li.Created.ToShortDateString(); StatusLabel.Text = (li.Properties["Status"].Value != null) ? CHelper.GetResFileString(MetaEnum.GetFriendlyName(MetaDataWrapper.GetEnumByName(ListManager.ListStatusEnumName), (int)li.Properties["Status"].Value)) : ""; TypeLabel.Text = (li.Properties["ListType"].Value != null) ? CHelper.GetResFileString(MetaEnum.GetFriendlyName(MetaDataWrapper.GetEnumByName(ListManager.ListTypeEnumName), (int)li.Properties["ListType"].Value)) : ""; string titleFieldName = mc.TitleFieldName; if (!String.IsNullOrEmpty(titleFieldName)) { if (mc.Fields[titleFieldName] != null) { DefaultFieldButton.Text = CHelper.GetResFileString(mc.Fields[titleFieldName].FriendlyName); DefaultFieldLabel.Text = DefaultFieldButton.Text; } else { DefaultFieldButton.Text = titleFieldName; } } else { DefaultFieldButton.Text = GetGlobalResourceObject("IbnFramework.ListInfo", "DefaultFieldNotSet").ToString(); DefaultFieldLabel.Text = GetGlobalResourceObject("IbnFramework.ListInfo", "DefaultFieldNotSet").ToString(); } foreach (MetaField mf in mc.Fields) { McDataType type = mf.GetOriginalMetaType().McDataType; if (mf.IsNullable || type != McDataType.String) { continue; } string itemText = ""; string name = mf.Name; itemText = CHelper.GetResFileString(mf.FriendlyName);; FieldsList.Items.Add(new ListItem(itemText, name)); } if (!String.IsNullOrEmpty(titleFieldName)) { CHelper.SafeSelect(FieldsList, titleFieldName); } if (FieldsList.Items.Count > 0) { DefaultFieldButton.Visible = true; DefaultFieldLabel.Visible = false; } else { DefaultFieldButton.Visible = false; DefaultFieldLabel.Visible = true; } FieldsList.Visible = false; SaveButton.Visible = false; CancelButton.Visible = false; base.DataBind(); }
/// <summary> /// Initializes the specified event storage. /// </summary> /// <param name="eventStorage">The event storage.</param> public void Initialize(MetaObject eventStorage) { _calendar = eventStorage as Calendar; if (_calendar == null) throw new ArgumentException("event storage"); }
/// <summary> /// Enables processing of HTTP Web requests by a custom HttpHandler that implements the <see cref="T:System.Web.IHttpHandler"/> interface. /// </summary> /// <param name="context">An <see cref="T:System.Web.HttpContext"/> object that provides references to the intrinsic server objects (for example, Request, Response, Session, and Server) used to service HTTP requests.</param> public void ProcessRequest(HttpContext context) { if (_CachedVersionIsOkay(context.Request)) { context.Response.StatusCode = 304; context.Response.SuppressContent = true; return; } string file = context.Request.FilePath; file = file.Substring(file.LastIndexOf("/") + 1); file = file.Substring(0, file.IndexOf(".")); string[] fileParams = file.Split(new char[] { '-' }); if (fileParams.Length < 3) { return; } int metaClassId = Int32.Parse(fileParams[0]); int objectId = Int32.Parse(fileParams[1]); string metaFieldName = fileParams[2]; bool thumbNail = false; if (fileParams.Length > 3) { if (fileParams[3] == "thumb") { thumbNail = true; } } MetaObject o = MetaObject.Load(CatalogContext.MetaDataContext, objectId, metaClassId); if (o != null) { MetaField mf = MetaField.Load(CatalogContext.MetaDataContext, metaFieldName); if (mf == null) { return; } MetaFile metafile = (MetaFile)o[mf]; if (metafile != null && metafile.Buffer != null && metafile.Buffer.Length > 0) { context.Response.Cache.SetExpires(DateTime.Now.Add(new TimeSpan(0, 1, 0))); context.Response.Cache.SetCacheability(HttpCacheability.Public); context.Response.Cache.SetLastModified(DateTime.Now); context.Response.AddHeader("content-disposition", "inline; filename=" + metafile.Name); context.Response.ContentType = metafile.ContentType; if (!thumbNail) { context.Response.BinaryWrite(metafile.Buffer); } else // create thumbnail { if (!metafile.ContentType.Contains("gif")) // dont create thumbnails for gifs { int thumbWidth = 0; int thumbHeight = 0; bool thumbStretch = false; object var = mf.Attributes["CreateThumbnail"]; if (var != null && Boolean.Parse(var.ToString())) { var = mf.Attributes["ThumbnailHeight"]; if (var != null) { thumbHeight = Int32.Parse(var.ToString()); } var = mf.Attributes["ThumbnailWidth"]; if (var != null) { thumbWidth = Int32.Parse(var.ToString()); } var = mf.Attributes["StretchThumbnail"]; if (var != null && Boolean.Parse(var.ToString())) { thumbStretch = true; } } byte[] data = ImageGenerator.CreateImageThumbnail(metafile.Buffer, metafile.ContentType, thumbHeight, thumbWidth, thumbStretch); context.Response.BinaryWrite(data); } else { context.Response.BinaryWrite(metafile.Buffer); } } } else { context.Response.Cache.SetExpires(DateTime.Now.Add(new TimeSpan(1, 0, 0))); context.Response.Cache.SetCacheability(HttpCacheability.Public); context.Response.Cache.SetValidUntilExpires(false); context.Response.AddHeader("content-disposition", "inline; filename=" + "nopic.png"); context.Response.ContentType = "image/png"; context.Response.WriteFile(context.Server.MapPath("~/images/nopic.png")); } } }
/// <summary> /// Initializes the specified calendar. /// </summary> /// <param name="calendar">The calendar.</param> public void Initialize(MetaObject obj) { Calendar calendar = obj as Calendar; if (obj == null) throw new ArgumentException("calendar"); foreach (IEventProvider provider in _eventProviders) { provider.Initialize(calendar); } }
public override MetaObject /*!*/ FallbackCreateInstance(MetaObject /*!*/ target, MetaObject /*!*/[] /*!*/ args, MetaObject errorSuggestion) { var result = TryBind(_context, this, target, args); if (result != null) { return(result); } throw new NotImplementedException(); // TODO: //return ((DefaultBinder)_context.Binder).Create(.GetMember(Name, self, Ast.Null(typeof(CodeContext)), true); }
public override MetaObject Call(CallAction action, MetaObject[] args) { if (ImplementsActions(StandardActionKinds.Call)) { return CallMethodNAry(action, args, "Call"); } return base.Call(action, args); }
public static MetaObject TryBind(RubyContext /*!*/ context, CreateInstanceBinder /*!*/ binder, MetaObject /*!*/ target, MetaObject /*!*/[] /*!*/ args) { Assert.NotNull(context, binder, target, args); var metaBuilder = new MetaObjectBuilder(); RubyCallAction.Bind(metaBuilder, "new", new CallArguments( new MetaObject(Ast.Constant(context), Restrictions.Empty, context), target, args, RubyCallSignature.Simple(args.Length) ) ); // TODO: we should return null if we fail, we need to throw exception due to version update optimization: return(metaBuilder.CreateMetaObject(binder, MetaObject.EmptyMetaObjects)); }
public override MetaObject Create(CreateAction action, MetaObject[] args) { if (ImplementsActions(StandardActionKinds.Create)) { return CallMethodNAry(action, args, "Create"); } return base.Create(action, args); }
private void MakeSetMemberRule(SetOrDeleteMemberInfo memInfo, Type type, Expression self, MetaObject target) { if (MakeOperatorSetMemberBody(memInfo, self, target, type, "SetMember")) { return; } // needed for GetMember call until DynamicAction goes away OldDynamicAction act = OldSetMemberAction.Make( this, memInfo.Name ); MemberGroup members = GetMember(act, type, memInfo.Name); // if lookup failed try the strong-box type if available. if (members.Count == 0 && typeof(IStrongBox).IsAssignableFrom(type)) { self = Ast.Field(AstUtils.Convert(self, type), type.GetField("Value")); type = type.GetGenericArguments()[0]; members = GetMember(act, type, memInfo.Name); } Expression error; TrackerTypes memberTypes = GetMemberType(members, out error); if (error == null) { switch (memberTypes) { case TrackerTypes.Method: case TrackerTypes.TypeGroup: case TrackerTypes.Type: case TrackerTypes.Constructor: memInfo.Body.FinishCondition( MakeError(MakeReadOnlyMemberError(type, memInfo.Name)) ); break; case TrackerTypes.Event: memInfo.Body.FinishCondition( MakeError(MakeEventValidation(members, self, target.Expression, memInfo.CodeContext)) ); break; case TrackerTypes.Field: MakeFieldRule(memInfo, self, target, type, members); break; case TrackerTypes.Property: MakePropertyRule(memInfo, self, target, type, members); break; case TrackerTypes.Custom: MakeGenericBody(memInfo, self, target, type, members[0]); break; case TrackerTypes.All: // no match if (MakeOperatorSetMemberBody(memInfo, self, target, type, "SetMemberAfter")) { return; } memInfo.Body.FinishCondition( MakeError(MakeMissingMemberError(type, memInfo.Name)) ); break; default: throw new InvalidOperationException(); } } else { memInfo.Body.FinishCondition(error); } }
public override MetaObject Invoke(InvokeAction action, MetaObject[] args) { if (ImplementsActions(StandardActionKinds.Invoke)) { return CallMethodNAry(action, args, "Invoke"); } return base.Invoke(action, args); }
private void MakeGenericBody(SetOrDeleteMemberInfo memInfo, Expression instance, MetaObject target, Type type, MemberTracker tracker) { if (instance != null) { tracker = tracker.BindToInstance(instance); } Expression val = tracker.SetValue(memInfo.CodeContext, this, type, target.Expression); if (val != null) { memInfo.Body.FinishCondition(val); } else { memInfo.Body.FinishCondition( MakeError(tracker.GetError(this)) ); } }
public override MetaObject SetMember(SetMemberAction action, MetaObject[] args) { if (ImplementsActions(StandardActionKinds.SetMember)) { return CallMethodBinary(action, args[1], "SetMember"); } return base.SetMember(action, args); }
private void BeforeNodeSelected(TreeNode node) { if (node != null) { if (node.Tag == null) { return; } NodeData data = node.Tag as NodeData; MetaObject obj = null; if (data.Type != NodeType.ESMETADATAENGINE) { obj = data.Meta as MetaObject; } if (data != null) { switch (data.Type) { case NodeType.COLUMNS: this.EditNiceNames(data.Meta as Columns); break; case NodeType.DATABASES: this.EditNiceNames(data.Meta as Databases); break; case NodeType.TABLES: case NodeType.SUBTABLES: this.EditNiceNames(data.Meta as Tables); break; case NodeType.VIEWS: case NodeType.SUBVIEWS: this.EditNiceNames(data.Meta as Views); break; case NodeType.FOREIGNKEYS: case NodeType.INDIRECTFOREIGNKEYS: this.EditNiceNames(data.Meta as ForeignKeys); break; case NodeType.PARAMETERS: this.EditNiceNames(data.Meta as Parameters); break; case NodeType.RESULTCOLUMNS: this.EditNiceNames(data.Meta as ResultColumns); break; case NodeType.INDEXES: this.EditNiceNames(data.Meta as Indexes); break; case NodeType.PROCEDURES: this.EditNiceNames(data.Meta as Procedures); break; case NodeType.DOMAINS: this.EditNiceNames(data.Meta as Domains); break; default: this.Grid.DataSource = null; break; } switch (data.Type) { case NodeType.DATABASE: { Database o = obj as Database; metadataProperties.DisplayDatabaseProperties(o, node); this.EditSingle(o, o.Alias); } break; case NodeType.COLUMN: { Column o = obj as Column; metadataProperties.DisplayColumnProperties(o, node); this.EditSingle(o, o.Alias); } break; case NodeType.TABLE: { Table o = obj as Table; metadataProperties.DisplayTableProperties(o, node); this.EditSingle(o, o.Alias); } break; case NodeType.VIEW: { EntitySpaces.MetadataEngine.View o = obj as EntitySpaces.MetadataEngine.View; metadataProperties.DisplayViewProperties(o, node); this.EditSingle(o, o.Alias); } break; case NodeType.PARAMETER: { Parameter o = obj as Parameter; metadataProperties.DisplayParameterProperties(o, node); this.EditSingle(o, o.Alias); } break; case NodeType.RESULTCOLUMN: { ResultColumn o = obj as ResultColumn; metadataProperties.DisplayResultColumnProperties(o, node); this.EditSingle(o, o.Alias); } break; case NodeType.FOREIGNKEY: { ForeignKey o = obj as ForeignKey; metadataProperties.DisplayForeignKeyProperties(o, node); this.EditSingle(o, o.Alias); } break; case NodeType.INDEX: { Index o = obj as Index; metadataProperties.DisplayIndexProperties(o, node); this.EditSingle(o, o.Alias); } break; case NodeType.PROCEDURE: { Procedure o = obj as Procedure; metadataProperties.DisplayProcedureProperties(o, node); this.EditSingle(o, o.Alias); } break; case NodeType.DOMAIN: { Domain o = obj as Domain; metadataProperties.DisplayDomainProperties(o, node); this.EditSingle(o, o.Alias); } break; default: metadataProperties.Clear(); break; } } } }
/// <summary> /// Helper method for generating a MetaObject which calls a specific method declared on /// Dynamic w/ one additional parameter. /// </summary> private MetaObject CallMethodBinary(SetMemberAction action, MetaObject arg, string methodName) { return new MetaObject( Expression.Call( GetLimitedSelf(), typeof(DynamicObject).GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance), Expression.Constant(action), arg.Expression ), GetRestrictions() ); }
public static string GetEventResourceString(MetaObject eventObject) { string retVal = GetResFileString(eventObject.Properties["EventTitle"].Value.ToString()); //{event:...} MatchCollection coll = Regex.Matches(retVal, "{event:(?<EventProp>[^}]*)}"); foreach (Match match in coll) { string sArg = match.Groups["EventProp"].Value; retVal = retVal.Replace(match.ToString(), GetResFileString(eventObject.Properties[sArg].Value.ToString())); } //{args:...} if (eventObject.Properties["ArgumentType"].Value != null && eventObject.Properties["ArgumentData"].Value != null) { string argumentType = eventObject.Properties["ArgumentType"].Value.ToString(); string argumentData = eventObject.Properties["ArgumentData"].Value.ToString(); MatchCollection argscoll = Regex.Matches(retVal, "{args:(?<EventArg>[^}]*)}"); if (argscoll.Count > 0) { Type objType = Mediachase.Ibn.Data.AssemblyUtil.LoadType(argumentType); object obj = McXmlSerializer.GetObject(objType, argumentData); if (obj != null) { foreach (Match match in argscoll) { string p_name = match.Groups["EventArg"].Value; PropertyInfo pinfo = objType.GetProperty(p_name); if (pinfo != null) { string sTemp = pinfo.GetValue(obj, null).ToString(); retVal = retVal.Replace(match.ToString(), GetResFileString(sTemp)); } } } } } return retVal; }
private void MakePropertyRule(SetOrDeleteMemberInfo memInfo, Expression instance, MetaObject target, Type targetType, MemberGroup properties) { PropertyTracker info = (PropertyTracker)properties[0]; MethodInfo setter = info.GetSetMethod(true); // Allow access to protected getters TODO: this should go, it supports IronPython semantics. if (setter != null && !setter.IsPublic && !(setter.IsFamily || setter.IsFamilyOrAssembly)) { if (!PrivateBinding) { setter = null; } } if (setter != null) { setter = CompilerHelpers.GetCallableMethod(setter, PrivateBinding); if (info.IsStatic != (instance == null)) { memInfo.Body.FinishCondition( MakeError( MakeStaticPropertyInstanceAccessError( info, true, instance, target.Expression ) ) ); } else if (info.IsStatic && info.DeclaringType != targetType) { memInfo.Body.FinishCondition( MakeError( MakeStaticAssignFromDerivedTypeError(targetType, info, target.Expression, memInfo.CodeContext) ) ); } else if (setter.ContainsGenericParameters) { memInfo.Body.FinishCondition( MakeGenericPropertyExpression(memInfo) ); } else if (setter.IsPublic && !setter.DeclaringType.IsValueType) { if (instance == null) { memInfo.Body.FinishCondition( AstUtils.SimpleCallHelper( setter, ConvertExpression( target.Expression, setter.GetParameters()[0].ParameterType, ConversionResultKind.ExplicitCast, memInfo.CodeContext ) ) ); } else { memInfo.Body.FinishCondition( MakeReturnValue( MakeCallExpression(memInfo.CodeContext, setter, instance, target.Expression), target ) ); } } else { // TODO: Should be able to do better w/ value types. memInfo.Body.FinishCondition( MakeReturnValue( Ast.Call( Ast.Constant(((ReflectedPropertyTracker)info).Property), // TODO: Private binding on extension properties typeof(PropertyInfo).GetMethod("SetValue", new Type[] { typeof(object), typeof(object), typeof(object[]) }), instance == null ? Ast.Constant(null) : AstUtils.Convert(instance, typeof(object)), AstUtils.Convert(target.Expression, typeof(object)), Ast.NewArrayInit(typeof(object)) ), target ) ); } } else { memInfo.Body.FinishCondition( MakeError( MakeMissingMemberError(targetType, memInfo.Name) ) ); } }
public Result BatchAdd(int tenantId, MetaObject metaObject, List <BsonDocument> bsonsList) { if (bsonsList != null && bsonsList.Any()) { List <BsonDocument> insertBsonsList = new List <BsonDocument>(); //获取到字段列表 var metaFields = metaFieldService.GetMetaFieldUpperKeyDicUnDeleted(metaObject.Id); for (int j = 0; j < bsonsList.Count; j++) { var bsons = bsonsList[j]; for (int i = bsons.ElementCount - 1; i >= 0; i--) { var item = bsons.GetElement(i); string upperKey = item.Name.ToUpperInvariant(); if (metaFields.ContainsKey(upperKey)) { //检查字段的值是否符合字段类型 var checkResult = metaFieldService.CheckAndGetFieldValueByFieldType(metaFields[upperKey], item.Value); if (checkResult.IsSuccess) { //如果大小写不匹配,则都转化成配置的字段Code形式 if (!item.Name.Equals(metaFields[upperKey].Code)) { bsons.RemoveElement(item); bsons.Add(new BsonElement(metaFields[upperKey].Code, BsonValue.Create(checkResult.Data))); } else { //重置字段的真实类型的值 bsons.SetElement(new BsonElement(metaFields[upperKey].Code, BsonValue.Create(checkResult.Data))); } } else { return(Result.Error($"字段[{item.Name}]传递的值[{item.Value}]不符合字段定义的类型")); //bsons.RemoveElement(item); } } else { //如果字段不在配置字段中,则不进行添加 bsons.RemoveElement(item); } } //预置字段及其默认值 foreach (var item in metaFieldService.GetPresetFieldBsonElements()) { //如果传入的字段已经有了,那么这里就不预置了 if (!bsons.Contains(item.Name)) { bsons.Add(item); } } //补充字段 bsons.SetElement(new BsonElement(MetaDataConst.TenantId, tenantId)); bsons.SetElement(new BsonElement("MetaObjectCode", metaObject.Code)); insertBsonsList.Add(bsons); } if (insertBsonsList.Any()) { db.GetCollectionBson(metaObject.Code).InsertMany(insertBsonsList); } return(Result.Success($"插入成功! 成功{insertBsonsList.Count}条,失败{bsonsList.Count - insertBsonsList.Count}条.")); } return(Result.Success($"插入失败! 失败原因:没有任何数据需要插入.")); }
private void MakeFieldRule(SetOrDeleteMemberInfo memInfo, Expression instance, MetaObject target, Type targetType, MemberGroup fields) { FieldTracker field = (FieldTracker)fields[0]; // TODO: Tmp variable for target if (field.DeclaringType.IsGenericType && field.DeclaringType.GetGenericTypeDefinition() == typeof(StrongBox <>)) { // work around a CLR bug where we can't access generic fields from dynamic methods. Type[] generic = field.DeclaringType.GetGenericArguments(); memInfo.Body.FinishCondition( MakeReturnValue( Ast.Assign( Ast.Field( AstUtils.Convert(instance, field.DeclaringType), field.DeclaringType.GetField("Value") ), AstUtils.Convert(target.Expression, generic[0]) ), target ) ); } else if (field.IsInitOnly || field.IsLiteral) { memInfo.Body.FinishCondition( MakeError( MakeReadOnlyMemberError(targetType, memInfo.Name) ) ); } else if (field.IsStatic && targetType != field.DeclaringType) { memInfo.Body.FinishCondition( MakeError( MakeStaticAssignFromDerivedTypeError(targetType, field, target.Expression, memInfo.CodeContext) ) ); } else if (field.DeclaringType.IsValueType && !field.IsStatic) { memInfo.Body.FinishCondition( Ast.Throw( Ast.New( typeof(ArgumentException).GetConstructor(new Type[] { typeof(string) }), Ast.Constant("cannot assign to value types") ) ) ); } else if (field.IsPublic && field.DeclaringType.IsVisible) { memInfo.Body.FinishCondition( MakeReturnValue( Ast.Assign( Ast.Field( field.IsStatic ? null : Ast.Convert(instance, field.DeclaringType), field.Field ), ConvertExpression(target.Expression, field.FieldType, ConversionResultKind.ExplicitCast, memInfo.CodeContext) ), target ) ); } else { memInfo.Body.FinishCondition( MakeReturnValue( Ast.Call( AstUtils.Convert(Ast.Constant(field.Field), typeof(FieldInfo)), typeof(FieldInfo).GetMethod("SetValue", new Type[] { typeof(object), typeof(object) }), field.IsStatic ? Ast.Constant(null) : (Expression)AstUtils.Convert(instance, typeof(object)), AstUtils.Convert(target.Expression, typeof(object)) ), target ) ); } }
protected void btnSave_Click(object sender, EventArgs e) { MetaObject mo = Mediachase.Ibn.Data.Services.RoleManager.GetObjectRole(mc, RoleName); MetaObject moState = StateMachineUtil.GetObjectRoleStateItem(ClassName, mo.PrimaryKeyId.Value, StateMachineId, StateId); if (moState == null) { MetaClass stateClass = StateMachineUtil.GetObjectRoleStateMetaClass(ClassName); moState = new MetaObject(stateClass); } MetaObjectPropertyCollection properties = moState.Properties; properties[StateMachineUtil.RoleField].Value = mo.PrimaryKeyId.Value; properties[StateMachineUtil.StateMachineField].Value = StateMachineId; properties[StateMachineUtil.StateField].Value = StateId; for (int i = 0; i < rights.Count; i++) { string rightName = rights[i].ToString(); properties[rightName].Value = ((CheckControl)checkControls[i]).Value; } moState.Save(); // Closing window if (RefreshButton == String.Empty) { CHelper.CloseItAndRefresh(Response); } else // Dialog Mode { CHelper.CloseItAndRefresh(Response, RefreshButton); } }
/// <summary> /// Initializes the specified event storage. /// </summary> /// <param name="eventStorage">The event storage.</param> public void Initialize(MetaObject eventStorage) { Calendar calendar = eventStorage as Calendar; if (calendar == null) throw new ArgumentException("event storage"); //Subscribe on delete primary event, for cleanup link CalendarEvent.CalEventDeleteEvent += PrimaryEventDeleteHandler; _calendarId = calendar.PrimaryKeyId.Value; }
public static ListPublication[] List(params Mediachase.Ibn.Data.SortingElement[] sorting) { return(MetaObject.List <ListPublication>(ListPublication.GetAssignedMetaClass(), sorting)); }
private void ProcessCollection(ControlCollection _coll, MetaObject mo) { foreach (Control c in _coll) { ProcessControl(c, mo); if (c.Controls.Count > 0) ProcessCollection(c.Controls, mo); } }
public static ListPublication[] List() { return(MetaObject.List <ListPublication>(ListPublication.GetAssignedMetaClass())); }
/// <summary> if a member-injector is defined-on or registered-for this type call it </summary> private bool MakeOperatorSetMemberBody(SetOrDeleteMemberInfo memInfo, Expression self, MetaObject target, Type type, string name) { if (self != null) { MethodInfo setMem = GetMethod(type, name); if (setMem != null && setMem.IsSpecialName) { ParameterExpression tmp = Ast.Variable(target.Expression.Type, "setValue"); memInfo.Body.AddVariable(tmp); Expression call = MakeCallExpression(memInfo.CodeContext, setMem, AstUtils.Convert(self, type), Ast.Constant(memInfo.Name), tmp); call = Ast.Block(Ast.Assign(tmp, target.Expression), call); if (setMem.ReturnType == typeof(bool)) { memInfo.Body.AddCondition( call, tmp ); } else { memInfo.Body.FinishCondition(Ast.Block(call, tmp)); } return(setMem.ReturnType != typeof(bool)); } } return(false); }
public static ListPublication[] List(Mediachase.Ibn.Data.FilterElementCollection filters, Mediachase.Ibn.Data.SortingElementCollection sorting, int start, int count) { return(MetaObject.List <ListPublication>(ListPublication.GetAssignedMetaClass(), filters, sorting, start, count)); }
private MetaObject GetMetaObjectById(MetaObject[] List, int? Id) { for (int i = 0; i < List.Length; i++) { if (List[i].PrimaryKeyId == Id) return List[i]; } return null; }
/// <summary> /// Builds a MetaObject for performing a member get. Supports all built-in .NET members, the OperatorMethod /// GetBoundMember, and StrongBox instances. /// </summary> /// <param name="name"> /// The name of the member to retrieve. This name is not processed by the DefaultBinder and /// is instead handed off to the GetMember API which can do name mangling, case insensitive lookups, etc... /// </param> /// <param name="target"> /// The MetaObject from which the member is retrieved. /// </param> /// <param name="value"> /// The value being assigned to the target member. /// </param> public MetaObject SetMember(string name, MetaObject target, MetaObject value) { return(SetMember(name, target, value, Ast.Constant(null, typeof(CodeContext)))); }
protected void btnSave_Click(object sender, EventArgs e) { Page.Validate(); if (!this.Page.IsValid) return; bool isNew = (PrincipalId == -1); if (isNew) // New { // Check for unicity if (Mediachase.Ibn.Data.Services.Security.GetGlobalAceByPrincipal(mc, (int)(PrimaryKeyId)principal.Value) != null) { // already exists if (Page.Validators.Count > 0) Page.Validators[0].IsValid = false; return; } } // Saving MetaObject mo = null; if (!isNew) mo = Mediachase.Ibn.Data.Services.Security.GetGlobalAceByPrincipal(mc, PrincipalId); if (mo == null) mo = new MetaObject(mc); MetaObjectPropertyCollection properties = mo.Properties; properties[principalField].Value = principal.Value; for (int i = 0; i < rights.Count; i++) { string rightName = rights[i].ToString(); properties[rightName].Value = ((CheckControl)checkControls[i]).Value; } mo.Save(); // Closing window if (RefreshButton == String.Empty) { CHelper.CloseItAndRefresh(Response); } else // Dialog Mode { CHelper.CloseItAndRefresh(Response, RefreshButton); } }
private MetaObject MakeSetMemberTarget(SetOrDeleteMemberInfo memInfo, MetaObject target, MetaObject value) { Type type = target.LimitType.IsCOMObject ? target.Expression.Type : target.LimitType; Expression self = target.Expression; target = target.Restrict(target.LimitType); memInfo.Body.Restrictions = target.Restrictions; if (typeof(TypeTracker).IsAssignableFrom(type)) { type = ((TypeTracker)target.Value).Type; self = null; memInfo.Body.Restrictions = memInfo.Body.Restrictions.Merge( Restrictions.GetInstanceRestriction(target.Expression, target.Value) ); } MakeSetMemberRule(memInfo, type, self, value); return(memInfo.Body.GetMetaObject(target, value)); }