Example #1
0
        private void _handleCargoEvent(CargoEvent @event)
        {
            if (@event.vessel == Constants.VEHICLE_SHIP)
            {
                cargoCarried = @event.cargocarried;
                if (@event.inventory != null)
                {
                    List <CargoInfo> infoList = @event.inventory.ToList();

                    // Remove strays from the manifest
                    foreach (Cargo inventoryCargo in inventory.ToList())
                    {
                        string    name = inventoryCargo.edname;
                        CargoInfo info = @event.inventory.FirstOrDefault(i => i.name.Equals(name, StringComparison.OrdinalIgnoreCase));
                        if (info == null)
                        {
                            if (inventoryCargo.haulageData?.Any() ?? false)
                            {
                                // Keep cargo entry in manifest with zeroed amounts, if missions are pending
                                inventoryCargo.haulage = 0;
                                inventoryCargo.owned   = 0;
                                inventoryCargo.stolen  = 0;
                                inventoryCargo.CalculateNeed();
                            }
                            else
                            {
                                // Strip out the stray from the manifest
                                _RemoveCargoWithEDName(inventoryCargo.edname);
                            }
                        }
                    }

                    // Update existing cargo in the manifest
                    while (infoList.Any())
                    {
                        string           name      = infoList.ToList().First().name;
                        List <CargoInfo> cargoInfo = infoList.Where(i => i.name.Equals(name, StringComparison.OrdinalIgnoreCase)).ToList();
                        Cargo            cargo     = inventory.FirstOrDefault(c => c.edname.Equals(name, StringComparison.OrdinalIgnoreCase));
                        if (cargo != null)
                        {
                            int total        = cargoInfo.Sum(i => i.count);
                            int stolen       = cargoInfo.Where(i => i.missionid == null).Sum(i => i.stolen);
                            int missionCount = cargoInfo.Count(i => i.missionid != null);
                            if (total != cargo.total || stolen != cargo.stolen || missionCount != cargo.haulageData.Count())
                            {
                                UpdateCargoFromInfo(cargo, cargoInfo);
                            }
                        }
                        else
                        {
                            // Add cargo entries for those missing
                            cargo = new Cargo(name);
                            UpdateCargoFromInfo(cargo, cargoInfo);
                        }
                        AddOrUpdateCargo(cargo);
                        infoList.RemoveAll(i => i.name == name);
                    }
                }
            }
        }
Example #2
0
 public ActionResult Edit(CargoInfo cargoInfo) ///////////////////////////
 {
     //var cargo = _db.CargoInfo.Find(cargoInfo.Id);
     //if (cargo == null)
     //{
     //    return Json(new { success = "fail", message = "修改失败,没有当前的商品" });
     //}
     //var temp = _db.CargoInfo.FirstOrDefault(c => c.CargoName == cargoInfo.CargoName.Replace(" ", "").Replace("  ", "") && c.Unit == cargoInfo.Unit && c.Specifications == cargoInfo.Specifications && c.Type == cargoInfo.Type && c.Amount == cargoInfo.Amount && c.Area == cargoInfo.Area);
     //if (temp != null)
     //{
     //    return Json(new { success = "fail", message = "修改失败,已经有这个商品" });
     //}
     //cargo.LastCargoName = cargo.CargoName;
     //cargo.CargoName = cargoInfo.CargoName.Replace(" ", "").Replace("  ", "");
     //cargo.Amount = cargoInfo.Amount;
     //cargo.Unit = cargoInfo.Unit;
     //cargo.Specifications = cargoInfo.Specifications;
     //cargo.Type = cargoInfo.Type;
     //cargo.Area = cargoInfo.Area;
     //_db.CargoInfo.Attach(cargo);
     //_db.Entry(cargo).Property(c => c.CargoName).IsModified = true;
     //_db.Entry(cargo).Property(c => c.Amount).IsModified = true;
     //_db.Entry(cargo).Property(c => c.Unit).IsModified = true;
     //_db.Entry(cargo).Property(c => c.LastCargoName).IsModified = true;
     //_db.Entry(cargo).Property(c => c.Specifications).IsModified = true;
     //_db.Entry(cargo).Property(c => c.Type).IsModified = true;
     //_db.Entry(cargo).Property(c => c.Area).IsModified = true;
     //return _db.SaveChanges() > 0
     //    ? Json(new { success = "success", message = "修改成功" })
     //    : Json(new { success = "fail", message = "修改失败" });
     return(Json(new { success = "fail", message = "修改失败" }));
 }
