public void Initialize()
        {
            var storage = new FileStreamStorageStrategy();
            var http = new HTTPConfigurationProvider();
            var communication = new BinaryHTTPAsynchronousCommunicationStrategy(http);
            var notification = new WindowsPhoneNotificationStrategy(http);
            communication.SetNotificationStrategy(notification);

            _community = new Community(storage);
            _community.AddAsynchronousCommunicationStrategy(communication);
            _community.Register<CorrespondenceModel>();
            _community.Subscribe(() => Individual);
            _community.Subscribe(() => Individual.MessageBoards);

            CreateIndividual(http);

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

            // Synchronize when the network becomes available.
            System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += (sender, e) =>
            {
                if (NetworkInterface.GetIsNetworkAvailable())
                    Synchronize();
            };

            // And synchronize on startup or resume.
            Synchronize();
        }
Exemple #2
0
        public void Initialize()
        {
            var storage       = new FileStreamStorageStrategy();
            var http          = new HTTPConfigurationProvider();
            var communication = new BinaryHTTPAsynchronousCommunicationStrategy(http);
            var notification  = new WindowsPhoneNotificationStrategy(http);

            communication.SetNotificationStrategy(notification);

            _community = new Community(storage);
            _community.AddAsynchronousCommunicationStrategy(communication);
            _community.Register <CorrespondenceModel>();
            _community.Subscribe(() => Individual);
            _community.Subscribe(() => Individual.MessageBoards);

            CreateIndividual(http);

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

            // Synchronize when the network becomes available.
            System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += (sender, e) =>
            {
                if (NetworkInterface.GetIsNetworkAvailable())
                {
                    Synchronize();
                }
            };

            // And synchronize on startup or resume.
            Synchronize();
        }
        public void Initialize()
        {
            // TODO: Uncomment these lines to choose a database storage strategy.
            // string correspondenceConnectionString = ConfigurationManager.ConnectionStrings["Correspondence"].ConnectionString;
            // var storage = new SQLStorageStrategy(correspondenceConnectionString).UpgradeDatabase();

            string path = HostingEnvironment.MapPath("~/App_Data/Correspondence");
            var storage = new FileStreamStorageStrategy(path);
            var http = new HTTPConfigurationProvider();
            var communication = new BinaryHTTPAsynchronousCommunicationStrategy(http);

            _community = new Community(storage);
            _community.AddAsynchronousCommunicationStrategy(communication);
            _community.Register<CorrespondenceModel>();
            _community.Subscribe(() => Domain);
            _community.ClientApp = false;

            LoadDomain();

            // 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();
        }
        public async void Initialize()
        {
            var storage       = new FileStreamStorageStrategy();
            var http          = new HTTPConfigurationProvider();
            var communication = new BinaryHTTPAsynchronousCommunicationStrategy(http);

            _community = new Community(storage);
            _community.AddAsynchronousCommunicationStrategy(communication);
            _community.Register <CorrespondenceModel>();
            _community.Subscribe(() => _individual.Value);
            _community.Subscribe(() => _conference.Value);

            // Synchronize periodically.
            DispatcherTimer timer          = new DispatcherTimer();
            int             timeoutSeconds = Math.Min(http.Configuration.TimeoutSeconds, 30);

            timer.Interval = TimeSpan.FromSeconds(5 * timeoutSeconds);
            timer.Tick    += delegate(object sender, object e)
            {
                Synchronize();
            };
            timer.Start();

            Individual individual = await _community.LoadFactAsync <Individual>(ThisIndividual);

            if (individual == null)
            {
                string randomId = Punctuation.Replace(Guid.NewGuid().ToString(), String.Empty).ToLower();
                individual = await _community.AddFactAsync(new Individual(randomId));

                await _community.SetFactAsync(ThisIndividual, individual);
            }
            var conference = await _community.AddFactAsync(new Conference(CommonSettings.ConferenceID));

            lock (this)
            {
                _individual.Value = individual;
                _conference.Value = conference;
            }

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

            // Synchronize when the network becomes available.
            System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += (sender, e) =>
            {
                if (NetworkInterface.GetIsNetworkAvailable())
                {
                    Synchronize();
                }
            };

            // And synchronize on startup or resume.
            Synchronize();
        }
