public override void Delete(System.Collections.IDictionary keys, System.Collections.IDictionary oldValues, DataSourceViewOperationCallback callback) { esDataSourceDeleteEventArgs e = null; try { if (keys != null && keys.Count > 0) { e = new esDataSourceDeleteEventArgs(); e.Keys = keys; e.OldValues = oldValues; this.OnPreDelete(e); if (e.Cancel) { return; } // Find the proper esEntity and set it's values object[] pks = new object[keys.Count]; int index = 0; foreach (object value in keys.Values) { pks[index++] = value; } esDataSourceCreateEntityEventArgs ce = new esDataSourceCreateEntityEventArgs(); ce.PrimaryKeys = pks; this.OnCreateEntity(ce); esEntity entity = ce.Entity; e.Entity = entity; //this.OnPreDelete(e); e.EventWasHandled = false; this.OnDelete(e); if (!e.EventWasHandled) { entity.MarkAsDeleted(); entity.Save(); this.OnDataSourceViewChanged(EventArgs.Empty); } this.OnPostDelete(e); } } catch (Exception ex) { esDataSourceExceptionEventArgs exArgs = new esDataSourceExceptionEventArgs(ex); exArgs.EventType = esDataSourceEventType.Delete; exArgs.DeleteArgs = e; try { this.OnException(exArgs); } catch { } if (!exArgs.ExceptionWasHandled) { throw; } } finally { callback(1, null); } }
public override void Insert(System.Collections.IDictionary values, DataSourceViewOperationCallback callback) { esDataSourceInsertEventArgs e = null; try { e = new esDataSourceInsertEventArgs(); e.Values = values; this.OnPreInsert(e); if (e.Cancel) { return; } esDataSourceCreateEntityEventArgs ce = new esDataSourceCreateEntityEventArgs(); this.OnCreateEntity(ce); esEntity entity = ce.Entity; e.Entity = entity; if (entity != null) { entity.SetProperties(values); } //this.OnPreInsert(e); e.EventWasHandled = false; this.OnInsert(e); if (!e.EventWasHandled) { entity.Save(); this.OnDataSourceViewChanged(EventArgs.Empty); } e.EventWasHandled = false; this.OnPostInsert(e); } catch (Exception ex) { esDataSourceExceptionEventArgs exArgs = new esDataSourceExceptionEventArgs(ex); exArgs.EventType = esDataSourceEventType.Insert; exArgs.InsertArgs = e; try { this.OnException(exArgs); } catch { } if (!exArgs.ExceptionWasHandled) { throw; } } finally { callback(1, null); } }