Example #1
0
        public async Task <IActionResult> Comms(IFormCollection request, int fleetId)
        {
            var fleet = await _Db.Fleets.Where(c => c.Id == fleetId && c.ClosedAt == null).FirstOrDefaultAsync();

            if (fleet == null)
            {
                // Fleet not found
                return(NotFound("Fleet not found."));
            }

            int commsId = request._int("commsId");

            CommChannel comm = await _Db.CommChannels.FindAsync(commsId);

            if (comm == null)
            {
                return(BadRequest("Comms setting is invalid"));
            }

            try
            {
                fleet.CommChannel = comm;
                await _Db.SaveChangesAsync();

                return(Ok());
            }
            catch (Exception ex)
            {
                _Logger.LogError("Cannot change the fleet comms (Fleet ID: {0}) channel {1} {2}.", fleet.Id, comm.LinkText, ex.Message);
                return(BadRequest("Error setting fleet comms."));
            }
        }
Example #2
0
        static void HostedMain()
        {
            //Initialize sync context
            SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext());
            var comm = new CommChannel(Console.OpenStandardInput(), Console.OpenStandardOutput());

            Console.SetOut(new NullTextWriter());
            Console.SetError(new NullTextWriter());
            comm.Disposed += () => Process.GetCurrentProcess().Kill();
            comm.SendMessage(new StateMessage("Staying awhile and listening..."));
            var service = new AvaloniaAppHost(comm);

            service.Start();
            Application.Run();
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (SessionId.Length != 0)
            {
                hash ^= SessionId.GetHashCode();
            }
            if (MessageId.Length != 0)
            {
                hash ^= MessageId.GetHashCode();
            }
            if (CommChannel.Length != 0)
            {
                hash ^= CommChannel.GetHashCode();
            }
            if (MessageJson.Length != 0)
            {
                hash ^= MessageJson.GetHashCode();
            }
            if (stampOne_ != null)
            {
                hash ^= StampOne.GetHashCode();
            }
            if (stampTwo_ != null)
            {
                hash ^= StampTwo.GetHashCode();
            }
            if (stampThree_ != null)
            {
                hash ^= StampThree.GetHashCode();
            }
            if (stampFour_ != null)
            {
                hash ^= StampFour.GetHashCode();
            }
            if (stampFive_ != null)
            {
                hash ^= StampFive.GetHashCode();
            }
            return(hash);
        }
Example #4
0
 public CommChannel_VM()
 {
     this.commChannel = new CommChannel();
 }
Example #5
0
 public RocketLauncher(string name, CommChannel channel) : base(name, channel)
 {
 }
Example #6
0
 //constructors
 protected Device(string name, CommChannel channel)
 {
     Name         = name;
     this.channel = channel;
     status       = false;
 }
Example #7
0
 public PerspexAppHost(CommChannel channel)
 {
     _comm = channel;
 }
Example #8
0
 protected Camera(string name, CommChannel channel) : base(name, channel)
 {
 }
 public AvaloniaAppHost(CommChannel channel)
 {
     _comm     = channel;
     _appModel = new HostedAppModel(this);
 }
Example #10
0
 public PerspexAppHost(CommChannel channel)
 {
     _comm     = channel;
     _appModel = new HostedAppModel(this);
 }
Example #11
0
        public async Task <IActionResult> Index(IFormCollection request)
        {
            string EsiUrl = request._str("EsiFleetUrl");
            long   fleetId;

            try
            {
                fleetId = request._str("EsiFleetUrl").GetEsiId();
            }
            catch (Exception ex)
            {
                _Logger.LogError("Cannot parse the ESI Fleet ID from the URL provided. {0}", EsiUrl);
                return(BadRequest(string.Format("Cannot parse the ESI Fleet ID from the URL provided. {0}\n{1}", EsiUrl, ex.Message)));
            }

            int   bossId = request._int("fleetBoss");
            Pilot pilot  = await _Db.Pilots.Where(c => c.CharacterID == bossId && c.AccountId == User.AccountId()).FirstOrDefaultAsync();

            if (pilot == null)
            {
                return(NotFound("Pilot not found, or you do not have access to it."));
            }

            string fleetType = request._str("FleetType");

            //Is there an active fleet with this ID? IF yes redirect to that fleet else continue
            var fleet = await _Db.Fleets.Where(c => c.EveFleetId == fleetId && c.ClosedAt == null).FirstOrDefaultAsync();

            if (fleet != null)
            {
                // Fleet already registered let's redirect the user to that page.
                return(Ok(fleet.Id));
            }

            CommChannel comms = await _Db.CommChannels.FindAsync(request._int("FleetComms"));

            if (comms == null)
            {
                // Fleet comms not found
                _Logger.LogError("Invalid Comms channel provided.");
            }


            // TODO: Can we actually ESI into this fleet?
            if (false)
            {
                _Logger.LogWarning("(ID: {0}) does not have access to fleet {1}.", bossId, fleetId);
                return(Forbid("Pilot selected does not have access to that fleet. Check you selected the correct fleet boss!"));
            }

            Fleet newFleet = new Fleet
            {
                EveFleetId    = fleetId,
                BossPilot     = pilot,
                CommChannelId = comms.Id,
                IsPublic      = false,
                Type          = fleetType,
                CreatedAt     = DateTime.UtcNow,
                UpdatedAt     = DateTime.UtcNow
            };

            await _Db.AddAsync(newFleet);

            await _Db.SaveChangesAsync();

            // Redirect to page!
            return(Ok(newFleet.Id));
        }