Example #1
0
        /// <summary>
        /// Create a new instance of <see cref="DocumentStoreViewModel"/>
        /// </summary>
        public DocumentStoreViewModel()
        {
            if(App.ActiveWorkSpace != null)
            {
                this._activeWorkspace = App.ActiveWorkSpace;
                this._workspaceLocation = Path.Combine(this._workspaceService.WorkspaceFolder, this.ActiveWorkspace.Name);
            }

            this.LoadDocumentStore = new DelegateCommand(this.OnLoadDocumentStore);
            this.SaveDocumentStore = new DelegateCommand(this.OnSaveDocumentStore);
            this.AddLocation = new DelegateCommand(OnAddLocation);
            this.RemoveLocation = new DelegateCommand(OnRemoveLocation);
            this.Index = new DelegateCommand(OnIndexAsync);
        }
Example #2
0
       /// <summary>
       /// Load local workspaces
       /// </summary>
       /// <returns></returns>
       public IList<WorkspaceModel> Load()
       {
           if(!Directory.Exists(WorkspaceFolder))
           {
               Directory.CreateDirectory(WorkspaceFolder);
               return new List<WorkspaceModel>();
           }

           IList<WorkspaceModel> result = new List<WorkspaceModel>();
           IEnumerable<string> workspaces =  Directory.EnumerateDirectories(WorkspaceFolder, "*", SearchOption.TopDirectoryOnly);
           foreach(var workspace in workspaces)
           {
               WorkspaceModel model = new WorkspaceModel();
               DirectoryInfo dir = new DirectoryInfo(workspace);
               model.Name = dir.Name;
               model.LastModified = dir.LastWriteTime;
               result.Add(model);
           }
           return result;
          
       }
Example #3
0
       /// <summary>
       /// Create a new Workspace
       /// </summary>
       /// <param name="workspaceName">Name of the workspace to create</param>
       public WorkspaceModel Create( string workspaceName)
       {
           string path = Path.Combine(WorkspaceFolder, workspaceName);
           if(Directory.Exists(path))
           {
               throw new ArgumentException(
                   String.Format("The workspace {0} already exist.", workspaceName)
                   , "workspaceName");
           }

          DirectoryInfo workspaceDir =  Directory.CreateDirectory(path);

           WorkspaceModel workspace = new WorkspaceModel();
           workspace.LastModified = workspaceDir.LastWriteTime;
           workspace.Name = workspaceName;

           return workspace;
       }
Example #4
0
      /// <summary>
      /// Physicaly remove a workspace
      /// </summary>
      /// <param name="workspace">Workspace to delete</param>
       public void Remove(WorkspaceModel workspace)
       {
           string path = Path.Combine(WorkspaceFolder, workspace.Name);

           if( Directory.Exists(path))
           {
               Directory.Delete(path, true);
           }
       }