コード例 #1
0
        public MainWindow()
        {
            //Retrieve a saved state of the ShipViewModel (if one exists)
            try
            {
                string json = System.IO.File.ReadAllText(String.Format(@"{0}\ViewModelState.txt", System.AppDomain.CurrentDomain.BaseDirectory));

                VM = JsonConvert.DeserializeObject <ShipViewModel>(json);
                VM.ShipList.Remove(VM.ShipList.First());
            }

            //Create a new instance of the ShipViewModel if a saved state does not exist
            catch (FileNotFoundException)
            {
                VM = new ShipViewModel();
            }

            DataContext = VM;
            InitializeComponent();

            MainView.Visibility      = Visibility.Visible;
            ConfigureView.Visibility = Visibility.Hidden;
            AddFleetView.Visibility  = Visibility.Hidden;

            Console.WriteLine("CONVERRSION: 00100001 == {0}", Convert.ToInt32("00100001", 2));

            VM.ServerStatusBox = txtStatus;
        }
コード例 #2
0
        public void Create_A_Ship_Should_Assign_Positions()
        {
            var shipVewModel = new ShipViewModel
            {
                StartingPosition = new BoardPosition {
                    X = 1, Y = 1
                },
                Length    = 5,
                Alignment = Alignment.Horizontal
            };

            var ship = Ship.Create(shipVewModel);

            Assert.NotNull(ship);
            var boardPositions = ship.BoardPositions;

            Assert.Equal(shipVewModel.Length, ship.BoardPositions.Count);

            for (var i = 0; i < shipVewModel.Length; i++)
            {
                Assert.Contains(boardPositions, (n) =>
                                (shipVewModel.StartingPosition.Y == n.Y && shipVewModel.StartingPosition.X + i == n.X)
                                );
            }
        }
コード例 #3
0
        public async Task <IActionResult> Ship([FromBody] ShipViewModel ship)
        {
            var createdShip = _gameTrackerService.AddShip(ship);
            var response    = await Task.FromResult(Created(new Uri("https://localhost:5071/board"), createdShip));

            return(response);
        }
コード例 #4
0
        public void ShouldNotValidateIfClosestScheduleIsNotClosestInList()
        {
            var schedule = new ScheduleViewModel {
                Arrival = DateTime.Now.AddDays(1), Departure = DateTime.Now.AddDays(2)
            };
            var closestSchedule = new ScheduleViewModel
            {
                Arrival   = DateTime.Now.AddDays(2),
                Departure = DateTime.Now.AddDays(3)
            };
            var invalidViewModel = new ShipViewModel
            {
                Schedules = new List <ScheduleViewModel>
                {
                    schedule, closestSchedule
                },
                ClosestSchedule = closestSchedule
            };
            var errors = new List <string>();

            scheduleViewModelValidator.Setup(x => x.IsValid(schedule)).Returns(true);
            scheduleViewModelValidator.Setup(x => x.IsValid(closestSchedule)).Returns(true);
            scheduleViewModelValidator.SetupGet(x => x.ErrorList).Returns(errors);

            var result = validator.IsValid(invalidViewModel);

            Assert.IsFalse(result);
            Assert.AreEqual(1, validator.ErrorList.Count);
            Assert.AreEqual(ShipViewModelMessages.ClosestScheduleIsNotClosest, validator.ErrorList[0]);
        }
コード例 #5
0
        public void ShouldValidateWhenAllSchedulesAreValid()
        {
            var schedule         = new ScheduleViewModel {
            };
            var closestSchedule  = new ScheduleViewModel {
            };
            var invalidViewModel = new ShipViewModel
            {
                Schedules = new List <ScheduleViewModel>
                {
                    schedule
                },
                ClosestSchedule = closestSchedule
            };
            var errors = new List <string>();

            scheduleViewModelValidator.Setup(x => x.IsValid(schedule)).Returns(true);
            scheduleViewModelValidator.Setup(x => x.IsValid(closestSchedule)).Returns(true);
            scheduleViewModelValidator.SetupGet(x => x.ErrorList).Returns(errors);


            var result = validator.IsValid(invalidViewModel);

            Assert.IsTrue(result);
            Assert.AreEqual(errors, validator.ErrorList);
        }
