public void LoaiBoCheck30phut(List <cChk> dscheck) // lọc này phải dảm bảo sort trước { if (dscheck == null || dscheck.Count == 0 || dscheck.Count == 1) { return; } int i = 0; while (i + 1 < dscheck.Count) { cChk before = dscheck[i]; cChk afterr = dscheck[i + 1]; if (afterr.TimeStr - before.TimeStr <= ThamSo._30phut) { if (before.GioLienQuan == null) { before.GioLienQuan = new List <cChk>(); } before.GioLienQuan.Add(afterr); dscheck.Remove(afterr); } else { i++; } } }
public void AddNewCheck_A(cChk check) { if (check.GetType() == typeof(cChkInn_A)) { ds_CheckInn_A.Add(check); } else if (check.GetType() == typeof(cChkOut_A)) { ds_CheckOut_A.Add(check); } }
public void AddNewCheck_A(cChk check) { if (check.GetType() == typeof(cChkInn_A)) { if (ds_CheckInn_A == null) { ds_CheckInn_A = new List <cChk>(); } ds_CheckInn_A.Add(check); } else if (check.GetType() == typeof(cChkOut_A)) { if (ds_CheckOut_A == null) { ds_CheckOut_A = new List <cChk>(); } ds_CheckOut_A.Add(check); } }
public List <cChkInOut_A> GhepCIO_A(List <cChk> DSchkInn, List <cChk> DSchkOut) { List <cChkInOut_A> kq = new List <cChkInOut_A>(); 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], HaveINOUT = -2, TongGioThuc = ThamSo._0gio, ThuocNgayCong = DSchkOut[x2].TimeStr.Date, TimeStrDaiDien = DSchkOut[x2].TimeStr }); } } else if (DSchkInn.Count != 0 && DSchkOut.Count == 0) { while (x1 < DSchkInn.Count) { kq.Add(new cChkInOut_A() { Vao = DSchkInn[x1], Raa = null, HaveINOUT = -1, TongGioThuc = ThamSo._0gio, ThuocNgayCong = DSchkInn[x1].TimeStr.Date, TimeStrDaiDien = DSchkInn[x1].TimeStr }); } } 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 { kq.Add(new cChkInOut_A() { Vao = null, Raa = DSchkOut[x2], HaveINOUT = -2, TongGioThuc = ThamSo._0gio, ThuocNgayCong = DSchkOut[x2].TimeStr.Date, TimeStrDaiDien = DSchkOut[x2].TimeStr }); x2++; } else { TimeSpan duration = timeOut - timeInn; if (duration <= ThamSo._30phut || duration > ThamSo._21h45) { kq.Add(new cChkInOut_A() { Vao = DSchkInn[x1], Raa = null, HaveINOUT = -1, TongGioThuc = ThamSo._0gio, ThuocNgayCong = DSchkInn[x1].TimeStr.Date, TimeStrDaiDien = DSchkInn[x1].TimeStr }); kq.Add(new cChkInOut_A() { Vao = null, Raa = DSchkOut[x2], HaveINOUT = -2, TongGioThuc = ThamSo._0gio, ThuocNgayCong = DSchkOut[x2].TimeStr.Date, TimeStrDaiDien = DSchkOut[x2].TimeStr }); } else { kq.Add(new cChkInOut_A() { Vao = DSchkInn[x1], Raa = DSchkOut[x2], HaveINOUT = 1, TongGioThuc = duration, ThuocNgayCong = ThamSo.GetDate(DSchkInn[x1].TimeStr), TimeStrDaiDien = DSchkInn[x1].TimeStr }); } x1++; x2++; } } if (x2 < DSchkOut.Count) { while (x2 < DSchkOut.Count) { kq.Add(new cChkInOut_A() { Vao = null, Raa = DSchkOut[x2], HaveINOUT = -2, TongGioThuc = ThamSo._0gio, ThuocNgayCong = DSchkOut[x2].TimeStr.Date, TimeStrDaiDien = DSchkOut[x2].TimeStr }); } } else if (x1 < DSchkInn.Count) { while (x1 < DSchkInn.Count) { kq.Add(new cChkInOut_A() { Vao = DSchkInn[x1], Raa = null, HaveINOUT = -1, TongGioThuc = ThamSo._0gio, ThuocNgayCong = DSchkInn[x1].TimeStr.Date, TimeStrDaiDien = DSchkInn[x1].TimeStr }); } } } return(kq); }
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); }