public void Select(ListItem item) { if (item == null) { return; } object actionObj; object mediaItemObj; if (!item.AdditionalProperties.TryGetValue(Consts.KEY_MEDIA_ITEM_ACTION, out actionObj) || !item.AdditionalProperties.TryGetValue(Consts.KEY_MEDIA_ITEM, out mediaItemObj)) { return; } ListItemAction action = actionObj as ListItemAction; item = mediaItemObj as ListItem; if (action == null || item == null) { return; } if (action.ConfirmationMessage(item) != null) { ShowConfirmation(action, item); } else { _ = InvokeAction(action, item); } }
public void EnterModelContext(NavigationContext oldContext, NavigationContext newContext) { _deferredAction = null; _deferredItem = null; IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>(); screenManager.ShowDialog(Consts.DIALOG_MEDIAITEM_ACTION_MENU, (dialogName, dialogInstanceId) => LeaveMediaItemActionState()); }
public void ForEachVisible(ListItemAction action) { Update(); for (int visibleIndex = 0; visibleIndex < _visibleCount && _topmostIndex + visibleIndex < _getTotalCount(); visibleIndex++) { int realIndex = _topmostIndex + visibleIndex; action(realIndex, visibleIndex, realIndex == _index); } }
protected async Task InvokeAction(ListItemAction action, ListItem item) { if (action.Deferred) { // Will be called when context is left _deferredAction = action; _deferredItem = item; return; } await InvokeInternal(action, item); }
private async Task InvokeInternal(ListItemAction action, ListItem item) { try { await action.ProcessAsync(item); } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Error("Error executing MediaItemAction '{0}':", ex, action.GetType()); } }
protected void ShowConfirmation(ListItemAction action, ListItem item) { IDialogManager dialogManager = ServiceRegistration.Get <IDialogManager>(); string header = LocalizationHelper.Translate(Consts.RES_CONFIRM_HEADER); string text = LocalizationHelper.Translate(action.ConfirmationMessage(item)); Guid handle = dialogManager.ShowDialog(header, text, DialogType.YesNoDialog, false, DialogButtonType.No); _dialogCloseWatcher = new DialogCloseWatcher(this, handle, async dialogResult => { if (dialogResult == DialogResult.Yes) { await InvokeAction(action, item); } _dialogCloseWatcher?.Dispose(); }); }
private async Task <bool> InvokeInternal(ListItemAction action, ListItem item) { try { var result = await action.ProcessAsync(item); if (_deferredAction?.DoesChangeWorkflow ?? false) { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.EndBatchUpdate(); } return(result); } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Error("Error executing MediaItemAction '{0}':", ex, action.GetType()); return(false); } }
/// <summary> /// Initializes a new instance of the <see cref="ListItemActionEventArgs"/> class. /// </summary> /// <param name="action">The action.</param> /// <param name="items">The items.</param> public ListItemActionEventArgs(ListItemAction action, ICollection items) { m_items = items; m_action = action; }
/// <summary> /// Initializes a new instance of the <see cref="ListItemActionEventArgs"/> class. /// </summary> /// <param name="action">The action.</param> /// <param name="items">The items.</param> public ListItemActionEventArgs(ListItemAction action, ICollection items) { m_items = items; m_action = action; }
public void HandleListItemEventException(Exception exception, SPEventPropertiesBase spItemEventProperties, ListItemAction listItemAction, string message) { try { var logger = GetLogger(exception); spItemEventProperties.Cancel = (ListItemAction.Cancel == listItemAction); spItemEventProperties.ErrorMessage = message; logger.LogToOperations(exception, defaultEventID, EventLogEntryType.Error, null); } catch (ExceptionHandlingException) { throw; } catch (Exception handlingException) { ThrowExceptionHandlingException(handlingException, exception); } }
/// <summary> /// Handle an exception in a listItemEvent. This will set the Cancel property of the <paramref name="spItemEventProperties"/> /// to true if the <paramref name="listItemAction"/> equals <see cref="ListItemAction.Cancel"/>, set the error message on /// the <paramref name="spItemEventProperties"/> and log the exception into the <see cref="ILogger"/> that's registered /// with the <see cref="SharePointServiceLocator"/>. /// </summary> /// <param name="exception">The exception to handle.</param> /// <param name="spItemEventProperties">The ItemEventProperties that will be updated.</param> /// <param name="listItemAction">Determines if the action should be canceled.</param> public void HandleListItemEventException(Exception exception, SPEventPropertiesBase spItemEventProperties, ListItemAction listItemAction) { this.HandleListItemEventException(exception, spItemEventProperties, listItemAction, exception.Message); }
public ListItemActionData(ListItemAction action, int index) { this.action = action; this.index = index; }