예제 #1
0
        /// <summary>
        /// Десериализует процесс
        /// </summary>
        /// <param name="br">Читатель из потока</param>
        protected virtual void DeserializeInternal(CustomBinaryReader br)
        {
            this.CompleteExecution = br.ReadBoolean();
            this.Id = br.ReadGuid();
            this.PopulateExceptions = br.ReadBoolean();
            this.Stage           = (BpStage)br.ReadByte();
            this.StartedOnServer = br.ReadNullableBoolean();
            this._status         = (BpStatus)br.ReadByte();
            this.TrackMode       = (BpTrackMode)br.ReadByte();
            this.StartTime       = br.ReadDateTime();
            this.FinishTime      = br.ReadDateTime();

            if (br.ReadBoolean())
            {
                this._contextData = new ContextData();
                this._contextData.DeserializeInternal(br);
            }

            int           count      = br.Read7BitEncodedInt();
            List <string> paramNames = new List <string>(count);

            this.Parameters = new Dictionary <string, object>(count);
            for (int i = 0; i < count; i++)
            {
                paramNames.Add(br.ReadString());
            }
            for (int i = 0; i < count; i++)
            {
                this.Parameters.Add(paramNames[i], br.ReadObject());
            }

            //this.Progress = (BpProgressData)br.ReadObject();
            //this.Result = (BpResultData)br.ReadObject();

            if (br.ReadBoolean())
            {
                this.Progress = this.GetProgressInstance();
                ((ICustomSerializable)this.Progress).DeserializeInternal(br);
            }

            if (br.ReadBoolean())
            {
                this.Result = this.GetResultInstance();
                ((ICustomSerializable)this.Result).DeserializeInternal(br);
            }

            count = br.Read7BitEncodedInt();
            this.ChildProcesses = new List <BizProcess>(count);
            for (int i = 0; i < count; i++)
            {
                BizProcess process = this.ReadChildProcess(br);
                this.AddChild(process);
            }

            BpRunningNode.Type brnType = (BpRunningNode.Type)br.ReadByte();
            string             brnName = br.ReadString();

            this.Node = new BpRunningNode(brnType, brnName);
        }
예제 #2
0
 /// <summary>
 /// Добавляет дочерний процесс
 /// </summary>
 /// <param name="child">Дочерний процесс</param>
 /// <returns>Дочерний процесс</returns>
 public void AddChild(BizProcess child)
 {
     lock (this.ChildProcesses)
     {
         child.ParentProcess = this;
         this.ChildProcesses.Add(child);
     }
 }
예제 #3
0
 /// <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);
             }
         }
     }
 }
예제 #4
0
 /// <summary/>
 protected void WriteChildProcess(CustomBinaryWriter bw, BizProcess childProcess)
 {
     if (BizProcessHolder.Instance.GetType(childProcess.ProcessTypeId) != null)
     {
         bw.Write(true);
         bw.Write(childProcess.ProcessTypeId);
         childProcess.SerializeInternal(bw);
     }
     else
     {
         bw.Write(false);
         bw.WriteObject(childProcess);
     }
 }
예제 #5
0
        /// <summary/>
        protected BizProcess ReadChildProcess(CustomBinaryReader br)
        {
            bool optimized = br.ReadBoolean();

            if (optimized)
            {
                string     typeId       = br.ReadString();
                Type       type         = BizProcessHolder.Instance.GetType(typeId);
                BizProcess childProcess = (BizProcess)Activator.CreateInstance(type, true);
                childProcess.DeserializeInternal(br);
                return(childProcess);
            }
            else
            {
                return(br.ReadObject <BizProcess>());
            }
        }
예제 #6
0
        /// <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;
        }
예제 #7
0
        /// <summary>
        /// Возвращает из поддерева процесс по его идентификатору
        /// </summary>
        /// <param name="process">Процесс, среди подпроцессов которого осуществляется поиск</param>
        /// <param name="id">Идентификатор процесса</param>
        /// <returns>Процесс</returns>
        private static BizProcess GetByIdInternal(BizProcess process, Guid id)
        {
            if (process.Id == id)
            {
                return(process);
            }

            lock (process.ChildProcesses)
            {
                foreach (BizProcess child in process.ChildProcesses)
                {
                    BizProcess foundProcess = GetByIdInternal(child, id);
                    if (foundProcess != null)
                    {
                        return(foundProcess);
                    }
                }
            }

            return(null);
        }