Exemplo n.º 1
0
        protected void TryResizeIfNeed(IEmployeeRelationService service)
        {
            EmployeeRelation firstRange = null;
            EmployeeRelation lastRange  = null;

            if (_Relations != null && _Relations.Count > 0)
            {
                _Relations.Sort();
                firstRange = _Relations[0];

                if (firstRange.BeginTime != BeginDate)
                {
                    firstRange.BeginTime = BeginDate;
                }
                lastRange = _Relations[_Relations.Count - 1];
                if (firstRange.EndTime != EndDate)
                {
                    firstRange.EndTime = EndDate;
                }

                if (_Relations.Count == 1)
                {
                    service.SaveOrUpdate(firstRange);
                }
                else
                {
                    service.SaveOrUpdate(firstRange);
                    service.SaveOrUpdate(lastRange);
                }
            }
            if (NextContract != null)
            {
                NextContract.TryResizeIfNeed(service);
            }
        }
Exemplo n.º 2
0
        public void CheckAndModify(EmployeeRelation relation, IEmployeeRelationService service)
        {
            if (CheckIfOutside(relation))
            {
                //relation.EndTime = relation.BeginTime.AddDays(-1);
                service.Delete(relation);
                return;
            }


            if (Include(relation))
            {
                Relations.Add(relation);
                return;
            }
            else if (DateTimeHelper.IsIntersectExc(relation.BeginTime, relation.EndTime, BeginDate, EndDate))
            {
                if (DateTimeHelper.Between(relation.BeginTime, BeginDate, EndDate))
                {
                    EmployeeRelation newrelation = relation.GetCopy();
                    newrelation.ID        = 0;
                    newrelation.BeginTime = NextDay;

                    relation.EndTime = EndDate;
                    Debug.Assert(relation.IsValidRelation());
                    Relations.Add(relation);
                    service.SaveOrUpdate(relation);
                    relation = newrelation;
                }
                else if (DateTimeHelper.Between(relation.EndTime, BeginDate, EndDate))
                {
                    EmployeeRelation newrelation = relation.GetCopy();
                    newrelation.ID      = 0;
                    newrelation.EndTime = PrevDay;

                    relation.BeginTime = BeginDate;
                    Debug.Assert(relation.IsValidRelation());

                    Relations.Add(relation);
                    service.SaveOrUpdate(relation);
                    relation = newrelation;
                }
                if (NextContract != null)
                {
                    NextContract.CheckAndModify(relation, service);
                }
            }
            else if (NextContract != null)
            {
                NextContract.CheckAndModify(relation, service);
            }
            return;
        }
Exemplo n.º 3
0
        public void CheckAndModifyRelations(List <EmployeeRelation> relations, IEmployeeRelationService service)
        {
            if (relations == null || relations.Count == 0)
            {
                return;
            }
            if (service == null)
            {
                return;
            }

            foreach (EmployeeRelation relation in relations)
            {
                CheckAndModify(relation, service);
            }

            TryResizeIfNeed(service);
        }
Exemplo n.º 4
0
 public ListEmployeeRelations(IEmployeeRelationService relationservice, long emplid)
 {
     _relationservice = relationservice;
     LoadRelations(emplid);
 }
Exemplo n.º 5
0
 public ListEmployeeRelations(IEmployeeRelationService relationservice)
 {
     _relationservice = relationservice;
 }
Exemplo n.º 6
0
 public void LoadRelations(IEmployeeRelationService service)
 {
     BuildDiction(service.LoadAllSorted());
 }