Example #3
0
 public ActionResult Delete(CargoInfo cargoInfo)
 {
     //var cargo = _db.CargoInfo.Find(cargoInfo.Id);
     //_db.CargoInfo.Remove(cargo);
     //return _db.SaveChanges() > 0
     //    ? Json(new { success = "success", message = "删除成功" })
     //    : Json(new { success = "fail", message = "删除失败" });
     return(Json(new { success = "fail", message = "删除失败" }));
 }
Example #4
0
        /// <summary>
        /// 添加仓库   zrx   2020年3月23日15:20:31
        /// </summary>
        /// <returns></returns>
        public CargoAddResponse AddCargo(CargoAddRequest request)
        {
            CargoAddResponse response = new CargoAddResponse();

            CargoInfo cargo = new CargoInfo()
            {
                CargoName     = request.CargoName,
                ShippingOrder = request.ShippingOrder,
                CargoWeight   = request.CargoWeight,
                CargoType     = request.CargoType,
                CargoState    = request.CargoState,
                CargoRemark   = request.CargoRemark
            };

            //获取名不能为空
            if (request == null || string.IsNullOrEmpty(request.CargoName))
            {
                response.Status  = false;
                response.Message = "货物名称不能为空";
                return(response);
            }
            //重量不能为0
            if (request.CargoWeight == 0)
            {
                response.Status  = false;
                response.Message = "重量不能为空";
                return(response);
            }
            //验证货物是否存在
            var shiporder = cdal.IsExistShipping(request.ShippingOrder);

            if (shiporder >= 1)
            {
                response.Status  = false;
                response.Message = "货物已存在";
                return(response);
            }

            var res = cdal.AddCargo(cargo);

            if (res > 0)
            {
                response.IsRegistSuccess = true;
                response.Message         = "添加货物成功";
            }
            else
            {
                response.Status  = false;
                response.Message = "添加货物失败";
            }

            return(response);
        }
Example #5
0
    public static void CreateCargoInfo(ref CargoInfo CI, out CargoMessage CargoMessage)
    {
        CargoMessage CM = new CargoMessage();

        CM.Name         = CI.Name;
        CM.Size         = CI.Size;
        CM.Number1      = CI.Number1;
        CM.Num          = CI.Num;
        CM.PositionInfo = CI.PositionInfo;
        CM.InputTime    = CI.InputTime;
        CM.Description  = CI.Description;
        CargoMessage    = CM;
    }
Example #6
0
        private void NewShip(ShipModel shipModel)
        {
            ShipType = shipModel;
            var @base = BaseInfo;

            Name       = @base.Name;
            Identifier = string.Empty;
            Fuel       = new Fuel();
            Cargo      = new CargoInfo {
                Max = @base.Cargo
            };
            EnergyManagement = new EnergyInfo(new byte[] { 4, 4, 4 });
            Flags            = ShipStatusFlags.Docked;
            Hull             = new HullInfo {
                UnladenMass = @base.Mass
            };
            MaxJumpRange = @base.JumpRange;
            IsHot        = false;
            Rebuy        = null;
        }
Example #7
0
 private static void Events_CargoEvent(object sender, CargoInfo e)
 {
     Console.WriteLine($"Got cargo event: {e.Event}");
     try
     {
         if (e.Inventory != null)
         {
             foreach (var inv in e.Inventory)
             {
                 Console.WriteLine($"Inv: {inv.NameLocalised} cnt {inv.Count}");
             }
         }
         else
         {
             Console.WriteLine("Inventory error?");
         }
     }
     catch (Exception ex)
     {
         // Bail...
     }
 }
