Exemple #1
0
        private async Task <bool> GetRecentItems()
        {
            try
            {
                var query = Utils.GetRecentItemsQuery(SelectedTvSeries.Id, new[] { "Season" });

                Log.Info("Getting recent items for TV Show [{0}] ({1})", SelectedTvSeries.Name, SelectedTvSeries.Id);

                var recent = await ApiClient.GetItemsAsync(query);

                if (recent != null && recent.Items != null)
                {
                    RecentItems.Clear();
                    recent.Items
                    .OrderByDescending(x => x.DateCreated)
                    .Take(6)
                    .ToList()
                    .ForEach(recentItem => RecentItems.Add(recentItem));
                }
                return(true);
            }
            catch (HttpException ex)
            {
                Utils.HandleHttpException("GetRecentItems()", ex, NavigationService, Log);

                App.ShowMessage(AppResources.ErrorRecentItems);
                return(false);
            }
        }
 private void ClearAllCollections()
 {
     try
     {
         if (MyMaps != null)
         {
             MyMaps.Clear();
         }
         if (FeaturedItems != null)
         {
             FeaturedItems.Clear();
         }
         if (RecentItems != null)
         {
             RecentItems.Clear();
         }
         if (MostPopularItems != null)
         {
             MostPopularItems.Clear();
         }
         if (FavoriteItems != null && (FavoriteItems.Items != null && FavoriteItems.Items.Count > 0))
         {
             FavoriteItems.Items.Clear();
         }
         if (PortalGroups != null)
         {
             PortalGroups.Clear();
         }
     }
     catch (Exception ex)
     {
         var _ = App.ShowExceptionDialog(ex);
     }
 }
Exemple #3
0
 public void ClearRecent()
 {
     foreach (var r in RecentItems.ToArray())
     {
         r.RemoveRecentInfo();
     }
 }
        private async Task <bool> GetRecentCollectionItems()
        {
            var query = Utils.GetRecentItemsQuery(SelectedFolder.Id);

            try
            {
                Log.Info("Getting recent items for collection [{0}]", SelectedFolder.Name);

                var items = await ApiClient.GetItemsAsync(query);

                if (items != null && items.Items != null)
                {
                    var recent = await Utils.SortRecentItems(items.Items, App.SpecificSettings.IncludeTrailersInRecent);

                    recent.ForEach(item => RecentItems.Add(item));
                }

                return(true);
            }
            catch (HttpException ex)
            {
                Utils.HandleHttpException(ex, "GetRecentCollectionItems()", NavigationService, Log);
                return(false);
            }
        }
Exemple #5
0
        public MasterContentPageViewModel(INavigationService navigationService, Realm realm, IDataService sourcesService, Prism.Events.IEventAggregator e) :
            base(navigationService)
        {
            Title = "Consulta el clima";
            _navigationService       = navigationService;
            _weatherDataSourceList   = new WeatherDataSource();
            _recentItemsList         = new ObservableCollection <RecentItems>();
            _OriginalrecentItemsList = new ObservableCollection <RecentItems>();
            _sourcesService          = sourcesService;
            _realm = realm;

            SearchButtonCommand   = new DelegateCommand(ExecuteClick, CanExecuteClick);
            ExecuteItemTapCommand = new DelegateCommand(ExecuteItemTap);

            CmdExecuteDeleteItemRecentList = new DelegateCommand <RecentItems>(DeleteItemRecentList);


            SearchCommand     = new  DelegateCommand(ExecuteSearchCommand);
            cmdRefreshCommand = new DelegateCommand(ExecuteRefreshCommand);

            cmdRefreshWhetherCommand = new DelegateCommand(ExecuteRefreshWhetherCommand);

            DeleteRecentItems();
            LoadRecentItemFromLocalDatabase();



            RecentItems itemfirstSelect = new RecentItems();

            itemfirstSelect = RecentItemsList.FirstOrDefault();
            if (itemfirstSelect != null)
            {
                GetWeatherDataSourceFromAPI(itemfirstSelect.Name);
            }
        }
        private async Task SortRecent(BaseItemDto[] items)
        {
            RecentItems.Clear();

            var recent = await Utils.SortRecentItems(items, App.SpecificSettings.IncludeTrailersInRecent);

            recent.Take(6).ToList().ForEach(recentItem => RecentItems.Add(recentItem));
        }
        private void Reset()
        {
            AuthenticationService.Current.Logout();

            _hasLoaded = false;
            Folders.Clear();
            RecentItems.Clear();
            Messenger.Default.Send(new NotificationMessage(Constants.Messages.ResetAppMsg));
        }
 private void Reset()
 {
     TileService.Current.ResetWideTile(App.SpecificSettings.UseTransparentTile);
     _hasLoaded = false;
     Folders.Clear();
     UserViews.Clear();
     RecentItems.Clear();
     FavouriteItems.Clear();
     InProgressItems.Clear();
 }
