Beispiel #1
0
        protected override void UpdatingItem(Operator newVal, Operator original, AttendanceDataContext attendance)
        {
            attendance.GetTable <Operator>().Attach(newVal, original);
            List <T_OperatorDept> optDepts = attendance.GetTable <T_OperatorDept>().Where(item => item.OperatorID == newVal.ID).ToList();

            if (!newVal.IsAdmin)
            {
                foreach (string item in newVal.Depts)
                {
                    if (!optDepts.Exists(it => it.DepartmentID == item))
                    {
                        attendance.GetTable <T_OperatorDept>().InsertOnSubmit(new T_OperatorDept()
                        {
                            OperatorID = newVal.ID, DepartmentID = item
                        });
                    }
                }
                foreach (T_OperatorDept item in optDepts)
                {
                    if (!newVal.Depts.Exists(it => it == item.DepartmentID))
                    {
                        attendance.GetTable <T_OperatorDept>().DeleteOnSubmit(item);
                    }
                }
            }
        }
 public void ResetID(string entity, long id)
 {
     try
     {
         AttendanceDataContext dc = AttendanceDataContextFactory.Createattendance(_ConnStr);
         IntegerID             ii = dc.GetTable <IntegerID>().SingleOrDefault(item => item.Entity == entity);
         if (ii == null)
         {
             ii = new IntegerID()
             {
                 Entity = entity, Value = id
             };
             dc.GetTable <IntegerID>().InsertOnSubmit(ii);
             dc.SubmitChanges();
         }
         else
         {
             ii.Value = id;
             dc.SubmitChanges();
         }
     }
     catch (Exception ex)
     {
         LJH.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
     }
 }
Beispiel #3
0
        protected override void DeletingItem(ShiftTemplate info, AttendanceDataContext attendance)
        {
            T_ShiftArrangeTemplate item = T_ShiftArrangeTemplate.Create(info);

            attendance.GetTable <T_ShiftArrangeTemplate>().Attach(item);
            attendance.GetTable <T_ShiftArrangeTemplate>().DeleteOnSubmit(item);
        }
Beispiel #4
0
        protected override void DeletingItem(Operator info, AttendanceDataContext attendance)
        {
            attendance.GetTable <Operator>().Attach(info);
            attendance.GetTable <Operator>().DeleteOnSubmit(info);
            List <T_OperatorDept> optDepts = attendance.GetTable <T_OperatorDept>().Where(item => item.OperatorID == info.ID).ToList();

            attendance.GetTable <T_OperatorDept>().DeleteAllOnSubmit(optDepts);
        }
Beispiel #5
0
 protected override void DeletingItem(Shift info, AttendanceDataContext attendance)
 {
     attendance.GetTable <Shift>().Attach(info);
     attendance.GetTable <Shift>().DeleteOnSubmit(info);
     if (info.Items != null && info.Items.Count > 0)
     {
         foreach (ShiftItem si in info.Items)
         {
             attendance.GetTable <ShiftItem>().Attach(si);
             attendance.GetTable <ShiftItem>().DeleteOnSubmit(si);
         }
     }
 }
 protected override void DeletingItem(AttendanceResult info, AttendanceDataContext attendance)
 {
     attendance.GetTable <AttendanceResult>().Attach(info);
     attendance.GetTable <AttendanceResult>().DeleteOnSubmit(info);
     if (info.AbsentItems != null && info.AbsentItems.Count > 0)
     {
         foreach (AbsentItem item in info.AbsentItems)
         {
             attendance.GetTable <AbsentItem>().Attach(item);
             attendance.GetTable <AbsentItem>().DeleteOnSubmit(item);
         }
     }
 }
