Ejemplo n.º 1
0
 public void RemoveInquirer(PeriodId periodId, SharedUnitId unitId, EmployeeId employeeId)
 {
     try
     {
         using (var tr = new TransactionScope())
         {
             var unit = unitRep.GetBy(new UnitId(periodId, unitId));
             var empl = unit.ConfigurationItemList.SingleOrDefault(c => c.Id.InquirerId == employeeId);
             if (empl != null)
             {
                 unit.DeleteInquirer(empl);
             }
             tr.Complete();
         }
     }
     catch (Exception exp)
     {
         var res = unitRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
Ejemplo n.º 2
0
        public SharedUnit GetSharedUnit(SharedUnitId sharedUnitId)
        {
            var unit       = unitService.GetBy(new PMSAdminModel.Units.UnitId(sharedUnitId.Id));
            var sharedUnit = new SharedUnit(new SharedUnitId(unit.Id.Id), unit.Name, unit.DictionaryName);

            return(sharedUnit);
        }
Ejemplo n.º 3
0
 public UnitId GetUnitIdBy(Period period, SharedUnitId sharedUnitId)
 {
     using (var tr = new TransactionScope())
     {
         var unitId = unitRep.GetUnitIdBy(period, sharedUnitId);
         tr.Complete();
         return(unitId);
     }
 }
Ejemplo n.º 4
0
        //public List<SharedJobCustomFieldId> GetSharedCutomFieldListForJob(SharedJobId sharedJobId,
        //                                                                IList<SharedJobCustomFieldId> customFieldIdList)
        //{
        //    var isValid = jobService.IsValidCustomFieldIdList(new PMSAdminModel.Jobs.JobId(sharedJobId.Id),
        //                                                      customFieldIdList.Select(c => new CustomFieldTypeId(c.Id))
        //                                                                       .ToList());
        //    if (!isValid)
        //        throw new ArgumentException("Invalid job customFieldIdList");

        //    var res = customFieldService.GetBy(customFieldIdList.Select(c => new CustomFieldTypeId(c.Id)).ToList());
        //    return
        //        res.Select(
        //            r => new JobCustomField(new SharedJobCustomFieldId(r.Id.Id), r.Name, r.DictionaryName, r.MinValue, r.MaxValue))
        //           .ToList();
        //}


        public List <SharedUnitCustomField> GetSharedCutomFieldListForUnit(SharedUnitId sharedUnitId, List <SharedUnitCustomFieldId> sharedUnitCustomFieldIds)
        {
            var isValid = unitService.IsValidCustomFieldIdList(new PMSAdminModel.Units.UnitId(sharedUnitId.Id),
                                                               sharedUnitCustomFieldIds.Select(c => new CustomFieldTypeId(c.Id))
                                                               .ToList());

            if (!isValid)
            {
                throw new ArgumentException("Invalid Unit customFieldIdList");
            }

            var res = customFieldService.GetBy(sharedUnitCustomFieldIds.Select(c => new CustomFieldTypeId(c.Id)).ToList());

            return
                (res.Select(
                     r => new SharedUnitCustomField(new SharedUnitCustomFieldId(r.Id.Id), r.Name, r.DictionaryName, r.MinValue, r.MaxValue, r.TypeId))
                 .ToList());
        }
Ejemplo n.º 5
0
 public Unit AssignUnit(PeriodId periodId, SharedUnitId sharedUnitId, SharedUnitId parentSharedUnitId)
 {
     using (var tr = new TransactionScope())
     {
         var period = periodRep.GetById(periodId);
         for (int i = 0; i < 100; i++)
         {
             var s = ipmsAdminService.GetSharedUnit(sharedUnitId);
         }
         var  sharedUnit = ipmsAdminService.GetSharedUnit(sharedUnitId);
         Unit parent     = null;
         if (parentSharedUnitId != null)
         {
             parent = unitRep.GetBy(new UnitId(periodId, parentSharedUnitId));
         }
         var unit = new Unit(period, sharedUnit, parent);
         unitRep.Add(unit);
         tr.Complete();
         return(unit);
     }
 }
Ejemplo n.º 6
0
        private void copyUnit(Period currentPeriod, UnitId sourceUnitId, SharedUnitId parentId)
        {

            List<Unit> childs = new List<Unit>();
            var srvManagerUnit = unitServiceFactory.Create();
            Unit sourceUnit;
            try
            {
                var unitService = srvManagerUnit.GetService();
                sourceUnit = unitService.GetUnitBy(sourceUnitId);
                unitService.AssignUnit(currentPeriod.Id, sourceUnit.SharedUnit.Id, parentId);
                childs = unitService.GetAllUnitByParentId(sourceUnit.Id);
            }
            finally
            {
                unitServiceFactory.Release(srvManagerUnit);
            }

            foreach (Unit u in childs)
                copyUnit(currentPeriod, u.Id, sourceUnit.SharedUnit.Id);

        }
Ejemplo n.º 7
0
 public void RemoveUnit(PeriodId periodId, SharedUnitId sharedUnitId)
 {
     try
     {
         using (var tr = new TransactionScope())
         {
             var period = periodRep.GetById(periodId);
             period.CheckRemovingUnit();
             var unit = unitRep.GetBy(new UnitId(periodId, sharedUnitId));
             unitRep.DeleteUnit(unit);
             tr.Complete();
         }
     }
     catch (Exception exp)
     {
         var res = unitRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
Ejemplo n.º 8
0
 public UnitId GetUnitIdBy(Period period, SharedUnitId sharedUnitId)
 {
     return(rep.Find(u => u.Id.PeriodId == period.Id && u.Id.SharedUnitId == sharedUnitId).Single().Id);
 }