コード例 #6
0
        public ActionResult ShipEdit(int id)
        {
            using (var warshipContext = new WarshipsContext())
            {
                var shipTypes = warshipContext.ShipTypes.Select(st => new SelectListItem
                {
                    Value = st.ShipTypeId.ToString(),
                    Text  = st.ShipTypeName
                }).ToList();

                ViewBag.ShipTypes = shipTypes;


                var ship = warshipContext.Ships.SingleOrDefault(p => p.ShipId == id);
                if (ship != null)
                {
                    var shipViewModel = new ShipViewModel
                    {
                        ShipId     = ship.ShipId,
                        ShipTypeId = ship.ShipTypeId,
                        ShipName   = ship.ShipName
                    };

                    return(View("AddEditShip", shipViewModel));
                }
            }

            return(new HttpNotFoundResult());
        }
コード例 #7
0
        private void HandleDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            var shipViewModel = DataContext as ShipViewModel;

            if (shipViewModel == null)
            {
                throw new InvalidCastException("DataContext for Ship should be correct type");
            }

            _shipViewModel = shipViewModel;
        }
コード例 #8
0
        public void AddShips()
        {
            foreach (var ship in _game.Ships)
            {
                var shipVM = new ShipViewModel(ship, _metersPerPixel, _game.SeaMapSizeInPixels, _game.SelectedShip);

                var shipControl = new Ship();
                shipControl.DataContext = shipVM;
                ShipGrid.Children.Add(shipControl);
            }
        }
コード例 #9
0
 public void BindToViewModel(ShipViewModel model)
 {
     tbId.DataBindings.Add("Text", model, nameof(model.IdInventory), true, DataSourceUpdateMode.OnPropertyChanged);
     tbId.DataBindings.Add("Enabled", model, nameof(model.IdInventoryInputEnabled), true, DataSourceUpdateMode.OnPropertyChanged);
     tbWeight.DataBindings.Add("Text", model, nameof(model.Weight), true, DataSourceUpdateMode.OnPropertyChanged);
     tbWeight.DataBindings.Add("Enabled", model, nameof(model.WeightInputEnabled), true, DataSourceUpdateMode.OnPropertyChanged);
     lblResult.DataBindings.Add("Text", model, nameof(model.Result), true, DataSourceUpdateMode.OnPropertyChanged);
     btnSubmitId.DataBindings.Add("Enabled", model, nameof(model.SubmitIdInventoryButtonEnabled), true, DataSourceUpdateMode.OnPropertyChanged);
     btnSubmitWeight.DataBindings.Add("Enabled", model, nameof(model.SubmitWeightButtonEnabled), true, DataSourceUpdateMode.OnPropertyChanged);
     btnCancel.DataBindings.Add("Enabled", model, nameof(model.CancelButtonEnabled), true, DataSourceUpdateMode.OnPropertyChanged);
     lblShippedCount.DataBindings.Add("Text", model, nameof(model.ShippedCount), true, DataSourceUpdateMode.OnPropertyChanged);
     lblScaleStatus.DataBindings.Add("Text", model, nameof(model.ScaleStatus), true, DataSourceUpdateMode.OnPropertyChanged);
 }
コード例 #10
0
ファイル: ApiTests.cs プロジェクト: Afshintm/Battleship
 public ApiTests(WebApplicationFactory <Startup> factory)
 {
     _factory           = factory;
     _stubShipViewModel = new ShipViewModel
     {
         Alignment        = Alignment.Horizontal,
         Length           = 3,
         StartingPosition = new BoardPosition
         {
             X = 3,
             Y = 3
         }
     };
 }