Beispiel #7
0
        protected override Operator GetingItemByID(string id, AttendanceDataContext attendance)
        {
            Operator opt = attendance.GetTable <Operator>().SingleOrDefault(o => o.ID == id);

            if (opt != null)
            {
                opt.Role = attendance.GetTable <Role>().SingleOrDefault(item => item.ID == opt.RoleID);
                if (!opt.IsAdmin)
                {
                    opt.Depts = attendance.GetTable <T_OperatorDept>().Where(item => item.OperatorID == id).Select(item => item.DepartmentID).ToList();
                }
            }
            return(opt);
        }
        protected override List <ShiftArrange> GetingItems(AttendanceDataContext attendance, SearchCondition search)
        {
            IQueryable <ShiftArrange> ret = attendance.GetTable <ShiftArrange>();

            if (search is ShiftArrangeSearchCondition)
            {
                ShiftArrangeSearchCondition con = search as ShiftArrangeSearchCondition;
                if (con.ShiftDate != null)
                {
                    ret = ret.Where(item => item.ShiftDate >= con.ShiftDate.Begin && item.ShiftDate <= con.ShiftDate.End);
                }
                if (con.StaffID != null)
                {
                    ret = ret.Where(item => item.StaffID == con.StaffID);
                }
                if (con.ShiftID != null)
                {
                    ret = ret.Where(item => item.ShiftID == con.ShiftID);
                }
            }
            List <ShiftArrange> items = ret.ToList();

            if (items != null && items.Count > 0)
            {
                List <Shift> shifts = (new ShiftProvider(ConnectStr)).GetItems(null).QueryObjects;
                foreach (ShiftArrange item in items)
                {
                    item.Shift = shifts.SingleOrDefault(it => it.ID == item.ShiftID);
                }
            }
            return(items.Where(item => item.Shift != null).ToList());
        }
        protected override List <TASheet> GetingItems(AttendanceDataContext attendance, SearchCondition search)
        {
            DataLoadOptions opts = new DataLoadOptions();

            opts.LoadWith <TASheet>(item => item.Items);
            attendance.LoadOptions = opts;
            IQueryable <TASheet> ret = attendance.GetTable <TASheet>();

            if (search is TASheetSearchCondition)
            {
                TASheetSearchCondition con = search as TASheetSearchCondition;
                if (!string.IsNullOrEmpty(con.SheetID))
                {
                    ret = ret.Where(item => item.SheetID == con.SheetID);
                }
                if (con.StaffID != null)
                {
                    ret = ret.Where(item => item.StaffID == con.StaffID);
                }
                if (!string.IsNullOrEmpty(con.SheetType))
                {
                    ret = ret.Where(item => item.SheetType == con.SheetType);
                }
                if (!string.IsNullOrEmpty(con.Department))
                {
                    ret = ret.Where(item => item.Department == con.Department);
                }
                if (con.StartDate != null)
                {
                    ret = ret.Where(item => item.StartDate >= con.StartDate.Begin && item.StartDate <= con.StartDate.End);
                }
            }
            return(ret.ToList());
        }
        protected override List <AttendanceResult> GetingItems(AttendanceDataContext attendance, SearchCondition search)
        {
            DataLoadOptions opts = new DataLoadOptions();

            opts.LoadWith <AttendanceResult>(item => item.AbsentItems);
            attendance.LoadOptions = opts;
            IQueryable <AttendanceResult> ret = attendance.GetTable <AttendanceResult>();

            if (search is StaffAttendanceResultSearchCondition)
            {
                StaffAttendanceResultSearchCondition con = search as StaffAttendanceResultSearchCondition;
                if (con.ShiftDate != null)
                {
                    ret = ret.Where(item => item.ShiftDate >= con.ShiftDate.Begin && item.ShiftDate <= con.ShiftDate.End);
                }
                if (con.Staff != null && con.Staff.Count > 0)
                {
                    ret = ret.Where(item => con.Staff.Contains(item.StaffID));
                }
                if (con.ShiftID != null)
                {
                    ret = ret.Where(item => item.ShiftID == con.ShiftID);
                }
            }
            return(ret.ToList());
        }
Beispiel #11
0
        protected override Shift GetingItemByID(string id, AttendanceDataContext attendance)
        {
            DataLoadOptions opts = new DataLoadOptions();

            opts.LoadWith <Shift>(item => item.Items);
            attendance.LoadOptions = opts;
            return(attendance.GetTable <Shift>().SingleOrDefault(item => item.ID == id));
        }
Beispiel #12
0
        protected override List <Shift> GetingItems(AttendanceDataContext attendance, SearchCondition search)
        {
            DataLoadOptions opts = new DataLoadOptions();

            opts.LoadWith <Shift>(item => item.Items);
            attendance.LoadOptions = opts;
            IQueryable <Shift> ret = attendance.GetTable <Shift>();

            return(ret.ToList());
        }
