Ejemplo n.º 1
0
 private void SaveFolderShortcut(FolderShortcut folderShortcut)
 {
     using (var session = _ravenDBConnector.Store.OpenSession())
     {
         session.Store(folderShortcut);
         session.SaveChanges();
     }
     Console.WriteLine(string.Format("The shortcut {0} has been added with the directory path: {1}", folderShortcut.Shortcut, folderShortcut.DirectoryPath));
 }
Ejemplo n.º 2
0
        private void SetCommand(string[] args)
        {
            if (args.Length.Equals(2))
            {
                var folderShortcut =
                    _folderShortcuts.SingleOrDefault(x => x.Shortcut.Equals(args[0], StringComparison.OrdinalIgnoreCase));
                if (folderShortcut != null)
                {
                    if (folderShortcut.DirectoryPath.Equals(args[1], StringComparison.OrdinalIgnoreCase) == false)
                    {
                        Console.WriteLine("Updating existing shortcut...");
                        folderShortcut.DirectoryPath = args[1];
                        UpdateFolderShortcut(folderShortcut);
                    }
                }
                else
                {
                    folderShortcut = new FolderShortcut() { Shortcut = args[0], DirectoryPath = args[1] };
                    _folderShortcuts.Add(folderShortcut);
                    SaveFolderShortcut(folderShortcut);
                }

            }
        }
Ejemplo n.º 3
0
 private void UpdateFolderShortcut(FolderShortcut folderShortcut)
 {
     string oldDirectoryPath;
     using (var session = _ravenDBConnector.Store.OpenSession())
     {
         var folderShortcutLoaded = session.Load<FolderShortcut>(folderShortcut.Id);
         oldDirectoryPath = folderShortcutLoaded.DirectoryPath;
         folderShortcutLoaded.DirectoryPath = folderShortcut.DirectoryPath;
         session.SaveChanges();
     }
     Console.WriteLine(string.Format("The existing shortcut {0} has been updated. The directory path changed from {1} to {2}", folderShortcut.Shortcut, oldDirectoryPath, folderShortcut.DirectoryPath));
 }