Пример #1
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            //Load up database
            using (ChatRoomDataContext context = new ChatRoomDataContext(Con_String))
            {
                if (!context.DatabaseExists())
                {
                    context.CreateDatabase();
                }

                list_chatrooms.ItemsSource = context.ChatRooms.ToList();
                updateChatRoomList();
            }
        }
Пример #2
0
        public void rest_updateChatRoomList_success(System.Net.HttpStatusCode code, dynamic data)
        {
            using (ChatRoomDataContext context = new ChatRoomDataContext(Con_String))
            {
                if (!context.DatabaseExists())
                {
                    context.CreateDatabase();
                }
                foreach (dynamic item in data)
                {
                    MyChatRoom room = new MyChatRoom
                    {
                        C_Name = (String)(item.name),
                        C_ID_String = (String)(item.class_id_string),
                        C_Course_Number = (int)(item.course_number),
                        C_Subject_Code = (String)(item.subject_code)
                    };
                    String room_string_id = (String)(item.class_id_string);
                    IEnumerable<MyChatRoom> queryRooms = from MyChatRoom in context.ChatRooms
                                                         where MyChatRoom.C_ID_String == room_string_id
                                                         select MyChatRoom;
                    if (queryRooms.Count() <= 0) //If we don't have this room in the database, add it.
                        context.ChatRooms.InsertOnSubmit(room);
                }
                context.SubmitChanges();

                list_chatrooms.ItemsSource = context.ChatRooms.ToList();
            }
            progress_chatlist.IsVisible = false;
        }
Пример #3
0
        private void updateChatRoomList()
        {
            //Show progress indicator
            progress_chatlist = new ProgressIndicator
            {
                IsVisible = true,
                IsIndeterminate = true,
                Text = "Updating Chat Room Listing..."
            };
            SystemTray.SetProgressIndicator(this, progress_chatlist);
            progress_chatlist.IsVisible = true;

            using (ChatRoomDataContext context = new ChatRoomDataContext(Con_String))
            {
                if (!context.DatabaseExists())
                {
                    context.CreateDatabase();
                }

                list_chatrooms.ItemsSource = context.ChatRooms.ToList();
                REST chatroomREST = new REST("chats", "GET", null);
                chatroomREST.call(rest_updateChatRoomList_success,rest_updateChatRoomList_failure);
            }
        }