Beispiel #13
0
        protected override Staff GetingItemByID(int id, AttendanceDataContext attendance)
        {
            Staff staff = attendance.GetTable <Staff>().SingleOrDefault(item => item.ID == id);

            if (staff != null && !string.IsNullOrEmpty(staff.DepartmentID))
            {
                staff.Department = (new DepartmentProvider(ConnectStr)).GetByID(staff.DepartmentID).QueryObject;
            }
            return(staff);
        }
        protected override ShiftArrange GetingItemByID(ShiftArrangeID id, AttendanceDataContext attendance)
        {
            ShiftArrange sa = attendance.GetTable <ShiftArrange>().SingleOrDefault(item => item.StaffID == id.StaffID && item.ShiftDate == id.ShiftDate && item.ShiftID == id.ShiftID);

            if (sa != null)
            {
                sa.Shift = (new ShiftProvider(ConnectStr)).GetByID(sa.ShiftID).QueryObject;
            }
            return(sa);
        }
        protected override AttendanceResult GetingItemByID(Guid id, AttendanceDataContext attendance)
        {
            DataLoadOptions opts = new DataLoadOptions();

            opts.LoadWith <AttendanceResult>(item => item.AbsentItems);
            attendance.LoadOptions = opts;
            AttendanceResult sa = attendance.GetTable <AttendanceResult>().SingleOrDefault(item => item.ID == id);

            return(sa);
        }
Beispiel #16
0
        protected override ShiftTemplate GetingItemByID(string id, AttendanceDataContext attendance)
        {
            T_ShiftArrangeTemplate tst = attendance.GetTable <T_ShiftArrangeTemplate>().SingleOrDefault(item => item.ID == id);

            if (tst != null)
            {
                return(T_ShiftArrangeTemplate.Create(tst));
            }
            return(null);
        }
        public long?GetCurID(string entity)
        {
            long?id = null;
            AttendanceDataContext dc = AttendanceDataContextFactory.Createattendance(_ConnStr);
            IntegerID             ii = dc.GetTable <IntegerID>().SingleOrDefault(item => item.Entity == entity);

            if (ii != null)
            {
                id = ii.Value;
            }
            return(id);
        }
Beispiel #18
0
 protected override void UpdatingItem(Shift newVal, Shift original, AttendanceDataContext attendance)
 {
     attendance.GetTable <Shift>().Attach(newVal, original);
     foreach (ShiftItem item in newVal.Items)
     {
         ShiftItem old = original.Items.SingleOrDefault(it => it.ID == item.ID);
         if (old != null)
         {
             attendance.GetTable <ShiftItem>().Attach(item, old);
         }
         else
         {
             attendance.GetTable <ShiftItem>().InsertOnSubmit(item);
         }
     }
     foreach (ShiftItem item in original.Items)
     {
         if (newVal.Items.SingleOrDefault(it => it.ID == item.ID) == null)
         {
             attendance.GetTable <ShiftItem>().Attach(item);
             attendance.GetTable <ShiftItem>().DeleteOnSubmit(item);
         }
     }
 }
Beispiel #19
0
        protected override List <Operator> GetingItems(AttendanceDataContext attendance, SearchCondition search)
        {
            IQueryable <Operator> ret = attendance.GetTable <Operator>();

            if (search == null)
            {
            }
            List <Operator> items = ret.ToList();

            if (items != null && items.Count > 0)
            {
                List <Role>           roles    = attendance.GetTable <Role>().ToList();
                List <T_OperatorDept> optDepts = attendance.GetTable <T_OperatorDept>().ToList();
                foreach (Operator opt in items)
                {
                    opt.Role = roles.SingleOrDefault(role => role.ID == opt.RoleID);
                    if (!opt.IsAdmin)
                    {
                        opt.Depts = optDepts.Where(item => item.OperatorID == opt.ID).Select(item => item.DepartmentID).ToList();
                    }
                }
            }
            return(items);
        }
        public long?CreateID(string entity)
        {
            long?id = null;
            AttendanceDataContext dc = AttendanceDataContextFactory.Createattendance(_ConnStr);
            IntegerID             ii = dc.GetTable <IntegerID>().SingleOrDefault(item => item.Entity == entity);

            if (ii == null)
            {
                ii = new IntegerID()
                {
                    Entity = entity, Value = 2
                };
                dc.GetTable <IntegerID>().InsertOnSubmit(ii);
                dc.SubmitChanges();
                id = 1;
            }
            else
            {
                id        = ii.Value;
                ii.Value += 1;
                dc.SubmitChanges();
            }
            return(id);
        }
Beispiel #21
0
        protected override List <ShiftTemplate> GetingItems(AttendanceDataContext attendance, SearchCondition search)
        {
            IQueryable <T_ShiftArrangeTemplate> ret   = attendance.GetTable <T_ShiftArrangeTemplate>();
            List <T_ShiftArrangeTemplate>       items = ret.ToList();

            List <ShiftTemplate> templates = new List <ShiftTemplate>();

            if (items != null && items.Count > 0)
            {
                foreach (T_ShiftArrangeTemplate item in items)
                {
                    templates.Add(T_ShiftArrangeTemplate.Create(item));
                }
            }
            return(templates);
        }
