/// <summary> /// 执行操作 /// </summary> /// <returns></returns> public virtual bool Execute() { bool result = false; try { var srcObjects = BatchExecutor.GetObjects(this.SourceKeys, this.CardinalityOfSource, this.Errors); var targetObjects = BatchExecutor.GetObjects(this.TargetKeys, this.CardinalityOfDestination, this.Errors); Util.EnsureOperationSafe(); this.ValidateObjects(); result = this.DoExecute(srcObjects, targetObjects); } catch (Exception ex) { result = false; if (this.HandleError(ex) == false) { throw; } } return(result); }
protected void DoTransferProgress(object sender, PostProgressDoPostedDataEventArgs e) { try { string ser = (string)e.Steps[0]; DeserialObject obj = JSONSerializerExecute.Deserialize <DeserialObject>(ser); BatchExecutor executor = null; switch (obj.ActionType) { case TransferActionType.UserCopyToGroup: executor = new CopyUsersToGroupsTransfer(obj.OrgKey, obj.SrcKeys, obj.TargetKeys); break; case TransferActionType.UserCopyToOrg: executor = new CopyUsersToOrgsTransfer(obj.OrgKey, obj.SrcKeys, obj.TargetKeys); break; case TransferActionType.UserMoveToOrg: executor = new MoveUsersToOrgsTransfer(obj.OrgKey, obj.SrcKeys, obj.TargetKeys); break; case TransferActionType.GroupMoveToOrg: case TransferActionType.OrgTransfer: case TransferActionType.MixedToOrg: executor = new MoveObjectsToOrgTransfer(obj.OrgKey, obj.SrcKeys, obj.TargetKeys); break; default: throw new InvalidOperationException("没有指定如何操作"); } executor.Execute(); } catch (Exception ex) { ProcessProgress.Current.Output.WriteLine(ex.ToString()); } e.Result.CloseWindow = false; e.Result.ProcessLog = ProcessProgress.Current.GetDefaultOutput(); }
public BatchExecutor(IEnumerable src, IEnumerable target) : this(BatchExecutor.ToArray(src), BatchExecutor.ToArray(target)) { }