Пример #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;
     }
 }
Пример #2
0
        public SubordinatesResultDTO GetTrainingNeedEmployeeInFieldInPeriod(long periodIdParam, long jobindexId)
        {
            var periodId = new PeriodId(periodIdParam);
            var period   = periodRep.GetById(periodId);
            var res      = new SubordinatesResultDTO
            {
                PeriodName     = period.Name,
                PeriodTimeLine = "از تاریخ " + PDateHelper.GregorianToHijri(period.StartDate, false) + " تا تاریخ " + PDateHelper.GregorianToHijri(period.EndDate.Date, false),
                //TotalUnitPoint = finalUnitPoint == null ? (0).ToString() : finalUnitPoint.Value.ToString(CultureInfo.InvariantCulture),
                Subordinates = new List <EmployeeResultDTO>()
            };
            var calculation = calculationRepository.GetDeterministicCalculation(period);
            var employeeIds = jobIndexPointRepository.GetJobIndexPointByLimitPoint(calculation.Id, 50).Where(j => j.JobIndexId.Id == jobindexId).Select(j => j.EmployeeId);

            foreach (var employeeId in employeeIds)
            {
                var employee            = employeeRepository.GetBy(employeeId);
                var employeeIndexPoints = jobIndexPointRepository.GetBy(calculation.Id, employee.Id);
                var employeeResult      = new EmployeeResultDTO
                {
                    EmployeeFullName = employee.FullName,
                    EmployeeNo       = employeeId.EmployeeNo,

                    //EmployeeJobPositionName = jobPositionNames,
                    TotalPoint = employee.FinalPoint.ToString(CultureInfo.InvariantCulture),
                };
                res.Subordinates.Add(employeeResult);
            }

            return(res);
        }