コード例 #11
0
        public void ShouldReturnBadRequestWhenAddFails()
        {
            var model  = new ShipViewModel();
            var entity = new Ship();

            validatorMock.Setup(x => x.IsValid(model)).Returns(true);
            mapperMock.Setup(x => x.Map <Ship>(model)).Returns(entity);
            serviceMock.Setup(x => x.Add(entity, shipOwnerId)).Returns(false);

            var result = controller.Add(model, shipOwnerId);

            Assert.IsInstanceOf <BadRequestResult>(result);
            mapperMock.Verify(x => x.Map <Ship>(model));
            serviceMock.Verify(x => x.Add(entity, shipOwnerId), Times.Once());
        }
コード例 #12
0
ファイル: OrderDao.cs プロジェクト: Vo-Thanh-Do-18110270/TMDT
        //trả vê 1 ShipViewModel để xem detail
        public ShipViewModel View1Ship(long orderID)
        {
            var model1 = new OrderDao().GetByID(orderID);
            var model2 = new ShipViewModel();

            model2.OrderID      = model1.ID;
            model2.CustomerID   = model1.CustomerID;
            model2.ShipToName   = model1.ShipName;
            model2.ShipMobile   = model1.ShipMobile;
            model2.ShipAddress  = model1.ShipAddress;
            model2.ShipEmail    = model1.ShipEmail;
            model2.Status       = model1.Status;
            model2.ShipItemList = new OrderDetailDao().ListByOrderId(model1.ID).ToList();
            return(model2);
        }
コード例 #13
0
        public void ShouldReturnBadRequestAndValidationErrorsWhenModelIsNotValid()
        {
            var model = new ShipViewModel();

            validatorMock.Setup(x => x.IsValid(model)).Returns(false);
            var errorsList = new List <string>();

            validatorMock.SetupGet(x => x.ErrorList).Returns(errorsList);

            var result = controller.Add(model, shipOwnerId);

            Assert.IsInstanceOf <BadRequestObjectResult>(result);
            var badReqest = result as BadRequestObjectResult;

            Assert.AreEqual(errorsList, badReqest.Value);
        }
