Exemple #1
0
        static void Main(string[] args)
        {
            string    path      = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FacetedWorlds", "MyConSurveys");
            Community community = new Community(FileStreamStorageStrategy.Load(path))
                                  .AddAsynchronousCommunicationStrategy(new BinaryHTTPAsynchronousCommunicationStrategy(new HTTPConfigurationProvider()))
                                  .Register <CorrespondenceModel>()
                                  .Subscribe(() => _conference)
                                  .Subscribe(() => _conference.AllSessionSurveys);

            _conference = community.AddFact(new Conference(CommonSettings.ConferenceID));

            Console.WriteLine("Receiving facts.");
            community.BeginReceiving();
            WaitWhileSynchronizing(community);

            var completedSurveys =
                from survey in _conference.AllSessionSurveys
                from completed in survey.Completed
                select new
            {
                SessionName = completed.SessionEvaluation.Schedule.SessionPlace.Session.Name,
                SpeakerName = completed.SessionEvaluation.Schedule.SessionPlace.Session.Speaker.Name,
                Ratings     =
                    from ratingAnswer in completed.SessionEvaluation.RatingAnswers
                    select new
                {
                    Question = ratingAnswer.Rating.Question.Text,
                    Answer   = ratingAnswer.Value
                },
                Essays =
                    from essayAnswer in completed.SessionEvaluation.EssayAnswers
                    select new
                {
                    Question = essayAnswer.Essay.Question.Text,
                    Answer   = essayAnswer.Value
                }
            };

            foreach (var completedSurvey in completedSurveys)
            {
                Console.WriteLine(completedSurvey.SessionName);
                Console.WriteLine(completedSurvey.SpeakerName);
                foreach (var rating in completedSurvey.Ratings)
                {
                    Console.WriteLine(String.Format("{0}: {1}", rating.Question, rating.Answer));
                }
                foreach (var essay in completedSurvey.Essays)
                {
                    Console.WriteLine(String.Format("{0}: {1}", essay.Question, essay.Answer));
                }
                Console.WriteLine();
            }

            Console.WriteLine("Finished.");
            Console.ReadKey();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            string folderPath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                "FacetedWorlds",
                "MyCon");
            Community community = new Community(FileStreamStorageStrategy.Load(folderPath))
                                  .AddAsynchronousCommunicationStrategy(new BinaryHTTPAsynchronousCommunicationStrategy(new HTTPConfigurationProvider()))
                                  .Register <CorrespondenceModel>()
                                  .Subscribe(() => _conference);

            _conference = community.AddFact(new Conference(CommonSettings.ConferenceID));

            Console.WriteLine("Receiving facts.");
            community.BeginReceiving();
            WaitWhileSynchronizing(community);

            Console.WriteLine("Finished.");
            Console.ReadKey();
        }
Exemple #3
0
        public void Initialize()
        {
            HTTPConfigurationProvider configurationProvider = new HTTPConfigurationProvider();
            string path = Path.Combine(HostingEnvironment.MapPath("~/App_Data"), "Correspondence");

            _community = new Community(FileStreamStorageStrategy.Load(path))
                         .AddAsynchronousCommunicationStrategy(new BinaryHTTPAsynchronousCommunicationStrategy(configurationProvider))
                         .Register <CorrespondenceModel>()
                         .Subscribe(() => _conference)
            ;
            _community.ClientApp = false;

            string conferenceId = ConfigurationManager.AppSettings["ConferenceID"];

            if (string.IsNullOrEmpty(conferenceId))
            {
                conferenceId = CommonSettings.ConferenceID;
            }
            _conference = _community.AddFact(new Conference(conferenceId));

            // Synchronize whenever the user has something to send.
            _community.FactAdded += delegate
            {
                _community.BeginSending();
            };

            // Resume in 5 minutes if there is an error.
            Timer synchronizeTimer = new Timer();

            synchronizeTimer.Elapsed += delegate
            {
                _community.BeginSending();
                _community.BeginReceiving();
            };
            synchronizeTimer.Interval = 5.0 * 60.0 * 1000.0;
            synchronizeTimer.Start();

            // And synchronize on startup.
            _community.BeginSending();
            _community.BeginReceiving();
        }