public cShift XetCa_1(cChkInOut_A CIO, List <cShift> dsCa)
        {
            DateTime t_vao = CIO.Vao.TimeStr;
            DateTime t_raa = CIO.Raa.TimeStr;

            return(dsCa.FirstOrDefault(ca => t_vao >= t_vao.Date.Add(ca.OnTimeInTS) && t_vao <= t_vao.Date.Add(ca.CutInTS) &&
                                       t_raa >= t_vao.Date.Add(ca.OnTimeOutTS) && t_raa <= t_vao.Date.Add(ca.CutOutTS)));
        }
 public void XetCa(List <cChkInOut_A> dsCIO, List <cShift> dsca)
 {
     for (int i = 0; i < dsCIO.Count; i++)
     {
         cChkInOut_A CIO = dsCIO[i];
         cShift      ca  = XetCa_1(CIO, dsca);
         if (ca != null)
         {
             if (ca.Workingday == 2f && ca.OnnDutyTS > ThamSo._20h00)
             {
                 cChk raaca3 = new cChkOut_A()
                 {
                     GioLienQuan = null, MachineNo = 22, Source = "O", TimeStr = CIO.Vao.TimeStr.Date.Add(ca.OnnDutyTS).Add(ThamSo._8gio)
                 };
                 cChk vaoca1 = new cChkInn_A()
                 {
                     GioLienQuan = null, MachineNo = 21, Source = "I", TimeStr = CIO.Vao.TimeStr.Date.Add(ca.OnnDutyTS).Add(ThamSo._8gio1giay)
                 };
                 CIO.Raa = raaca3;
                 i       = i - 1;
                 cChkInOut_A newCIO = new cChkInOut_A()
                 {
                     Vao = vaoca1, Raa = CIO.Raa, HaveINOUT = 1,
                 };
                 dsCIO.Insert(i, newCIO);
             }
             else
             {
                 CIO.ThuocCa = ca;
             }
         }
         else
         {
             ca = new cShift()
             {
                 ShiftID = int.MinValue, ShiftCode = "Ca 8 tiếng"
             };
             TaoCaTuDo(ca, CIO.Vao.TimeStr, ThamSo._8gio, ThamSo._05phut, ThamSo._10phut, ThamSo._30phut, 1f);
             CIO.ThuocCa = ca;
         }
     }
 }
