示例#1
0
        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;
        }
示例#2
0
文件: CurveBS.cs 项目: Juliusz/Test
        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();
        }
示例#3
0
        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);
        }
示例#4
0
        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;
        }
示例#5
0
        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;
        }