Beispiel #1
0
        public void ExecuteCommand(IConnection connection, AsyncBinaryCommandInfo request)
        {
            try
            {
                if (request.Buffer == null || request.Buffer.Length == 0)
                {
                    // do some logging here
                    connection.BeginDisconnect();
                    return;
                }

                NextRequest  nr       = request.Buffer.Deserialize <NextRequest>();
                NextResponse response = new NextResponse();
                for (var i = 0; i < nr.Count; i++)
                {
                    response.Sequence.Add(Generation.Next());
                }

                // get from protocol buffers
                request.Reply(connection, response.Serialize());
            }
            catch (Exception exp)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Error.WriteLine(exp.Message);
                Console.Error.WriteLine(exp.StackTrace);
                Console.ForegroundColor = ConsoleColor.Gray;
            }
        }
Beispiel #2
0
        public void SaveIncomingFile(string FileName, bool PrintAlso = false)
        {
            State = NextResponse.SaveFile;
            if (PrintAlso)
            {
                State = NextResponse.SaveFile | NextResponse.Print1KB;
            }

            stream = new StreamWriter(FileName);
        }
Beispiel #3
0
        public HttpResponseMessage Next(int conferenceId)
        {
            var res = new NextResponse();

            res.Sessions  = new Dictionary <int, IEnumerable <Session> >();
            res.Attendees = new Dictionary <int, IEnumerable <SessionAttendee> >();
            var rooms     = LocationRepository.Instance.GetLocationsByConference(conferenceId);
            var sessions  = SessionRepository.Instance.GetSessionsByConference(conferenceId).Where(s => s.SessionEnd > System.DateTime.Now & s.SessionDateAndTime != null && ((System.DateTime)s.SessionDateAndTime).Date == System.DateTime.Now.Date);
            var attendees = SessionAttendeeRepository.Instance.GetSessionAttendees(conferenceId);

            foreach (var room in rooms)
            {
                res.Sessions.Add(room.LocationId, sessions.Where(s => s.LocationId == room.LocationId).OrderBy(s => s.SessionDateAndTime));
            }
            foreach (var session in sessions)
            {
                res.Attendees.Add(session.SessionId, attendees.Where(a => a.SessionId == session.SessionId).OrderBy(a => a.SessionAttendeeName));
            }
            return(Request.CreateResponse(HttpStatusCode.OK, res));
        }
Beispiel #4
0
        public async Task<NextResponse> Next(string userId)
        {
            var user = await GetUser(userId);

            if (null == user)
                return null;

            var response = new NextResponse();

            response.Videos = svc.GetRandomVideos(user.User);
            response.IsNewUser = user.IsNewUser;

            response.WatchHistory = user.User.WatchedVideos;
           
            //-- We want to remove the cirucular references here for the json serializer
            foreach (var wv in user.User.WatchedVideos)
            {
                wv.User = null;
            }
            return response;
        }
Beispiel #5
0
        public void OnChunkDataRecieved(object sender, DataChunkArgs e)
        {
            if (!e.Finished)
            {
                var decoded = Encoding.ASCII.GetString(e.Buffer);

                if (State.HasFlag(NextResponse.PrintFile) || State.HasFlag(NextResponse.Print1KB))
                {
                    if (State.HasFlag(NextResponse.Print1KB))
                    {
                        Console.Write(Encoding.ASCII.GetString(e.Buffer, 0, Math.Min(e.Buffer.Length, 1024)));
                    }
                    else
                    {
                        Console.Write(decoded);
                    }
                }


                if (State.HasFlag(NextResponse.SaveFile))
                {
                    stream.Write(decoded);
                }
            }
            else
            {
                if (State == NextResponse.PrintFile)
                {
                    Console.Write("\n");
                }

                if (State == NextResponse.SaveFile)
                {
                    stream.Write("\n");
                    stream.Close();
                }

                State = NextResponse.DoNothing;
            }
        }
 public HttpResponseMessage Next(int conferenceId)
 {
     var res = new NextResponse();
     res.Sessions = new Dictionary<int, IEnumerable<Session>>();
     res.Attendees = new Dictionary<int, IEnumerable<SessionAttendee>>();
     var rooms = LocationRepository.Instance.GetLocations(conferenceId);
     var sessions = SessionRepository.Instance.GetSessions(conferenceId).Where(s => s.SessionEnd > System.DateTime.Now & s.SessionDateAndTime != null && ((System.DateTime)s.SessionDateAndTime).Date == System.DateTime.Now.Date);
     var attendees = SessionAttendeeRepository.Instance.GetSessionAttendees(conferenceId);
     foreach (var room in rooms)
     {
         res.Sessions.Add(room.LocationId, sessions.Where(s => s.LocationId == room.LocationId).OrderBy(s => s.SessionDateAndTime));
     }
     foreach (var session in sessions)
     {
         res.Attendees.Add(session.SessionId, attendees.Where(a => a.SessionId == session.SessionId).OrderBy(a => a.SessionAttendeeName));
     }
     return Request.CreateResponse(HttpStatusCode.OK, res);
 }
Beispiel #7
0
 public void PrintIncomingFile()
 {
     State = NextResponse.PrintFile;
 }