/// <summary> /// Клонирует значения параметров /// </summary> /// <param name="origin">Оригинальный экземпляр</param> /// <param name="cloneContext">Контекст клонирования</param> protected virtual void CloneParameters(BizProcess origin, BpCloneContext cloneContext) { if (!cloneContext.IsStatus()) { lock (origin.Parameters) { foreach (KeyValuePair <string, object> pair in origin.Parameters) { this.Parameters.Add(pair.Key, pair.Value); } } } }
/// <summary> /// Конструктор. Используется только при клонировании /// </summary> /// <param name="origin">Оригинальный экземпляр</param> /// <param name="cloneContext">Контекст клонирования</param> protected BizProcess(BizProcess origin, BpCloneContext cloneContext) { this.CompleteExecution = origin.CompleteExecution; this.StartedOnServer = origin.StartedOnServer; this.Id = (cloneContext.IsPrototype() ? Guid.NewGuid() : origin.Id); this.Stage = origin.Stage; this._status = origin._status; this.StartTime = origin.StartTime; this.FinishTime = origin.FinishTime; if (!cloneContext.IsAnyPeristence()) { this.Progress = origin.Progress; } this.ChildProcesses = new List <BizProcess>(); if (!cloneContext.IsShortPeristence()) { lock (origin.ChildProcesses) { foreach (BizProcess childProcess in origin.ChildProcesses) { this.AddChild(childProcess.Clone(cloneContext)); } } } if (!cloneContext.IsAnyPeristence() || origin.ParentProcess == null) { this._contextData = origin._contextData; } this.Parameters = new Dictionary <string, object>(); this.CloneParameters(origin, cloneContext); if (!cloneContext.IsStatus()) { this.Result = origin.Result.Clone(cloneContext); } this.PopulateExceptions = origin.PopulateExceptions; this.TrackMode = origin.TrackMode; this.Node = origin.Node; }
/// <summary> /// Клонирует поддерево процессов, начиная с текущего /// </summary> /// <param name="cloneContext">Контекст клонирования</param> /// <returns>Копия процесса</returns> public virtual BizProcess Clone(BpCloneContext cloneContext) { throw new NotImplementedException(); }
/// <summary> /// Клонирует дерево процесса, начиная с корня /// </summary> /// <param name="cloneContext">Контекст клонирования</param> /// <returns>Копия процесса</returns> public BizProcess CloneWithParents(BpCloneContext cloneContext) { return(this.GetRoot().Clone(cloneContext).GetById(this.Id)); }