Example #8
0
    public static void Create_Cargo(CargoInfo CI, GameObject Cargo)
    {
        Vector3    Size  = CI.Size;
        Vector2    size1 = new Vector2(Size.x, Size.z);
        Vector3    size2 = new Vector3(Size.x, Size.y - 0.15f, Size.z);
        GameObject Tray  = new GameObject(); Tray.name = "Tray";

        Create_Tray1(size1, Tray);
        GameObject Container = new GameObject(); Container.name = "Container";

        Create_Container(size2, Container);
        Tray.transform.parent      = Cargo.transform; Tray.transform.localPosition = new Vector3(0, 0, 0);
        Container.transform.parent = Cargo.transform; Container.transform.localPosition = new Vector3(0, 0.15f, 0);
        MyClass.Create2(Cargo);
        //给货物添加Message
        Cargo.AddComponent <ShowCargoInfo>();
        ShowCargoInfo ShowCargoInfo = Cargo.GetComponent <ShowCargoInfo>();
        CargoMessage  CargoMessage;

        CreateCargoInfo(ref CI, out CargoMessage);
        ShowCargoInfo.Cargomessage = CargoMessage;
    }
Example #9
0
        public IEnumerable <CargoViewDTO> GetCargoes()
        {
            List <CargoViewDTO> cargoesView = new List <CargoViewDTO>();
            var cargoes = Database.Cargoes.GetAll();

            if (cargoes.Count() > 0)
            {
                foreach (var cargo in cargoes)
                {
                    CargoViewDTO cView = new CargoViewDTO();
                    cView.UserIdNumber       = cargo.UserId;
                    cView.CargoIdNumber      = cargo.CargoId;
                    cView.CityArrivalId      = cargo.CityArrivalId;
                    cView.CityShipmentId     = cargo.CityShipmentId;
                    cView.IsCargoDeactivated = cargo.IsCargoDeactivated;

                    UserBizInformation u = Database.UserBizInfo.Get(cargo.UserId);
                    cView.UserBizName = u.BizName;

                    City    cityArr    = Database.Cities.Get(cargo.CityArrivalId);
                    City    citySh     = Database.Cities.Get(cargo.CityShipmentId);
                    Country countryArr = Database.Countries.Get(cityArr.CountryId);
                    Country countrySh  = Database.Countries.Get(citySh.CountryId);
                    Region  regionSh   = Database.Regions.Get(citySh.RegionId);
                    Region  regionArr  = Database.Regions.Get(cityArr.RegionId);

                    cView.CityArrivalName         = cityArr.CityName;
                    cView.CityShipmentName        = citySh.CityName;
                    cView.CountryShipmentISOCode2 = countrySh.ISOCode2;
                    cView.CountryArrivalISOCode2  = countryArr.ISOCode2;
                    cView.RegionShipmentName      = regionSh.RegionName;
                    cView.RegionArrivalName       = regionArr.RegionName;

                    CargoDate date = Database.CargoDates.Get(cargo.CargoId);
                    if (date != null)
                    {
                        cView.DateOfFormation      = date.DateOfFormation;
                        cView.ShipmentDateStart    = date.ShipmentDateStart;
                        cView.ShipmentDateFinished = date.ShipmentDateFinished;
                    }
                    CargoInfo info = Database.CargoInfoes.Get(cargo.CargoId);
                    if (info != null)
                    {
                        cView.AdditionalInfo           = info.AdditionalInfo;
                        cView.ADR                      = info.ADR;
                        cView.CargoFrequency           = info.CargoFrequency;
                        cView.Height                   = info.Height;
                        cView.Length                   = info.Length;
                        cView.Name                     = info.Name;
                        cView.RequiredCountOfTransport = info.RequiredCountOfTransport;
                        cView.SizeMax                  = info.SizeMax;
                        cView.SizeMin                  = info.SizeMin;
                        cView.WeightMax                = info.WeightMax;
                        cView.WeightMin                = info.WeightMin;
                        cView.Width                    = info.Width;
                    }

                    CargoPayment payments = Database.CargoPayments.Get(cargo.CargoId);
                    if (payments != null)
                    {
                        cView.CostUnit        = payments.CostUnit;
                        cView.CurrencyId      = payments.CurrencyId;
                        cView.IsCostKnown     = payments.IsCostKnown;
                        cView.IsVATApplicable = payments.IsVATApplicable;
                        cView.PaymentMethod   = payments.PaymentMethod;
                        cView.PrePayment      = payments.PrePayment;
                        cView.SumOfPayment    = payments.SumOfPayment;
                        cView.TimeOfPayment   = payments.TimeOfPayment;

                        Currency cur = Database.Currencies.Get(payments.CurrencyId);
                        cView.CurrencySymbol = cur.ISOCode3;
                    }

                    var phones = Database.Phones.Find(f => f.UserId == cargo.UserId);
                    if (phones.Count() > 0)
                    {
                        Mapper.Initialize(cfg => cfg.CreateMap <Phone, PhoneDTO>());
                        cView.PhonesDTO = Mapper.Map <IEnumerable <Phone>, List <PhoneDTO> >(phones);
                    }

                    cargoesView.Add(cView);
                }
                return(cargoesView);
            }
            return(null);
        }
