Пример #1
0
        public ManifestEntity Execute()
        {
            _DbContext.BeginTransaction(); //TODO should be using WebDbContentProvider

            var now           = _DateTimeProvider.Now();
            var releaseCutoff = now - TimeSpan.FromHours(_GaenContentConfig.ManifestLifetimeHours);

            var e = _DbContext.ManifestContent
                    .Where(x => x.Release > releaseCutoff)
                    .OrderByDescending(x => x.Release)
                    .Take(1)
                    .SingleOrDefault();

            if (e != null)
            {
                return(e);
            }

            _DbContext.BulkDelete(_DbContext.Set <ManifestEntity>().ToList()); //TODO execute sql.
            var content = JsonConvert.SerializeObject(_ManifestBuilder.Execute());
            var bytes   = Encoding.UTF8.GetBytes(content);

            e = new ManifestEntity
            {
                Release         = now,
                ContentTypeName = ContentHeaderValues.Json,
                Content         = bytes,
            };
            e.PublishingId = _PublishingId.Create(e.Content);
            _DbContext.ManifestContent.Add(e);
            _DbContext.SaveAndCommit();

            return(e);
        }
Пример #2
0
 public bool Put(int id, [FromBody] ManifestEntity manifestEntity)
 {
     if (id > 0)
     {
         return(_manifestServices.UpdateManifestEntity(id, manifestEntity));
     }
     return(false);
 }
Пример #3
0
        /// <inheritdoc/>
        public List <ManifestEntity> ExtractEntities(IConduitAssembly assembly)
        {
            if (!_initialized)
            {
                throw new InvalidOperationException("Assembly Miner not initialized");
            }

            var entities = new List <ManifestEntity>();

            var enums = assembly.GetEnumTypes();

            foreach (var enumType in enums)
            {
                var enumUnderlyingType = Enum.GetUnderlyingType(enumType);
                Debug.Log(enumType.Name);
                Array enumValues;
                try
                {
                    if (enumType.GetCustomAttributes(typeof(ConduitEntityAttribute), false).Length == 0)
                    {
                        // This is not a tagged entity.
                        // TODO: In these cases we should only include the enum if it's referenced by any of the actions.
                    }

                    enumValues = enumType.GetEnumValues();
                }
                catch (Exception e)
                {
                    Debug.Log($"Failed to get enumeration values. {e}");
                    continue;
                }

                var entity = new ManifestEntity
                {
                    ID   = $"{enumType.Name}",
                    Type = "Enum",
                    Name = $"{enumType.Name}"
                };

                var values = new List <string>();

                foreach (var enumValue in enumValues)
                {
                    object underlyingValue = Convert.ChangeType(enumValue, enumUnderlyingType);
                    Debug.Log($"{enumValue} = {underlyingValue}");
                    values.Add(enumValue.ToString() ?? string.Empty);
                }

                entity.Values = values;
                entities.Add(entity);
            }

            return(entities);
        }
 public int CreateManifest(ManifestEntity manifestEntity)
 {
     using (var scope = new TransactionScope())
     {
         Mapper.CreateMap <Manifest, ManifestEntity>();
         var manifest = Mapper.Map <ManifestEntity, Manifest>(manifestEntity);
         _unitOfWork.ManifestRepository.Insert(manifest);
         _unitOfWork.Save();
         scope.Complete();
         return(manifest.Id);
     }
 }
Пример #5
0
        public async Task <ManifestEntity?> Execute()
        {
            var e = new ManifestEntity
            {
                Release = _DateTimeProvider.Now(),
            };
            var content   = _ManifestBuilder.Execute();
            var formatter = new StandardContentEntityFormatter(new ZippedSignedContentFormatter(_ContentSigner), new StandardPublishingIdFormatter());
            await formatter.Fill(e, content);

            return(e);
        }
