internal void SendSpeakerNavigatingMessage(Speaker speaker)
 {
     throw new System.NotImplementedException();
 }
예제 #2
0
 ////public override void Cleanup()
 ////{
 ////    // Clean own resources if needed
 ////    base.Cleanup();
 ////}
 internal void SendSpeakerNavigatingMessage(Speaker speaker)
 {
     Messenger.Default.Send<SpeakerSelectionChangedMessage>(new SpeakerSelectionChangedMessage { Speaker = speaker });
 }
예제 #3
0
        void SessionDownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                string stringArray = e.Result.Substring(12, e.Result.Length - 13);

                ReportSessionProgress("Reading data...", 80);
                List <SessionDto> sessions = JsonConvert.DeserializeObject <List <SessionDto> >(stringArray);

                ReportSessionProgress("Preparing to save data...", 85);
                ConferenceDataContext dc = new ConferenceDataContext("isostore:/conference.sdf");

                dc.Sessions.DeleteAllOnSubmit(dc.Sessions);
                dc.SubmitChanges();

                ReportSessionProgress("Saving to device...", 90);
                List <Session> sessionList = new List <Session>();
                foreach (var ssn in sessions.OrderBy(r => r.title))
                {
                    // check to see if the tags exist already, if not add them
                    foreach (var tag in ssn.tags)
                    {
                        if (dc.Tags.Where(t => t.Title == tag).Count() == 0)
                        {
                            dc.Tags.InsertOnSubmit(new Tag {
                                Title = tag, SessionTags = new EntitySet <SessionTags>()
                            });
                            dc.SubmitChanges();
                        }
                    }

                    // create a db version of the record
                    Session s = new Session
                    {
                        Abstract        = ssn.@abstract,
                        Finish          = ssn.finish,
                        Room            = ssn.room,
                        SessionId       = ssn.id,
                        Start           = ssn.start,
                        TagList         = string.Join(", ", ssn.tags).ToUpper(),
                        Title           = ssn.title,
                        SessionSpeakers = new EntitySet <SessionSpeakers>(),
                        SessionTags     = new EntitySet <SessionTags>()
                    };

                    // update the db
                    dc.Sessions.InsertOnSubmit(s);
                    dc.SubmitChanges();

                    // build up the speaker list
                    foreach (int speakerId in ssn.speakers)
                    {
                        Speaker speaker = dc.Speakers.Where(sp => sp.SpeakerId == speakerId).First();
                        s.SessionSpeakers.Add(new SessionSpeakers {
                            Speaker = speaker, Session = s
                        });
                        dc.SubmitChanges();
                    }

                    // default is a speaker if none are present
                    if (s.SessionSpeakers.Count == 0)
                    {
                        s.SessionSpeakers.Add(new SessionSpeakers {
                            Session = s, Speaker = dc.Speakers.Where(k => k.FirstName == "TBD").First()
                        });
                    }

                    // build up the tag list
                    foreach (var item in ssn.tags)
                    {
                        Tag tag = dc.Tags.Where(t => t.Title == item).First();
                        s.SessionTags.Add(new SessionTags {
                            Session = s, Tag = tag
                        });
                        dc.SubmitChanges();
                    }
                }


                ReportSessionProgress("Sessions downloaded and saved.", 95);

                int sessionCount  = dc.Sessions.Count();
                int speakersCount = dc.Speakers.Count();
                ReportCompletedRefresh(sessionCount, speakersCount);
                dc.Dispose();
                dc = null;
            }
            else
            {
                NetworkWentBoom();
            }
        }