Example #10
0
        public IEnumerable <CargoViewDTO> GetCargoes(string countryArrM = null, string countryDestM = null,
                                                     string regArrM     = null, string regDestM     = null, string cityArrM   = null, string cityDestM = null,
                                                     DateTime?dateStart = null, DateTime?dateFin    = null, decimal weightMin = 0, decimal weightMax   = 0,
                                                     int capMin         = 0, int capMax = 0)
        {
            List <CargoViewDTO> cargoesView = new List <CargoViewDTO>();
            Region regionCargoArrM, regionCargoDestM = new Region();
            City   cityCargoArrM, cityCargoDestM = new City();

            if (countryArrM != null && countryDestM != null)
            {
                Country countryCargoArrM  = Database.Countries.Find(c => c.CountryName == countryArrM).FirstOrDefault();
                Country countryCargoDestM = Database.Countries.Find(c => c.CountryName == countryDestM).FirstOrDefault();

                var cargoes = Database.Cargoes.GetAll();
                if (cargoes.Count() > 0)
                {
                    foreach (var cargo in cargoes)
                    {
                        CargoViewDTO cView = new CargoViewDTO();
                        cView.UserIdNumber       = cargo.UserId;
                        cView.CargoIdNumber      = cargo.CargoId;
                        cView.CityArrivalId      = cargo.CityArrivalId;
                        cView.CityShipmentId     = cargo.CityShipmentId;
                        cView.IsCargoDeactivated = cargo.IsCargoDeactivated;

                        UserBizInformation u = Database.UserBizInfo.Get(cargo.UserId);
                        cView.UserBizName = u.BizName;

                        City cityArr = Database.Cities.Get(cargo.CityArrivalId);
                        if (cityDestM != null)
                        {
                            cityCargoDestM = Database.Cities.Find(c => c.CityName == cityDestM).FirstOrDefault();
                            if (cityArr.CityId != cityCargoDestM.CityId)
                            {
                                continue;
                            }
                        }
                        City citySh = Database.Cities.Get(cargo.CityShipmentId);
                        if (cityArrM != null)
                        {
                            cityCargoArrM = Database.Cities.Find(c => c.CityName == cityArrM).FirstOrDefault();
                            if (citySh.CityId != cityCargoArrM.CityId)
                            {
                                continue;
                            }
                        }
                        Country countryArr = Database.Countries.Get(cityArr.CountryId);
                        if (countryArr.CountryId != countryCargoDestM.CountryId)
                        {
                            continue;
                        }

                        Country countrySh = Database.Countries.Get(citySh.CountryId);
                        if (countrySh.CountryId != countryCargoArrM.CountryId)
                        {
                            continue;
                        }

                        Region regionSh = Database.Regions.Get(citySh.RegionId);
                        if (regArrM != null)
                        {
                            regionCargoArrM = Database.Regions.Find(r => r.RegionName == regArrM).FirstOrDefault();
                            if (regionSh.RegionId != regionCargoArrM.RegionId)
                            {
                                continue;
                            }
                        }
                        Region regionArr = Database.Regions.Get(cityArr.RegionId);
                        if (regDestM != null)
                        {
                            regionCargoDestM = Database.Regions.Find(r => r.RegionName == regDestM).FirstOrDefault();
                            if (regionArr.RegionId != regionCargoDestM.RegionId)
                            {
                                continue;
                            }
                        }


                        cView.CityArrivalName         = cityArr.CityName;
                        cView.CityShipmentName        = citySh.CityName;
                        cView.CountryShipmentISOCode2 = countrySh.ISOCode2;
                        cView.CountryArrivalISOCode2  = countryArr.ISOCode2;
                        cView.RegionShipmentName      = regionSh.RegionName;
                        cView.RegionArrivalName       = regionArr.RegionName;

                        CargoDate date = Database.CargoDates.Get(cargo.CargoId);
                        if (date != null)
                        {
                            cView.DateOfFormation      = date.DateOfFormation;
                            cView.ShipmentDateStart    = date.ShipmentDateStart;
                            cView.ShipmentDateFinished = date.ShipmentDateFinished;
                        }
                        if (Convert.ToDateTime(dateStart).Year > 2000)
                        {
                            if (DateTime.Compare((DateTime)date.ShipmentDateStart, (DateTime)dateStart) < 0 ||
                                DateTime.Compare((DateTime)date.ShipmentDateFinished, (DateTime)dateStart) < 0)
                            {
                                continue;
                            }
                        }
                        if (Convert.ToDateTime(dateFin).Year > 2000)
                        {
                            if (DateTime.Compare((DateTime)date.ShipmentDateFinished, (DateTime)dateFin) > 0)
                            {
                                continue;
                            }
                        }
                        CargoInfo info = Database.CargoInfoes.Get(cargo.CargoId);
                        if (info != null)
                        {
                            cView.AdditionalInfo           = info.AdditionalInfo;
                            cView.ADR                      = info.ADR;
                            cView.CargoFrequency           = info.CargoFrequency;
                            cView.Height                   = info.Height;
                            cView.Length                   = info.Length;
                            cView.Name                     = info.Name;
                            cView.RequiredCountOfTransport = info.RequiredCountOfTransport;
                            cView.SizeMax                  = info.SizeMax;
                            cView.SizeMin                  = info.SizeMin;
                            cView.WeightMax                = info.WeightMax;
                            cView.WeightMin                = info.WeightMin;
                            cView.Width                    = info.Width;
                        }
                        if (info.WeightMin < weightMin || info.SizeMin < capMin)
                        {
                            continue;
                        }
                        if (info.WeightMax > weightMax && weightMax != 0)
                        {
                            continue;
                        }
                        if (info.SizeMax > capMax && capMax != 0)
                        {
                            continue;
                        }

                        CargoPayment payments = Database.CargoPayments.Get(cargo.CargoId);
                        if (payments != null)
                        {
                            cView.CostUnit        = payments.CostUnit;
                            cView.CurrencyId      = payments.CurrencyId;
                            cView.IsCostKnown     = payments.IsCostKnown;
                            cView.IsVATApplicable = payments.IsVATApplicable;
                            cView.PaymentMethod   = payments.PaymentMethod;
                            cView.PrePayment      = payments.PrePayment;
                            cView.SumOfPayment    = payments.SumOfPayment;
                            cView.TimeOfPayment   = payments.TimeOfPayment;

                            Currency cur = Database.Currencies.Get(payments.CurrencyId);
                            cView.CurrencySymbol = cur.ISOCode3;
                        }

                        var phones = Database.Phones.Find(f => f.UserId == cargo.UserId);
                        if (phones.Count() > 0)
                        {
                            Mapper.Initialize(cfg => cfg.CreateMap <Phone, PhoneDTO>());
                            cView.PhonesDTO = Mapper.Map <IEnumerable <Phone>, List <PhoneDTO> >(phones);
                        }

                        cargoesView.Add(cView);
                    }
                    return(cargoesView);
                }
            }
            return(null);
        }