Пример #6
0
        private ShipmentEntity convertFromManifest(ManifestEntity manifest)
        {
            ShipmentEntity shipment = new ShipmentEntity();

            shipment.ShipmentId    = manifest.ShipmentNo;
            shipment.BoxId         = currentBoxIdInt;
            shipment.DateCreated   = DateTime.Now;
            shipment.WarehouseId   = FormLogin.mWarehouse.Id;
            shipment.EmployeeId    = currentEmployee.Id;
            shipment.NumberPackage = manifest.Quantity;
            shipment.Sender        = manifest.CompanyName;
            shipment.Address       = manifest.Address;
            shipment.Content       = manifest.Content;
            shipment.Destination   = manifest.Destination;
            shipment.Consignee     = manifest.Destination;
            shipment.Receiver      = manifest.ContactName;
            shipment.Weight        = manifest.Weight;
            shipment.Country       = manifest.Country;
            return(shipment);
        }
        public bool UpdateManifestEntity(int manifestId, ManifestEntity manifestEntity)
        {
            var success = false;

            if (manifestEntity != null)
            {
                using (var scope = new TransactionScope())
                {
                    var manifest = _unitOfWork.ManifestRepository.GetByID(manifestId);
                    if (manifest != null)
                    {
                        Manifest manifestNew = new Manifest();
                        manifestNew.MasterAirWayBill = manifestEntity.MasterAirWayBill;
                        manifestNew.Id = manifest.Id;
                        _unitOfWork.ManifestRepository.Update(manifest, manifestNew);
                        _unitOfWork.Save();
                        scope.Complete();
                        success = true;
                    }
                }
            }
            return(success);
        }
