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 #2
0
 private void CreateIndividual(HTTPConfigurationProvider http)
 {
     Community.Perform(async delegate
     {
         var individual  = await _community.AddFactAsync(new Individual(GetAnonymousUserId()));
         Individual      = individual;
         http.Individual = individual;
     });
 }
        public async Task Initialize()
        {
            _community = new Community(new MemoryStorageStrategy())
                .Register<CorrespondenceModel>();

            _company = await _community.AddFactAsync(new Company("improvingEnterprises"));
            _quarter = await _community.AddFactAsync(new Quarter(_company, new DateTime(2013, 1, 1)));
            _categoryGenerator = new CategoryGenerator(_community, _company, _quarter);
            await _categoryGenerator.GenerateAsync();
        }
        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 InitializeForDesignTime()
        {
            var storage = new MemoryStorageStrategy();

            _community = new Community(storage);
            _community.Register <CorrespondenceModel>();

            Individual individual = _community.AddFactAsync(new Individual("DesignTimeUser")).Result;
            var        conference = _community.AddFactAsync(new Conference(CommonSettings.ConferenceID)).Result;

            _individual.Value = individual;
            _conference.Value = conference;
        }
Exemple #6
0
 private void CreateIndividual()
 {
     Community.Perform(async delegate
     {
         var 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);
         }
         Individual = individual;
     });
 }
 public void SendMessage(string text)
 {
     Community.Perform(async delegate
     {
         var domain = await Community.AddFactAsync(new Domain());
         await Community.AddFactAsync(new Message(this, domain, text));
     });
 }
        private async Task CreateIndividualsAsync()
        {
            _individualFlynn = await _communityFlynn.AddFactAsync(
                new Individual("flynn"));

            _individualAlan = await _communityAlan.AddFactAsync(
                new Individual("alan"));
        }
        public async Task <Share> JoinMessageBoardAsync(string topic)
        {
            MessageBoard messageBoard = await Community.AddFactAsync(new MessageBoard(topic));

            Share share = await Community.AddFactAsync(new Share(this, messageBoard));

            return(share);
        }
        private void LoadDomain()
        {
            _community.Perform(async delegate
            {
                var domain = await _community.AddFactAsync(new Domain());
                Domain     = domain;

                _community.BeginSending();
                _community.BeginReceiving();
            });
        }
Exemple #11
0
 public async Task RemoveScheduleAsync(SessionPlace sessionPlace)
 {
     foreach (var attendee in await Attendees.EnsureAsync())
     {
         foreach (var schedule in await attendee.CurrentSchedules.EnsureAsync())
         {
             if (schedule.SessionPlace == sessionPlace)
             {
                 await Community.AddFactAsync(new ScheduleRemove(schedule));
             }
         }
     }
 }
Exemple #12
0
        public static async Task Populate(Community community, Conference conference, Individual individual)
        {
            conference.Name = "AwesomeFest 2013: The Gathering";

            var day = await community.AddFactAsync(new Day(conference, new DateTime(2013, 2, 23)));
            var placeTime = await community.AddFactAsync(new Time(day, new DateTime(2013, 2, 23, 8, 0, 0)));
            var room = await community.AddFactAsync(new Room(conference));
            room.RoomNumber = "101";
            var place = await community.AddFactAsync(new Place(placeTime, room));
            var speaker = await community.AddFactAsync(new Speaker(conference, "Speaker One"));
            var track = await community.AddFactAsync(new Track(conference, "Agile"));
            var session = await community.AddFactAsync(new Model.Session(conference, speaker, track));
            session.Name = "Kanban, Planning Poker, and Other Crazy Practices";
            var sessionPlace = await community.AddFactAsync(new SessionPlace(session, place, Enumerable.Empty<SessionPlace>()));
        }
Exemple #13
0
        public async Task Initialize()
        {
            var sharedCommunication = new MemoryCommunicationStrategy();
            _communityFlynn = new Community(new MemoryStorageStrategy())
                .AddCommunicationStrategy(sharedCommunication)
                .Register<CorrespondenceModel>()
                .Subscribe(() => _individualFlynn)
				;
            _communityAlan = new Community(new MemoryStorageStrategy())
                .AddCommunicationStrategy(sharedCommunication)
                .Register<CorrespondenceModel>()
                .Subscribe(() => _individualAlan)
                ;

            _individualFlynn = await _communityFlynn.AddFactAsync(new Individual("flynn"));
            _individualAlan = await _communityAlan.AddFactAsync(new Individual("alan"));
        }
Exemple #14
0
        public async Task <Schedule> AddScheduleAsync(SessionPlace sessionPlace)
        {
            Attendee attendee = (await Attendees.EnsureAsync()).FirstOrDefault();

            if (attendee == null)
            {
                attendee = await Community.AddFactAsync(new Attendee(
                                                            sessionPlace.Session.Conference,
                                                            Guid.NewGuid().ToString()));
            }
            await Community.AddFactAsync(new IndividualAttendee(this, attendee));

            var slot = await Community.AddFactAsync(new Slot(
                                                        attendee,
                                                        sessionPlace.Place.PlaceTime));

            return(await Community.AddFactAsync(new Schedule(slot, sessionPlace)));
        }