Beispiel #22
0
        protected override List <Staff> GetingItems(AttendanceDataContext attendance, SearchCondition search)
        {
            IQueryable <Staff> ret   = attendance.GetTable <Staff>();
            List <Staff>       items = ret.ToList();

            if (items != null)
            {
                List <Department> depts = (new DepartmentProvider(ConnectStr)).GetItems(null).QueryObjects;
                if (depts != null && depts.Count > 0)
                {
                    foreach (Staff staff in items)
                    {
                        if (!string.IsNullOrEmpty(staff.DepartmentID))
                        {
                            staff.Department = depts.SingleOrDefault(dept => staff.DepartmentID == dept.ID);
                        }
                    }
                }
            }
            return(items);
        }
Beispiel #23
0
        protected override List <StaffBioTemplate> GetingItems(AttendanceDataContext attendance, SearchCondition search)
        {
            IQueryable <StaffBioTemplate> ret = attendance.GetTable <StaffBioTemplate>();

            if (search is StaffBioTemplateSearchCondition)
            {
                StaffBioTemplateSearchCondition con = search as StaffBioTemplateSearchCondition;
                if (con.StaffID != null)
                {
                    ret = ret.Where(item => item.StaffID == con.StaffID.Value);
                }
                if (!string.IsNullOrEmpty(con.Version))
                {
                    ret = ret.Where(item => item.Version == con.Version);
                }
                if (con.Staff != null && con.Staff.Count > 0)
                {
                    ret = ret.Where(item => con.Staff.Contains(item.StaffID));
                }
            }
            return(ret.ToList());
        }
Beispiel #24
0
        protected override List <AttendanceLog> GetingItems(AttendanceDataContext attendance, SearchCondition search)
        {
            IQueryable <AttendanceLog> ret = attendance.GetTable <AttendanceLog>();

            if (search is AttendanceLogSearchCondition)
            {
                AttendanceLogSearchCondition con = search as AttendanceLogSearchCondition;
                if (con.ReadDateTime != null)
                {
                    ret = ret.Where(item => item.ReadDateTime >= con.ReadDateTime.Begin && item.ReadDateTime <= con.ReadDateTime.End);
                }
                if (con.Staff != null && con.Staff.Count > 0)
                {
                    ret = ret.Where(item => con.Staff.Contains(item.StaffID));
                }
                if (con.Readers != null && con.Readers.Count > 0)
                {
                    ret = ret.Where(item => con.Readers.Contains(item.ReaderID) || item.IsManual == true);                                               //人工签卡记录可能没有读卡器ID
                }
            }
            List <AttendanceLog> items = ret.ToList();

            return(items);
        }
 protected override DeviceInfo GetingItemByID(string id, AttendanceDataContext attendance)
 {
     return(attendance.GetTable <DeviceInfo>().SingleOrDefault(item => item.ID == id));
 }
Beispiel #26
0
 protected override StaffBioTemplate GetingItemByID(Guid id, AttendanceDataContext attendance)
 {
     return(attendance.GetTable <StaffBioTemplate>().SingleOrDefault(item => item.ID == id));
 }
Beispiel #27
0
 protected override void UpdatingItem(ShiftTemplate newVal, ShiftTemplate original, AttendanceDataContext attendance)
 {
     attendance.GetTable <T_ShiftArrangeTemplate>().Attach(T_ShiftArrangeTemplate.Create(newVal), T_ShiftArrangeTemplate.Create(original));
 }
Beispiel #28
0
        protected override void InsertingItem(ShiftTemplate info, AttendanceDataContext attendance)
        {
            T_ShiftArrangeTemplate template = T_ShiftArrangeTemplate.Create(info);

            attendance.GetTable <T_ShiftArrangeTemplate>().InsertOnSubmit(template);
        }
        protected override List <Holiday> GetingItems(AttendanceDataContext attendance, SearchCondition search)
        {
            IQueryable <Holiday> ret = attendance.GetTable <Holiday>();

            return(ret.ToList());
        }
 protected override Holiday GetingItemByID(string id, AttendanceDataContext attendance)
 {
     return(attendance.GetTable <Holiday>().SingleOrDefault(item => item.ID == id));
 }