public override void Insert(IDictionary values, DataSourceViewOperationCallback callback) { try { ISoodaObjectFactory fact = SoodaTransaction.ActiveTransaction.GetFactory(_owner.ClassName); SoodaObject obj = fact.CreateNew(SoodaTransaction.ActiveTransaction); Type type = obj.GetType(); foreach (DictionaryEntry v in values) { PropertyInfo pi = type.GetProperty((string)v.Key, BindingFlags.Public | BindingFlags.Instance); if (pi == null) { throw new SoodaException(v.Key + " not found in " + type.FullName); } pi.SetValue(obj, v.Value, null); } callback(1, null); } catch (Exception ex) { callback(0, ex); } }
public virtual void Insert(IDictionary values, DataSourceViewOperationCallback callback) { if (callback == null) { throw new ArgumentNullException("callback"); } int affectedRecords = 0; bool performedCallback = false; try { affectedRecords = ExecuteInsert(values); } catch (Exception ex) { performedCallback = true; if (!callback(affectedRecords, ex)) { throw; } } finally { if (!performedCallback) { callback(affectedRecords, null); } } }
public virtual void Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) { if (callback == null) { throw new ArgumentNullException("callback"); } int affectedRecords = 0; bool flag = false; try { affectedRecords = this.ExecuteDelete(keys, oldValues); } catch (Exception exception) { flag = true; if (!callback(affectedRecords, exception)) { throw; } } finally { if (!flag) { callback(affectedRecords, null); } } }
public virtual void Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callBack) { if (callBack == null) { throw new ArgumentNullException("callBack"); } int rowAffected; try { rowAffected = ExecuteUpdate(keys, values, oldValues); } catch (Exception e) { if (!callBack(0, e)) { throw; } return; } callBack(rowAffected, null); }
public override void Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) { try { if (keys.Count == 0) { throw new SoodaException("No keys passed to SoodaObjectDataSourceView.Update"); } if (keys.Count > 1) { throw new SoodaException("More than one key passed to SoodaObjectDataSourceView.Update"); } ISoodaObjectFactory fact = SoodaTransaction.ActiveTransaction.GetFactory(_owner.ClassName); // we just want to get the first key from "keys" // therefore we break at the end of the loop foreach (DictionaryEntry de in keys) { SoodaObject obj = SoodaTransaction.ActiveTransaction.GetObject(_owner.ClassName, Convert.ToString(de.Value)); obj.MarkForDelete(); break; } callback(1, null); } catch (Exception ex) { callback(0, ex); } }
public override void Insert(IDictionary values, DataSourceViewOperationCallback callback) { var insertArgs = new InsertEventArgs() { DataSourceView = UnderlyingView, Callback = callback, Values = values }; AppContext.EventBroker.PublishInTransaction(ActionDS, insertArgs); }
public override void Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) { var deleteArgs = new DeleteEventArgs() { DataSourceView = UnderlyingView, Callback = callback, OldValues = oldValues, Keys = keys }; AppContext.EventBroker.PublishInTransaction(ActionDS, deleteArgs); }
public override void Insert(IDictionary values, DataSourceViewOperationCallback callback) { var context = new ActionContext( new InsertEventArgs() { DataSourceView = UnderlyingView, Callback = callback, Values = values } ) { Origin = ActionDS.ActionSourceControl ?? ActionDS.NamingContainer, Sender = ActionDS }; PerformAction(context, callback); }
protected void ViewOperationAsync(Func <Task> asyncViewOperation, DataSourceViewOperationCallback callback) { if (!_owner.DataControl.Page.IsAsync) { throw new InvalidOperationException(Resources.ExtendedModelDataSourceView_MustBeAsyncPage); } _owner.DataControl.Page.RegisterAsyncTask(new PageAsyncTask(async() => { var operationTask = asyncViewOperation(); var operationTaskInt = operationTask as Task <int>; var operationThrew = false; var affectedRecords = 0; try { await operationTask; if (operationTaskInt != null) { affectedRecords = operationTaskInt.Result; } } catch (Exception ex) { operationThrew = true; if (!callback(affectedRecords, ex)) { // Nobody handled the operation error so re-throw throw; } } finally { _viewOperationInProgress = false; if (!operationThrew) { // The following line is technically meant to be called, but this causes an exception deep in ListView for some reason, // but it appears to automatically rebind anyway even without this call, so leaving commented out. //if (_owner.DataControl.Page.ModelState.IsValid) //{ // OnDataSourceViewChanged(EventArgs.Empty); //} // Success callback(affectedRecords, null); } } })); }
public override void Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) { var context = new ActionContext( new DeleteEventArgs() { DataSourceView = UnderlyingView, Callback = callback, OldValues = oldValues, Keys = keys } ) { Origin = ActionDS.ActionSourceControl ?? ActionDS.NamingContainer, Sender = ActionDS }; PerformAction(context, callback); }
public override void Insert(IDictionary values, DataSourceViewOperationCallback callback) { if (callback == null) { throw new ArgumentNullException("callback"); } if (typeof(Task).IsAssignableFrom(FindMethod(InsertMethod).MethodInfo.ReturnType)) { ViewOperationAsync(() => (Task)GetInsertMethodResult(values), callback); } else { base.Insert(values, callback); } }
public virtual void Delete (IDictionary keys, IDictionary values, DataSourceViewOperationCallback callBack) { if (callBack == null) throw new ArgumentNullException ("callBack"); int rowAffected = 0; Exception passOn = null; try { rowAffected = ExecuteDelete (keys, values); } catch (Exception e) { passOn = e; } if (!callBack (rowAffected, passOn) && passOn != null) throw passOn; }
public virtual void Delete (IDictionary keys, IDictionary values, DataSourceViewOperationCallback callBack) { if (callBack == null) throw new ArgumentNullException ("callBack"); int rowAffected; try { rowAffected = ExecuteDelete (keys, values); } catch (Exception e) { if (!callBack (0, e)) throw; return; } callBack (rowAffected, null); }
public override void Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) { if (callback == null) { throw new ArgumentNullException("callback"); } _viewOperationInProgress = true; if (typeof(Task).IsAssignableFrom(FindMethod(DeleteMethod).MethodInfo.ReturnType)) { ViewOperationAsync(() => (Task)GetDeleteMethodResult(keys, oldValues), callback); } else { base.Delete(keys, oldValues, callback); } }
protected void AddQualificationButton_Click(object sender, EventArgs e) { IDataSource ds = InstructorQualificationsDataSource; DataSourceView dsv = ds.GetView(InstructorQualificationsList.DataMember); System.Collections.IDictionary dict = new Dictionary<String, String>(); InstructorQualification iq = new InstructorQualification(); iq.CourseID = int.Parse(UnqualifiedQualificationList.SelectedValue); iq.InstructorID = int.Parse(InstructorList.SelectedValue); dict.Add("InstructorID", iq.InstructorID.ToString()); dict.Add("CourseID", iq.CourseID.ToString()); DataSourceViewOperationCallback callback = new DataSourceViewOperationCallback(delegate {return false;}); dsv.Insert(dict, callback); InstructorQualificationsList.DataBind(); UnqualifiedQualificationList.DataBind(); }
public override void Insert(IDictionary values, DataSourceViewOperationCallback callback) { try { ISoodaObjectFactory fact = SoodaTransaction.ActiveTransaction.GetFactory(_owner.ClassName); SoodaObject obj = fact.CreateNew(SoodaTransaction.ActiveTransaction); Type type = obj.GetType(); foreach (DictionaryEntry v in values) { PropertyInfo pi = type.GetProperty((string)v.Key, BindingFlags.Public | BindingFlags.Instance); if (pi == null) throw new SoodaException(v.Key + " not found in " + type.FullName); pi.SetValue(obj, v.Value, null); } callback(1, null); } catch (Exception ex) { callback(0, ex); } }
public void Delete(IDictionary keys, IDictionary values, DataSourceViewOperationCallback callback) { this.GetView(String.Empty).Delete(keys, values, callback); }
public void Insert(IDictionary values, DataSourceViewOperationCallback callback) { this.GetView(String.Empty).Insert(values, callback); }
public override void Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) { base.Update(keys, values, oldValues, callback); }
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 Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) { throw new NotSupportedException(); }
protected void PerformAction(ActionContext context, DataSourceViewOperationCallback callback) { WebManager.ExecuteAction(context); }
public override void Insert(IDictionary values, DataSourceViewOperationCallback callback) { // Keep track of the values to do foreign key processing in InsertDataObject _values = values; base.Insert(values, callback); }
public virtual new void Insert(System.Collections.IDictionary values, DataSourceViewOperationCallback callback) { }
public void Insert(IDictionary values, DataSourceViewOperationCallback callback) { this.GetView(String.Empty).Insert(values,callback); }
public virtual new void ExecuteCommand (string commandName, System.Collections.IDictionary keys, System.Collections.IDictionary values, DataSourceViewOperationCallback callback) { }
public virtual void Insert(System.Collections.IDictionary values, DataSourceViewOperationCallback callback) {}
public virtual void Update(System.Collections.IDictionary keys, System.Collections.IDictionary values, System.Collections.IDictionary oldValues, DataSourceViewOperationCallback callback) {}
private void ViewOperationAsync(Func<CancellationToken, Task> asyncViewOperation, DataSourceViewOperationCallback callback) { ValidateAsyncModelBindingRequirements(); Func<object, Task> func = async _ => { CancellationTokenSource cancellationTokenSource = _owner.DataControl.Page.CreateCancellationTokenFromAsyncTimeout(); CancellationToken cancellationToken = cancellationTokenSource.Token; var viewOperationTask = _viewOperationTask; if (viewOperationTask != null) { await viewOperationTask; } var operationTask = asyncViewOperation(cancellationToken); _viewOperationTask = operationTask; var operationTaskInt = operationTask as Task<int>; var operationThrew = false; var affectedRecords = -1; try { if (null != operationTask) { await operationTask; if (operationTaskInt != null) { affectedRecords = operationTaskInt.Result; } } } catch (Exception ex) { operationThrew = true; if (!callback(affectedRecords, ex)) { // Nobody handled the operation error so re-throw throw; } } finally { _viewOperationTask = null; // Data Method is done executing, turn off the TryUpdateModel _owner.DataControl.Page.SetActiveValueProvider(null); if (!operationThrew) { if (_owner.DataControl.Page.ModelState.IsValid) { OnDataSourceViewChanged(EventArgs.Empty); } // Success callback(affectedRecords, null); } } if (cancellationToken.IsCancellationRequested) { throw new TimeoutException(SR.GetString(SR.Async_task_timed_out)); } }; var syncContext = _owner.DataControl.Page.Context.SyncContext as AspNetSynchronizationContext; if (null == syncContext) { throw new InvalidOperationException(SR.GetString(SR.ModelDataSourceView_UseAsyncMethodMustBeUsingAsyncPage)); } syncContext.PostAsync(func, null); }
/* * protected override int ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) * { * int count = 0; * * if (SPContext.Current.Web.CurrentUser != null) * { * int result; * ClubCloud_Setting Settings = null; * if(int.TryParse(SPContext.Current.Web.CurrentUser.UserId.NameId, out result)) * Settings = Client.GetSettingById(result); * * if (Settings != null && Settings.VerenigingId != null) * { * * } * } * * return count; * } */ /* * protected override int ExecuteCommand(string commandName, IDictionary keys, IDictionary values) * { * return base.ExecuteCommand(commandName, keys, values); * } */ public override void Insert(IDictionary values, DataSourceViewOperationCallback callback) { base.Insert(values, callback); }
public virtual void Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) { if (callback == null) { throw new ArgumentNullException("callback"); } int affectedRecords = 0; bool performedCallback = false; try { affectedRecords = ExecuteUpdate(keys, values, oldValues); } catch (Exception ex) { performedCallback = true; if (!callback(affectedRecords, ex)) { throw; } } finally { if (!performedCallback) { callback(affectedRecords, null); } } }
public override void Insert(IDictionary values, DataSourceViewOperationCallback callback) { throw new NotSupportedException(); }
public override void Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) { try { if (keys.Count == 0) throw new SoodaException("No keys passed to SoodaObjectDataSourceView.Update"); if (keys.Count > 1) throw new SoodaException("More than one key passed to SoodaObjectDataSourceView.Update"); ISoodaObjectFactory fact = SoodaTransaction.ActiveTransaction.GetFactory(_owner.ClassName); // we just want to get the first key from "keys" // therefore we break at the end of the loop foreach (DictionaryEntry de in keys) { SoodaObject obj = SoodaTransaction.ActiveTransaction.GetObject(_owner.ClassName, Convert.ToString(de.Value)); obj.MarkForDelete(); break; } callback(1, null); } catch (Exception ex) { callback(0, ex); } }
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); } }
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 virtual new void ExecuteCommand(string commandName, System.Collections.IDictionary keys, System.Collections.IDictionary values, DataSourceViewOperationCallback callback) { }
public virtual new void Update(System.Collections.IDictionary keys, System.Collections.IDictionary values, System.Collections.IDictionary oldValues, DataSourceViewOperationCallback callback) { }
public override void Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCallback callback) { var context = new ActionContext( new UpdateEventArgs() { DataSourceView = UnderlyingView, Callback = callback, Values = values, OldValues = oldValues, Keys = keys } ) { Origin = ActionDS.ActionSourceControl ?? ActionDS.NamingContainer, Sender = ActionDS }; PerformAction(context, callback); }
public override void Delete(IDictionary keys, IDictionary oldValues, DataSourceViewOperationCallback callback) { if (callback == null) { throw new ArgumentNullException("callback"); } ModelDataSourceMethod method; if (RequireAsyncModelBinding(DeleteMethod, out method)) { ViewOperationAsync((cancellationToken) => (Task)GetDeleteMethodResult(keys, oldValues, method, true/*isAsyncMethod*/, cancellationToken), callback); } else { base.Delete(keys, oldValues, callback); } }
/// <summary> /// Performs an asynchronous insert operation on the list of data that the <see cref="DataSourceView"/> object represents. /// </summary> /// <param name="values">An <see cref="IDictionary"/> of name/value pairs used during an insert operation.</param> /// <param name="callback"></param> public override void Insert(IDictionary values, DataSourceViewOperationCallback callback) { TypeDescriptionHelper.ThrowIfNoDefaultConstructor(GetDataObjectType()); base.Insert(values, callback); }
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); } }