Exemple #1
0
        public async Task CreateTracking(string username, TrackingDto trackingDto)
        {
            var user    = Unit.All <Entity.User>().FirstOrDefault(u => u.Name == username);
            var project = await Unit.Repo <Entity.Project, INamedRepository <Entity.Project> >().FindOrCreateAsync(trackingDto.ProjectName);

            var task = await Unit.Repo <Entity.Task, INamedRepository <Entity.Task> >().FindOrCreateAsync(trackingDto.TaskName, t =>
            {
                t.Project     = project;
                t.Description = trackingDto.TaskDescription;
                t.Type        = trackingDto.TaskType;
            });

            var tracking = new Entity.Tracking
            {
                Task      = task,
                AsOfDate  = trackingDto.TrackingDate,
                RangeFrom = trackingDto.StartTime.ToSpan(),
                RangeTo   = trackingDto.EndTime.ToSpan(),
                User      = user
            };
            var repo = Unit.Repo <Entity.Tracking>();

            repo.Create(tracking);
            await repo.Commit();
        }
        public async Task <ActionResult <TrackingDto> > DeleteAsync(int trackingId)
        {
            TrackingDto tracking = _trackingApplicationServices.Delete(trackingId);
            await _signalRService.TrackingServerEvents.DeleteTracking(tracking);

            return(Ok(tracking));
        }
        public async Task <ActionResult <TrackingDto> > Update(int trackingId, [FromBody] TrackingDto tracking)
        {
            tracking = _trackingApplicationServices.Update(trackingId, tracking);
            await _signalRService.TrackingServerEvents.UpdateTracking(tracking);

            return(Ok(tracking));
        }
        public async Task <ActionResult <TrackingDto> > Update(int trackingId, [FromBody] JsonPatchDocument <TrackingDto> trackingPatch)
        {
            TrackingDto tracking = _trackingApplicationServices.UpdatePatch(trackingId, trackingPatch);
            await _signalRService.TrackingServerEvents.UpdateTracking(tracking);

            return(Ok(tracking));
        }
        public async Task <ActionResult <TrackingDto> > Insert([FromBody] TrackingDto tracking)
        {
            tracking = _trackingApplicationServices.Insert(tracking);
            await _signalRService.TrackingServerEvents.NewTracking(tracking);

            return(Ok(tracking));
        }
        public TrackingDto Update(TrackingDto tracking)
        {
            Tracking trackingUpdate = _context.Trackings.Where(w => w.TrackingId == tracking.TrackingId).FirstOrDefault();

            trackingUpdate = _mapper.Map <Tracking>(tracking);
            _context.Trackings.Update(trackingUpdate);
            _context.SaveChanges();

            return(_mapper.Map <TrackingDto>(trackingUpdate));
        }
        public TrackingDto GetByTrackingId(int trackingId)
        {
            TrackingDto tracking = _mapper.Map <TrackingDto>(_context.Trackings
                                                             .Include(t => t.Order).ThenInclude(o => o.Client)
                                                             .Include(t => t.TrackingStatus)
                                                             .Include(t => t.TrackingProducts).ThenInclude(tp => tp.Product)
                                                             .Where(w => w.TrackingId == trackingId).FirstOrDefault());

            tracking.Total = tracking.TrackingProducts.Sum(tp => tp.Product.Price);

            return(tracking);
        }
        public TrackingDto UpdatePatch(int trackingId, JsonPatchDocument <TrackingDto> trackingPatch)
        {
            Tracking    trackingUpdate    = _context.Trackings.Where(w => w.TrackingId == trackingId).FirstOrDefault();
            TrackingDto trackingUpdateDto = _mapper.Map <TrackingDto>(trackingUpdate);

            trackingPatch.ApplyTo(trackingUpdateDto);
            _mapper.Map(trackingUpdateDto, trackingUpdate);

            //_context.Trackings.Update(trackingUpdate);
            _context.SaveChanges();

            return(_mapper.Map <TrackingDto>(trackingUpdate));
        }
        public TrackingDto Insert(TrackingDto tracking)
        {
            Tracking trackingCreate = new Tracking();

            try
            {
                _mapper.Map(tracking, trackingCreate);
                _context.Trackings.Add(trackingCreate);
                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(_mapper.Map <TrackingDto>(trackingCreate));
        }
Exemple #10
0
        public async Task <TrackingDto> GetShipmentTracking(GetShipmentTrackingInput input)
        {
            var resultDto = new TrackingDto()
            {
                Status = ShippingStatus.NotYetShipped.GetLocalizedEnum(_localizationManager)
            };

            Shipment shipment = null;

            if (input.OrderId.HasValue && input.OrderId > 0)
            {
                var order = await _orderManager.GetByIdAsync(input.OrderId.Value);

                if (order != null)
                {
                    await _orderManager.OrderRepository.EnsureCollectionLoadedAsync(order, t => t.Shipments);

                    shipment = order.Shipments.FirstOrDefault();
                }
            }
            else
            {
                shipment = await _shipmentManager.GetByIdAsync(input.ShipmentId.Value);
            }

            if (await IsShippingSettingAvailable())
            {
                return(resultDto);
            }

            var traces = await _shipmentTracker.GetShipmentTracesAsync(shipment, input.Refresh);

            resultDto.Status = ((ShippingStatus)traces.State).GetLocalizedEnum(_localizationManager);
            resultDto.Traces = traces.Traces.Select(t =>
            {
                return(new TrackingItemDto()
                {
                    Station = t.AcceptStation,
                    Time = t.AcceptTime,
                    Remark = t.Remark
                });
            }).ToList();

            return(resultDto);
        }
Exemple #11
0
        public static XLWorkbook ExportaTracking(TrackingDto data, string filtro, string valor)
        {
            if (!Directory.Exists(@"C:\Templates"))
            {
                if (!File.Exists(@"C:\Templates\TrackingList.xlsx"))
                {
                    return(null);
                }
            }

            XLWorkbook book  = new XLWorkbook(@"C:\Templates\TrackingList.xlsx");
            var        hojaE = book.Worksheet("Entry List");
            int        index = 7;

            hojaE.Cell("B3").Value = filtro;
            hojaE.Cell("B4").Value = DateTime.Now.Date;
            hojaE.Cell("C3").Value = valor;

            foreach (var item in data.EntryList)
            {
                hojaE.Cell("A" + index).Value  = item.Euid;
                hojaE.Cell("B" + index).Value  = item.Year;
                hojaE.Cell("C" + index).Value  = item.Country;
                hojaE.Cell("D" + index).Value  = item.Location;
                hojaE.Cell("E" + index).Value  = item.Rng;
                hojaE.Cell("F" + index).Value  = item.Plt;
                hojaE.Cell("G" + index).Value  = item.Ent;
                hojaE.Cell("H" + index).Value  = item.ExpName;
                hojaE.Cell("I" + index).Value  = item.ProjectLead;
                hojaE.Cell("J" + index).Value  = item.Cc;
                hojaE.Cell("K" + index).Value  = item.Crop;
                hojaE.Cell("L" + index).Value  = item.Obs;
                hojaE.Cell("M" + index).Value  = item.ProjectCode;
                hojaE.Cell("N" + index).Value  = item.GmoEvent;
                hojaE.Cell("O" + index).Value  = item.Sag;
                hojaE.Cell("P" + index).Value  = item.CodInternacion;
                hojaE.Cell("Q" + index).Value  = item.Client;
                hojaE.Cell("R" + index).Value  = item.EntName;
                hojaE.Cell("S" + index).Value  = item.EntRole;
                hojaE.Cell("T" + index).Value  = item.ResImportacion;
                hojaE.Cell("U" + index).Value  = item.GranosHilera;
                hojaE.Cell("V" + index).Value  = item.Bi1;
                hojaE.Cell("W" + index).Value  = item.Bi2;
                hojaE.Cell("X" + index).Value  = item.Bi3;
                hojaE.Cell("Y" + index).Value  = item.Bi4;
                hojaE.Cell("Z" + index).Value  = item.Owner;
                hojaE.Cell("AA" + index).Value = item.CodPermanencia;
                hojaE.Cell("AB" + index).Value = item.LotId;
                index++;
            }

            var hoja = book.Worksheet("Tracking");

            index = 7;

            hoja.Cell("B3").Value = filtro;
            hoja.Cell("B4").Value = DateTime.Now.Date;
            hoja.Cell("C3").Value = valor;

            foreach (var item in data.Info)
            {
                hoja.Cell("A" + index).Value = item.euid;
                hoja.Cell("B" + index).Value = item.indEuid;
                hoja.Cell("C" + index).Value = item.year;
                hoja.Cell("D" + index).Value = item.country;
                hoja.Cell("E" + index).Value = item.location;
                hoja.Cell("F" + index).Value = item.order;
                hoja.Cell("G" + index).Value = item.breedersCode1;
                hoja.Cell("H" + index).Value = item.breedersCode2;
                hoja.Cell("I" + index).Value = item.breedersCode3;
                hoja.Cell("J" + index).Value = item.breedersCode4;
                hoja.Cell("K" + index).Value = item.rng;
                hoja.Cell("L" + index).Value = item.ent;
                hoja.Cell("M" + index).Value = item.opExpName;
                hoja.Cell("N" + index).Value = item.projecLead;
                hoja.Cell("O" + index).Value = item.cc;
                hoja.Cell("P" + index).Value = item.shipTo;
                hoja.Cell("Q" + index).Value = item.crop;
                hoja.Cell("R" + index).Value = item.obs;
                hoja.Cell("S" + index).Value = item.projectCode;
                hoja.Cell("T" + index).Value = item.gmoEvent;
                hoja.Cell("U" + index).Value = item.sag;
                hoja.Cell("V" + index).Value = item.codInternacion;
                hoja.Cell("W" + index).Value = item.codReception;
                hoja.Cell("X" + index).Value = item.client;
                index++;
            }

            //Rogging
            var hojaR = book.Worksheet("Rogging");

            hojaR.Cell("B3").Value = filtro;
            hojaR.Cell("B4").Value = DateTime.Now.Date;
            hojaR.Cell("C3").Value = valor;
            index = 7;
            if (data.Rogging != null)
            {
                foreach (var item in data.Rogging)
                {
                    hojaR.Cell("A" + index).Value  = item.Euid;
                    hojaR.Cell("B" + index).Value  = item.FechaRogging;
                    hojaR.Cell("C" + index).Value  = item.Reason;
                    hojaR.Cell("D" + index).Value  = item.Year;
                    hojaR.Cell("E" + index).Value  = item.Country;
                    hojaR.Cell("F" + index).Value  = item.Location;
                    hojaR.Cell("G" + index).Value  = item.Rng;
                    hojaR.Cell("H" + index).Value  = item.Plt;
                    hojaR.Cell("I" + index).Value  = item.Ent;
                    hojaR.Cell("J" + index).Value  = item.ExpName;
                    hojaR.Cell("K" + index).Value  = item.ProjectLead;
                    hojaR.Cell("L" + index).Value  = item.Cc;
                    hojaR.Cell("M" + index).Value  = item.Crop;
                    hojaR.Cell("N" + index).Value  = item.Obs;
                    hojaR.Cell("O" + index).Value  = item.ProjectCode;
                    hojaR.Cell("P" + index).Value  = item.GmoEvent;
                    hojaR.Cell("Q" + index).Value  = item.Sag;
                    hojaR.Cell("R" + index).Value  = item.CodInternacion;
                    hojaR.Cell("S" + index).Value  = item.Client;
                    hojaR.Cell("T" + index).Value  = item.EntName;
                    hojaR.Cell("U" + index).Value  = item.EntRole;
                    hojaR.Cell("V" + index).Value  = item.ResImportacion;
                    hojaR.Cell("W" + index).Value  = item.GranosHilera;
                    hojaR.Cell("X" + index).Value  = item.Bi1;
                    hojaR.Cell("Y" + index).Value  = item.Bi2;
                    hojaR.Cell("Z" + index).Value  = item.Bi3;
                    hojaR.Cell("AA" + index).Value = item.Bi4;
                    hojaR.Cell("AB" + index).Value = item.Owner;
                    hojaR.Cell("AC" + index).Value = item.CodPermanencia;
                    hojaR.Cell("AD" + index).Value = item.LotId;
                    index++;
                }
            }

            //Cosecha
            var hoja2 = book.Worksheet("Cosecha");

            hoja2.Cell("B3").Value = filtro;
            hoja2.Cell("B4").Value = DateTime.Now.Date;
            hoja2.Cell("C3").Value = valor;
            index = 7;
            if (data.Cosecha != null)
            {
                foreach (var item in data.Cosecha)
                {
                    hoja2.Cell("A" + index).Value = item.Euid;
                    hoja2.Cell("B" + index).Value = item.FechaCosecha;
                    hoja2.Cell("C" + index).Value = item.Bin;
                    hoja2.Cell("D" + index).Value = item.order;
                    hoja2.Cell("E" + index).Value = item.breedersCode1;
                    hoja2.Cell("F" + index).Value = item.breedersCode2;
                    hoja2.Cell("G" + index).Value = item.breedersCode3;
                    hoja2.Cell("H" + index).Value = item.breedersCode4;
                    hoja2.Cell("I" + index).Value = item.crop;
                    hoja2.Cell("J" + index).Value = item.client;
                    hoja2.Cell("K" + index).Value = item.projecLead;
                    hoja2.Cell("L" + index).Value = item.location;
                    hoja2.Cell("M" + index).Value = item.opExpName;
                    hoja2.Cell("N" + index).Value = item.gmoEvent;
                    hoja2.Cell("O" + index).Value = item.sag;
                    index++;
                }
            }

            //Secado
            var hoja3 = book.Worksheet("Secado");

            hoja3.Cell("B3").Value = filtro;
            hoja3.Cell("B4").Value = DateTime.Now.Date;
            hoja3.Cell("C3").Value = valor;
            index = 7;
            if (data.Secado != null)
            {
                foreach (var item in data.Secado)
                {
                    hoja3.Cell("A" + index).Value = item.euid;
                    hoja3.Cell("B" + index).Value = item.fechaInicio;
                    hoja3.Cell("C" + index).Value = item.fechaTermino;
                    hoja3.Cell("D" + index).Value = item.cajaSecador;
                    hoja3.Cell("E" + index).Value = item.order;
                    hoja3.Cell("F" + index).Value = item.breedersCode1;
                    hoja3.Cell("G" + index).Value = item.breedersCode2;
                    hoja3.Cell("H" + index).Value = item.breedersCode3;
                    hoja3.Cell("I" + index).Value = item.breedersCode4;
                    hoja3.Cell("J" + index).Value = item.crop;
                    hoja3.Cell("K" + index).Value = item.client;
                    hoja3.Cell("L" + index).Value = item.projecLead;
                    hoja3.Cell("M" + index).Value = item.location;
                    hoja3.Cell("N" + index).Value = item.opExpName;
                    hoja3.Cell("O" + index).Value = item.gmoEvent;
                    hoja3.Cell("P" + index).Value = item.sag;
                    index++;
                }
            }

            //Desgrane
            var hoja4 = book.Worksheet("Desgrane");

            hoja4.Cell("B3").Value = filtro;
            hoja4.Cell("B4").Value = DateTime.Now.Date;
            hoja4.Cell("C3").Value = valor;
            index = 7;
            if (data.Desgrane != null)
            {
                foreach (var item in data.Desgrane)
                {
                    hoja4.Cell("A" + index).Value = item.euid;
                    hoja4.Cell("B" + index).Value = item.fecha;
                    hoja4.Cell("C" + index).Value = item.sheller;
                    hoja4.Cell("D" + index).Value = item.shelling;
                    hoja4.Cell("E" + index).Value = item.instructions;
                    hoja4.Cell("F" + index).Value = item.order;
                    hoja4.Cell("G" + index).Value = item.breedersCode1;
                    hoja4.Cell("H" + index).Value = item.breedersCode2;
                    hoja4.Cell("I" + index).Value = item.breedersCode3;
                    hoja4.Cell("J" + index).Value = item.breedersCode4;
                    hoja4.Cell("K" + index).Value = item.crop;
                    hoja4.Cell("L" + index).Value = item.client;
                    hoja4.Cell("M" + index).Value = item.projecLead;
                    hoja4.Cell("N" + index).Value = item.location;
                    hoja4.Cell("O" + index).Value = item.opExpName;
                    hoja4.Cell("P" + index).Value = item.gmoEvent;
                    hoja4.Cell("Q" + index).Value = item.sag;
                    index++;
                }
            }

            //Packing
            var hoja5 = book.Worksheet("Packing");

            hoja5.Cell("B3").Value = filtro;
            hoja5.Cell("B4").Value = DateTime.Now.Date;
            hoja5.Cell("C3").Value = valor;
            index = 7;
            if (data.Packing != null)
            {
                foreach (var item in data.Packing)
                {
                    hoja5.Cell("A" + index).Value = item.euid;
                    hoja5.Cell("B" + index).Value = item.indEuid;
                    hoja5.Cell("C" + index).Value = item.fechaPacking;
                    hoja5.Cell("D" + index).Value = item.totalWeight;
                    hoja5.Cell("E" + index).Value = item.totalKernels;
                    hoja5.Cell("F" + index).Value = item.totalEars;
                    hoja4.Cell("G" + index).Value = item.shelling;
                    hoja4.Cell("H" + index).Value = item.instructions;
                    hoja4.Cell("I" + index).Value = item.targears;
                    hoja4.Cell("J" + index).Value = item.targetKern;
                    hoja4.Cell("K" + index).Value = item.targetWg;
                    hoja5.Cell("L" + index).Value = item.order;
                    hoja5.Cell("M" + index).Value = item.breedersCode1;
                    hoja5.Cell("N" + index).Value = item.breedersCode2;
                    hoja5.Cell("O" + index).Value = item.breedersCode3;
                    hoja5.Cell("P" + index).Value = item.breedersCode4;
                    hoja5.Cell("Q" + index).Value = item.crop;
                    hoja5.Cell("R" + index).Value = item.client;
                    hoja5.Cell("S" + index).Value = item.projecLead;
                    hoja5.Cell("T" + index).Value = item.location;
                    hoja5.Cell("U" + index).Value = item.opExpName;
                    hoja5.Cell("V" + index).Value = item.gmoEvent;
                    hoja5.Cell("W" + index).Value = item.sag;
                    index++;
                }
            }

            //Llenado
            var hoja6 = book.Worksheet("Cajas");

            hoja6.Cell("B3").Value = filtro;
            hoja6.Cell("B4").Value = DateTime.Now.Date;
            hoja6.Cell("C3").Value = valor;
            index = 7;
            if (data.Caja != null)
            {
                foreach (var item in data.Shipping)
                {
                    hoja6.Cell("A" + index).Value = item.euid;
                    hoja6.Cell("B" + index).Value = item.indEuid;
                    hoja6.Cell("C" + index).Value = item.fechaPreparacion;
                    hoja6.Cell("D" + index).Value = item.cajaEnvio;
                    hoja6.Cell("E" + index).Value = item.order;
                    hoja6.Cell("F" + index).Value = item.breedersCode1;
                    hoja6.Cell("G" + index).Value = item.breedersCode2;
                    hoja6.Cell("H" + index).Value = item.breedersCode3;
                    hoja6.Cell("I" + index).Value = item.breedersCode4;
                    hoja6.Cell("J" + index).Value = item.crop;
                    hoja6.Cell("K" + index).Value = item.client;
                    hoja6.Cell("L" + index).Value = item.projecLead;
                    hoja6.Cell("M" + index).Value = item.location;
                    hoja6.Cell("N" + index).Value = item.opExpName;
                    hoja6.Cell("O" + index).Value = item.gmoEvent;
                    hoja6.Cell("P" + index).Value = item.sag;
                    index++;
                }
            }

            //Envio
            var hoja7 = book.Worksheet("Envío");

            hoja7.Cell("B3").Value = filtro;
            hoja7.Cell("B4").Value = DateTime.Now.Date;
            hoja7.Cell("C3").Value = valor;
            index = 7;
            if (data.Caja != null)
            {
                foreach (var item in data.Caja)
                {
                    hoja7.Cell("A" + index).Value = item.shipTo;
                    hoja7.Cell("B" + index).Value = item.cajaEnvio;
                    hoja7.Cell("C" + index).Value = item.creacion;
                    hoja7.Cell("D" + index).Value = item.envio;
                    hoja7.Cell("E" + index).Value = item.shipmentCode;
                    hoja7.Cell("F" + index).Value = item.pesoNeto;
                    hoja7.Cell("G" + index).Value = item.pesoBruto;
                    index++;
                }
            }

            return(book);
        }
Exemple #12
0
 public async Task NewTracking(TrackingDto tracking)
 {
     await Clients.All.NewTracking(tracking);
 }
Exemple #13
0
 public TrackingDto Insert(TrackingDto tracking)
 {
     return(_trackingRepository.Insert(tracking));
 }
Exemple #14
0
 public TrackingDto Update(int trackingId, TrackingDto tracking)
 {
     tracking.TrackingId = trackingId;
     return(_trackingRepository.Update(tracking));
 }
Exemple #15
0
 public async Task DeleteTracking(TrackingDto tracking)
 {
     await _hubConnection.InvokeAsync("DeleteTracking", tracking);
 }
Exemple #16
0
 public async Task NewTracking(TrackingDto tracking)
 {
     await _hubConnection.InvokeAsync("NewTracking", tracking);
 }
Exemple #17
0
 public async Task UpdateTracking(TrackingDto tracking)
 {
     await Clients.All.UpdateTracking(tracking);
 }
Exemple #18
0
 public async Task Post([FromBody] TrackingDto trackingDto)
 {
     await _service.CreateTracking(User.FindFirst(ClaimTypes.Name).Value, trackingDto);
 }
Exemple #19
0
 public async Task DeleteTracking(TrackingDto tracking)
 {
     await Clients.All.DeleteTracking(tracking);
 }