Ejemplo n.º 1
0
        public MainWindow()
        {
            Globals.currUserSub = new List <Channel>();
            InitializeComponent();
            lbNewsLists.ItemsSource = articleList;

            string isRemember = ConfigurationManager.AppSettings["isRemember"];


// if not login or first sign up user, will open today's canada news list

            if (Globals.currUserSub.Count == 0 && isRemember == "false")
            {
                Label messageLable = new Label();
                messageLable.Content = "Today's news in Canada. Login to see your channels";
                wpChannels.Children.Add(messageLable);
                try
                {
                    items = Utiles.GetTodayInCanada();
                    AddArticleList(items);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Fatal error: enable to connect API \n" + ex.Message,
                                    "HeadLine News API error", MessageBoxButton.OK, MessageBoxImage.Error);
                    Close();
                }
            }
            else
            {
                //read from app.config, to see if user checked remember me
                try
                {
                    string userEmail = ConfigurationManager.AppSettings["userEmail"];
                    string password  = ConfigurationManager.AppSettings["password"];

                    Globals.Db = new Database();
                    //get current user info
                    Globals.currUser = Globals.Db.LoginVerification(userEmail);
                    //get current user subscribed channel info
                    Globals.currUserSub = Globals.Db.GetSubscriptChannels(Globals.currUser);
                    loadCurrUserSub();
                    loadArticle();
                    lbNewsLists.Items.Refresh();
                }
                catch (SqlException ex)
                {
                    MessageBox.Show("Fatal error: unable to connext to database\n" + ex.Message,
                                    "HeadLine News Database", MessageBoxButton.OK, MessageBoxImage.Error);
                    Close();
                }
            }



            HideScriptErrors(wbIE, true);
        }
Ejemplo n.º 2
0
        private void RegisteLogout_ButtonClick(object sender, RoutedEventArgs e)
        {
            RegisteLogout registeLogout = new RegisteLogout();

            registeLogout.ShowDialog();
            if (Globals.currUser != null)
            {
                loadCurrUserSub();

                loadArticle();
            }
            else
            {
                wpChannels.Children.Clear();
                Label messageLable = new Label();
                messageLable.Content = "Today's news in Canada. Login to see your channels";
                wpChannels.Children.Add(messageLable);
                items = Utiles.GetTodayInCanada();

                AddArticleList(items);
                lbNewsLists.Items.Refresh();
            }
        }