Пример #3
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;
     }
 }
        public Task <IReadOnlyList <IPeriodOperation> > SearchOperation(string filter)
        {
            if (filter.IsEmpty())
            {
                return(Task.FromResult((IReadOnlyList <IPeriodOperation>) new List <IPeriodOperation>()));
            }

            var filterElements = filter.Split(new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            return(Task.FromResult((IReadOnlyList <IPeriodOperation>)filterElements
                                   .Aggregate(_operations.SelectMany(a => a.Value).ToList(), Filter)));

            List <IPeriodOperation> Filter(IReadOnlyList <IPeriodOperation> operations, string filterCriteria)
            {
                return(operations
                       .Where(operation => operation.Label.Match(filterCriteria) ||
                              operation.Amount.ToString(frCulture).Match(filterCriteria) ||
                              operation.Pair.Match(filterCriteria) ||
                              PeriodId.From(operation.PeriodId).ToPeriodName().ToString().Split(' ')[0].Match(filterCriteria) ||
                              operation.Category.Match(filterCriteria) ||
                              operation.Type.Match(filterCriteria))
                       .ToList());
            }

            double GetNumber(string source)
            => double.TryParse(source, out var result)
                    ? result
                    : -1;
        }
Пример #5
0
        public void be_equatable()
        {
            var id1 = PeriodId.From(2, 2019);
            var id2 = PeriodId.From(PeriodName.From(2, 2019));

            id1.Should().Be(id2);
        }
Пример #6
0
 public JobIndexGroup AddJobIndexGroup(PeriodId periodId, AbstractJobIndexId parentId, string name,
                                       string dictionaryName)
 {
     try
     {
         using (var tr = new TransactionScope())
         {
             var           id     = jobIndexRep.GetNextId();
             var           period = periodRep.GetById(periodId);
             JobIndexGroup parent = null;
             if (parentId != null)
             {
                 parent = jobIndexRep.GetJobIndexGroupById(new AbstractJobIndexId(parentId.Id));
             }
             var jobIndexGroup = new JobIndexGroup(id, period, parent, name, dictionaryName);
             jobIndexRep.Add(jobIndexGroup);
             tr.Complete();
             return(jobIndexGroup);
         }
     }
     catch (Exception exp)
     {
         var res = jobIndexRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
Пример #7
0
        protected CalculationPoint(CalculationPointId id, Period period, Calculation calculation,
                                   string name, decimal value, bool isFinal = false) : base()
        {
            this.value = value;
            if (id == null)
            {
                throw new ArgumentNullException("calculationPointId");
            }
            this.id = id;

            if (period == null || period.Id == null)
            {
                throw new ArgumentNullException("period");
            }
            this.periodId = period.Id;

            if (calculation == null || calculation.Id == null)
            {
                throw new ArgumentNullException("employee");
            }
            this.calculationId = calculation.Id;

            this.isFinal = isFinal;
            this.name    = name;
        }
Пример #8
0
        public void be_created_from_periodName()
        {
            var periodName = PeriodName.From(1, 2018);
            var periodId   = PeriodId.From(periodName);

            periodId.Value.Should().Be("2018-01");
        }
Пример #9
0
        public Claim(ClaimId claimId, Period period, string employeeNo, string title, DateTime claimDate,
                     ClaimTypeEnum claimTypeId, string request)
        {
            period.CheckAddClaim();

            if (claimId == null)
            {
                throw new ArgumentNullException("claimId");
            }
            if (period == null)
            {
                throw new ArgumentNullException("period");
            }

            id            = claimId;
            this.periodId = period.Id;
            if (string.IsNullOrWhiteSpace(employeeNo))
            {
                throw new ClaimArgumentException("Claim", "EmployeeNo");
            }
            this.employeeNo  = employeeNo;
            this.title       = title;
            this.claimDate   = claimDate;
            this.claimTypeId = claimTypeId;
            this.request     = request;
            state            = new ClaimOpenedState();
        }
Пример #10
0
 public Employee Add(PeriodId periodId, string personnelNo, string firstName, string lastName, Dictionary <SharedEmployeeCustomFieldId, string> customFieldIds)
 {
     try
     {
         using (var tr = new TransactionScope())
         {
             var period = periodRep.GetById(periodId);
             var employeeCustomFields = converter.GetSharedEmployeeCustomField(customFieldIds.Keys.ToList());
             var employee             = new Employee(personnelNo, period, firstName, lastName,
                                                     employeeCustomFields.ToDictionary(e => e, e => customFieldIds[e.Id]));
             employeeRep.Add(employee);
             tr.Complete();
             return(employee);
         }
     }
     catch (Exception exp)
     {
         var res = employeeRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
 public void RemoveOperation(PeriodId periodId, OperationId operationId)
 {
     if (_operations.ContainsKey(periodId.Value))
     {
         _operations[periodId.Value].RemoveAll(o => o.OperationId == operationId.Value);
     }
 }
Пример #12
0
 public AddSpending(PeriodId periodId, Amount amount, Label label, Pair pair, SpendingCategory category)
 {
     PeriodId = periodId;
     Amount   = amount;
     Label    = label;
     Pair     = pair;
     Category = category;
 }
Пример #13
0
        public decimal GetEmployeeFinalPointBy(PeriodId periodId, string employeeNo, CalculationId calculationId)
        {
            var employeePoint =
                repEmp.Find(e => e.PeriodId == periodId && e.CalculationId == calculationId && e.IsFinal && e.EmployeeId.EmployeeNo == employeeNo)
                .SingleOrDefault();

            return(employeePoint == null ? 0 : employeePoint.Value);
        }
Пример #14
0
 public AddRecipe(PeriodId periodId, Amount amount, Label label, Pair pair, RecipeCategory category)
 {
     PeriodId = periodId;
     Amount   = amount;
     Label    = label;
     Pair     = pair;
     Category = category;
 }
        public Task <IReadOnlyList <IPeriodOperation> > GetAllOperation(PeriodId periodId)
        {
            IReadOnlyList <IPeriodOperation> result = _operations.ContainsKey(periodId.Value)
                ? _operations[periodId.Value]
                : new List <IPeriodOperation>();

            return(Task.FromResult(result));
        }
Пример #16
0
 public ChangeSpending(PeriodId periodId, OperationId operationId, Amount amount = null, Label label = null, Pair pair = null, SpendingCategory category = null)
 {
     PeriodId = periodId;
     OperationId = operationId;
     Amount = amount;
     Label = label;
     Pair = pair;
     Category = category;
 }
Пример #17
0
 public void CompleteCopyingBasicData(PeriodId periodId, PeriodState preState)
 {
     using (var scope = new TransactionScope())
     {
         var period = periodRep.GetById(periodId);
         period.CompleteCopyingBasicData(periodManagerService, preState);
         scope.Complete();
     }
 }
Пример #18
0
 public void CompleteInquiry(PeriodId periodId)
 {
     using (var scope = new TransactionScope())
     {
         var period = periodRep.GetById(periodId);
         period.CompleteInquiry(periodManagerService);
         scope.Complete();
     }
 }
Пример #19
0
 public void StartConfirmation(PeriodId periodId)
 {
     using (var scope = new TransactionScope())
     {
         var period = periodRep.GetById(periodId);
         period.StartConfirmation(periodManagerService);
         scope.Complete();
     }
 }
Пример #20
0
 public async Task <IActionResult> AddRecipe([FromBody] NewRecipe input)
 {
     return(await SendCommandAsync(new AddRecipe(
                                       PeriodId.From(input.PeriodId),
                                       Amount.From(input.Amount),
                                       Label.From(input.Label),
                                       Pair.From(input.Pair),
                                       RecipeCategory.From(input.Category))));
 }
Пример #21
0
 public List <JobId> GetAllJobIdList(PeriodId periodId)
 {
     using (var tr = new TransactionScope())
     {
         var jobId = jobRep.GetAllJobIdList(periodId);
         tr.Complete();
         return(jobId);
     }
 }
Пример #22
0
 public async Task <IActionResult> AddSpending([FromBody] Spending input)
 {
     return(await SendCommandAsync(new AddSpending(
                                       PeriodId.From(input.PeriodId),
                                       Amount.From(input.Amount),
                                       Label.From(input.Label),
                                       Pair.From(input.Pair),
                                       SpendingCategory.From(input.Category))));
 }
Пример #23
0
 public void FinishClaiming(PeriodId periodId)
 {
     using (var scope = new TransactionScope())
     {
         var period = periodRep.GetById(periodId);
         period.FinishClaiming(periodManagerService);
         scope.Complete();
     }
 }
Пример #24
0
 public async Task <IActionResult> ChangeRecipe([FromBody] UpdateRecipe input)
 {
     return(await SendCommandAsync(new ChangeRecipe(
                                       PeriodId.From(input.PeriodId),
                                       OperationId.From(input.OperationId),
                                       Amount.From(input.Amount),
                                       Label.From(input.Label),
                                       Pair.From(input.Pair),
                                       RecipeCategory.From(input.Category))));
 }
 public List <InquiryJobIndexPoint> GetAllBy(PeriodId periodId, EmployeeId inquirerEmployeeId, AbstractJobIndexId jobIndexId)
 {
     return
         (rep.Find(
              i =>
              i.ConfigurationItemId.InquirerId.PeriodId == periodId &&
              i.ConfigurationItemId.InquirerId.EmployeeNo == inquirerEmployeeId.EmployeeNo &&
              i.JobIndexId == jobIndexId)
          .ToList());
 }
Пример #26
0
 public InquiryInitializingProgress GetPeriodInitializeInquiryState(PeriodId periodId)
 {
     using (var scope = new TransactionScope())
     {
         var period = periodRep.GetById(periodId);
         var res    = period.GetInitializeInquiryProgress(periodManagerService);
         scope.Complete();
         return(res);
     }
 }
Пример #27
0
 public BasicDataCopyingProgress GetPeriodCopyingStateProgress(PeriodId periodId)
 {
     using (var scope = new TransactionScope())
     {
         var period = periodRep.GetById(periodId);
         var res    = period.GetCopyingStateProgress(periodManagerService);
         scope.Complete();
         return(res);
     }
 }
Пример #28
0
        public void ChangePeriodActiveStatus(PeriodId periodId, bool active)
        {
            using (var scope = new TransactionScope())
            {
                var period = periodRep.GetById(periodId);
                setInitData(period);
                period.ChangeActiveStatus(periodManagerService, active);

                scope.Complete();
            }
        }
Пример #29
0
        public AbstractUnitIndex(AbstractUnitIndexId abstractUnitIndexId, PeriodId periodId)
        {
            if (abstractUnitIndexId == null)
            {
                throw new ArgumentNullException("abstractUnitIndexId");
            }
            if (periodId == null)
            {
                throw new ArgumentNullException("periodId");
            }

            id            = abstractUnitIndexId;
            this.periodId = periodId;
        }
Пример #30
0
        public IEnumerable <JobPositionInPeriodDTO> GetJobPositions(long periodIdParam)
        {
            var periodId     = new PeriodId(periodIdParam);
            var jobPositions = jobPositionRep.GetJobPositions(periodId);
            var res          = jobPositions.Select(u => jobPositionInPeriodDTOMapper.MapToModel(u)).ToList();

            res.ForEach(d =>
            {
                d.UnitName = _unitRepository.GetBy(new UnitId(periodId, new SharedUnitId(d.Unitid))).Name;
                d.JobName  = _jobRepository.GetById(new JobId(periodId, new SharedJobId(d.JobId))).Name;
                d.Name    += "-" + d.UnitName;
            });
            return(res);
        }