101 lines
3.2 KiB
C#
101 lines
3.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Common;
|
|
|
|
namespace SharedDatabase.Entities
|
|
{
|
|
public class Process
|
|
{
|
|
public virtual int Id { get; protected set; }
|
|
public virtual int ItemNr { get; set; }
|
|
public virtual string Name { get; set; }
|
|
public virtual string Description { get; set; }
|
|
public virtual string CreatedBy { get; set; }
|
|
public virtual DateTime TimeStamp { get; set; }
|
|
public virtual string ApprovedBy { get; set; }
|
|
public virtual DateTime TimeStamp2 { get; set; }
|
|
public virtual string ReleaseNotes { get; set; }
|
|
public virtual ReleaseStatus ReleaseStatus { get; set; }
|
|
public virtual IList<Part> Parts { get; set; }
|
|
public virtual IList<Workstep> Worksteps { get; set; }
|
|
|
|
/// <summary>
|
|
/// Default (private) constructor inicializing lists
|
|
/// </summary>
|
|
protected Process()
|
|
{
|
|
Parts = new List<Part>();
|
|
Worksteps = new List<Workstep>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructor used when this process is created
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
public Process(string name)
|
|
: this()
|
|
{
|
|
Name = name;
|
|
Description = string.Empty;
|
|
ReleaseNotes = string.Empty;
|
|
CreatedBy = "admin";
|
|
TimeStamp = DateTime.Now;
|
|
ApprovedBy = string.Empty;
|
|
TimeStamp2 = DateTime.Now;
|
|
ReleaseStatus = ReleaseStatus.In_preparation;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create a copy of a process with a new name and original 'Created by' user.
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
/// <returns></returns>
|
|
public virtual Process Clone(string name)
|
|
{
|
|
return Clone(name, CreatedBy);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create a copy of a process with a new name.
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
/// <returns></returns>
|
|
public virtual Process Clone(string name, string userName)
|
|
{
|
|
Process rslt = new Process(name);
|
|
rslt.Description = Description;
|
|
rslt.ReleaseNotes = ReleaseNotes;
|
|
rslt.CreatedBy = userName;
|
|
rslt.TimeStamp = DateTime.Now;
|
|
rslt.ApprovedBy = string.Empty;
|
|
rslt.ReleaseStatus = ReleaseStatus.In_preparation;
|
|
|
|
foreach (var part in Parts) rslt.Parts.Add(part.Clone(rslt));
|
|
foreach (var workstep in Worksteps) rslt.Worksteps.Add(workstep.Clone(rslt));
|
|
|
|
return rslt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets a process with a specified name from a list of processes.
|
|
/// </summary>
|
|
/// <param name="processes">List of processes (ReleasedActive processs)</param>
|
|
/// <param name="processName">Process name</param>
|
|
/// <returns>Process or null if not found</returns>
|
|
public static Process GetProcessFromName(IList<Process> processes, string processName)
|
|
{
|
|
foreach (var proc in processes)
|
|
{
|
|
if (proc.Name == processName) return proc;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return string.IsNullOrEmpty(Name) ? string.Empty : ((Id != 0) ? Name : string.Format("{0} ({1})", Name, SharedDatabase.Resources.Strings.unsaved));
|
|
}
|
|
}
|
|
}
|