Exemple #5
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();
        }
        public async void Initialize()
        {
            var storage = new FileStreamStorageStrategy();
            var http = new HTTPConfigurationProvider();
            var communication = new BinaryHTTPAsynchronousCommunicationStrategy(http);

            _community = new Community(storage);
            _community.AddAsynchronousCommunicationStrategy(communication);
            _community.Register<CorrespondenceModel>();
            _community.Subscribe(() => _individual.Value);
            _community.Subscribe(() => _conference.Value);

            // Synchronize periodically.
            DispatcherTimer timer = new DispatcherTimer();
            int timeoutSeconds = Math.Min(http.Configuration.TimeoutSeconds, 30);
            timer.Interval = TimeSpan.FromSeconds(5 * timeoutSeconds);
            timer.Tick += delegate(object sender, object e)
            {
                Synchronize();
            };
            timer.Start();

            Individual individual = await _community.LoadFactAsync<Individual>(ThisIndividual);
            if (individual == null)
            {
                string randomId = Punctuation.Replace(Guid.NewGuid().ToString(), String.Empty).ToLower();
                individual = await _community.AddFactAsync(new Individual(randomId));
                await _community.SetFactAsync(ThisIndividual, individual);
            }
            var conference = await _community.AddFactAsync(new Conference(CommonSettings.ConferenceID));
            lock (this)
            {
                _individual.Value = individual;
                _conference.Value = conference;
            }

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

            // Synchronize when the network becomes available.
            System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += (sender, e) =>
            {
                if (NetworkInterface.GetIsNetworkAvailable())
                    Synchronize();
            };

            // And synchronize on startup or resume.
            Synchronize();
        }
        public void Initialize()
        {
            var storage       = new FileStreamStorageStrategy();
            var http          = new HTTPConfigurationProvider();
            var communication = new BinaryHTTPAsynchronousCommunicationStrategy(http);

            _community = new Community(storage);
            _community.AddAsynchronousCommunicationStrategy(communication);
            _community.Register <CorrespondenceModel>();
            _community.Subscribe(() => Individual);
            _community.Subscribe(() => Individual.MessageBoards);

            // Synchronize periodically.
            DispatcherTimer timer          = new DispatcherTimer();
            int             timeoutSeconds = Math.Min(http.Configuration.TimeoutSeconds, 30);

            timer.Interval = TimeSpan.FromSeconds(5 * timeoutSeconds);
            timer.Tick    += delegate(object sender, object e)
            {
                Synchronize();
            };
            timer.Start();

            CreateIndividual(http);

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

            // Synchronize when the network becomes available.
            System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += (sender, e) =>
            {
                if (NetworkInterface.GetIsNetworkAvailable())
                {
                    Synchronize();
                }
            };

            // And synchronize on startup or resume.
            Synchronize();
        }
Exemple #8
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 #9
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();
        }
        public void Initialize()
        {
            var storage = new FileStreamStorageStrategy();
            var http = new HTTPConfigurationProvider();
            var communication = new BinaryHTTPAsynchronousCommunicationStrategy(http);

            _community = new Community(storage);
            _community.AddAsynchronousCommunicationStrategy(communication);
            _community.Register<CorrespondenceModel>();
            _community.Subscribe(() => Individual);
            _community.Subscribe(() => Individual.MessageBoards);

            // Synchronize periodically.
            DispatcherTimer timer = new DispatcherTimer();
            int timeoutSeconds = Math.Min(http.Configuration.TimeoutSeconds, 30);
            timer.Interval = TimeSpan.FromSeconds(5 * timeoutSeconds);
            timer.Tick += delegate(object sender, object e)
            {
                Synchronize();
            };
            timer.Start();

            CreateIndividual(http);

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

            // Synchronize when the network becomes available.
            System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += (sender, e) =>
            {
                if (NetworkInterface.GetIsNetworkAvailable())
                    Synchronize();
            };

            // And synchronize on startup or resume.
            Synchronize();
        }
        public void Initialize()
        {
            // TODO: Uncomment these lines to choose a database storage strategy.
            // string correspondenceConnectionString = ConfigurationManager.ConnectionStrings["Correspondence"].ConnectionString;
            // var storage = new SQLStorageStrategy(correspondenceConnectionString).UpgradeDatabase();

            string path          = HostingEnvironment.MapPath("~/App_Data/Correspondence");
            var    storage       = new FileStreamStorageStrategy(path);
            var    http          = new HTTPConfigurationProvider();
            var    communication = new BinaryHTTPAsynchronousCommunicationStrategy(http);

            _community = new Community(storage);
            _community.AddAsynchronousCommunicationStrategy(communication);
            _community.Register <CorrespondenceModel>();
            _community.Subscribe(() => Domain);
            _community.ClientApp = false;

            LoadDomain();

            // 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();
        }
        public async void Initialize()
        {
            try
            {
                var storage = new FileStreamStorageStrategy();
                var http = new HTTPConfigurationProvider();
                var communication = new BinaryHTTPAsynchronousCommunicationStrategy(http);

                _community = new Community(storage);
                //_community.AddAsynchronousCommunicationStrategy(communication);
                _community.Register<CorrespondenceModel>();
                _community.Subscribe(() => _individual.Value);

                // Synchronize periodically.
                DispatcherTimer timer = new DispatcherTimer();
                int timeoutSeconds = Math.Min(http.Configuration.TimeoutSeconds, 30);
                timer.Interval = TimeSpan.FromSeconds(5 * timeoutSeconds);
                timer.Tick += delegate(object sender, object e)
                {
                    Synchronize();
                };
                timer.Start();

                var company = await _community.AddFactAsync(new Company("improvingEnterprises"));
                var quarter = await _community.AddFactAsync(new Quarter(company, CurrentQuarter));

                var categoryGenerator = new CategoryGenerator(_community, company, quarter);
                await categoryGenerator.GenerateAsync();

                lock (this)
                {
                    _company.Value = company;
                    _quarter.Value = quarter;
                }

                Individual individual = await _community.LoadFactAsync<Individual>(ThisIndividual);
                if (individual == null)
                {
                    string randomId = Punctuation.Replace(Guid.NewGuid().ToString(), String.Empty).ToLower();
                    individual = await _community.AddFactAsync(new Individual(randomId));
                    await _community.SetFactAsync(ThisIndividual, individual);
                }
                lock (this)
                {
                    _individual.Value = individual;
                }
                http.Individual = individual;

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

                // Synchronize when the network becomes available.
                System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += (sender, e) =>
                {
                    if (NetworkInterface.GetIsNetworkAvailable())
                        Synchronize();
                };

                // And synchronize on startup or resume.
                Synchronize();
            }
            catch (Exception x)
            {
                System.Diagnostics.Debug.WriteLine(x.Message);
            }
        }