예제 #1
0
        public List <BeamCutPo> CloneOriginalPo(int scheduleId)
        {
            try
            {
                SequenceQuery  sequenceQuery  = new SequenceQuery(database);
                ScheduleQuery  scheduleQuery  = new ScheduleQuery(database);
                ComponentQuery componentQuery = new ComponentQuery(database);

                var schedule = scheduleQuery.GetSchedule(scheduleId);
                if (schedule == null)
                {
                    return(null);
                }

                var components = componentQuery.GetModelComponents(schedule.Model).Where(i => i.CuttingType.id == 2).ToList();

                if (components == null)
                {
                    return(null);
                }

                var originalPo = sequenceQuery.GetOriginalPo(schedule);

                if (originalPo == null)
                {
                    return(null);
                }

                // make return value
                List <BeamCutPo> PoList = new List <BeamCutPo>();

                foreach (var component in components)
                {
                    if (FindOriginalPo(originalPo.id, component.Id))
                    {
                        Console.WriteLine("Po is already added\r\nContinue.");
                        continue;
                    }
                    // New BeamCutPo
                    var beamCutPo = AddNewBeamCutPo(originalPo.id, component.Id);

                    if (beamCutPo == null)
                    {
                        continue;
                    }

                    // make return value
                    beamCutPo.BeamCutSeqs = new List <BeamCutSeq>();

                    foreach (var seq in originalPo.OriginalPOsequences)
                    {
                        var currentSeq = sequenceQuery.GetOriginalSequence(seq.id);

                        //New BeamCutSeq
                        var beamSeq = AddNewBeamSeq(currentSeq, component.Id, beamCutPo.id);

                        if (beamSeq == null)
                        {
                            continue;
                        }
                        // make return value
                        beamSeq.BeamCutSizes = new List <BeamCutSize>();

                        foreach (var size in currentSeq.OriginalSizes)
                        {
                            var beamSize = AddNewBeamSize(size, beamSeq.id, ShareFuncs.GetInt(beamSeq.SequenceNo), component.Id, beamCutPo.id);
                            if (beamSize == null)
                            {
                                continue;
                            }
                            // make return value
                            beamSeq.BeamCutSizes.Add(beamSize);
                        }
                        // make return value
                        beamCutPo.BeamCutSeqs.Add(beamSeq);
                    }
                    // make return value
                    PoList.Add(beamCutPo);
                }

                return(PoList);
            }
            catch { return(null); }
        }
예제 #2
0
        public BeamCutPo CloneOriginalPo(int scheduleId, int componentId)
        {
            try
            {
                SequenceQuery  sequenceQuery  = new SequenceQuery(database);
                ScheduleQuery  scheduleQuery  = new ScheduleQuery(database);
                ComponentQuery componentQuery = new ComponentQuery(database);

                var schedule = scheduleQuery.GetSchedule(scheduleId);
                if (schedule == null)
                {
                    return(null);
                }

                var originalPo = sequenceQuery.GetOriginalPo(schedule);

                if (originalPo == null)
                {
                    return(null);
                }

                if (FindOriginalPo(originalPo.id, componentId))
                {
                    Console.WriteLine("Po is already added\r\nContinue.");
                    return(null);
                }
                // New BeamCutPo
                var beamCutPo = AddNewBeamCutPo(originalPo.id, componentId);

                if (beamCutPo == null)
                {
                    Console.WriteLine("Can not add new beam cut po");
                    return(null);
                }
                // make return value
                beamCutPo.BeamCutSeqs = new List <BeamCutSeq>();

                foreach (var seq in originalPo.OriginalPOsequences)
                {
                    var currentSeq = sequenceQuery.GetOriginalSequence(seq.id);

                    //New BeamCutSeq
                    var beamSeq = AddNewBeamSeq(currentSeq, componentId, beamCutPo.id);

                    if (beamSeq == null)
                    {
                        continue;
                    }
                    // make return value
                    beamSeq.BeamCutSizes = new List <BeamCutSize>();

                    foreach (var size in currentSeq.OriginalSizes)
                    {
                        var beamSize = AddNewBeamSize(size, beamSeq.id, ShareFuncs.GetInt(beamSeq.SequenceNo), componentId, beamCutPo.id);
                        if (beamSize == null)
                        {
                            continue;
                        }
                        // make return value
                        beamSeq.BeamCutSizes.Add(beamSize);
                    }
                    // make return value
                    beamCutPo.BeamCutSeqs.Add(beamSeq);
                }
                // make return value
                return(beamCutPo);
            }
            catch { return(null); }
        }