Exemple #9
0
        private BlogPost GetFeatureItem()
        {
            var featureItem = RecentItems.FirstOrDefault(p => !string.IsNullOrWhiteSpace(p.Image));

            if (featureItem == null)
            {
                featureItem = RecentItems[0];
            }

            return(featureItem);
        }
        public async void SelectionChanged(SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count == 0)
            {
                return;
            }

            var item = (RecentItemViewModel)e.AddedItems[0];

            item.LastUsedDate = DateTime.Now;
            await recentManager.Save(RecentItems.ToList());

            NavigationService.UriFor <HostPageViewModel>().WithParam(x => x.PresetFileName, item.FilePath).Navigate();
            SelectedIndex = -1;
        }
        public void Create_NoValidList_Test()
        {
            var testParams = "<Data>" +
                             "<Param key=\"SiteId\">7F316E11-C842-4440-9918-39A8F1C12DA9</Param>" +
                             "<Param key=\"WebId\">1A8F7946-CCA1-4A24-8785-CE8E32D012BE</Param>" +
                             "<Param key=\"ListId\">5D592B57-C072-4B36-8809-11262120484D</Param>" +
                             "</Data>";


            using (new SPEmulators.SPEmulationContext(SPEmulators.IsolationLevel.Fake))
            {
                PrepareShims("My Timesheet");

                Assert.IsTrue(string.IsNullOrEmpty(RecentItems.Create(testParams)));
            }
        }
        public void Create_ErrorQueryExecuting_Test()
        {
            var testParams = "<Data>" +
                             "<Param key=\"SiteId\">7F316E11-C842-4440-9918-39A8F1C12DA9</Param>" +
                             "<Param key=\"WebId\">1A8F7946-CCA1-4A24-8785-CE8E32D012BE</Param>" +
                             "<Param key=\"ListId\">5D592B57-C072-4B36-8809-11262120484D</Param>" +
                             "</Data>";


            using (new SPEmulators.SPEmulationContext(SPEmulators.IsolationLevel.Fake))
            {
                PrepareShims("Some list", true);

                Assert.AreEqual(RecentItems.Create(testParams), "error: message");
            }
        }
Exemple #13
0
        protected override void OnClosing(ToolStripDropDownClosingEventArgs e)
        {
            base.OnClosing(e);

            if (RibbonInDesignMode)
            {
                RibbonItem item = RibbonDesigner.Current.SelectedElement as RibbonItem;
                e.Cancel = item != null &&
                           (MenuItems.Contains(item) || RecentItems.Contains(item) || OptionItems.Contains(item)) &&
                           e.CloseReason != ToolStripDropDownCloseReason.Keyboard &&
                           e.CloseReason != ToolStripDropDownCloseReason.AppClicked;
            }
            else
            {
                Console.WriteLine(e.CloseReason.ToString());
            }
        }
        internal void HandleDesignerItemRemoved(RibbonItem item)
        {
            if (MenuItems.Contains(item))
            {
                MenuItems.Remove(item);
            }
            else if (RecentItems.Contains(item))
            {
                RecentItems.Remove(item);
            }
            else if (OptionItems.Contains(item))
            {
                OptionItems.Remove(item);
            }

            OnRegionsChanged();
        }
