Exemplo n.º 1
0
 public CrewController(MyContext context)
 {
     _context = context;
     assembly = new SendDataMsg();
 }
Exemplo n.º 2
0
        public IActionResult Load()
        {
            List <ComponentViewModel> list = new List <ComponentViewModel>();
            string identity = "";

            if (base.user.IsLandHome)
            {
                identity = base.user.ShipId;
            }
            List <Models.Component> components = new List <Models.Component>();
            SendDataMsg             assembly   = new SendDataMsg();

            assembly.SendComponentQuery(identity);
            ProtoBuffer.Models.ComponentResponse response = new ProtoBuffer.Models.ComponentResponse();
            //Task.WhenAny();
            bool flag = true;

            new TaskFactory().StartNew(() =>
            {
                while (ManagerHelp.ComponentReponse == "" && flag)
                {
                    Thread.Sleep(100);
                }
            }).Wait(3000);
            flag = false;
            try
            {
                if (ManagerHelp.ComponentReponse != "")
                {
                    response = JsonConvert.DeserializeObject <ProtoBuffer.Models.ComponentResponse>(ManagerHelp.ComponentReponse);
                    ManagerHelp.ComponentReponse = "";
                    if (response.result == 0 && response.componentinfos != null && response.componentinfos.Count > 0)
                    {
                        SaveData(response.componentinfos);
                        foreach (var item in response.componentinfos)
                        {
                            if (item.componentid == ManagerHelp.ComponentId)
                            {
                                continue;
                            }
                            ComponentViewModel model = new ComponentViewModel()
                            {
                                Id   = item.componentid,
                                name = item.cname,
                                type = (int)item.type
                            };
                            list.Add(model);
                        }
                    }
                }
            }
            catch (Exception)
            {
            }

            var data = new
            {
                code = 0,
                data = list
            };

            return(new JsonResult(data));
        }
Exemplo n.º 3
0
 public ShipController(MyContext context, ILogger <ShipController> logger)
 {
     _context = context;
     _logger  = logger;
     assembly = new SendDataMsg();
 }