protected override int DeleteObject(object oldEntity)
        {
            LinqDataSourceDeleteEventArgs deleteEventArgs = new LinqDataSourceDeleteEventArgs(oldEntity);

            OnDeleting(deleteEventArgs);
            if (deleteEventArgs.Cancel)
            {
                return(-1);
            }

            LinqDataSourceStatusEventArgs deletedEventArgs = null;

            try {
                DeleteDataObject(Context, EntitySet, deleteEventArgs.OriginalObject);
            }
            catch (Exception e) {
                // allow user to handle dlinq exceptions including OnValidate validation.
                deletedEventArgs = new LinqDataSourceStatusEventArgs(e);
                OnDeleted(deletedEventArgs);
                OnException(new DynamicValidatorEventArgs(e, DynamicDataSourceOperation.Delete));
                if (deletedEventArgs.ExceptionHandled)
                {
                    return(-1);
                }
                throw;
            }
            deletedEventArgs = new LinqDataSourceStatusEventArgs(deleteEventArgs.OriginalObject);
            OnDeleted(deletedEventArgs);

            return(1);
        }
 protected virtual void OnDeleting(LinqDataSourceDeleteEventArgs e)
 {
     if (Deleting != null)
     {
         Deleting(this, e);
     }
 }
        protected virtual void OnDeleting(LinqDataSourceDeleteEventArgs e)
        {
            EventHandler <LinqDataSourceDeleteEventArgs> handler =
                (EventHandler <LinqDataSourceDeleteEventArgs>)Events[EventDeleting];

            if (handler != null)
            {
                handler(this, e);
            }
        }
		protected void lqResources_Deleting(object sender, LinqDataSourceDeleteEventArgs e)
		{
			e.Cancel = true;
			if ((bool?)Session["login"] == true) {
				var db = new ZkDataContext();
				var todel = db.Resources.Single(x=>x.InternalName == ((Resource)e.OriginalObject).InternalName);
        PlasmaServer.RemoveResourceFiles(todel);

				
				db.Resources.DeleteOnSubmit(todel);
				db.SubmitChanges();
				
				MessageBox.Show("Deleted " +  todel.InternalName);
        
			} else {
				MessageBox.Show("Not logged in");
			}
		}
		protected void lqContentFiles_Deleting(object sender, LinqDataSourceDeleteEventArgs e)
		{
			e.Cancel = true;
			if ((bool?)Session["login"] == true)
			{
				var db = new ZkDataContext();
				var todel = db.ResourceContentFiles.Single(x => x.Md5 == ((ResourceContentFile)e.OriginalObject).Md5);
				Utils.SafeDelete(PlasmaServer.GetTorrentPath(todel));

				db.ResourceContentFiles.DeleteOnSubmit(todel);
			    db.SaveChanges();

			    MessageBox.Show("Deleted " + todel.FileName);

			}
			else
			{
				MessageBox.Show("Not logged in");
			}

		}
        protected override void HandleValidationErrors(IDictionary <string, Exception> errors, DataSourceOperation operation)
        {
            LinqDataSourceValidationException exception = new LinqDataSourceValidationException(String.Format(CultureInfo.InvariantCulture,
                                                                                                              AtlasWeb.LinqDataSourceView_ValidationFailed,
                                                                                                              EntityType, errors.Values.First().Message),
                                                                                                errors);

            bool exceptionHandled = false;

            switch (operation)
            {
            case DataSourceOperation.Delete:
                LinqDataSourceDeleteEventArgs deleteEventArgs = new LinqDataSourceDeleteEventArgs(exception);
                OnDeleting(deleteEventArgs);
                OnException(new DynamicValidatorEventArgs(exception, DynamicDataSourceOperation.Delete));
                exceptionHandled = deleteEventArgs.ExceptionHandled;
                break;

            case DataSourceOperation.Insert:
                LinqDataSourceInsertEventArgs insertEventArgs = new LinqDataSourceInsertEventArgs(exception);
                OnInserting(insertEventArgs);
                OnException(new DynamicValidatorEventArgs(exception, DynamicDataSourceOperation.Insert));
                exceptionHandled = insertEventArgs.ExceptionHandled;
                break;

            case DataSourceOperation.Update:
                // allow user to handle conversion or dlinq property validation exceptions.
                LinqDataSourceUpdateEventArgs updateEventArgs = new LinqDataSourceUpdateEventArgs(exception);
                OnUpdating(updateEventArgs);
                OnException(new DynamicValidatorEventArgs(exception, DynamicDataSourceOperation.Update));
                exceptionHandled = updateEventArgs.ExceptionHandled;
                break;
            }

            if (!exceptionHandled)
            {
                throw exception;
            }
        }
