Beispiel #1
0
 public UnitIndexCategory UpdateUnitIndexCategory(AbstractUnitIndexId unitIndexCatId, AbstractUnitIndexId parentId, string name, string dictionaryName)
 {
     //todo:(medium)Update not working
     try
     {
         using (var scope = new TransactionScope())
         {
             UnitIndexCategory parent = null;
             if (parentId != null)
             {
                 parent = unitIndexRep.GetUnitIndexCategory(parentId);
             }
             var unitIndexCategory = new UnitIndexCategory(unitIndexCatId, parent, name, dictionaryName);
             unitIndexRep.Update(unitIndexCategory);
             scope.Complete();
             return(unitIndexCategory);
         }
     }
     catch (Exception exp)
     {
         var res = unitIndexRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
Beispiel #2
0
 public UnitUnitIndex(AbstractUnitIndexId unitIndexId, bool showforTopLevel, bool showforSameLevel, bool showforLowLevel)
 {
     this.unitIndexId      = unitIndexId;
     this.showforTopLevel  = showforTopLevel;
     this.showforSameLevel = showforSameLevel;
     this.showforLowLevel  = showforLowLevel;
 }
Beispiel #3
0
 public UnitIndex UpdateUnitIndex(AbstractUnitIndexId unitIndexId, AbstractUnitIndexId categoryId, string name
                                  , string dictionaryName, IList <CustomFieldTypeId> customFieldTypeIdList)
 {
     try
     {
         using (var scope = new TransactionScope())
         {
             if (categoryId == null)
             {
                 throw new ArgumentException("CategoryId is null");
             }
             var category              = unitIndexRep.GetUnitIndexCategory(categoryId);
             var unitIndex             = unitIndexRep.GetUnitIndex(unitIndexId);
             var unitIndexCustomFields = customFieldRep.GetAll(EntityTypeEnum.UnitIndex)
                                         .Where(c => customFieldTypeIdList.Contains(c.Id)).ToList();
             unitIndex.Update(name, dictionaryName, category, unitIndexCustomFields);
             unitIndexRep.Update(unitIndex);
             scope.Complete();
             return(unitIndex);
         }
     }
     catch (Exception exp)
     {
         var res = unitIndexRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
Beispiel #4
0
        public UnitEmployee(Employee employee, Unit unit, DateTime fromDate, DateTime toDate,
                            IDictionary <UnitCustomField, string> employeeUnitCustomFieldValues,
                            AbstractUnitIndexId abstractUnitIndexId)
        {
            if (unit == null)
            {
                throw new ArgumentNullException("Unit");
            }
            if (unit.Id == null)
            {
                throw new ArgumentException("Unit.Id");
            }
            if (abstractUnitIndexId == null)
            {
                throw new ArgumentNullException("UnitIndexId");
            }


            //  this._unitIndexId = abstractUnitIndexId;
            this._unit    = unit;
            this.fromDate = fromDate;
            this.toDate   = toDate.Date;

            if (employee == null || employee.Id == null)
            {
                throw new ArgumentNullException("employee");
            }
            this.employeeId = employee.Id;
            this.employeeUnitCustomFieldValues = employeeUnitCustomFieldValues.ToDictionary(e => e.Key.Id, e => e.Value);
        }
Beispiel #5
0
 public virtual void AddCustomInquirer(EmployeeId employeeId, AbstractUnitIndexId unitIndexId)//, UnitId emploeeyUnitId)
 {
     configurationItemList.Add(
         new UnitInquiryConfigurationItem(
             new UnitInquiryConfigurationItemId(null, employeeId, Id, unitIndexId),
             this, false, true)); // JobPositionLevel.None));
 }
Beispiel #6
0
 public UnitIndexGroup UpdateUnitIndexGroup(AbstractUnitIndexId unitIndexGroupId, AbstractUnitIndexId parentId,
                                            string name,
                                            string dictionaryName)
 {
     try
     {
         using (var tr = new TransactionScope())
         {
             UnitIndexGroup parent = null;
             if (parentId != null)
             {
                 parent = unitIndexRep.GetUnitIndexGroupById(parentId);
             }
             var group = unitIndexRep.GetUnitIndexGroupById(unitIndexGroupId);
             if (parentId != null && parent.PeriodId != group.PeriodId)
             {
                 throw new ArgumentException("parentId is not valid");
             }
             group.Update(parent, name, dictionaryName);
             tr.Complete();
             return(group);
         }
     }
     catch (Exception exp)
     {
         var res = unitIndexRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
Beispiel #7
0
        public bool IsValidCustomFieldIdList(AbstractUnitIndexId unitIndexId, IList <CustomFieldTypeId> customFieldTypeIds)
        {
            var unitIndex       = (UnitIndex)unitIndexRep.GetById(unitIndexId);
            var customFieldList = customFieldRep.Find(customFieldTypeIds);

            return(unitIndex.IsValidCustomFields(customFieldList));
        }
Beispiel #8
0
 public UnitIndex AddUnitIndex(PeriodId periodId, AbstractUnitIndexId groupId, SharedUnitIndexId unitIndexId, IDictionary <SharedUnitIndexCustomFieldId, string> customFieldValues, bool isInquireable, int calculationOrder, long calculationLevel)
 {
     try
     {
         using (var tr = new TransactionScope())
         {
             var period     = periodRep.GetById(periodId);
             var sharedUnit = pmsAdminService.GetSharedUnitIndex(unitIndexId);
             var id         = unitIndexRep.GetNextId();
             if (groupId == null)
             {
                 throw new ArgumentException("groupId is null");
             }
             var group     = unitIndexRep.GetUnitIndexGroupById(groupId);
             var unitIndex = new UnitIndex(id, period, sharedUnit, group, isInquireable, calculationLevel,
                                           calculationOrder);
             var validateCustomFldValues = getSharedUnitIndexCustomFields(unitIndexId, customFieldValues);
             unitIndex.UpdateCustomFields(validateCustomFldValues);
             unitIndexRep.Add(unitIndex);
             tr.Complete();
             return(unitIndex);
         }
     }
     catch (Exception exp)
     {
         var res = unitIndexRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
Beispiel #9
0
 public UnitIndexCategory AddUnitIndexCategory(AbstractUnitIndexId parentId, string name, string dictionaryName)
 {
     try
     {
         using (var scope = new TransactionScope())
         {
             var id = unitIndexRep.GetNextId();
             UnitIndexCategory parent = null;
             if (parentId != null)
             {
                 parent = unitIndexRep.GetUnitIndexCategory(new AbstractUnitIndexId(parentId.Id));
             }
             var unitIndexCategory = new UnitIndexCategory(id, parent, name, dictionaryName);
             unitIndexRep.Add(unitIndexCategory);
             scope.Complete();
             return(unitIndexCategory);
         }
     }
     catch (Exception exp)
     {
         var res = unitIndexRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
Beispiel #10
0
 public UnitIndex AddUnitIndex(AbstractUnitIndexId categoryId, string name
                               , string dictionaryName, IList <CustomFieldTypeId> customFieldTypeIdList, Guid transferId)
 {
     try
     {
         using (var scope = new TransactionScope())
         {
             var id        = unitIndexRep.GetNextId();
             var category  = unitIndexRep.GetUnitIndexCategory(categoryId);
             var unitIndex = new UnitIndex(id, category, name, dictionaryName);
             assignUnitIndexCustomField(unitIndex, customFieldTypeIdList);
             unitIndex.TransferId = transferId;
             unitIndexRep.Add(unitIndex);
             scope.Complete();
             return(unitIndex);
         }
     }
     catch (Exception exp)
     {
         var res = unitIndexRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
Beispiel #11
0
 public UnitIndexGroup AddUnitIndexGroup(PeriodId periodId, AbstractUnitIndexId parentId, string name,
                                         string dictionaryName)
 {
     try
     {
         using (var tr = new TransactionScope())
         {
             var            id     = unitIndexRep.GetNextId();
             var            period = periodRep.GetById(periodId);
             UnitIndexGroup parent = null;
             if (parentId != null)
             {
                 parent = unitIndexRep.GetUnitIndexGroupById(new AbstractUnitIndexId(parentId.Id));
             }
             var unitIndexGroup = new UnitIndexGroup(id, period, parent, name, dictionaryName);
             unitIndexRep.Add(unitIndexGroup);
             tr.Complete();
             return(unitIndexGroup);
         }
     }
     catch (Exception exp)
     {
         var res = unitIndexRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
Beispiel #12
0
 public UnitIndexForUnit(AbstractUnitIndexId jobIndexId, bool showforTopLevel, bool showforSameLevel, bool showforLowLevel)
 {
     UnitIndexId      = jobIndexId;
     ShowforLowLevel  = showforLowLevel;
     ShowforTopLevel  = showforTopLevel;
     ShowforSameLevel = showforSameLevel;
 }
Beispiel #13
0
 public AbstractUnitIndex GetUnitIndexById(AbstractUnitIndexId unitIndexId)
 {
     using (var tr = new TransactionScope())
     {
         var res = unitIndexRep.GetById(unitIndexId);
         tr.Complete();
         return(res);
     }
 }
Beispiel #14
0
 public SharedUnitIndexId GetSharedUnitIndexIdBy(AbstractUnitIndexId abstractUnitIndexId)
 {
     using (var tr = new TransactionScope())
     {
         var res = unitIndexRep.GetSharedUnitIndexIdBy(abstractUnitIndexId);
         tr.Complete();
         return(res);
     }
 }
Beispiel #15
0
 public List <AbstractUnitIndex> GetAllAbstractUnitIndexByParentId(AbstractUnitIndexId id)
 {
     using (var tr = new TransactionScope())
     {
         var res = unitIndexRep.GetAllAbstractUnitIndexByParentId(id);
         tr.Complete();
         return(res);
     }
 }
Beispiel #16
0
 public UnitInquiryConfigurationItemId(UnitId inquirerUnitId, EmployeeId inquirerId,
                                       UnitId inquirySubjectUnitId, AbstractUnitIndexId abstractUnitIndexId)//, EmployeeId inquirySubjectId)
 {
     this.inquirerId           = inquirerId;
     this.inquirySubjectUnitId = inquirySubjectUnitId;
     // this.inquirySubjectId = inquirySubjectId;
     this.inquirerUnitId        = inquirerUnitId;
     this.unitIndexIdUintPeriod = abstractUnitIndexId;
 }
Beispiel #17
0
        public List <AbstractUnitIndex> GetAllAbstractUnitIndexByParentId(AbstractUnitIndexId id)
        {
            var unitIndexChilds      = rep.Find <UnitIndex>(u => u.Group.Id == id).ToList();
            var unitIndexGroupChilds = rep.Find <UnitIndexGroup>(u => u.Parent.Id == id).ToList();

            List <AbstractUnitIndex> res = new List <AbstractUnitIndex>(unitIndexChilds);

            res.AddRange(unitIndexGroupChilds);
            return(res);
        }
Beispiel #18
0
 public void Update(UnitInquiryConfigurationItemId configurationItemId, AbstractUnitIndexId unitIndexId,
                    string unitIndexValue)
 {
     using (var tr = new TransactionScope())
     {
         InquiryUnitIndexPoint inquiryUnitIndexPoint = inquiryUnitIndexPointRep.GetBy(configurationItemId);
         inquiryUnitIndexPoint.SetValue(unitIndexValue, periodChecker);
         tr.Complete();
     }
 }
Beispiel #19
0
 public void DeleteAbstractUnitIndex(AbstractUnitIndexId unitIndexId)
 {
     try
     {
         using (var scope = new TransactionScope())
         {
             unitIndexRep.Delete(unitIndexId);
             scope.Complete();
         }
     }
     catch (Exception exp)
     {
         var res = unitIndexRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
Beispiel #20
0
        public InquiryUnitIndexPoint(InquiryUnitIndexPointId id, UnitInquiryConfigurationItem configurationItem,
                                     AbstractUnitIndexId unitIndex, string unitIndexValue)
        {
            if (id == null)
            {
                throw new ArgumentNullException("inquiryUnitIndexPointId");
            }
            this.id = id;
            if (configurationItem == null)
            {
                throw new ArgumentNullException("configurationItem");
            }
            configurationItemId = configurationItem.Id;

            if (id == null)
            {
                throw new ArgumentNullException("unitIndex");
            }

            //  unitIndexId = unitIndex;
            this.unitIndexValue = unitIndexValue;
        }
Beispiel #21
0
 public UnitIndex UpdateUnitIndex(AbstractUnitIndexId unitIndexId, AbstractUnitIndexId groupId, IDictionary <SharedUnitIndexCustomFieldId, string> customFieldValues, bool isInquireable, int calculationOrder, long calculationLevel)
 {
     try
     {
         using (var tr = new TransactionScope())
         {
             if (groupId == null)
             {
                 throw new ArgumentException("groupId is null");
             }
             var group = unitIndexRep.GetUnitIndexGroupById(groupId);
             if (group == null)
             {
                 throw new ArgumentException("group is null");
             }
             var unitIndex = unitIndexRep.GetUnitIndexById(unitIndexId);
             if (group.PeriodId != unitIndex.PeriodId)
             {
                 throw new ArgumentException("groupId is not valid");
             }
             var customFldValues = getSharedUnitIndexCustomFields(unitIndex.SharedUnitIndexId, customFieldValues);
             unitIndex.Update(group, isInquireable, customFldValues, periodChecker, calculationOrder,
                              calculationLevel);
             unitIndexRep.Update(unitIndex);
             tr.Complete();
             return(unitIndex);
         }
     }
     catch (Exception exp)
     {
         var res = unitIndexRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
Beispiel #22
0
 public SharedUnitIndexId GetSharedUnitIndexIdBy(AbstractUnitIndexId abstractUnitIndexId)
 {
     //return rep.Find<UnitIndex>(i => abstractUnitIndexIds.Contains(i.Id)).Select(i => i.SharedUnitIndexId).ToList();
     return(rep.Single <UnitIndex>(j => j.Id == abstractUnitIndexId).SharedUnitIndexId);
 }
Beispiel #23
0
        public List <CustomFieldType> GetAllCustomField(AbstractUnitIndexId unitIndexId)
        {
            var unitIndex = Session.Query <UnitIndex>().Single(j => j.Id == unitIndexId);

            return(Session.Query <CustomFieldType>().Where(c => unitIndex.CustomFieldTypeIdList.Contains(c.Id)).ToList());
        }
Beispiel #24
0
 public UnitIndex GetBy(AbstractUnitIndexId unitIndexId)
 {
     return(unitIndexRep.GetUnitIndex(unitIndexId));
 }
Beispiel #25
0
 public UnitIndexCategory GetUnitIndexCategory(AbstractUnitIndexId id)
 {
     return(rep.Single <UnitIndexCategory>(p => p.Id == id));
 }
Beispiel #26
0
 public UnitIndexGroup GetUnitIndexGroupById(AbstractUnitIndexId id)
 {
     return(rep.Single <UnitIndexGroup>(u => u.Id == id));
 }
Beispiel #27
0
 public virtual void UpdateInquirersBy(Employee inquirySubject, AbstractUnitIndexId unitIndexId)
 {
     AddCustomInquirer(inquirySubject.Id, unitIndexId);
 }
Beispiel #28
0
 public AbstractUnitIndex GetById(AbstractUnitIndexId unitIndexId)
 {
     return(rep.FindByKey(unitIndexId));
 }
Beispiel #29
0
        public void Delete(AbstractUnitIndexId unitIndexId)
        {
            var abstractIndex = GetById(unitIndexId);

            rep.Delete(abstractIndex);
        }
Beispiel #30
0
 public UnitIndex GetUnitIndex(AbstractUnitIndexId id)
 {
     return(rep.Single <UnitIndex>(p => p.Id == id));
 }