Exemple #15
0
        public Editor(MenuForm menu, RecentItems newRecentItems)
        {
            InitializeComponent();
            menuForm = menu;
            Log.LogInfo("Opening editor");
            menuForm.Hide();

            catagories      = new Dictionary <VDFCatagory, TreeNode>();
            catagoryViaNode = new Dictionary <TreeNode, VDFCatagory>();
            items           = new Dictionary <VDFItem, TreeNode>();
            nodeType        = new Dictionary <TreeNode, string>();
            catagoryNodes   = new List <TreeNode>();
            itemNodes       = new List <TreeNode>();
            itemViaNode     = new Dictionary <TreeNode, VDFItem>();
            treeView1.Nodes.Clear();

            recentItems = newRecentItems;
        }
        private async Task <bool> GetRecentItems()
        {
            try
            {
                var query = new ItemQuery
                {
                    UserId           = AuthenticationService.Current.LoggedInUser.Id,
                    ParentId         = SelectedTvSeries.Id,
                    Filters          = new[] { ItemFilter.IsRecentlyAdded },
                    ExcludeItemTypes = new [] { "Season" },
                    Fields           = new[]
                    {
                        ItemFields.ParentId
                    },
                    Recursive = true,
                    IsMissing = App.SpecificSettings.ShowMissingEpisodes,
                    IsUnaired = App.SpecificSettings.ShowUnairedEpisodes
                };

                Log.Info("Getting recent items for TV Show [{0}] ({1})", SelectedTvSeries.Name, SelectedTvSeries.Id);

                var recent = await _apiClient.GetItemsAsync(query);

                if (recent != null && recent.Items != null)
                {
                    RecentItems.Clear();
                    recent.Items
                    .OrderByDescending(x => x.DateCreated)
                    .Take(6)
                    .ToList()
                    .ForEach(recentItem => RecentItems.Add(recentItem));
                }
                return(true);
            }
            catch (HttpException ex)
            {
                Log.ErrorException("GetRecentItems()", ex);

                App.ShowMessage(AppResources.ErrorRecentItems);
                return(false);
            }
        }
        public async Task Initialize()
        {
            RecentItems.Clear();
            ShouldShowRecent = true;
            var result = await recentManager.GetCollection <RecentItemViewModel>();

            var partial    = result.OrderByDescending(x => x.LastUsedDate);
            var showRecent = settings.Get <string>("RecentItemsShown").GetOrDefault();
            int takeFirst;

            if (string.IsNullOrEmpty(showRecent) || showRecent.Equals("No limit"))
            {
                RecentItems.AddRange(partial);
            }
            else if (int.TryParse(showRecent, out takeFirst))
            {
                RecentItems.AddRange(partial.Take(takeFirst));
            }
            else
            {
                ShouldShowRecent = false;
            }
        }
Exemple #18
0
        private async Task LoadRecentItems()
        {
            var response = await _cacheService.GetRecentItemsFromCache();

            if (RecentItems.IsNullOrEmpty())
            {
                RecentItems = new ObservableCollection <ReaderItem>(response.ReaderItems);
                return;
            }

            foreach (var item in response.ReaderItems)
            {
                var existingItem = RecentItems.FirstOrDefault(x => x.Id == item.Id);
                if (existingItem != null)
                {
                    item.CopyItem(existingItem);
                }
                else
                {
                    RecentItems.Add(item);
                }
            }
        }
