コード例 #1
0
 /// <param name="context">bad in normal code, but well, this is an example so random data preparation simplification</param>
 private static void NewDeviationDtoDecorator(IRepo <DeviationShard> repo, DeviationShard x, dynamic context)
 {
     x.DeviationType = DeviationTypes[repo.Rng.Next(DeviationTypes.Length)];
     x.DutyId        = context.duty.Id;
     x.Start         = context.duty.Start;
     x.End           = context.duty.End;
 }
コード例 #2
0
 public DeviationModel(DeviationShard shard)
 {
     this.Id            = shard.Id;
     this.DutyId        = shard.DutyId;
     this.DeviationId   = shard.DeviationId;
     this.DeviationType = shard.DeviationType;
     this.Start         = shard.Start;
     this.End           = shard.End;
 }
コード例 #3
0
        private void HandleLoadDutyplanRequest(ApiRequestContext <LoadDutyplanRequest, long[]> requestContext)
        {
            ApiResponse <LoadDutyplanRequest, DutyShard[]> response = this.ExecuteMeasuredApiRequest(
                requestContext.Request,
                request =>
            {
                // create random data and some dummy time waste
                // each employment has at least one duty one day in range of requested dutyplan.
                // additionally, there can be up to 2 deviations (with zero). simplification for later steps like normtime, absence and validation to work anyhow.
                var duties = new List <DutyShard>();

                DateTime from = requestContext.Request.From.Date;
                DateTime to   = requestContext.Request.To.Date;

                foreach (long employmentId in requestContext.Context)
                {
                    var stamp = from;

                    while (stamp <= to)
                    {
                        DutyShard duty = this.Repo.Get(new { employmentId, stamp });
                        var deviations = new List <DeviationShard>();

                        for (int j = 0; j < this.Rng.Next(2); j++)
                        {
                            DeviationShard deviation = this.repoDeviation.Get(new { duty });

                            deviations.Add(deviation);
                        }

                        duty.Deviations = deviations.ToArray();
                        duties.Add(duty);

                        // send back
                        requestContext.Origin.Tell(new ApiResponse <LoadDutyplanRequest, DutyShard[]>(
                                                       request,
                                                       success: true,
                                                       new[] { duty }));

                        stamp = stamp.AddDays(1);
                    }
                }

                return(duties.ToArray());
            },
                this.CallerName(requestContext.Request.Id));

            // send info to sender
            this.Sender.Tell(response);
        }