Exemple #1
0
 public JobIndex AddJobIndex(PeriodId periodId, AbstractJobIndexId groupId, SharedJobIndexId jobIndexId, IDictionary <SharedJobIndexCustomFieldId, string> customFieldValues, bool isInquireable, int calculationOrder, long calculationLevel)
 {
     try
     {
         using (var tr = new TransactionScope())
         {
             var period    = periodRep.GetById(periodId);
             var sharedJob = pmsAdminService.GetSharedJobIndex(jobIndexId);
             var id        = jobIndexRep.GetNextId();
             if (groupId == null)
             {
                 throw new ArgumentException("groupId is null");
             }
             var group    = jobIndexRep.GetJobIndexGroupById(groupId);
             var jobIndex = new JobIndex(id, period, sharedJob, group, isInquireable, calculationLevel,
                                         calculationOrder);
             var validateCustomFldValues = getSharedJobIndexCustomFields(jobIndexId, customFieldValues);
             jobIndex.UpdateCustomFields(validateCustomFldValues);
             jobIndexRep.Add(jobIndex);
             tr.Complete();
             return(jobIndex);
         }
     }
     catch (Exception exp)
     {
         var res = jobIndexRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
Exemple #2
0
        public static void CreateJobIndex(IJobIndexRepository jobIndexRepository, PMSAdmin.Domain.Model.JobIndices.JobIndex adminJobIndex,
                                          JobIndexGroup jobIndexGroup, bool isInquireable, Dictionary <PMSAdmin.Domain.Model.CustomFieldTypes.CustomFieldType, string> customFieldsDictionary, long clacLevel)
        {
            var sharedJobIndex = new SharedJobIndex(new SharedJobIndexId(adminJobIndex.Id.Id), adminJobIndex.Name,
                                                    adminJobIndex.DictionaryName);
            var jobIndex = new JobIndex(jobIndexRepository.GetNextId(), Period, sharedJobIndex, jobIndexGroup,
                                        isInquireable, clacLevel);
            var sharedCustomFieldsDic =
                customFieldsDictionary.ToDictionary(
                    c =>
                    new SharedJobIndexCustomField(new SharedJobIndexCustomFieldId(c.Key.Id.Id), c.Key.Name,
                                                  c.Key.DictionaryName, c.Key.MinValue, c.Key.MaxValue),
                    c => c.Value);

            jobIndex.UpdateCustomFields(sharedCustomFieldsDic);
            jobIndexRepository.Add(jobIndex);
            jobIndices.Add(jobIndex);
        }