public CurveFamily Add(CurveFamily parent) { CurveFamily detail = new CurveFamily(); detail.Default(Context.UserName); detail.Approve(Context.UserName); if (Context.CurveFamilies.Local.Any()) { detail.CurveFamilyID = Context.CurveFamilies.Local.Max(x => x.CurveFamilyID) + 1; } else { detail.CurveFamilyID = 1; } Context.CurveFamilies.Add(detail); if (parent != null) { detail.CurveFamilyParent = parent; detail.CurveFamilyParentID = parent.CurveFamilyID; } detail.Name = "Curve Family Name"; return detail; }
internal static void AddFamilies(ScenarioGeneratorModel context) { DateTime now = context.AsOfDate; var parent = new CurveFamily() { Name = "LBG", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true }; context.CurveFamilies.Add(parent); var child = new CurveFamily() { Name = "SWAPS", StartTime = now.AddDays(-100), EndTime = DateTime.MaxValue, CreatedAt = now, CreatedBy = "A", ApprovedAt = now.AddDays(-100), ApprovedBy = "B", Latest = true }; child.CurveFamilyParent = parent; context.CurveFamilies.Add(child); context.SaveChanges(); }
public static CurveFamily[] ConvertCurveFamilies(CurveFamilyF[] oldFamilies, PhysicalQuantity xPhysicalQuantity, PhysicalQuantity yPhysicalQuantity) { // Note: this also converts the values from model's default Unit System to the current Unit System CurveFamily[] newFamilies = new CurveFamily[oldFamilies.Length]; int k = 0; foreach (CurveFamilyF curveFamily in oldFamilies) { CurveFamily cf = new CurveFamily(); cf.Name = curveFamily.Name; PhysicalQuantity pq = curveFamily.PhysicalQuantity; cf.Unit = UnitSystemService.GetInstance().GetUnitAsString(pq); Curve[] newCurves = new Curve[curveFamily.Curves.Length]; int j = 0; foreach (CurveF curve in curveFamily.Curves) { Curve c = new Curve(); c.Name = curve.Name; c.Unit = UnitSystemService.GetInstance().GetUnitAsString(pq); c.Value = (float)UnitSystemService.GetInstance().ConvertFromSIValue(pq, curve.Value); PointF[] newData = new PointF[curve.Data.Length]; int i = 0; foreach (PointF point in curve.Data) { float newX = (float)UnitSystemService.GetInstance().ConvertFromSIValue(xPhysicalQuantity, point.X); float newY = (float)UnitSystemService.GetInstance().ConvertFromSIValue(yPhysicalQuantity, point.Y); PointF p = new PointF(newX, newY); newData[i++] = p; } c.Data = newData; // the new curve is built, so add it to the array of curves newCurves[j++] = c; } cf.Curves = newCurves; // the new family is built, so add it to the array of families newFamilies[k++] = cf; } return(newFamilies); }
public bool Move(CurveFamily curve, CurveFamily newParent) { CurveFamily checkParent = newParent; //check for circular reference while ((checkParent != null) && (checkParent != curve.CurveFamilyParent)) { checkParent = checkParent.CurveFamilyParent; } //circular reference check failed - abort movement if (checkParent == curve) return false; curve.CurveFamilyParent = newParent; curve.CurveFamilyParentID = newParent.CurveFamilyID; return true; }
public bool Move(CurveFamily curve, CurveFamily newParent) { CurveFamily checkParent = newParent; //check for circular reference while ((checkParent != null) && (checkParent != curve.CurveFamilyParent)) { checkParent = checkParent.CurveFamilyParent; } //circular reference check failed - abort movement if (checkParent == curve) return false; curve.CurveFamilyParent = newParent; curve.CurveFamilyParentID = newParent.CurveFamilyID; //if (curve.Status == EntityStatus.Approved) // curve.Default(Context.UserName); return true; }