Exemple #19
0
        private async Task <bool> GetRecentCollectionItems()
        {
            var query = new ItemQuery
            {
                Filters = new[] { ItemFilter.IsRecentlyAdded, ItemFilter.IsNotFolder },
                UserId  = AuthenticationService.Current.LoggedInUser.Id,
                Fields  = new[]
                {
                    ItemFields.DateCreated,
                    ItemFields.ProviderIds,
                    ItemFields.ParentId,
                },
                ParentId  = SelectedFolder.Id,
                Recursive = true
            };

            try
            {
                Log.Info("Getting recent items for collection [{0}]", SelectedFolder.Name);

                var items = await _apiClient.GetItemsAsync(query);

                if (items != null && items.Items != null)
                {
                    var recent = await Utils.SortRecentItems(items.Items, App.SpecificSettings.IncludeTrailersInRecent);

                    recent.ForEach(item => RecentItems.Add(item));
                }

                return(true);
            }
            catch (HttpException ex)
            {
                Utils.HandleHttpException(ex, "GetRecentCollectionItems()", _navigationService, Log);
                return(false);
            }
        }
        private void Deserialize()
        {
            string pathToAppData;

            try
            {
                pathToAppData = Path.Combine(SavePath, _fileName);
            }
            catch (SecurityException)
            {
                Console.WriteLine("Security exception was raised. " +
                                  "Probably because you are running UnityEngine.dll outside Unity player.");
                pathToAppData = _fileName;
            }

            if (File.Exists(pathToAppData))
            {
                _recent = JsonConvert.DeserializeObject <RecentItems>(File.ReadAllText(pathToAppData));
            }
            else
            {
                _recent = new RecentItems();
            }
        }
        private void _keyboardHook_KeyUp(object sender, KeyEventArgs e)
        {
            //base.OnKeyUp(e);
            if (e.KeyCode == Keys.Down)
            {
                RibbonItem NextItem     = null;
                RibbonItem SelectedItem = null;
                foreach (RibbonItem itm in MenuItems)
                {
                    if (itm.Selected)
                    {
                        SelectedItem = itm;
                        break;
                    }
                }
                if (SelectedItem != null)
                {
                    //get the next item in the chain
                    int Index = MenuItems.IndexOf(SelectedItem);
                    NextItem = GetNextSelectableMenuItem(Index + 1);
                }
                else
                {
                    //nothing found so lets search through the recent buttons
                    foreach (RibbonItem itm in RecentItems)
                    {
                        if (itm.Selected)
                        {
                            SelectedItem = itm;
                            itm.SetSelected(false);
                            itm.RedrawItem();
                            break;
                        }
                    }
                    if (SelectedItem != null)
                    {
                        //get the next item in the chain
                        int Index = RecentItems.IndexOf(SelectedItem);
                        NextItem = GetNextSelectableRecentItem(Index + 1);
                    }
                    else
                    {
                        //nothing found so lets search through the option buttons
                        foreach (RibbonItem itm in OptionItems)
                        {
                            if (itm.Selected)
                            {
                                SelectedItem = itm;
                                itm.SetSelected(false);
                                itm.RedrawItem();
                                break;
                            }
                        }
                        if (SelectedItem != null)
                        {
                            //get the next item in the chain
                            int Index = OptionItems.IndexOf(SelectedItem);
                            NextItem = GetNextSelectableOptionItem(Index + 1);
                        }
                    }
                }
                //last check to make sure we found a selected item
                if (SelectedItem == null)
                {
                    //we should have the right item by now so lets select it
                    NextItem = GetNextSelectableMenuItem(0);
                    if (NextItem != null)
                    {
                        NextItem.SetSelected(true);
                        NextItem.RedrawItem();
                    }
                }
                else
                {
                    SelectedItem.SetSelected(false);
                    SelectedItem.RedrawItem();

                    NextItem.SetSelected(true);
                    NextItem.RedrawItem();
                }
                //_sensor.SelectedItem = NextItem;
                //_sensor.HittedItem = NextItem;
            }
            else if (e.KeyCode == Keys.Up)
            {
            }
        }
        public App()
        {
            //Calling order found was:: Dispatcher -> Main Window -> XAML Application Dispatcher -> Unhandeled
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Dispatcher.UnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Dispatcher_UnhandledException);
            Application.Current.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Application_DispatcherUnhandledException);
            MainWindow mwindow = container.Resolve <MainWindow>();

            container.RegisterInstance <MainWindow>(mwindow);///new line
            mwindow.Show();
            mwindow.Visibility = Visibility.Hidden;

            ShowProgressbar();        //strat showing progress bar
            bool BlueSkyFound = true; //Assuming BlueSky R package is present.

            LifetimeService.Instance.Container = container;
            container.RegisterInstance <ILoggerService>(new LoggerService());                   /// For Application log. Starts with default level "Error"
            container.RegisterInstance <IConfigService>(new ConfigService());                   //For App Config file
            container.RegisterInstance <IAdvancedLoggingService>(new AdvancedLoggingService()); //For Advanced Logging
            ////////////// TRY LOADING BSKY R PACKAGES HERE  /////////

            ILoggerService logService = container.Resolve <ILoggerService>();

            logService.SetLogLevelFromConfig();                                               //loading log level from config file
            logService.WriteToLogLevel("R.Net,Logger and Config loaded:", LogLevelEnum.Info); ///

            ////Recent default packages. This code must appear before loading any R package. (including uadatapackage)
            XMLitemsProcessor defaultpackages = container.Resolve <XMLitemsProcessor>();//06Feb2014

            defaultpackages.MaxRecentItems = 50;
            defaultpackages.XMLFilename    = string.Format(@"{0}DefaultPackages.xml", BSkyAppData.BSkyDataDirConfigFwdSlash);//23Apr2015 @"./Config/DefaultPackages.xml";
            defaultpackages.RefreshXMLItems();
            container.RegisterInstance <XMLitemsProcessor>(defaultpackages);

            //Recent user packages. This code must appear before loading any R package. (including uadatapackage)
            RecentItems userpackages = container.Resolve <RecentItems>();//06Feb2014

            userpackages.MaxRecentItems = 50;
            userpackages.XMLFilename    = string.Format(@"{0}UserPackages.xml", BSkyAppData.BSkyDataDirConfigFwdSlash);//23Apr2015 @"./Config/UserPackages.xml";
            userpackages.RefreshXMLItems();
            container.RegisterInstance <RecentItems>(userpackages);

            try
            {
                BridgeSetup.ConfigureContainer(container);
            }
            catch (Exception ex)
            {
                string s1 = "\n1. R is installed. BlueSky Statistics requires R.";
                string s2 = "\n2. Binary incompatibility between BlueSky Statistics and R. 64bit BlueSky Statistics requires 64bit R and 32bit BlueSky Statistics required 32bit R. (Go to Help > About in BlueSky Statistics)";
                string s3 = "\n3. Another session of the BlueSky application is not already running.";
                MessageBox.Show("Please make sure:" + s1 + s2 + s3, "Error: Can't Launch BlueSky Application!", MessageBoxButton.OK, MessageBoxImage.Stop);
                logService.WriteToLogLevel("Unable to launch the BlueSky Application." + s1 + s3, LogLevelEnum.Error);
                Environment.Exit(0);
            }
            finally
            {
                HideProgressbar();
            }
            container.RegisterInstance <IDashBoardService>(container.Resolve <XmlDashBoardService>());
            container.RegisterInstance <IDataService>(container.Resolve <DataService>());

            IOutputWindowContainer iowc = container.Resolve <OutputWindowContainer>();

            container.RegisterInstance <IOutputWindowContainer>(iowc);

            SessionDialogContainer sdc = container.Resolve <SessionDialogContainer>(); //13Feb2013
            //Recent Files settings
            RecentDocs rdoc = container.Resolve <RecentDocs>();                        //21Feb2013

            rdoc.MaxRecentItems = 7;
            rdoc.XMLFilename    = string.Format(@"{0}Recent.xml", BSkyAppData.BSkyDataDirConfigFwdSlash);
            container.RegisterInstance <RecentDocs>(rdoc);

            Window1 window = container.Resolve <Window1>();

            container.RegisterInstance <Window1>(window);     ///new line
            window.Closed += new EventHandler(window_Closed); //28Jan2013
            window.Owner   = mwindow;                         //28Jan2013

            window.Show();
            window.Activate();
            ShowMouseBusy();//02Apr2015 show mouse busy
            //// one Syntax Editor window for one session ////29Jan2013
            SyntaxEditorWindow sewindow = container.Resolve <SyntaxEditorWindow>();

            container.RegisterInstance <SyntaxEditorWindow>(sewindow);///new line
            sewindow.Owner = mwindow;

            //load default packages
            window.setLMsgInStatusBar("Please wait ... Loading required R packages ...");
            IAnalyticsService IAService = LifetimeService.Instance.Container.Resolve <IAnalyticsService>();

            BridgeSetup.LoadDefaultRPackages(IAService);
            string PkgLoadStatusMessage = BridgeSetup.PkgLoadStatusMessage;

            if (PkgLoadStatusMessage != null && PkgLoadStatusMessage.Trim().Length > 0)
            {
                StringBuilder sb          = new StringBuilder();
                string[]      defpacklist = PkgLoadStatusMessage.Split('\n');
                foreach (string s in defpacklist)
                {
                    if (s != null && (s.ToLower().Contains("error"))) //|| s.ToLower().Contains("warning")))
                    {
                        sb.Append(s.Replace("Error loading R package:", "") + "\n");
                    }
                }
                if (sb.Length > 0)
                {
                    sb.Remove(sb.Length - 1, 1);//removing last comma
                    string defpkgs  = sb.ToString();
                    string firstmsg = "Error loading following R package(s):\n\n";
                    string msg      = "\n\nInstall required R packages from CRAN by clicking:\nTools > Package > Install required package(s) from CRAN.";// +

                    HideMouseBusy();
                    MessageBox.Show(firstmsg + defpkgs + msg, "Error: Required R Package(s) Missing", MessageBoxButton.OK, MessageBoxImage.Warning);

                    if (defpkgs.Contains("BlueSky"))
                    {
                        BlueSkyFound = false;
                    }
                }
            }

            //deimal default should be set here as now BlueSky is loaded
            window.SetRDefaults();
            IAdvancedLoggingService advlog = container.Resolve <IAdvancedLoggingService>();;//01May2015

            advlog.RefreshAdvancedLogging();

            HideMouseBusy();//02Apr2015 hide mouse busy
            if (BlueSkyFound)
            {
                try
                {
                    //Try loading empty dataset(newdataset) just after app finished loading itself and R packages.
                    FileNewCommand newds = new FileNewCommand();
                    newds.NewFileOpen("");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error Loading new dataset. Make sure you have BlueSky R package installed", "BlueSky pacakge missing", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            window.setLMsgInStatusBar("For additional functionality and for details on the commercial edition, ");
        }
Exemple #23
0
 private void ClearAll()
 {
     _recent.ClearAll();
     RecentItems.Clear();
 }
Exemple #24
0
        public App()
        {
            //25Aug2017 To see how Date fomatting changes in the Datagrid
            Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US");//US English en-US
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

            //Calling order found was:: Dispatcher -> Main Window -> XAML Application Dispatcher -> Unhandeled
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Dispatcher.UnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Dispatcher_UnhandledException);
            Application.Current.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Application_DispatcherUnhandledException);

            MainWindow mwindow = container.Resolve <MainWindow>();

            container.RegisterInstance <MainWindow>(mwindow);///new line
            mwindow.Show();
            mwindow.Visibility = Visibility.Hidden;

            ShowProgressbar();

            bool BlueSkyFound = true;

            string upath      = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "BlueSky");;//Per User path
            string applogpath = BSkyAppData.RoamingUserBSkyLogPath;

            DirectoryHelper.UserPath = upath;

            LifetimeService.Instance.Container = container;
            container.RegisterInstance <ILoggerService>(new LoggerService(applogpath));

            //Check if user profies has got old files. If so overwrite all(dialogs, modelclasses and other xmls, txt etc.)
            bool hasOldUserContent = CheckIfOldInUserProfile();

            //Copy folders inside Bin/Config to User profile BlueSky\config.
            if (hasOldUserContent)
            {
                CopyL18nDialogsToUserRoamingConfig();
            }

            //copy config file to user profile.
            CopyNewAndRetainOldSettings(string.Format(@"{0}BlueSky.exe.config", "./"),
                                        string.Format(@"{0}BlueSky.exe.config", BSkyAppData.RoamingUserBSkyConfigPath));

            container.RegisterInstance <IConfigService>(new ConfigService());                   //For App Config file

            container.RegisterInstance <IAdvancedLoggingService>(new AdvancedLoggingService()); //For Advanced Logging
            ////////////// TRY LOADING BSKY R PACKAGES HERE  /////////

            ILoggerService logService = container.Resolve <ILoggerService>();

            logService.SetLogLevelFromConfig();                                               //loading log level from config file
            logService.WriteToLogLevel("R.Net,Logger and Config loaded:", LogLevelEnum.Info); ///

            ////Recent default packages. This code must appear before loading any R package. (including BlueSky R package)
            XMLitemsProcessor defaultpackages = container.Resolve <XMLitemsProcessor>();//06Feb2014

            defaultpackages.MaxRecentItems = 100;
            if (hasOldUserContent)
            {
                CopyIfNotExistsOrOld(string.Format(@"{0}DefaultPackages.xml", BSkyAppData.BSkyAppDirConfigPath), string.Format(@"{0}DefaultPackages.xml", BSkyAppData.RoamingUserBSkyConfigPath));
            }
            defaultpackages.XMLFilename = string.Format(@"{0}DefaultPackages.xml", BSkyAppData.RoamingUserBSkyConfigPath);//23Apr2015 ;BSkyAppData.BSkyDataDirConfigFwdSlash
            defaultpackages.RefreshXMLItems();
            container.RegisterInstance <XMLitemsProcessor>("defaultpackages", defaultpackages);

            //Recent user packages. This code must appear before loading any R package. (including uadatapackage)
            RecentItems userpackages = container.Resolve <RecentItems>();//06Feb2014

            userpackages.MaxRecentItems = 100;
            userpackages.XMLFilename    = string.Format(@"{0}UserPackages.xml", BSkyAppData.RoamingUserBSkyConfigPath);//23Apr2015 @"./Config/UserPackages.xml";
            userpackages.RefreshXMLItems();
            container.RegisterInstance <RecentItems>(userpackages);

            ////User listed model classes.
            XMLitemsProcessor modelClasses = container.Resolve <XMLitemsProcessor>();//

            modelClasses.MaxRecentItems = 100;
            if (hasOldUserContent)
            {
                CopyIfNotExistsOrOld(string.Format(@"{0}ModelClasses.xml", BSkyAppData.BSkyAppDirConfigPath), string.Format(@"{0}ModelClasses.xml", BSkyAppData.RoamingUserBSkyConfigPath));
            }
            modelClasses.XMLFilename = string.Format(@"{0}ModelClasses.xml", BSkyAppData.RoamingUserBSkyConfigPath);//23Apr2015 ;BSkyAppData.BSkyDataDirConfigFwdSlash
            modelClasses.RefreshXMLItems();
            container.RegisterInstance <XMLitemsProcessor>("modelClasses", modelClasses);

            if (hasOldUserContent)
            {
                CopyIfNotExistsOrOld(string.Format(@"{0}GraphicCommandList.txt", BSkyAppData.BSkyAppDirConfigPath), string.Format(@"{0}GraphicCommandList.txt", BSkyAppData.RoamingUserBSkyConfigPath));
            }

            try
            {
                BridgeSetup.ConfigureContainer(container);
            }
            catch (Exception ex)
            {
                bool anothersessionrunning = false;
                if (ex.Message.Contains("used by another process"))
                {
                    anothersessionrunning = true;
                }

                string s1         = "\n" + BSky.GlobalResources.Properties.Resources.MakeSureRInstalled;
                string s2         = "\n" + BSky.GlobalResources.Properties.Resources.MakeSure32x64Compatibility;
                string s3         = "\n" + BSky.GlobalResources.Properties.Resources.MakeSureAnotherBSkySession;
                string s4         = "\n" + BSky.GlobalResources.Properties.Resources.MakeSureRHOME2LatestR;
                string s5         = "\n" + BSky.GlobalResources.Properties.Resources.PleaseMakeSure;
                string mboxtitle0 = "\n" + BSky.GlobalResources.Properties.Resources.CantLaunchBSkyApp;

                //MessageBox.Show(s5 + s3 + s4, mboxtitle0, MessageBoxButton.OK, MessageBoxImage.Stop);
                if (anothersessionrunning)
                {
                    MessageBox.Show(s5 + s3, mboxtitle0, MessageBoxButton.OK, MessageBoxImage.Stop);
                }
                else
                {
                    MessageBox.Show(s5 + s4, mboxtitle0, MessageBoxButton.OK, MessageBoxImage.Stop);
                }

                #region R Home Dir edit prompt
                if (!anothersessionrunning)
                {
                    //Provide R Home Dir check/modify option to the user so that he can have a chance to fix this issue.
                    //Otherwise app will not launch until reinstalled or manually modify the config file.
                    //So following is much better and easier way to fix the issue.
                    HideMouseBusy();
                    HideProgressbar();
                    ChangeConfigForRHome();
                }
                #endregion
                logService.WriteToLogLevel("Unable to launch the BlueSky Statistics Application." + s1 + s3, LogLevelEnum.Error);
                logService.WriteToLogLevel("Exception:" + ex.Message, LogLevelEnum.Fatal);
                Environment.Exit(0);
            }
            finally
            {
                HideProgressbar();
            }
            container.RegisterInstance <IDashBoardService>(container.Resolve <XmlDashBoardService>());
            container.RegisterInstance <IDataService>(container.Resolve <DataService>());

            IOutputWindowContainer iowc = container.Resolve <OutputWindowContainer>();
            container.RegisterInstance <IOutputWindowContainer>(iowc);

            SessionDialogContainer sdc = container.Resolve <SessionDialogContainer>();                    //13Feb2013
            //Recent Files settings
            RecentDocs rdoc = container.Resolve <RecentDocs>();                                           //21Feb2013
            rdoc.MaxRecentItems = 7;
            rdoc.XMLFilename    = string.Format(@"{0}Recent.xml", BSkyAppData.RoamingUserBSkyConfigPath); //23Apr2015 @"./Config/Recent.xml";
            container.RegisterInstance <RecentDocs>(rdoc);

            Window1 window = container.Resolve <Window1>();
            container.RegisterInstance <Window1>(window);     ///new line
            window.Closed += new EventHandler(window_Closed); //28Jan2013
            window.Owner   = mwindow;                         //28Jan2013

            //17Apr2017 Showing version number on titlebar of main window
            Version ver            = Assembly.GetExecutingAssembly().GetName().Version;
            string  strfullversion = ver.ToString(); //Full version with four parts
            string  shortversion   = string.Format("{0}.{1}", ver.Major.ToString(), ver.Minor.ToString());
            string  titlemsg       = string.Empty;

            titlemsg = string.Format("BlueSky Statistics (Open Source Desktop Edition. Ver- {0})", shortversion);

            window.Title = titlemsg;

            window.Show();
            window.Activate();
            ShowMouseBusy();//02Apr2015 show mouse busy
            //// one Syntax Editor window for one session ////29Jan2013
            SyntaxEditorWindow sewindow = container.Resolve <SyntaxEditorWindow>();
            container.RegisterInstance <SyntaxEditorWindow>(sewindow);///new line
            sewindow.Owner = mwindow;

            #region Create Column Significance codes List
            SignificanceCodesHandler.CreateSignifColList();
            #endregion

            //load default packages
            window.setLMsgInStatusBar(BSky.GlobalResources.Properties.Resources.StatMsgPkgLoad);
            IAnalyticsService IAService = LifetimeService.Instance.Container.Resolve <IAnalyticsService>();
            BridgeSetup.LoadDefaultRPackages(IAService);
            string PkgLoadStatusMessage = BridgeSetup.PkgLoadStatusMessage;
            bool   BlueSkyPkgErr        = PkgLoadStatusMessage.Contains("BlueSky") ? true : false;

            if (PkgLoadStatusMessage != null && PkgLoadStatusMessage.Trim().Length > 0)
            {
                StringBuilder sb          = new StringBuilder();
                string[]      defpacklist = PkgLoadStatusMessage.Split('\n');

                foreach (string s in defpacklist)
                {
                    if (s != null && (s.ToLower().Contains("error")))//|| s.ToLower().Contains("warning")))
                    {
                        //sb.Append(s.Substring(0, s.IndexOf(". ")) + "\n");
                        sb.Append(s.Replace("Error loading R package:", "") + "\n");
                    }
                }
                if (sb.Length > 0)
                {
                    sb.Remove(sb.Length - 1, 1);//removing last comma

                    string defpkgs  = sb.ToString();
                    string firstmsg = BSky.GlobalResources.Properties.Resources.ErrLoadingRPkg + "\n\n";

                    string msg = "\n\n" + BSky.GlobalResources.Properties.Resources.DisableAntivirus;// +
                    if (BlueSkyPkgErr)
                    {
                        msg = string.Empty;
                    }

                    HideMouseBusy();
                    string mboxtitle1 = BSky.GlobalResources.Properties.Resources.ErrReqRPkgMissing;
                    MessageBox.Show(firstmsg + defpkgs + msg, mboxtitle1, MessageBoxButton.OK, MessageBoxImage.Error);

                    Window1.DatasetReqPackages = defpkgs;

                    BlueSkyFound = false;
                }
            }

            //deimal default should be set here as now BlueSky is loaded
            window.SetRDefaults();
            IAdvancedLoggingService advlog = container.Resolve <IAdvancedLoggingService>();;//01May2015
            advlog.RefreshAdvancedLogging();

            window.setInitialAllModels(); //select All_Models in model class dropdown.
            window.setLMsgInStatusBar("");
            HideMouseBusy();              //02Apr2015 hide mouse busy
            if (BlueSkyFound)
            {
                try
                {
                    FileNewCommand newds = new FileNewCommand();
                    newds.NewFileOpen("");
                }
                catch (Exception ex)
                {
                    string so         = BSky.GlobalResources.Properties.Resources.ErrLoadingNewDS;
                    string mboxtitle2 = BSky.GlobalResources.Properties.Resources.BSkyPkgMissing;
                    logService.WriteToLogLevel("ERROR: " + ex.Message, LogLevelEnum.Error);
                    MessageBox.Show(so, mboxtitle2, MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Exemple #25
0
 public NewVDF(MenuForm menu, RecentItems recentItems)
 {
     InitializeComponent();
     menuForm = menu;
     recent   = recentItems;
 }
 private BlogPost GetFeatureItem()
 {
     return(RecentItems.FirstOrDefault(p => !string.IsNullOrWhiteSpace(p.Image)));
 }
Exemple #27
0
        async Task LoadMoreItemsAsync(bool refresh = false)
        {
            if (!HasMoreItems && !refresh)
            {
                //IsLoading = false;
                return;
            }
            try
            {
                if (refresh)
                {
                    Pagination = PaginationParameters.MaxPagesToLoad(1);
                    Views.Main.ActivitiesView.Current?.ShowTopLoadingYou();
                }
                else
                {
                    Views.Main.ActivitiesView.Current?.ShowBottomLoadingYou();
                }
                Views.Main.ActivitiesView.Current?.HideComments();
                CommentFeed = null;
                var result = await InstaApi.UserProcessor.GetRecentActivityFeedAsync(Pagination);

                FirstRun = false;
                Pagination.MaximumPagesToLoad = 1;
                if (!result.Succeeded)
                {
                    //IsLoading = false;
                    if (result.Value == null || result.Value?.Items?.Count == 0)
                    {
                        if (refresh)
                        {
                            Views.Main.ActivitiesView.Current?.HideTopLoadingYou();
                        }
                        else
                        {
                            Views.Main.ActivitiesView.Current?.HideBottomLoadingYou();
                        }
                        return;
                    }
                }
                MainPage.Current?.ShowActivityNotify(result.Value.Counts);
                if (string.IsNullOrEmpty(result.Value.NextMaxId))
                {
                    HasMoreItems = false;
                }

                if (result.Value?.Items?.Count > 0)
                {
                    if (refresh)
                    {
                        RecentItems.Clear();
                        RecentItems.CurrentList = null;
                    }

                    result.Value.Items.ForEach(item => RecentItems.AddWithColumns(item.ToRecentActivityFeed()));
                }
                await Task.Delay(1000);

                //IsLoading = false;
                await InstaApi.UserProcessor.MarkNewsInboxSeenAsync();

                await InstaApi.UserProcessor.MarkDiscoverMarkSuSeenAsync();
            }
            catch (Exception ex)
            {
                FirstRun =
                    /* IsLoading =*/ false;
                ex.PrintException("ActivitiesViewModel.LoadMoreItemsAsync");
            }
            if (refresh)
            {
                Views.Main.ActivitiesView.Current?.HideTopLoadingYou();
            }
            else
            {
                Views.Main.ActivitiesView.Current?.HideBottomLoadingYou();
            }
            refresh = false;
        }