Пример #8
0
        private void txtShipmentIdOut_KeyDown(object sender, KeyEventArgs e)
        {
            string         shipmentinput = txtShipmentIdOut.Text.Trim().ToUpper();
            ShipmentEntity shipment      = new ShipmentEntity();

            try
            {
                if (e.KeyCode == Keys.Tab || e.KeyCode == Keys.Enter)
                {
                    if (String.IsNullOrEmpty(shipmentinput) || String.IsNullOrWhiteSpace(txtShipmentIdOut.Text))
                    {
                        return;
                    }
                    if (startProcessing)
                    {
                        return;
                    }
                    startProcessing = true;
                    #region Kiểm tra trùng trên lưới nhập
                    if (IsExistsOnTheGridView(grvShipmentListOut, shipmentinput))
                    {
                        beep7.Play();
                        txtShipmentIdOut.Enabled = false;
                        int             rowIndex = -1;
                        DataGridViewRow row      = grvShipmentListOut.Rows
                                                   .Cast <DataGridViewRow>()
                                                   .Where(r => r.Cells[0].Value.ToString().Equals(shipmentinput))
                                                   .First();
                        rowIndex = row.Index;
                        grvShipmentListOut.Rows[rowIndex].Selected = true;
                        MessageBox.Show("TRÙNG DỮ LIỆU TRÊN LƯỚI !!!\nBạn hãy kiểm tra dữ liệu vừa nhập!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        txtShipmentIdOut.Enabled = true;
                        txtShipmentIdOut.Text    = String.Empty;
                        txtShipmentNo.Text       = "";
                        txtShipmentIdOut.Focus();
                        startProcessing = false;
                        return;
                    }
                    #endregion
                    #region Kiểm tra trùng trên thùng đã xuất
                    if (_repositoryShipment.ShipmentOutExist(shipmentinput))
                    {
                        beep7.Play();
                        txtShipmentIdOut.Enabled = false;
                        MessageBox.Show("TRÙNG DỮ LIỆU TRÊN THÙNG ĐÃ XUẤT KHO !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtShipmentIdOut.Enabled = true;
                        txtShipmentIdOut.Text    = String.Empty;
                        txtShipmentNo.Text       = "";
                        txtShipmentIdOut.Focus();
                        startProcessing = false;
                        return;
                    }
                    #endregion
                    #region Kiểm tra vị trí thùng
                    if (_repositoryShipment.ShipmentExist(shipmentinput))
                    {
                        beep7.Play();
                        manifestnew = new ManifestEntity();
                        manifestnew = _repositoryShipment.GetManifestByShipmentNo(shipmentinput);
                        if (manifestnew.BoxID != cbbBoxIdOut.Text.Trim())
                        {
                            txtShipmentIdOut.Enabled = false;
                            if (MessageBox.Show("LẠC HƯỚNG THÙNG !!! \nDữ liệu bạn nhập có thể nằm ở thùng: " + manifestnew.BoxID + "(" + manifestnew.MasterAirWayBill + ")\nBạn có muốn tiếp tục không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                            {
                                txtShipmentIdOut.Enabled = true;
                                txtShipmentIdOut.Text    = String.Empty;
                                txtShipmentNo.Text       = "";
                                startProcessing          = false;
                                return;
                            }
                        }
                    }
                    #endregion
                    #region Kiểm tra hàng thông quan
                    if (!_shipmentOutServices.GetStatusCompletion(shipmentinput))
                    {
                        beep.Play();
                        txtShipmentIdOut.BackColor = Color.Tomato;
                        if (MessageBox.Show("Hàng chưa được phép thông quan. \nBạn có muốn tiếp tục không ?", "Hàng chưa được phép thông quan", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                        {
                            txtShipmentIdOut.Enabled = true;
                            startProcessing          = false;
                            txtShipmentIdOut.Text    = "";
                            txtShipmentIdOut.Focus();
                            txtShipmentNo.Text         = "";
                            txtShipmentIdOut.BackColor = Color.LightYellow;
                            return;
                        }
                        else
                        {
                            txtShipmentIdOut.BackColor = Color.LightYellow;
                        }
                    }
                    #endregion
                    try
                    {
                        //grvShipmentListOut.Rows.Add(grvShipmentListOut.Rows.Count + 1, shipmentinput, DateTime.Now, Math.Round(manifestnew.Weight, 3));
                        grvShipmentListOut.Rows.Insert(0, shipmentinput, DateTime.Now, Math.Round(manifestnew.Weight, 3));
                        // grvShipmentListOut.FirstDisplayedScrollingRowIndex = grvShipmentListOut.RowCount - 1;
                        grvShipmentListOut.FirstDisplayedScrollingRowIndex = 0;
                        lblShipmentScanedOut.Text = "" + grvShipmentListOut.Rows.Count;
                        numberShipmentOut++;
                        grvShipmentListOut.ClearSelection();
                        grvShipmentListOut.Rows[0].Selected = true;
                        //  grvShipmentListOut.Rows[grvShipmentListOut.Rows.Count - 1].Selected = true;
                        //  AddOneShipmentToGridView(grvShipmentListOut.Rows.Count + 1, shipmentexport, grvShipmentListOut);
                    }
                    catch
                    {
                        startProcessing = false;
                    }
                    ShipmentOutEntity shipmentOut = new ShipmentOutEntity();
                    shipmentOut.ShipmentId         = shipmentinput;
                    shipmentOut.BoxIdRef           = currentBoxOut.Id;
                    shipmentOut.BoxIdString        = currentBoxOut.BoxId;
                    shipmentOut.MasterBillId       = currentMasterOut.Id;
                    shipmentOut.MasterBillIdString = currentMasterOut.MasterAirwayBill;
                    shipmentOut.DateOut            = dtpNgayXuat.Value;
                    shipmentOut.DateCreated        = DateTime.Now;
                    shipmentOut.DateInt            = _repositoryShipment.DateToInt(DateTime.Now);
                    shipmentOut.EmployeeId         = currentEmployee.Id;
                    shipmentOut.WarehouseId        = FormLogin.mWarehouse.Id;
                    shipmentOut.Weight             = Math.Round(Convert.ToDouble(manifestnew.Weight), 3);
                    shipmentOut.DeclarationNo      = _shipmentOutServices.GetDeclarationNo(shipmentinput);
                    shipmentOut.DateOfCompletion   = _shipmentOutServices.GetDateOfCompletion(shipmentinput);
                    shipmentOut.Tel         = manifestnew.Tel;
                    shipmentOut.Address     = manifestnew.Address;
                    shipmentOut.ContactName = manifestnew.ContactName;
                    shipmentOut.CompanyName = manifestnew.CompanyName;
                    shipmentOut.Content     = manifestnew.Content;
                    shipmentOut.Country     = manifestnew.Country;
                    shipmentOut.Destination = manifestnew.Destination;
                    shipmentOut.Original    = manifestnew.Original;
                    shipmentOut.Quantity    = manifestnew.Quantity;
                    shipmentOut.TotalValue  = manifestnew.TotalValue;
                    _repositoryShipment.CreateShipmentOut(shipmentOut);
                    // SaveShipmentOut(grvShipmentListOut.Rows.Count, shipmentOut);
                    ding.Play();
                    txtShipmentIdOut.Text = String.Empty;
                    startProcessing       = false;
                }
                else
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                Ultilities.FileHelper.WriteLog(Ultilities.ExceptionLevel.Function, "txtShipmentIdOut_KeyDown", ex);
                return;
            }
        }
 public string Create(ManifestEntity e)
 => Create(e.Content);