tbf/SharedDatabase/Entities/Part.cs

87 lines
2.5 KiB
C#

using System;
using System.Collections.Generic;
namespace SharedDatabase.Entities
{
public class Part
{
public virtual int Id { get; protected set; }
public virtual string Name { get; set; }
public virtual string Description { get; set; }
public virtual sbyte CodeType { get; set; }
public virtual sbyte CodeForm { get; set; }
public virtual CodeLocation CodeLocation { get; set; }
public virtual string DefaultCode { get; set; }
public virtual LifetimeManagement LifetimeManagement { get; set; }
public virtual int StepNumber { get; set; }
public virtual Process Workflow { get; set; }
public virtual Workstep Workstep { get; set; }
/// <summary>
/// Create a copy of a part (1) belongig to another process, (2) not assigned to any workstep yet.
/// </summary>
/// <param name="process">Process owning the cloned part</param>
/// <returns>Cloned part</returns>
public virtual Part Clone(Process owningWorkflow)
{
Part rslt = new Part();
rslt.Name = Name;
rslt.Description = Description;
rslt.CodeType = CodeType;
rslt.CodeForm = CodeForm;
rslt.CodeLocation = CodeLocation;
rslt.DefaultCode = DefaultCode;
rslt.LifetimeManagement = LifetimeManagement;
rslt.StepNumber = StepNumber;
rslt.Workflow = owningWorkflow;
rslt.Workstep = null;
return rslt;
}
public Part()
{
Name = string.Empty;
Description = string.Empty;
}
public Part(string name, Process workflow, string description)
{
Name = name;
Workflow = workflow;
Description = description;
Workstep = null;
}
/// <summary>
/// Constructor used when the part is added to a process
/// </summary>
/// <param name="name"></param>
/// <param name="codeType"></param>
/// <param name="codeForm"></param>
/// <param name="workflow"></param>
public Part(string name, Process workflow, CodeType codeType, CodeForm codeForm, CodeLocation codeLocation)
{
Name = name;
Description = string.Empty;
CodeType = (sbyte)codeType;
CodeForm = (sbyte)codeForm;
CodeLocation = codeLocation;
DefaultCode = string.Empty;
StepNumber = 0;
Workflow = workflow;
Workstep = null;
}
public override string ToString()
{
return string.Format("{0} ({1}: {2})", Name, StepNumber, Description);
}
}
}