Esempio n. 3
0
        public void XetCa(List <cChkInOut_A> dsCIO, List <cShift> dsca, bool macdinhtinhPC150)
        {
            int i = 0;

            while (i < dsCIO.Count)
            {
                cChkInOut_A CIO = dsCIO[i];
                if (CIO.HaveINOUT < 0)
                {
                    if (CIO.HaveINOUT == -1)
                    {
                        //CIO.kiem
                    }
                    else
                    {
                    }
                    i++;
                    continue;
                }
                cShift ca = KiemtraThuocKhoangHieuCa(CIO, dsca);
                if (ca != null)
                {
                    if (ca.Workingday == 2f && ca.OnnDutyTS > ThamSo._20h00)
                    {
                        List <cChk> gioLQvaoca3 = (CIO.Vao.GioLienQuan != null)
                                                                                                         ? new List <cChk>(CIO.Vao.GioLienQuan)
                                                                                                         : new List <cChk>();
                        List <cChk> gioLQraaca1 = (CIO.Raa.GioLienQuan != null)
                                                                                                        ? new List <cChk>(CIO.Raa.GioLienQuan)
                                                                                                         : new List <cChk>();

                        cChk raaca3 = new cChkOut_A()
                        {
                            GioLienQuan = null, MachineNo = 22, Source = "PC", TimeStr = CIO.Vao.TimeStr.Date.Add(ca.OnnDutyTS).Add(ThamSo._8gio)
                        };
                        cChk vaoca1 = new cChkInn_A()
                        {
                            GioLienQuan = null, MachineNo = 21, Source = "PC", TimeStr = CIO.Vao.TimeStr.Date.Add(ca.OnnDutyTS).Add(ThamSo._8gio1giay)
                        };
                        cChk vaoca3 = new cChkInn_A()
                        {
                            GioLienQuan = gioLQvaoca3, MachineNo = CIO.Vao.MachineNo, Source = CIO.Vao.Source, TimeStr = CIO.Vao.TimeStr
                        };
                        cChk raaca1 = new cChkInn_A()
                        {
                            GioLienQuan = gioLQraaca1, MachineNo = CIO.Raa.MachineNo, Source = CIO.Raa.Source, TimeStr = CIO.Raa.TimeStr
                        };
                        dsCIO[i] = new cChkInOut_A()
                        {
                            TinhPC150 = macdinhtinhPC150, Vao = vaoca3, Raa = raaca3, TG = new ThoiGian(), HaveINOUT = 1, TongGioThuc = raaca3.TimeStr - vaoca3.TimeStr, ThuocNgayCong = vaoca3.TimeStr.Date, TimeStrDaiDien = vaoca3.TimeStr
                        };
                        cShift ca3 = dsca.Find(o => o.OnnDutyTS > ThamSo._20h00 && o.Workingday == 1f);
                        dsCIO[i].ThuocCa = ca3;
                        dsCIO[i].QuaDem  = true;

                        cChkInOut_A newCIO = new cChkInOut_A()
                        {
                            TinhPC150 = macdinhtinhPC150, Vao = vaoca1, Raa = raaca1, TG = new ThoiGian(), HaveINOUT = 1, TongGioThuc = raaca1.TimeStr - vaoca1.TimeStr, ThuocNgayCong = vaoca1.TimeStr.Date, TimeStrDaiDien = vaoca1.TimeStr
                        };
                        cShift ca1 = dsca.Find(o => o.OnnDutyTS <= ThamSo._05h45 && o.Workingday == 1f);
                        newCIO.ThuocCa = ca1;
                        newCIO.QuaDem  = false;

                        // vì hàm insert ko cho phép chèn ở vị trí > số lượng phần tử
                        // => nên nếu i là phần tử cuối thì add vào cuối danh sách, ngược lại thì insert vào vị trí i+1
                        if (i == (dsCIO.Count - 1))
                        {
                            dsCIO.Add(newCIO);
                        }
                        else
                        {
                            dsCIO.Insert(i + 1, newCIO);
                        }
                        i = i + 2;                         // +2 vì i là ca3, i+1 là ca 1
                    }
                    else
                    {
                        CIO.TinhPC150 = macdinhtinhPC150;
                        CIO.ThuocCa   = ca;
                        i++;
                    }
                }
                else
                {
                    ca = new cShift()
                    {
                        ShiftID = int.MinValue, ShiftCode = "Ca 8 tiếng"
                    };
                    TaoCaTuDo(ca, CIO.Vao.TimeStr, ThamSo._8gio, ThamSo._05phut, ThamSo._10phut, ThamSo._30phut, 1f);
                    CIO.TinhPC150 = macdinhtinhPC150;
                    CIO.ThuocCa   = ca;
                    i++;
                }
            }
        }
Esempio n. 4
0
        public List <cShift> KiemtraThuocKhoangHieuRaaCa(cChkInOut_A CIO, List <cShift> dsCa)
        {
            TimeSpan t_raa = CIO.Raa.TimeStr.TimeOfDay;

            return(dsCa.FindAll(ca => ((t_raa >= ca.OnTimeOutTS.Subtract(new TimeSpan(ca.DayCount, 0, 0, 0))) && (t_raa <= ca.CutOutTS.Subtract(new TimeSpan(ca.DayCount, 0, 0, 0))))));
        }
Esempio n. 5
0
        public List <cShift> KiemtraThuocKhoangHieuVaoCa(cChkInOut_A CIO, List <cShift> dsCa)
        {
            DateTime t_vao = CIO.Vao.TimeStr;

            return(dsCa.FindAll(ca => t_vao >= t_vao.Date.Add(ca.OnTimeInTS) && t_vao <= t_vao.Date.Add(ca.CutInTS)));
        }