示例#7
0
		protected virtual void OnDeleting (LinqDataSourceDeleteEventArgs e)
		{
			if (Deleting != null)
				Deleting (this, e);
		}
 protected virtual void OnDeleting(LinqDataSourceDeleteEventArgs e) {
     EventHandler<LinqDataSourceDeleteEventArgs> handler =
         (EventHandler<LinqDataSourceDeleteEventArgs>)Events[EventDeleting];
     if (handler != null) {
         handler(this, e);
     }
 }
        protected override void HandleValidationErrors(IDictionary<string, Exception> errors, DataSourceOperation operation) {
            LinqDataSourceValidationException exception = new LinqDataSourceValidationException(String.Format(CultureInfo.InvariantCulture,
                AtlasWeb.LinqDataSourceView_ValidationFailed,
                EntityType, errors.Values.First().Message),
                errors);

            bool exceptionHandled = false;

            switch (operation) {
                case DataSourceOperation.Delete:
                    LinqDataSourceDeleteEventArgs deleteEventArgs = new LinqDataSourceDeleteEventArgs(exception);
                    OnDeleting(deleteEventArgs);
                    OnException(new DynamicValidatorEventArgs(exception, DynamicDataSourceOperation.Delete));
                    exceptionHandled = deleteEventArgs.ExceptionHandled;
                    break;

                case DataSourceOperation.Insert:
                    LinqDataSourceInsertEventArgs insertEventArgs = new LinqDataSourceInsertEventArgs(exception);
                    OnInserting(insertEventArgs);
                    OnException(new DynamicValidatorEventArgs(exception, DynamicDataSourceOperation.Insert));
                    exceptionHandled = insertEventArgs.ExceptionHandled;
                    break;
                case DataSourceOperation.Update:
                    // allow user to handle conversion or dlinq property validation exceptions.
                    LinqDataSourceUpdateEventArgs updateEventArgs = new LinqDataSourceUpdateEventArgs(exception);
                    OnUpdating(updateEventArgs);
                    OnException(new DynamicValidatorEventArgs(exception, DynamicDataSourceOperation.Update));
                    exceptionHandled = updateEventArgs.ExceptionHandled;
                    break;
            }

            if (!exceptionHandled) {
                throw exception;
            }
        } 
        protected override int DeleteObject(object oldEntity) {
            LinqDataSourceDeleteEventArgs deleteEventArgs = new LinqDataSourceDeleteEventArgs(oldEntity);
            OnDeleting(deleteEventArgs);
            if (deleteEventArgs.Cancel) {
                return -1;
            }

            LinqDataSourceStatusEventArgs deletedEventArgs = null;
            try {
                DeleteDataObject(Context, EntitySet, deleteEventArgs.OriginalObject);
            }
            catch (Exception e) {
                // allow user to handle dlinq exceptions including OnValidate validation.
                deletedEventArgs = new LinqDataSourceStatusEventArgs(e);
                OnDeleted(deletedEventArgs);
                OnException(new DynamicValidatorEventArgs(e, DynamicDataSourceOperation.Delete));
                if (deletedEventArgs.ExceptionHandled) {
                    return -1;
                }
                throw;
            }
            deletedEventArgs = new LinqDataSourceStatusEventArgs(deleteEventArgs.OriginalObject);
            OnDeleted(deletedEventArgs);

            return 1;
        }