Beispiel #1
0
        public RespPoInfo(IDbName _database, int scheduleId, int originalPoId, int componentId)
        {
            try
            {
                ScheduleQuery  scheduleQuery  = new ScheduleQuery(_database);
                SequenceQuery  sequenceQuery  = new SequenceQuery(_database);
                BeamCutQuery   beamCutQuery   = new BeamCutQuery(_database);
                SequenceQuery  SequenceQuery  = new SequenceQuery(_database);
                ComponentQuery componentQuery = new ComponentQuery(_database);

                var schedule = scheduleQuery.GetSchedule(scheduleId);

                var originalPo = SequenceQuery.GetOriginalPo(originalPoId);

                var shoeComponent = componentQuery.GetShoeComponent(componentId);

                if (schedule == null)
                {
                    if (originalPo == null)
                    {
                        Exception = new RespException(true, "Can not find schedule", EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
                        return;
                    }

                    schedule = scheduleQuery.GetSchedule(originalPo);

                    if (schedule == null)
                    {
                        Exception = new RespException(true, "Can not find schedule", EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
                        return;
                    }
                }

                if (shoeComponent == null)
                {
                    Exception = new RespException(true, "Can not find component", EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
                    return;
                }

                PoInfo = new PoInfo(_database, schedule);

                if (originalPo == null)
                {
                    Exception = new RespException(true, "Empty sequence file", EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
                    return;
                }

                var clonePo = beamCutQuery.FindClonePo(originalPo.id, componentId);

                if (clonePo != null)
                {
                    ClonePoId = clonePo.id;

                    SeqList = new List <SeqInfo>();
                    foreach (var item in clonePo.BeamCutSeqs)
                    {
                        SeqList.Add(new SeqInfo
                        {
                            id         = item.id,
                            CuttingQty = ShareFuncs.GetInt(item.CutQty),
                            SeqNo      = ShareFuncs.GetInt(item.SequenceNo),
                            SeqQty     = ShareFuncs.GetInt(item.SequenceQty),
                            Finish     = item.Finish == true ? true : false,
                        });
                    }
                }
                else
                {
                    var bClonePo = beamCutQuery.CloneOriginalPo(originalPo, shoeComponent);

                    if (bClonePo == null)
                    {
                        Exception = new RespException(true, "An error occured while requesting po information", EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
                        return;
                    }

                    ClonePoId = bClonePo.id;

                    SeqList = new List <SeqInfo>();
                    foreach (var item in bClonePo.BeamCutSeqs)
                    {
                        SeqList.Add(new SeqInfo
                        {
                            id         = item.id,
                            CuttingQty = ShareFuncs.GetInt(item.CutQty),
                            SeqNo      = ShareFuncs.GetInt(item.SequenceNo),
                            SeqQty     = ShareFuncs.GetInt(item.SequenceQty),
                            Finish     = item.Finish == true ? true : false,
                        });
                    }
                }

                Exception = new RespException(false, "Get Poinfo: OK", EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
            }
            catch (Exception e)
            {
                Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_GET_PO_INFO);
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            IDbName       database      = new RealDb();
            SequenceQuery sequenceQuery = new SequenceQuery(database);
            ScheduleQuery ScheduleQuery = new ScheduleQuery(database);

            var po       = sequenceQuery.GetOriginalPo(3987);
            var schedule = ScheduleQuery.GetSchedule(po);


            //IDbName database = new FakeDb();
            while (true)
            {
                string s = Console.ReadLine().ToLower();
                if (s.Contains("update-database"))
                {
                    SERVER_INITIALIZE.DbSeed DB = new SERVER_INITIALIZE.DbSeed(database);
                    DB.Runing();
                }

                if (s.Contains("update-schedule"))
                {
                    Console.WriteLine("Start checking...");

                    AutoScheule AutoSchedule = new AutoScheule(database);
                    AutoSchedule.Update();

                    Console.WriteLine("Stop checking...");
                }

                if (s.Contains("get-schedule"))
                {
                    ScheduleQuery scheduleQuery = new ScheduleQuery(database);
                    var           schedules     = scheduleQuery.GetSchedules("012").Take(5);
                    foreach (var item in schedules)
                    {
                        Console.WriteLine($"Id:{item.id}, Number: {item.PoNumber}");
                    }

                    Console.WriteLine("Please select scheule to clone");
                    string num        = Console.ReadLine();
                    int    scheduleId = 0;
                    int.TryParse(num, out scheduleId);

                    BeamCutQuery beamCutQuery = new BeamCutQuery(database);
                    var          results      = beamCutQuery.CloneOriginalPo(scheduleId);

                    if (results != null)
                    {
                        foreach (var item in results)
                        {
                            Console.WriteLine($"Original Id: {item.OriginalPo_Id}, Comp Id: {item.Component_Id}");
                            foreach (var seq in item.BeamCutSeqs)
                            {
                                Console.WriteLine($"Seq Id: {seq.id}, Seq No: {seq.SequenceNo}, Seq Qty: {seq.SequenceQty}");
                                foreach (var size in seq.BeamCutSizes)
                                {
                                    Console.WriteLine($"Size Id: {size.SizeId},Beam Po Id: {size.BeamCutPo_Id}, Beam Seq Id: {size.BeamCutSeq_Id}");
                                }
                            }
                        }
                    }
                }

                if (s.Contains("request-schedule"))
                {
                    var schedules = new RespSchedule(database, "L3", 12, 0);
                    Console.WriteLine(JsonConvert.SerializeObject(schedules));
                }
                if (s.Contains("request-poinfo"))
                {
                    //var schedules = new EKB_WEBSERVER.API.RuntimeModels.RespPoInfo(database,  2541 ,341);
                }

                if (s.Contains("request-size"))
                {
                    var sizes = new RespSize(database, 3, 9, 341);
                    Console.WriteLine(JsonConvert.SerializeObject(sizes));
                }

                if (s.Contains("request-lastcut"))
                {
                    //Console.WriteLine(JsonConvert.SerializeObject(new BLastCut(database, 4)));
                }

                if (s.Contains("info"))
                {
                    //var sizes = new EKB_WEBSERVER.API.RuntimeModels.RespPoInfo(database, 2540, 322);
                    //Console.WriteLine(JsonConvert.SerializeObject(sizes));
                }

                if (s.Contains("cuttime"))
                {
                    var temp = new BDeviceCutTime(database, 1, 6);
                }
            }
        }