Example #11
0
 public override void CargaDatosActuales()
 {
     base.CargaDatosActuales();
     _Cargo = ObjetoLista.Current as CargoInfo;
 }
Example #12
0
        private bool _handleCargoEvent(CargoEvent @event)
        {
            bool cargoUpdated = false;

            if (@event.vessel == Constants.VEHICLE_SHIP)
            {
                cargoCarried = @event.cargocarried;
                if (@event.inventory != null)
                {
                    List <CargoInfo> infoList = @event.inventory.ToList();

                    // Remove strays from the manifest
                    foreach (Cargo inventoryCargo in inventory.ToList())
                    {
                        CargoInfo info = @event.inventory.FirstOrDefault(i => i.name == inventoryCargo.edname.ToLowerInvariant());
                        if (info == null)
                        {
                            if (inventoryCargo.haulageData == null || !inventoryCargo.haulageData.Any())
                            {
                                // Strip out the stray from the manifest
                                _RemoveCargoWithEDName(inventoryCargo.edname);
                                cargoUpdated = true;
                            }
                            else
                            {
                                // Keep cargo entry in manifest with zeroed amounts, if missions are pending
                                inventoryCargo.total   = 0;
                                inventoryCargo.haulage = 0;
                                inventoryCargo.owned   = 0;
                                inventoryCargo.stolen  = 0;
                                inventoryCargo.CalculateNeed();
                            }
                            cargoUpdated = true;
                        }
                    }

                    while (infoList.Count() > 0)
                    {
                        string           name      = infoList.ToList().First().name;
                        List <CargoInfo> cargoInfo = infoList.Where(i => i.name == name).ToList();
                        Cargo            cargo     = inventory.FirstOrDefault(c => c.edname.ToLowerInvariant() == name);
                        if (cargo != null)
                        {
                            int total        = cargoInfo.Sum(i => i.count);
                            int stolen       = cargoInfo.Where(i => i.missionid == null).Sum(i => i.stolen);
                            int missionCount = cargoInfo.Where(i => i.missionid != null).Count();
                            if (total != cargo.total || stolen != cargo.stolen || missionCount != cargo.haulageData.Count())
                            {
                                UpdateCargoFromInfo(cargo, cargoInfo);
                                if (@event.update)
                                {
                                    return(true);
                                }
                                cargoUpdated = true;
                            }
                        }
                        else
                        {
                            // Add cargo entries for those missing
                            cargo = new Cargo(name, 0);
                            UpdateCargoFromInfo(cargo, cargoInfo);
                            AddCargo(cargo);
                            cargoUpdated = true;
                        }

                        infoList.RemoveAll(i => i.name == name);
                    }
                }
            }
            return(cargoUpdated);
        }
 public override void CargaDatosActuales()
 {
     base.CargaDatosActuales();
     _Cargo = ObjetoLista.Current as CargoInfo;
 }
Example #14
0
        /// <summary>
        /// 保存货物
        /// </summary>
        /// <returns></returns>
        public int SaveCargo(CargoInfo info)
        {
            string sql = $"update Cargo set CargoName='{info.CargoName}',CargoType={info.CargoType},CargoWeight={info.CargoWeight},CargoRemark='{info.CargoRemark}',CargoState= {info.CargoState},UpdateTime=GETDATE(),UpdateId=1 where CargoId={info.CargoId}";

            return(DBHelper.ExecuteNonQuery(sql));
        }
Example #15
0
        /// <summary>
        /// 添加货物
        /// </summary>
        /// <returns></returns>
        public int AddCargo(CargoInfo info)
        {
            string sql = $"insert into Cargo values('{info.CargoName}',{info.CargoType},{info.CargoWeight},'{info.ShippingOrder}',{info.CargoState},'{info.CargoRemark}',GETDATE(),GETDATE(),1,1,1)";

            return(DBHelper.ExecuteNonQuery(sql));
        }
Example #16
0
 public Cargo( Actor self, CargoInfo info )
 {
     this.self = self; this.info = info;
 }