Exemplo n.º 1
0
        public void RefreshRecommendationsWatch()
        {
            try
            {
                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
                {
                    RecommendationsWatch.Clear();
                });

                List<JMMServerBinary.Contract_Recommendation> contracts =
                    JMMServerVM.Instance.clientBinaryHTTP.GetRecommendations(UserSettingsVM.Instance.Dash_RecWatch_Items, JMMServerVM.Instance.CurrentUser.JMMUserID.Value,
                    (int)RecommendationType.Watch);

                System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)delegate()
                {
                    foreach (JMMServerBinary.Contract_Recommendation contract in contracts)
                    {
                        RecommendationVM rec = new RecommendationVM();
                        rec.Populate(contract);
                        RecommendationsWatch.Add(rec);
                    }

                    // add a dummy object so that we can display a prompt
                    // for the user to sync thier votes
                    if (RecommendationsWatch.Count == 0)
                        RecommendationsWatch.Add(new SyncVotesDummy());

                    ViewRecommendationsWatch.Refresh();
                });
            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
            }
        }
        private void RefreshData()
        {
            try
            {
                Window parentWindow = Window.GetWindow(this);
                parentWindow.Cursor = Cursors.Wait;

                Recs.Clear();

                List<JMMServerBinary.Contract_Recommendation> contracts =
                    JMMServerVM.Instance.clientBinaryHTTP.GetRecommendations(UserSettingsVM.Instance.DownloadsRecItems, JMMServerVM.Instance.CurrentUser.JMMUserID.Value,
                    (int)RecommendationType.Download);

                foreach (JMMServerBinary.Contract_Recommendation contract in contracts)
                {
                    RecommendationVM rec = new RecommendationVM();
                    rec.Populate(contract);
                    Recs.Add(rec);
                }

                ViewRecs.Refresh();

                parentWindow.Cursor = Cursors.Arrow;

            }
            catch (Exception ex)
            {
                Utils.ShowErrorMessage(ex);
            }
            finally
            {
            }
        }