public void DeletesAndRestoresTheFileCorrectly() { const string fileToDelete = @"C:\Some File.png"; var fsMock = new Mock <IFileSystem>(); var recycleBinMock = new Mock <IRecycleBin>(); var fileRestorerMock = new Mock <IDisposable>(); fsMock.Setup(fs => fs.FileExists(fileToDelete)).Returns(true).Verifiable(); fileRestorerMock.Setup(fr => fr.Dispose()).Verifiable(); recycleBinMock.Setup(recycleBin => recycleBin.Send(fileToDelete, false)).Returns(fileRestorerMock.Object) .Verifiable(); var deleteAction = new DeleteAction(fileToDelete, fsMock.Object, recycleBinMock.Object); fsMock.Verify(fs => fs.FileExists(fileToDelete)); deleteAction.Act(); recycleBinMock.Verify(recycleBin => recycleBin.Send(fileToDelete, false)); deleteAction.Revert(); fileRestorerMock.Verify(fr => fr.Dispose()); }
/// <summary> /// 事务操作 /// </summary> public void TranstionDemo() { MultiAction actions = new MultiAction(); for (int i = 0; i < 10; i++) { if (i % 4 == 0) { DeleteAction delete = new DeleteAction(Entity); delete.Cast <cms_user>().Where(u => u.username == "wangjun"); actions.AddAction(delete); } if (i % 4 == 1) { UpdateAction update = new UpdateAction(Entity); update.Cast <cms_user>() .Where(u => u.username == "wangjun") .UnCast() .SqlKeyValue(cms_user.Columns.password, "1234567"); actions.AddAction(update); } } try { actions.Commit(); } catch (Exception) { actions.Rollback(); } }
/// <summary> /// Removes an author from the authors list, as well as from the respective books list. /// </summary> /// <param name="authorToRemove">The author to remove</param> public void RemoveAuthor(Author authorToRemove) { IUpdateAction removeBooksWithAuthorAction = new DummyAction(); authors.Remove(authorToRemove); if (booksWithAuthor.ContainsKey(authorToRemove) == true) { removeBooksWithAuthorAction = new DeleteAction(booksWithAuthor[authorToRemove]); foreach (Book currentBook in booksWithAuthor[authorToRemove]) { currentBook.Authors.Remove(authorToRemove); } booksWithAuthor.Remove(authorToRemove); } try { IUpdateAction removeAuthorAction = new DeleteAction(authorToRemove); DatabaseManager.Instance.PerformDataUpdate(removeBooksWithAuthorAction, removeAuthorAction); } catch (DatabaseException ex) { throw new BookEntitiesException(ex.Message, ex); } }
/// <summary> /// Removes a publishing house from the publishing houses list, as well as /// from the respective books list. /// </summary> /// <param name="publishingHouseToRemove">The publishing house to remove</param> public void RemovePublishingHouse(PublishingHouse publishingHouseToRemove) { IUpdateAction removeBooksWithPublishingHouseAction = new DummyAction(); publishingHouses.Remove(publishingHouseToRemove); if (booksWithPublishingHouse.ContainsKey(publishingHouseToRemove) == true) { removeBooksWithPublishingHouseAction = new DeleteAction( booksWithPublishingHouse[publishingHouseToRemove]); foreach (Book currentBook in booksWithPublishingHouse[publishingHouseToRemove]) { currentBook.PublishingHouse = null; } booksWithPublishingHouse.Remove(publishingHouseToRemove); } try { IUpdateAction removePublishingHouseAction = new DeleteAction(publishingHouseToRemove); DatabaseManager.Instance.PerformDataUpdate(removeBooksWithPublishingHouseAction, removePublishingHouseAction); } catch (DatabaseException ex) { throw new BookEntitiesException(ex.Message, ex); } }
public void OnAction() { DeleteAction action = ScriptableObject.CreateInstance <DeleteAction>(); action.init(LegacyEditorData.instance.currentAction); LegacyEditorData.instance.DoAction(action); }
/// <summary> /// Removes a year of publishing from the years of publishing list, as well as /// from the respective books list. /// </summary> /// <param name="yearOfPublishingToRemove">The year of publishing to remove</param> public void RemoveYearOfPublishing(YearOfPublishing yearOfPublishingToRemove) { IUpdateAction removeBooksWithYearOfPublishingAction = new DummyAction(); yearsOfPublishing.Remove(yearOfPublishingToRemove); if (booksWithYearOfPublishing.ContainsKey(yearOfPublishingToRemove) == true) { removeBooksWithYearOfPublishingAction = new DeleteAction( booksWithYearOfPublishing[yearOfPublishingToRemove]); foreach (Book currentBook in booksWithYearOfPublishing[yearOfPublishingToRemove]) { currentBook.YearOfPublishing = null; } booksWithYearOfPublishing.Remove(yearOfPublishingToRemove); } try { IUpdateAction removeYearOfPublishingAction = new DeleteAction(yearOfPublishingToRemove); DatabaseManager.Instance.PerformDataUpdate(removeBooksWithYearOfPublishingAction, removeYearOfPublishingAction); } catch (DatabaseException ex) { throw new BookEntitiesException(ex.Message, ex); } }
/// <summary> /// Removes a tag from the tags list, as well as from the respective books list. /// </summary> /// <param name="tagToRemove">The tag to remove</param> public void RemoveTag(Tag tagToRemove) { IUpdateAction removeBooksWithTagAction = new DummyAction(); tags.Remove(tagToRemove); if (booksWithTag.ContainsKey(tagToRemove) == true) { removeBooksWithTagAction = new DeleteAction(booksWithTag[tagToRemove]); foreach (Book currentBook in booksWithTag[tagToRemove]) { currentBook.Tags.Remove(tagToRemove); } booksWithTag.Remove(tagToRemove); } try { IUpdateAction removeTagAction = new DeleteAction(tagToRemove); DatabaseManager.Instance.PerformDataUpdate(removeBooksWithTagAction, removeTagAction); } catch (DatabaseException ex) { throw new BookEntitiesException(ex.Message, ex); } }
public override void Execute(object parameter) { DeleteAction deleteAction = new DeleteAction(_context.SelectedEntities, _context); deleteAction.Do(); GlobalManagement.Instance.UndoStack.Push(deleteAction); }
public ProductEditorCommandController( // base dependencies IContentDefinitionService contentDefinitionService, IProductService productService, IReadOnlyArticleService articleService, EditorSchemaService editorSchemaService, EditorDataService editorDataService, EditorPartialContentService editorPartialContentService, EditorLocaleService editorLocaleService, // self dependencies IFieldService fieldService, IProductUpdateService productUpdateService, CloneBatchAction cloneBatchAction, DeleteAction deleteAction, PublishAction publishAction) : base(contentDefinitionService, productService, articleService, editorSchemaService, editorDataService, editorPartialContentService, editorLocaleService) { _fieldService = fieldService; _productUpdateService = productUpdateService; _cloneBatchAction = cloneBatchAction; _deleteAction = deleteAction; _publishAction = publishAction; }
public void DeleteKeyword(string ids) { using (DeleteAction action = new DeleteAction(this.Entity)) { action.SqlWhere(SmsContentfilterkeyInfo.Columns.ID, ids, ConditionEnum.And, RelationEnum.In); action.Excute(); } }
public void deleteMt(int mtid) { using (DeleteAction action = new DeleteAction(new SmsBatchWaitInfo())) { action.SqlWhere(SmsBatchWaitInfo.Columns.ID, mtid); action.Excute(); } }
public int DelGroup(int groupId) { using (DeleteAction action = new DeleteAction(this.Entity)) { action.SqlWhere(SmsContactgroupInfo.Columns.ID, groupId); return(action.Excute().ReturnCode); } }
public void ClearKeyword(int EnterpriseID) { using (DeleteAction action = new DeleteAction(this.Entity)) { action.SqlWhere(SmsContentfilterkeyInfo.Columns.EnterpriseID, EnterpriseID); action.Excute(); } }
public void DeleteBlack(string ids) { using (DeleteAction action = new DeleteAction(this.Entity)) { action.SqlWhere(SmsBlackphoneInfo.Columns.ID, ids, ConditionEnum.And, RelationEnum.In); action.Excute(); } }
public void ClearBlack(int EnterpriseID) { using (DeleteAction action = new DeleteAction(this.Entity)) { action.SqlWhere(SmsBlackphoneInfo.Columns.EnterpriseID, EnterpriseID); action.Excute(); } }
private void Update() { // In case the object was disabled while dragging around; // (Undo action 'deleted' the object while the cube was being dragged around) if (currentlySelectedCube != null) { if (!currentlySelectedCube.gameObject.activeInHierarchy) { currentlySelectedCube.DeselectCube(); currentlySelectedCube = null; } } if (Input.GetKeyDown(DRAG_KEY)) { // Cant select another cube if one is currently selected. if (currentlySelectedCube == null) { HandlePlayerSelectingCube(); } } if (Input.GetKeyUp(DRAG_KEY) && currentlySelectedCube != null) { MoveAction moveAction = new MoveAction(currentlySelectedCube.gameObject, startDragPosition, currentlySelectedCube.transform.position); UserActionCache.Instance.AddActionPerformed(moveAction); currentlySelectedCube.DeselectCube(); currentlySelectedCube = null; } if (currentlySelectedCube != null) { MoveCurrentlySelectedCubeByCursorMovement(); if (Input.GetKeyDown(DELETE_KEY)) { DeleteAction deleteAction = new DeleteAction(currentlySelectedCube.gameObject); UserActionCache.Instance.AddActionPerformed(deleteAction); currentlySelectedCube.DeselectCube(); currentlySelectedCube.gameObject.SetActive(false); currentlySelectedCube = null; } } if (Input.GetKeyDown(UNDO_KEY)) { UserActionCache.Instance.UndoLastAction(); } if (Input.GetKeyDown(REDO_KEY)) { UserActionCache.Instance.RedoLastUndoneAction(); } }
public Table(CreateAction create, ReadAction read, UpdateAction update, DeleteAction delete, string name) { this.CreateAction = create; this.ReadAction = read; this.UpdateAction = update; this.DeleteAction = delete; this.Name = name; this.Refresh(); }
private void ObjectOnDelete(IObjectContainer container) { IUpdateAction deleteDiscEntryAction = new DeleteAction(discEntry); IUpdateAction deleteAuthorsAction = new DeleteAction(authors); IUpdateAction deleteTagsAction = new DeleteAction(tags); DatabaseManager.Instance.PerformDataUpdate(deleteDiscEntryAction, deleteAuthorsAction, deleteTagsAction); }
/// <summary> /// 按钮点击事件 /// </summary> /// <param name="obj"></param> private void ButtonClickFunc(object obj) { string buttonName = obj.ToString(); if (buttonName == "DeleteItem") { if (DeleteAction != null) { DeleteAction.Invoke(); } } }
public ProductUpdateService( IProductService productService, IArticleService articleService, IFieldService fieldService, DeleteAction deleteAction, Func <ITransaction> createTransaction) { _productService = productService; _articleService = articleService; _fieldService = new CachedFieldService(fieldService); _createTransaction = createTransaction; _deleteAction = deleteAction; }
public void Delete(DeleteAction delete) { if (null == delete) { throw new ArgumentNullException("delete"); } if (Guid.Empty == delete.Identifier) { throw new ArgumentException("Identifier"); } var userId = User.Identifier(); this.borrow.Delete(delete, userId); }
private void DeleteIntenal <TEntity>(TEntity entity) where TEntity : class { this._metadataStore.AddEntity(typeof(TEntity)); var tableInfo = this._metadataStore.GetTableInfo <TEntity>(); var deleteAction = new DeleteAction <TEntity>(this._metadataStore, entity, this._connection, this._dialect, this._environment); Action proceed = () => deleteAction.Delete(entity); var invocation = new DataInvocation(this, this._metadataStore, entity, proceed); _interceptorPipeline.ExecuteOnDelete(invocation); this._sessionCache.Remove(entity, tableInfo.GetPrimaryKeyValue(entity)); }
public DeleteActionLink(IPortalContext portalContext, int languageCode, DeleteAction action, bool enabled = true, UrlBuilder url = null, string portalName = null) : base( portalContext, languageCode, action, LinkActionType.Delete, enabled, url, portalName, DefaultButtonLabel, DefaultButtonTooltip) { if (string.IsNullOrWhiteSpace(Confirmation)) { Confirmation = DefaultConfirmation; } Modal = new ViewDeleteModal(); if (url == null) { URL = EntityListFunctions.BuildControllerActionUrl("Delete", "EntityGrid", new { area = "Portal", __portalScopeId__ = portalContext.Website.Id }); } }
public DeleteActionLink(IPortalContext portalContext, FormActionMetadata formMetadata, int languageCode, DeleteAction action, bool enabled = true, UrlBuilder url = null, string portalName = null) : this(portalContext, languageCode, action, enabled, url, portalName) { if (formMetadata.DeleteDialog == null) { return; } Modal.CloseButtonCssClass = formMetadata.DeleteDialog.CloseButtonCssClass; Modal.CloseButtonText = formMetadata.DeleteDialog.CloseButtonText.GetLocalizedString(languageCode); Modal.CssClass = formMetadata.DeleteDialog.CssClass; Modal.DismissButtonSrText = formMetadata.DeleteDialog.DismissButtonSrText.GetLocalizedString(languageCode); Modal.PrimaryButtonCssClass = formMetadata.DeleteDialog.PrimaryButtonCssClass; Modal.PrimaryButtonText = formMetadata.DeleteDialog.PrimaryButtonText.GetLocalizedString(languageCode); Modal.Size = formMetadata.DeleteDialog.Size; Modal.Title = formMetadata.DeleteDialog.Title.GetLocalizedString(languageCode); Modal.TitleCssClass = formMetadata.DeleteDialog.TitleCssClass; }
public void ImportList(List <SmsContactInfo> contacts, int groupid) { if (contacts.Count > 0) { using (TradAction action = new TradAction()) { List <string> sqls = new List <string>(); foreach (var filterkey in contacts) { InserAction inserAction = new InserAction(filterkey); sqls.Add(inserAction.CreateSql(OperateEnum.Insert)); } action.ExecuteSqlTran(sqls); } string ids = ""; using (SelectAction action = new SelectAction(this.Entity)) { action.SqlClomns = " min(id) as id "; action.SqlGroupBy("Mobile,EnterpriseID,GroupID HAVING COUNT(1)>1"); action.SqlWhere("EnterpriseID", contacts[0].EnterpriseId); if (groupid > 0) { action.SqlWhere("GroupID", groupid); } action.SqlPageParms(-1); List <SmsBlackphoneInfo> idlist = action.QueryPage <SmsBlackphoneInfo>(0); foreach (SmsBlackphoneInfo info in idlist) { ids += info.ID + ","; } } using (DeleteAction taction = new DeleteAction(this.Entity)) { taction.SqlWhere(SmsBlackphoneInfo.Columns.ID, ids.TrimEnd(','), ConditionEnum.And, RelationEnum.In); taction.SqlWhere(SmsBlackphoneInfo.Columns.EnterpriseID, contacts[0].EnterpriseId); taction.Excute(); } } }
/// <summary> /// Removes the structure from the database. /// </summary> private void ObjectOnDelete(IObjectContainer container) { try { for (int i = 0; i < byteBuffers.Count; i++) { IUpdateAction activateIndividualBufferAction = new ActivateAction(byteBuffers[i], 1); IUpdateAction deleteIndividualBufferAction = new DeleteAction(byteBuffers[i]); IUpdateAction clearIndividualBufferAction = new DeactivateAction(byteBuffers[i], 1); DatabaseManager.Instance.PerformDataUpdate(activateIndividualBufferAction, deleteIndividualBufferAction, clearIndividualBufferAction); } IUpdateAction deleteListOfBuffers = new DeleteAction(byteBuffers); IUpdateAction clearListOfBuffers = new DeactivateAction(byteBuffers, 1); DatabaseManager.Instance.PerformDataUpdate(deleteListOfBuffers, clearListOfBuffers); } catch (DatabaseException) { } }
internal void Merge(FieldInfo merge) { this.DataType = merge.DataType; if (merge.Description != null) { this.Description = (this.Description != null ? this.Description + "\n" : "") + merge.Description; } if (merge.Size != -1) { this.Size = merge.Size; } if (merge.Precision != -1) { this.Precision = merge.Size; } if (merge.References != null) { this.References = merge.References; } if (merge.PrecommitValue != null) { this.PrecommitValue = merge.PrecommitValue; } this.IsPrimaryKey = merge.IsPrimaryKey; this.IsNullable = merge.IsNullable; this.ReadOnly = merge.ReadOnly; this.ForceTrigger = merge.ForceTrigger; this.DeleteAction = merge.DeleteAction; this.IsLabel = merge.IsLabel; this.PrefetchLevel = merge.PrefetchLevel; this.FindMethod = merge.FindMethod; this.FindListMethod = merge.FindListMethod; if (merge.dbcolumn != null) { this.DBColumnName = merge.dbcolumn; } }
/// <summary> /// Removes a book from the list of books, as well as from the database. /// </summary> /// <param name="bookToRemove">The book to be removed</param> public void RemoveBook(Book bookToRemove) { books.Remove(bookToRemove); foreach (Author currentAuthor in booksWithAuthor.Keys) { booksWithAuthor[currentAuthor].Remove(bookToRemove); } foreach (Tag currentTag in booksWithTag.Keys) { booksWithTag[currentTag].Remove(bookToRemove); } foreach (PublishingHouse currentPublishingHouse in booksWithPublishingHouse.Keys) { booksWithPublishingHouse[currentPublishingHouse].Remove(bookToRemove); } foreach (YearOfPublishing currentYearOfPublishing in booksWithYearOfPublishing.Keys) { booksWithYearOfPublishing[currentYearOfPublishing].Remove(bookToRemove); } try { IUpdateAction removeBook = new DeleteAction(bookToRemove); DatabaseManager.Instance.PerformDataUpdate(removeBook); } catch (DatabaseException ex) { throw new BookEntitiesException(ex.Message, ex); } UpdateDatabase(); }
/// <summary> /// Metoda usuwająca element z bazy /// </summary> protected virtual async void DeleteCommandExecute() { if (!DialogService.ShowQuestion_BoolResult("Czy usunąć wskazaną pozycję?")) { return; } if (DeleteAction is null) { var entityInDB = await Repository.GetByIdAsync(GetElementId(SelectedVMEntity)); if (entityInDB is null) { ListOfVMEntities.Remove(SelectedVMEntity); } else { Repository.Remove(SelectedVMEntity); ListOfVMEntities.Remove(SelectedVMEntity); } } else { DeleteAction.Invoke(); } await UnitOfWork.SaveAsync(); AfterDeleteAction?.Invoke(); Messenger.Send(SelectedVMEntity); //Messenger.Send(new RefreshListMessage()); //DialogService.ShowInfo_BtnOK("Pozycja została usunięta"); //await LoadAsync(null); }
protected override void WriteSourceDeleteBehavior(BidirectionalAssociation association, List <string> segments) { if (!association.Source.IsDependentType && !association.Target.IsDependentType && (association.TargetRole == EndpointRole.Principal || association.SourceRole == EndpointRole.Principal)) { DeleteAction deleteAction = association.SourceRole == EndpointRole.Principal ? association.SourceDeleteAction : association.TargetDeleteAction; switch (deleteAction) { case DeleteAction.None: segments.Add("OnDelete(DeleteBehavior.NoAction)"); break; case DeleteAction.Cascade: segments.Add("OnDelete(DeleteBehavior.Cascade)"); break; } } }
internal void Merge(FieldInfo merge) { this.DataType = merge.DataType; if (merge.Description != null) this.Description = (this.Description != null ? this.Description + "\n" : "") + merge.Description; if (merge.Size != -1) this.Size = merge.Size; if (merge.Precision != -1) this.Precision = merge.Size; if (merge.References != null) this.References = merge.References; if (merge.PrecommitValue != null) this.PrecommitValue = merge.PrecommitValue; this.IsPrimaryKey = merge.IsPrimaryKey; this.IsNullable = merge.IsNullable; this.ReadOnly = merge.ReadOnly; this.ForceTrigger = merge.ForceTrigger; this.DeleteAction = merge.DeleteAction; this.IsLabel = merge.IsLabel; this.PrefetchLevel = merge.PrefetchLevel; this.FindMethod = merge.FindMethod; this.FindListMethod = merge.FindListMethod; if (merge.dbcolumn != null) this.DBColumnName = merge.dbcolumn; }
private IAutomationSettingsSchema AssertDeleteCommand(bool verifySettings, DeleteAction action) { var command = this.container.AutomationSettings.FirstOrDefault(set => set.Name.Equals(Properties.Resources.ArtifactExtension_DeleteCommandName)); Assert.NotNull(command); var commandSettings = command.GetExtensions<ICommandSettings>().FirstOrDefault(); Assert.NotNull(commandSettings); if (verifySettings) { Assert.Equal(CustomizationState.False, command.IsCustomizable); Assert.True(command.IsSystem); Assert.Equal(commandSettings.TypeId, typeof(DeleteArtifactsCommand).FullName); var deleteProperty = (DeleteAction)TypeDescriptor.GetProperties(commandSettings)[Reflector<DeleteArtifactsCommand>.GetPropertyName(c => c.Action)] .GetValue(commandSettings); Assert.Equal(action, deleteProperty); } return command; }
/// <summary> /// Sets the delete action for this foreign key /// </summary> /// <param name="action">the delete action to set</param> /// <returns>the foreign key with deleteAction added</returns> public ForeignKey WithDeleteAction(DeleteAction action) { this.DeleteAction = action; return this; }