コード例 #14
0
        public ActionResult AddShip(ShipViewModel ShipViewModel)
        {
            using (var warshipContext = new WarshipsContext())
            {
                var ship = new Ship
                {
                    ShipName   = ShipViewModel.ShipName,
                    ShipTypeId = ShipViewModel.ShipTypeId
                };

                warshipContext.Ships.Add(ship);
                warshipContext.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
コード例 #15
0
        public ActionResult DeleteShip(ShipViewModel shipViewModel)
        {
            using (var warshipsContext = new WarshipsContext())
            {
                var ship = warshipsContext.Ships.SingleOrDefault(p => p.ShipId == shipViewModel.ShipId);

                if (ship != null)
                {
                    warshipsContext.Ships.Remove(ship);
                    warshipsContext.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }

            return(new HttpNotFoundResult());
        }
コード例 #16
0
        public void ShouldReturnModelWhenEntityExists()
        {
            int idToFind = 1;
            var entity   = new Ship();
            var model    = new ShipViewModel();

            serviceMock.Setup(x => x.Find(idToFind)).Returns(entity);
            mapperMock.Setup(x => x.Map <ShipViewModel>(entity)).Returns(model);

            var result = controller.GetById(idToFind);

            serviceMock.Verify(x => x.Find(idToFind), Times.Once());
            Assert.IsInstanceOf <OkObjectResult>(result);
            var okResult = result as OkObjectResult;

            Assert.AreEqual(model, okResult.Value);
        }
コード例 #17
0
        public ActionResult EditShip(ShipViewModel shipViewModel)
        {
            using (var warshipsContext = new WarshipsContext())
            {
                var ship = warshipsContext.Ships.SingleOrDefault(p => p.ShipId == shipViewModel.ShipId);

                if (ship != null)
                {
                    ship.ShipName   = shipViewModel.ShipName;
                    ship.ShipTypeId = shipViewModel.ShipTypeId;
                    warshipsContext.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }

            return(new HttpNotFoundResult());
        }
コード例 #18
0
        public ActionResult ShipAdd()
        {
            var shipViewModel = new ShipViewModel();

            using (var warshipContext = new WarshipsContext())
            {
                var shipTypes = warshipContext.ShipTypes.Select(st => new SelectListItem
                {
                    Value = st.ShipTypeId.ToString(),
                    Text  = st.ShipTypeName
                }).ToList();

                ViewBag.ShipTypes = shipTypes;
            }



            return(View("AddEditShip", shipViewModel));
        }
コード例 #19
0
        public ActionResult ShipDetail(int id)
        {
            using (var warshipsContext = new WarshipsContext())
            {
                //Allows the ship name and type to be displayed
                var ship = warshipsContext.Ships.Include("ShipType").SingleOrDefault(p => p.ShipId == id);
                if (ship != null)
                {
                    var ShipViewModel = new ShipViewModel
                    {
                        ShipId       = ship.ShipId,
                        ShipName     = ship.ShipName,
                        ShipTypeName = ship.ShipType.ShipTypeName
                    };

                    return(View(ShipViewModel));
                }
            }

            return(new HttpNotFoundResult());
        }
コード例 #20
0
        public void ValidateIfShipCanFitIn_Should_Throw_Exception_When_Ship_Position_Cross_Border()
        {
            //Arrange
            var shipViewModel = new ShipViewModel
            {
                StartingPosition = new BoardPosition {
                    X = 3, Y = 3
                },
                Alignment = Alignment.Horizontal,
                Length    = 10
            };
            var ship = Ship.Create(shipViewModel);

            var tracker = new GameTrackerService();

            tracker.Status = GameStatus.Setup;

            Action act = () => tracker.ValidateIfShipCanFitIn(ship);

            Assert.Throws <HttpStatusCodeException>(act);
        }
コード例 #21
0
        private void OnProcessingStopped(object sender, ProcessingStoppedEventArgs e)
        {
            UpdateShipOrders();

            m_refreshOperation?.Abort();
            m_refreshOperation = Dispatcher.InvokeAsync(() =>
            {
                var entityLookup = AppModel.GameData.EntityManager.DisplayEntityLookup;

                var ships    = entityLookup.GetEntitiesMatchingKey(entityLookup.CreateComponentKey <OrbitalUnitDesignComponent>());
                var newShips = ships
                               .Where(x => !m_ships.ContainsKey(x.Id));
                foreach (var newShip in newShips)
                {
                    Ship = new ShipViewModel(newShip);
                    m_ships.Add(newShip.Id, Ship);
                }

                foreach (var planet in m_planets)
                {
                    planet.UpdateFromEntity(entityLookup);
                }
                foreach (var ship in m_ships.Values)
                {
                    ship.UpdateFromEntity(entityLookup);
                }

                UpdateCurrentDate();

                if (ShouldRunAtFullSpeed)
                {
                    m_gameServices.Processor.StartRunning();
                }
            }, DispatcherPriority.Background);

            foreach (var notification in e.Notifications)
            {
                Log.Info($"{AppModel.GameData.Calendar.FormatTime(notification.Date, TimeFormat.Short)} - {TokenStringUtility.GetString(notification.Message, AppModel.GameData.EntityManager)}");
            }
        }
コード例 #22
0
        public async Task <string> Edit(ShipViewModel model)
        {
            var ship = this._repository.All().FirstOrDefault(sh => sh.Id == model.Id);

            ship.Name         = model.Name;
            ship.Launched     = model.Launched;
            ship.Passengers   = model.Passengers;
            ship.Crew         = model.Crew;
            ship.Length       = model.Length;
            ship.Staterooms   = model.Staterooms;
            ship.Suites       = model.Suites;
            ship.CaptainId    = model.CaptainId;
            ship.ImageUrl     = model.ImageUrl;
            ship.Description  = model.Description;
            ship.Amenities    = model.Amenities;
            ship.Dining       = model.Dining;
            ship.DeckPlansUrl = model.DeckPlansUrl;

            this._repository.Update(ship);
            await this._repository.SaveChangesAsync();

            return(ship.Id);
        }
コード例 #23
0
        public void ShouldNotValidateWhenScheduleInListIsNotValid()
        {
            var schedule         = new ScheduleViewModel {
            };
            var invalidViewModel = new ShipViewModel
            {
                Schedules = new List <ScheduleViewModel>
                {
                    schedule
                }
            };
            var errors = new List <string> {
                "error"
            };

            scheduleViewModelValidator.Setup(x => x.IsValid(schedule)).Returns(false);
            scheduleViewModelValidator.SetupGet(x => x.ErrorList).Returns(errors);

            var result = validator.IsValid(invalidViewModel);

            Assert.IsFalse(result);
            Assert.AreEqual(errors, validator.ErrorList);
        }
コード例 #24
0
        public void ShouldMapViewModelToEntity()
        {
            var model = new ShipViewModel
            {
                Id              = 1,
                Name            = "ship_name",
                ClosestSchedule = new ScheduleViewModel
                {
                    Arrival   = new DateTime(2020, 10, 10),
                    Departure = new DateTime(2020, 10, 9)
                },
                Schedules = new List <ScheduleViewModel>
                {
                    new ScheduleViewModel {
                        Id = 1, Arrival = new DateTime(2020, 1, 1), Departure = new DateTime(2020, 2, 2)
                    },
                    new ScheduleViewModel {
                        Id = 2, Arrival = new DateTime(2020, 1, 2), Departure = new DateTime(2020, 2, 3)
                    }
                }
            };

            var result = mapper.Map <ShipViewModel>(model);

            Assert.AreEqual(model.Id, result.Id);
            Assert.AreEqual(model.Name, result.Name);
            Assert.AreEqual(model.ClosestSchedule.Arrival, result.ClosestSchedule.Arrival);
            Assert.AreEqual(model.ClosestSchedule.Departure, result.ClosestSchedule.Departure);
            Assert.AreEqual(model.Schedules.Count(), result.Schedules.Count);
            Assert.AreEqual(model.Schedules.ElementAt(0).Id, result.Schedules[0].Id);
            Assert.AreEqual(model.Schedules.ElementAt(0).Arrival, result.Schedules[0].Arrival);
            Assert.AreEqual(model.Schedules.ElementAt(0).Departure, result.Schedules[0].Departure);
            Assert.AreEqual(model.Schedules.ElementAt(1).Id, result.Schedules[1].Id);
            Assert.AreEqual(model.Schedules.ElementAt(1).Arrival, result.Schedules[1].Arrival);
            Assert.AreEqual(model.Schedules.ElementAt(1).Departure, result.Schedules[1].Departure);
        }
コード例 #25
0
        private bool CompareExpeditionData(string Mission, ShipViewModel[] fleet)
        {
            this.vFlag = Visibility.Collapsed;
            this.vFlagType = Visibility.Collapsed;
            this.vNeed = Visibility.Collapsed;
            this.vTotal = Visibility.Collapsed;
            this.vDrum = Visibility.Collapsed;
            this.vFuel = Visibility.Collapsed;
            this.vArmo = Visibility.Collapsed;
            this.vResource = Visibility.Collapsed;

            if (fleet.Count() <= 0) return false;
            if (Mission == null) return false;
            bool Chk = true;
            int MissionNum = 0;
            try
            {
                MissionNum = Convert.ToInt32(Mission);
            }
            catch
            {
                return false;
            }
            if (this.ShipTypeTable.Count <= 0) Chk = false;
            if (MissionNum < 1) return false;
            this.ShipTypeTable = this.ChangeSpecialType(this.ShipTypeTable, MissionNum);

            this.nArmoLoss = LossResource(fleet, MissionNum, 1);
            this.nFuelLoss = LossResource(fleet, MissionNum);

            var NeedShipRaw = KanColleClient.Current.Translations.GetExpeditionData("FormedNeedShip", MissionNum).Split(';');
            var FLv = KanColleClient.Current.Translations.GetExpeditionData("FlagLv", MissionNum);
            var TotalLevel = KanColleClient.Current.Translations.GetExpeditionData("TotalLv", MissionNum);
            var FlagShipType = KanColleClient.Current.Translations.GetExpeditionData("FlagShipType", MissionNum);
            StringBuilder strb = new StringBuilder();

            if (KanColleClient.Current.Translations.GetExpeditionData("DrumCount", MissionNum) != string.Empty) Chk = this.DrumCount(MissionNum, fleet);

            if (NeedShipRaw[0] == string.Empty) return false;
            else strb.Append("총" + Convert.ToInt32(NeedShipRaw[0]) + "(");

            if (fleet.Count() < Convert.ToInt32(NeedShipRaw[0])) Chk = false;

            if (FLv != string.Empty && FLv != "-")
            {
                int lv = Convert.ToInt32(FLv);
                if (fleet[0] != null && fleet[0].Ship.Level < lv) Chk = false;
                this.FlagLv = ("Lv" + lv);
                this.vFlag = Visibility.Visible;
            }
            if (TotalLevel != string.Empty)
            {
                int totallv = Convert.ToInt32(TotalLevel);
                if (fleet.Sum(x => x.Ship.Level) < totallv) Chk = false;
                this.TotalLv = ("Lv" + totallv);
                this.vTotal = Visibility.Visible;
            }
            if (FlagShipType != string.Empty)
            {
                int flagship = Convert.ToInt32(FlagShipType);
                if (fleet[0].Ship.Info.ShipType.Id != flagship) Chk = false;
                this.FlagType = (KanColleClient.Current.Translations.GetTranslation("", TranslationType.ShipTypes, false, null, flagship));
                this.vFlagType = Visibility.Visible;
            }

            Dictionary<int, int> ExpeditionTable = new Dictionary<int, int>();

            if (NeedShipRaw.Count() > 1)
            {
                var Ships = NeedShipRaw[1].Split(',');
                for (int i = 0; i < Ships.Count(); i++)
                {
                    var shipInfo = Ships[i].Split('*');
                    if (shipInfo.Count() > 1)
                        ExpeditionTable.Add(Convert.ToInt32(shipInfo[0]), Convert.ToInt32(shipInfo[1]));
                }
                var list = ExpeditionTable.ToList();
                for (int i = 0; i < ExpeditionTable.Count; i++)
                {
                    if (i == 0)
                    {
                        strb.Append(KanColleClient.Current.Translations.GetTranslation("", TranslationType.ShipTypes, false, null, list[i].Key) + "×" + list[i].Value);
                    }
                    else strb.Append("・" + KanColleClient.Current.Translations.GetTranslation("", TranslationType.ShipTypes, false, null, list[i].Key) + "×" + list[i].Value);
                }
                strb.Append(")");
                strb = strb.Replace("()", "");
                this.ShipTypeString = strb.ToString();
                if (this.ShipTypeString.Count() > 0) this.vNeed = Visibility.Visible;

                for (int i = 0; i < ExpeditionTable.Count; i++)
                {
                    var test = ExpeditionTable.ToList();
                    if (this.ShipTypeTable.ContainsKey(test[i].Key))
                    {
                        var Count = this.ShipTypeTable[test[i].Key];
                        if (ExpeditionTable[test[i].Key] > this.ShipTypeTable[test[i].Key])
                            Chk = false;
                    }
                    else Chk = false;
                }
            }
            return Chk;
        }
コード例 #26
0
ファイル: ShipController.cs プロジェクト: Colinwang531/web
        /// <summary>
        /// 陆地端获取船信息
        /// </summary>
        /// <returns></returns>
        public IActionResult LoadAll()
        {
            try
            {
                List <ShipViewModel> list = new List <ShipViewModel>();
                //var compents = _context.Component.Where(c => c.Type == ComponentType.XMQ).ToList();
                var compents = from a in _context.Component
                               join b in _context.Ship on a.ShipId equals b.Id into c
                               from d in c.DefaultIfEmpty()
                               where a.Type == ComponentType.XMQ
                               select new
                {
                    a.Cid,
                    a.ShipId,
                    a.Line,
                    d.Name,
                    d.Flag
                };

                foreach (var item in compents)
                {
                    ShipViewModel model = new ShipViewModel()
                    {
                        Id   = item.Cid,
                        Name = item.Name,
                        flag = item.Flag,
                        Line = item.Line == 0 ? true : false//默认离线
                    };
                    list.Add(model);
                }
                var comLine = compents.Where(c => c.Line == 0).ToList();
                Console.WriteLine("异步执行开始:" + DateTime.Now);
                new TaskFactory().StartNew(() =>
                {
                    Console.WriteLine("异步执行方法:" + DateTime.Now);
                    foreach (var item in comLine)
                    {
                        //根据当前XMQ的ID
                        assembly.SendComponentQuery(item.Cid);
                        Task.Factory.StartNew(state => {
                            while (ManagerHelp.ComponentReponse == "")
                            {
                                Thread.Sleep(10);
                            }
                            var webcom   = JsonConvert.DeserializeObject <ProtoBuffer.Models.ComponentResponse>(ManagerHelp.ComponentReponse);
                            string webId = "";
                            if (webcom != null && webcom.componentinfos.Count > 0)
                            {
                                var web = webcom.componentinfos.FirstOrDefault(c => c.type == ComponentInfo.Type.WEB);
                                if (web != null)
                                {
                                    webId = web.componentid;
                                }
                            }
                            if (webId != "")
                            {
                                assembly.SendStatusQuery(item.Cid + ":" + webId);
                                Task.Factory.StartNew(ss => {
                                    while (ManagerHelp.StatusReponse == "")
                                    {
                                        Thread.Sleep(10);
                                    }
                                    var response = JsonConvert.DeserializeObject <StatusResponse>(ManagerHelp.StatusReponse);
                                    if (response != null)
                                    {
                                        list.FirstOrDefault(c => c.Id == item.Cid).flag = response.flag;
                                        LandSave(response, item.ShipId);
                                    }
                                }, TaskCreationOptions.LongRunning);
                            }
                        }, TaskCreationOptions.LongRunning);
                    }
                    Console.WriteLine("结束:" + DateTime.Now);
                }).Wait(5000);
                Console.WriteLine("完成:" + DateTime.Now);
                var result = new
                {
                    code  = 0,
                    data  = list,
                    isSet = base.user.EnableConfigure
                };
                return(new JsonResult(result));
            }
            catch (Exception ex)
            {
                _logger.LogError("陆地端获取船信息异常【LoadAll】" + ex.Message);
                return(new JsonResult(new { code = 1, msg = "获取数据失败!" + ex.Message }));
            }
        }
コード例 #27
0
ファイル: ShipView.xaml.cs プロジェクト: hnjm/flight
 private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     this.shipVM            = e.NewValue as ShipViewModel;
     this.shipVM.ShipFired += (o, a) => { this.OnShipFired(); };
 }
コード例 #28
0
        public IActionResult Edit(ShipViewModel model)
        {
            var id = this._shipsService.Edit(model);

            return(this.RedirectToAction("Details", new RouteValueDictionary(new { controller = "Ships", action = "Details", id = id.Result })));
        }
コード例 #29
0
 public IActionResult Delete(ShipViewModel model)
 {
     return(null);
 }
コード例 #30
0
        private Dictionary<int, int> MakeShipTypeTable(ShipViewModel[] source)
        {
            if (source.Count() <= 0) return new Dictionary<int, int>();
            Dictionary<int, int> temp = new Dictionary<int, int>();
            List<int> rawList = new List<int>();
            List<int> DistinctList = new List<int>();

            foreach (var ship in source)
            {
                int ID = ship.Ship.Info.ShipType.Id;
                rawList.Add(ID);
            }
            for (int i = 0; i < rawList.Count; i++)
            {
                if (DistinctList.Contains(rawList[i]))
                    continue;
                DistinctList.Add(rawList[i]);
            }
            for (int i = 0; i < DistinctList.Count; i++)
            {
                temp.Add(DistinctList[i], rawList.Where(x => x == DistinctList[i]).Count());
            }
            return temp;
        }
コード例 #31
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="total"></param>
        /// <param name="MissonNum"></param>
        /// <param name="ResourceType">0=연료 1=탄</param>
        /// <returns></returns>
        private int LossResource(ShipViewModel[] fleet, int MissionNum, int ResourceType = 0)
        {
            double total = 0;

            string losstype = "FuelLoss";
            if (ResourceType == 1) losstype = "ArmoLoss";

            var percent = KanColleClient.Current.Translations.GetExpeditionData(losstype, MissionNum);
            if (percent == string.Empty) return -1;

            double LossPercent = (double)Convert.ToInt32(percent) / 100d;

            for (int i = 0; i < fleet.Count(); i++)
            {
                double temp = 0;
                if (ResourceType == 1) temp = Convert.ToInt32(Math.Truncate((double)fleet[i].Ship.Bull.Maximum * LossPercent));
                else temp = Convert.ToInt32(Math.Truncate((double)fleet[i].Ship.Fuel.Maximum * LossPercent));

                total += temp;
            }

            if (ResourceType == 1) this.vArmo = Visibility.Visible;
            else this.vFuel = Visibility.Visible;

            this.vResource = Visibility.Visible;
            return Convert.ToInt32(total);
        }
コード例 #32
0
 internal EquipedShipViewModel(ShipViewModel rpShip, int rpCount)
 {
     Ship = rpShip;
     Count = rpCount;
 }
コード例 #33
0
        private bool DrumCount(int Mission, ShipViewModel[] fleet)
        {
            bool result = false;
            var NeedDrumRaw = KanColleClient.Current.Translations.GetExpeditionData("DrumCount", Mission);

            var sNeedDrumRaw = NeedDrumRaw.Split(';');
            int nTotalDrum = Convert.ToInt32(sNeedDrumRaw[0]);
            int nHasDrumShip = Convert.ToInt32(sNeedDrumRaw[1]);
            this.nDrum = "총" + sNeedDrumRaw[0] + "개, " + "장착칸무스 최소 " + sNeedDrumRaw[1] + "척";
            this.vDrum = Visibility.Visible;
            int rTotalDrum = 0;
            int rHasDrumShip = 0;
            bool shipCheck = false;

            for (int i = 0; i < fleet.Count(); i++)
            {
                for (int j = 0; j < fleet[i].Ship.Slots.Count(); j++)
                {
                    if (fleet[i].Ship.Slots[j].Equipped && fleet[i].Ship.Slots[j].Item.Info.CategoryId == 30)
                    {
                        rTotalDrum++;
                        if (!shipCheck)
                        {
                            rHasDrumShip++;
                            shipCheck = true;
                        }
                    }
                }
                shipCheck = false;
            }
            if (rTotalDrum >= nTotalDrum && rHasDrumShip >= nHasDrumShip) result = true;

            return result;
        }