Exemple #15
0
        public async Task Initialize()
        {
            var sharedCommunication = new MemoryCommunicationStrategy();

            _communityFlynn = new Community(new MemoryStorageStrategy())
                              .AddCommunicationStrategy(sharedCommunication)
                              .Register <CorrespondenceModel>()
                              .Subscribe(() => _individualFlynn)
            ;
            _communityAlan = new Community(new MemoryStorageStrategy())
                             .AddCommunicationStrategy(sharedCommunication)
                             .Register <CorrespondenceModel>()
                             .Subscribe(() => _individualAlan)
            ;

            _individualFlynn = await _communityFlynn.AddFactAsync(new Individual("flynn"));

            _individualAlan = await _communityAlan.AddFactAsync(new Individual("alan"));
        }
Exemple #16
0
        public static async Task Populate(Community community, Conference conference, Individual individual)
        {
            conference.Name = "AwesomeFest 2013: The Gathering";

            var day = await community.AddFactAsync(new Day(conference, new DateTime(2013, 2, 23)));

            var placeTime = await community.AddFactAsync(new Time(day, new DateTime(2013, 2, 23, 8, 0, 0)));

            var room = await community.AddFactAsync(new Room(conference));

            room.RoomNumber = "101";
            var place = await community.AddFactAsync(new Place(placeTime, room));

            var speaker = await community.AddFactAsync(new Speaker(conference, "Speaker One"));

            var track = await community.AddFactAsync(new Track(conference, "Agile"));

            var session = await community.AddFactAsync(new Model.Session(conference, speaker, track));

            session.Name = "Kanban, Planning Poker, and Other Crazy Practices";
            var sessionPlace = await community.AddFactAsync(new SessionPlace(session, place, Enumerable.Empty <SessionPlace>()));
        }
Exemple #17
0
 public void Leave()
 {
     Community.AddFactAsync(new ShareDelete(this));
 }
        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);
            }
        }
        public async Task Initialize()
        {
            _community = new Community(new MemoryStorageStrategy())
                .Register<CorrespondenceModel>();

            _profile = await _community.AddFactAsync(new Profile());
            _profile.Name = "Michael Perry";

            var company = await _community.AddFactAsync(new Company("improvingEnterprises"));
            var quarter = await _community.AddFactAsync(new Quarter(company, new DateTime(2012, 7, 1)));

            var industryContributionLeadership = await _community.AddFactAsync(new Category(company, "industryContributionLeadership"));
            industryContributionLeadership.Description = "Industry Contribution/Leadership";
            var leadUserGroup = await _community.AddFactAsync(new ActivityDefinition(industryContributionLeadership, "leadUserGroup"));
            leadUserGroup.Description = "Lead a user group";
            leadUserGroup.Qualifier = "mtg";
            var leadUserGroupReward = await _community.AddFactAsync(new ActivityReward(leadUserGroup, quarter));
            leadUserGroupReward.Points = 3;
            var presentationUserGroup = await _community.AddFactAsync(new ActivityDefinition(industryContributionLeadership, "presentationUserGroup"));
            presentationUserGroup.Description = "Presentation - user group";
            presentationUserGroup.Qualifier = "presentation";
            var presentationUserGroupReward = await _community.AddFactAsync(new ActivityReward(presentationUserGroup, quarter));
            presentationUserGroupReward.Points = 10;

            var certificationRecognition = await _community.AddFactAsync(new Category(company, "certificationRecognition"));
            certificationRecognition.Description = "Certification/Recognition";
            var mvp = await _community.AddFactAsync(new ActivityDefinition(certificationRecognition, "microsoftMvp"));
            mvp.Description = "Microsoft MVP";
            var mvpReward = await _community.AddFactAsync(new ActivityReward(mvp, quarter));
            mvpReward.Points = 50;

            var profileQuarter = await _community.AddFactAsync(new ProfileQuarter(_profile, quarter));

            var a1 = await _community.AddFactAsync(new Activity(profileQuarter, leadUserGroupReward, new DateTime(2012, 9, 4)));
            a1.Description = "Dallas XAML User Group";
            var a2 = await _community.AddFactAsync(new Activity(profileQuarter, mvpReward, new DateTime(2012, 7, 1)));
            var a3 = await _community.AddFactAsync(new Activity(profileQuarter, presentationUserGroupReward, new DateTime(2012, 9, 4)));
            a3.Description = "Dallas XAML User Group";

            _viewModel = new ActivityReportViewModel(_profile);
        }
        public void InitializeForDesignTime()
        {
            var storage = new MemoryStorageStrategy();

            _community = new Community(storage);
            _community.Register<CorrespondenceModel>();

            Individual individual = _community.AddFactAsync(new Individual("DesignTimeUser")).Result;
            var conference = _community.AddFactAsync(new Conference(CommonSettings.ConferenceID)).Result;
            _individual.Value = individual;
            _conference.Value = conference;
        }
Exemple #21
0
 public Task <Slot> NewSlot(Time time)
 {
     return(Community.AddFactAsync(new Slot(this, time)));
 }