Esempio n. 6
0
        public List <cChkInOut_A> GhepCIO_A(List <cChk> DSchkInn, List <cChk> DSchkOut)
        {
            List <cChkInOut_A> kq = new List <cChkInOut_A>();

            try {
                int x1 = 0, x2 = 0;
                if (DSchkInn.Count == 0 && DSchkOut.Count != 0)
                {
                    while (x2 < DSchkOut.Count)
                    {
                        kq.Add(new cChkInOut_A()
                        {
                            Vao = null, Raa = DSchkOut[x2], TG = new ThoiGian(), HaveINOUT = -2, TongGioThuc = ThamSo._0gio, ThuocNgayCong = DSchkOut[x2].TimeStr.Date, TimeStrDaiDien = DSchkOut[x2].TimeStr,
                        });
                        x2++;
                    }
                }
                else if (DSchkInn.Count != 0 && DSchkOut.Count == 0)
                {
                    while (x1 < DSchkInn.Count)
                    {
                        kq.Add(new cChkInOut_A()
                        {
                            Vao = DSchkInn[x1], Raa = null, TG = new ThoiGian(), HaveINOUT = -1, TongGioThuc = ThamSo._0gio, ThuocNgayCong = DSchkInn[x1].TimeStr.Date, TimeStrDaiDien = DSchkInn[x1].TimeStr,
                        });
                        x1++;
                    }
                }
                else if (DSchkInn.Count != 0 && DSchkOut.Count != 0)
                {
                    while (x1 < DSchkInn.Count && x2 < DSchkOut.Count)
                    {
                        cChk     chkinn  = DSchkInn[x1];
                        cChk     chkout  = DSchkOut[x2];
                        DateTime timeInn = chkinn.TimeStr;
                        DateTime timeOut = chkout.TimeStr;
                        if (timeOut <= timeInn)                        //ra ko vào
                        {
                            cChkInOut_A CIO = new cChkInOut_A {
                                Vao = null, Raa = DSchkOut[x2], TG = new ThoiGian(), HaveINOUT = -2, TongGioThuc = ThamSo._0gio, ThuocNgayCong = DSchkOut[x2].TimeStr.Date, TimeStrDaiDien = DSchkOut[x2].TimeStr
                            };
                            // lưu prev
                            kq.Add(CIO);
                            x2++;
                        }
                        else
                        {
                            TimeSpan duration = timeOut - timeInn;
                            if (duration <= ThamSo._30phut)
                            {
                                kq.Add(new cChkInOut_A()
                                {
                                    Vao = DSchkInn[x1], Raa = null, TG = new ThoiGian(), HaveINOUT = -1, TongGioThuc = ThamSo._0gio, ThuocNgayCong = DSchkInn[x1].TimeStr.Date, TimeStrDaiDien = DSchkInn[x1].TimeStr,
                                });
                                kq.Add(new cChkInOut_A()
                                {
                                    Vao = null, Raa = DSchkOut[x2], TG = new ThoiGian(), HaveINOUT = -2, TongGioThuc = ThamSo._0gio, ThuocNgayCong = DSchkOut[x2].TimeStr.Date, TimeStrDaiDien = DSchkOut[x2].TimeStr,
                                });
                                x1++;
                                x2++;
                            }
                            else if (duration > ThamSo._21h45)
                            {
                                cChkInOut_A CIO = new cChkInOut_A()
                                {
                                    Vao = DSchkInn[x1], Raa = null, TG = new ThoiGian(), HaveINOUT = -1, TongGioThuc = ThamSo._0gio, ThuocNgayCong = DSchkInn[x1].TimeStr.Date, TimeStrDaiDien = DSchkInn[x1].TimeStr
                                };
                                kq.Add(CIO);
                                x1++;
                            }
                            else
                            {
                                kq.Add(new cChkInOut_A()
                                {
                                    Vao = DSchkInn[x1], Raa = DSchkOut[x2], TG = new ThoiGian(), HaveINOUT = 1, TongGioThuc = duration, ThuocNgayCong = ThamSo.GetDate(DSchkInn[x1].TimeStr), TimeStrDaiDien = DSchkInn[x1].TimeStr
                                });
                                x1++;
                                x2++;
                            }
                        }
                    }
                    if (x2 < DSchkOut.Count)
                    {
                        while (x2 < DSchkOut.Count)
                        {
                            cChkInOut_A CIO = new cChkInOut_A()
                            {
                                Vao = null, Raa = DSchkOut[x2], TG = new ThoiGian(), HaveINOUT = -2, TongGioThuc = ThamSo._0gio, ThuocNgayCong = DSchkOut[x2].TimeStr.Date, TimeStrDaiDien = DSchkOut[x2].TimeStr
                            };
                            kq.Add(CIO);
                            x2++;
                        }
                    }
                    else if (x1 < DSchkInn.Count)
                    {
                        while (x1 < DSchkInn.Count)
                        {
                            cChkInOut_A CIO = new cChkInOut_A()
                            {
                                Vao = DSchkInn[x1], Raa = null, TG = new ThoiGian(), HaveINOUT = -1, TongGioThuc = ThamSo._0gio, ThuocNgayCong = DSchkInn[x1].TimeStr.Date, TimeStrDaiDien = DSchkInn[x1].TimeStr
                            };
                            kq.Add(CIO);
                            x1++;
                        }
                    }
                }
            } catch (Exception ex) {
                log4net.Config.XmlConfigurator.Configure();
                ILog lg = LogManager.GetLogger("GhepCaCIO_A");
                lg.Error(null, ex);
                throw ex;
            }

            return(kq);
        }