private void CreateList() { try { var stagedFiles = DirectoryStructure.GetStagedFiles(); lblStagedFiles.Text = $"Currently you have {stagedFiles.Count()} files to process."; listView1.Columns.Clear(); listView1.Items.Clear(); listView1.View = View.Details; //listView1.GridLines = true; listView1.FullRowSelect = true; listView1.Sort(); //listView1.CheckBoxes = true; //Add column header // listView1.Items.AddRange(stagedFiles); foreach (var itm in stagedFiles.Select(item => new ListViewItem(item))) { listView1.Items.Add(Path.GetFileName(itm.Text)); } if (stagedFiles.Length > 0) { listView1.Columns.Add("File Name", 300); listView1.Columns[0].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); } } catch (Exception exp) { log.Error(exp); MessageBox.Show(exp.Message); } }
public DirectoryStructureViewModel() { this.Items = new ObservableCollection <DirectoryItemViewModel>( DirectoryStructure.GetLogicalDrives() .Select(drive => new DirectoryItemViewModel(drive.FullPath, DirectoryItemType.Drive))); }
public void ExecuteAsync_KnownEndpointWithRequestMethods_NoWarning() { ChangeDirectoryCommand command = new ChangeDirectoryCommand(); Setup(commandText: "cd AnEndpoint", out MockedShellState mockedShellState, out HttpState httpState, out ICoreParseResult parseResult); DirectoryStructure directoryStructure = new DirectoryStructure(null); DirectoryStructure childDirectory = directoryStructure.DeclareDirectory("AnEndpoint"); RequestInfo childRequestInfo = new RequestInfo(); childRequestInfo.AddMethod("GET"); childDirectory.RequestInfo = childRequestInfo; ApiDefinition apiDefinition = new ApiDefinition() { DirectoryStructure = directoryStructure }; httpState.ApiDefinition = apiDefinition; string expectedOutput = "/AnEndpoint [GET]"; command.ExecuteAsync(mockedShellState, httpState, parseResult, CancellationToken.None); Assert.Single(mockedShellState.Output); Assert.Equal(expectedOutput, mockedShellState.Output[0]); }
/// <summary> /// Determine and create the directory where the raw data is saved in 1-hour chunks. /// </summary> private void DetermineFilePath() { if (isActive) { if (presentHour != DateTime.Now.Hour) { if (bwPLFormat != null) { bwPLFormat.CloseFile(); } presentHour = DateTime.Now.Hour; // Need to create a new directory and switch the file name dayPath = DirectoryStructure.DayDirectoryToUse(aRootPathName); // Make sure hour directory exists currentDataFile = dayPath + "\\" + presentHour + "\\"; if (!System.IO.Directory.Exists(currentDataFile)) { System.IO.Directory.CreateDirectory(currentDataFile); } currentDataFile = currentDataFile + FILE_TYPE_MONIKER + "." + DirectoryStructure.GetDate() + "." + COMP_ID + "." + FILE_EXT; bwPLFormat = new ByteWriter(currentDataFile, true); bwPLFormat.OpenFile(); // Ensure that the first data point in the new file will start // with the full, rather than differential, timecode info. isForceTimestampSave = true; } } }
/// <summary> /// Loads a folder from the file directory into a VersionData /// </summary> /// <param name="dirPath">The absolute path to the version directory in which all files are contained</param> /// <param name="filepath">The relative path to a file or directory from dirpath</param> /// <param name="loadData">Whether or not to read the files</param> /// <param name="directory">The content directory from which to read</param> /// <param name="changelog">An optional Changelog parameter to fill in hashes</param> /// <returns></returns> private static VersionData LoadFile(string dirPath, string filepath, bool loadData, DirectoryStructure directory, Changelog changelog) { string path = Path.Combine(dirPath, filepath); string filename = Path.GetFileName(path); if (loadData) { FileStream fs = new FileStream(path, FileMode.Open); if (changelog == null) { return(new VersionData(filename, fs)); } else { string hash = changelog.GetCachedHash(filepath); return(new VersionData(filename, fs, hash)); } } else { string versionHash = Path.GetFileName(dirPath); if (changelog == null) { return(VersionDataProxy.Create(versionHash, filepath, filename, directory)); } else { string hash = changelog.GetCachedHash(filepath); return(VersionDataProxy.Create(versionHash, filepath, filename, directory, hash)); } } }
private void Expand() { if (Type != DirectoryItemType.File) { Children = new ObservableCollection <DirectoryItemViewModel>(DirectoryStructure.GetDirectoryContents(FullPath).Select(c => new DirectoryItemViewModel(c.FullPath, c.Type))); DirectoryStructure.GetDirectoryContents(FullPath).Select(c => new DirectoryItemViewModel(c.FullPath, c.Type)); } }
public void GetValueCompletions_NoMethod_ReturnsAll() { DirectoryStructure directoryStructure = new DirectoryStructure(null); RequestInfo requestInfo = new RequestInfo(); requestInfo.SetRequestBody("GET", "application/json", ""); requestInfo.SetRequestBody("GET", "text/plain", ""); requestInfo.SetRequestBody("PUT", "application/xml", ""); directoryStructure.RequestInfo = requestInfo; HttpState httpState = SetupHttpState(); httpState.BaseAddress = new Uri("https://localhost/"); ApiDefinition apiDefinition = new ApiDefinition(); apiDefinition.DirectoryStructure = directoryStructure; httpState.ApiDefinition = apiDefinition; IEnumerable <string> result = HeaderCompletion.GetValueCompletions(method: null, path: "", header: "Content-Type", "", httpState); Assert.Equal(3, result.Count()); Assert.Contains("application/json", result, StringComparer.OrdinalIgnoreCase); Assert.Contains("text/plain", result, StringComparer.OrdinalIgnoreCase); Assert.Contains("application/xml", result, StringComparer.OrdinalIgnoreCase); }
/// <summary> /// Loads a Commit from the file directory /// </summary> /// <param name="filepath">The absolute path to the commit file</param> /// <param name="directory">The directory to load dependencies</param> /// <param name="loader">The loader object to specify which dependencies to load</param> /// <returns></returns> public static Commit LoadCommit(string filepath, DirectoryStructure directory, CommitDependencyLoader loader) { string json; CommitJSON commit; try { json = File.ReadAllText(filepath); } catch { throw new ArgumentException("Could not read file " + filepath); } commit = JsonSerializer.Deserialize <CommitJSON>(json); if (commit == null) { throw new ArgumentNullException("commitjson is null"); } if (loader != null) { return(commit.GetCommit(directory, loader)); } else { return(commit.GetCommit(directory)); } }
public Startup(IConfiguration configuration) { Configuration = configuration; DirectoryStructure dirStructure = new DirectoryStructure(); dirStructure.SetUp(); }
public void Update() { var directoryItems = DirectoryStructure.GetDirectoryContents(this.FullPath); var children = new ObservableCollection <DirectoryItemViewModel>(); if (this.searchToLevel == DirectoryItemType.File && !string.IsNullOrEmpty(this.fileExtention)) { directoryItems = directoryItems.Where(x => x.Type == DirectoryItemType.File ? IsCorectFileExtantion(x) : true).ToList(); } foreach (DirectoryItem directoryItem in directoryItems) { if (directoryItem.Type != DirectoryItemType.Folder && this.searchToLevel == DirectoryItemType.Folder) { continue; } var childViewModel = new DirectoryItemViewModel(directoryItem.FullPath, directoryItem.Type, searchToLevel, this.fileExtention); childViewModel.Parent = this; childViewModel.SelectDirectoryItem += SelectDirectoryItem; children.Add(childViewModel); } this.Children = children; }
public void GetApplicableContentTypes_WithPath_ReturnsCorrectOne() { DirectoryStructure parentDirectoryStructure = new DirectoryStructure(null); RequestInfo parentRequestInfo = new RequestInfo(); parentRequestInfo.SetRequestBody("GET", "application/json", ""); parentDirectoryStructure.RequestInfo = parentRequestInfo; DirectoryStructure childDirectoryStructure = parentDirectoryStructure.DeclareDirectory("child"); RequestInfo childRequestInfo = new RequestInfo(); childRequestInfo.SetRequestBody("GET", "application/xml", ""); childDirectoryStructure.RequestInfo = childRequestInfo; HttpState httpState = SetupHttpState(); httpState.BaseAddress = new Uri("https://localhost/"); ApiDefinition apiDefinition = new ApiDefinition(); apiDefinition.DirectoryStructure = parentDirectoryStructure; httpState.ApiDefinition = apiDefinition; IEnumerable <string> result = httpState.GetApplicableContentTypes("GET", "child"); Assert.Single(result); Assert.Contains("application/xml", result, StringComparer.OrdinalIgnoreCase); }
/// <summary> /// Loads the VersionData that contains all child elements; i.e. the root node /// </summary> /// <param name="dirPath">The absolute path to the version directory in which all files are contained</param> /// <param name="rootName">The filename of the root VersionData</param> /// <param name="loadData">Whether or not to read the files</param> /// <param name="directory">The content directory from which to read</param> /// <param name="changelog">An optional Changelog parameter to fill in hashes</param> /// <returns></returns> public static VersionData LoadTopLevelVD(string dirPath, string rootName, bool loadData, DirectoryStructure directory, Changelog changelog = null) { VDKeyedCollection datas = GetVersionDatas(dirPath, "", loadData, directory, changelog); return(new VersionData(rootName, datas)); }
public void GetApplicableContentTypes_NoMethod_ReturnsAll() { DirectoryStructure directoryStructure = new DirectoryStructure(null); RequestInfo requestInfo = new RequestInfo(); requestInfo.SetRequestBody("GET", "application/json", ""); requestInfo.SetRequestBody("PUT", "application/xml", ""); directoryStructure.RequestInfo = requestInfo; HttpState httpState = SetupHttpState(); httpState.BaseAddress = new Uri("https://localhost/"); ApiDefinition apiDefinition = new ApiDefinition(); apiDefinition.DirectoryStructure = directoryStructure; httpState.ApiDefinition = apiDefinition; IEnumerable <string> result = httpState.GetApplicableContentTypes(null, ""); Assert.NotNull(result); Assert.Equal(2, result.Count()); Assert.Contains("application/json", result, StringComparer.OrdinalIgnoreCase); Assert.Contains("application/xml", result, StringComparer.OrdinalIgnoreCase); }
/// <summary> /// Aggregates files from various Versions into one Version /// </summary> /// <param name="aggregated"></param> /// <param name="directory"></param> /// <returns></returns> public static Version AggregateVersion(AggregatedChangelog aggregated, DirectoryStructure directory) { var versions = new Dictionary <string, Version>(); VersionBuilder builder = new VersionBuilder(); Action <Dictionary <string, Tuple <string, Commit> > > build = vals => { foreach (var val in vals) { string versionHash = val.Value.Item2.Version.Hash; Version v; if (versions.ContainsKey(versionHash)) { v = versions[versionHash]; } else { v = directory.GetVersion(versionHash); versions.Add(v.Hash, v); } var vdata = v.GetVersionData(val.Key); builder.AddVersionData(val.Key, vdata); } }; build(aggregated.Added); build(aggregated.Modified); foreach (var pair in aggregated.Renamed) { builder.RenameVersionData(pair.Key, pair.Value); } return(builder.GetVersion()); }
private void ExecuteNewFolderCommand() { var items = SourcePane.Items.Select(item => item.Name).ToList(); var wkDirs = DirectoryStructure.WellKnownDirectoriesOf(SourcePane.CurrentFolder.Path); var suggestion = wkDirs.Where(d => !items.Contains(d)).Select(d => new InputDialogOptionViewModel { Value = d, DisplayName = TitleRecognizer.GetTitle(d) }).ToList(); var name = WindowManager.ShowTextInputDialog(Resx.AddNewFolder, Resx.FolderName + Strings.Colon, string.Empty, suggestion); if (name == null) { return; } name = name.Trim(); if (name == string.Empty) { WindowManager.ShowMessage(Resx.AddNewFolder, Resx.CannotCreateFolderWithNoName); return; } //var invalidChars = Path.GetInvalidFileNameChars(); //if (invalidChars.Any(name.Contains)) //{ // WindowManager.ShowMessage(Resx.AddNewFolder, Resx.CannotCreateFolderWithInvalidCharacters); // return; //} var path = string.Format("{0}{1}", SourcePane.CurrentFolder.Path, name); WorkHandler.Run(() => SourcePane.CreateFolder(path), result => NewFolderSuccess(result, name), NewFolderError); }
/// <summary> /// Converts this object to a Commit object /// </summary> /// <param name="directory">The directory dependency for proxies</param> /// <param name="loader">The loader object which specifies which objects to load</param> /// <returns></returns> public Commit GetCommit(DirectoryStructure directory, CommitDependencyLoader loader) { Commit[] parents = new Commit[Parents.Length]; for (int i = 0; i < parents.Length; i++) { string p = Parents[i]; if (loader.LoadParents && loader.ShouldLoadParent(p)) { parents[i] = directory.GetCommit(p, loader.GetParent(p)); } else { parents[i] = new CommitProxy(p, directory); } } Changelog changelog = loader.LoadChangelog ? directory.GetChangelog(Changelog) : new ChangelogProxy(Changelog, directory); Version version = loader.LoadVersion ? directory.GetVersion(Hash, loader.LoadVersionData) : new VersionProxy(Version, directory); CommitMetadata metadata = Metadata != null?Metadata.GetMetadata() : throw new FormatException("Commit must contain metadata"); return(new Commit(parents, changelog, version, metadata, Hash)); }
/// <summary> /// Loads the Version from the file directory, using VersionData.Hash as its hash /// </summary> /// <param name="filepath">The absolute path to this Version file</param> /// <param name="directory">The directory from which to load dependencies</param> /// <param name="loadData">Whether or not to read the files into VersionData</param> /// <param name="changelog">An optional Changelog to load the hashes of VersionData</param> /// <returns></returns> public static Version LoadVersion(string filepath, DirectoryStructure directory, bool loadData, Changelog changelog = null) { VersionData data = VersionDataFileManager.LoadTopLevelVD(filepath, "", loadData, directory, changelog); return(new Version(data, data.Hash)); }
public void OpenChild(InspectViewModel child, MouseButtonEventArgs e) { if (e.ClickCount >= 2) { if (child.Type != DirectoryType.File) { this._backstack.Push(this.ViewPort); if (this._forwardstack.Count > 0) { this._forwardstack.Clear(); } for (int i = 0; i < ViewPort.Children.Count; i++) { if (ViewPort.Children[i].FullPath == child.FullPath) { ViewPort.Children[i].Visted = true; } } this.ViewPort = child; ViewPort.Visted = true; RefreshViewPort(); } else { DirectoryStructure.OpenFileInProgramme(child.FullPath); } } }
private void button1_Click(object sender, EventArgs e) { try { button1.Enabled = false; button1.ForeColor = Color.White; if (!GenerateReports()) { return; } DirectoryStructure.MoveProcessedFile(listView1.SelectedItems[0].SubItems[0].Text); processedBar.Visible = false; lblProcessing.Visible = false; CreateList(); button1.Enabled = true; txtThresholdCutoff.Enabled = true; MessageBox.Show(Resources.LoadData_button1_Click_Reports_generated_Successfuuly); Process.Start(Path.Combine(DirectoryStructure.ActigraphReportsFolderName, DirectoryStructure.CurrentDateTime)); } catch (Exception exp) { log.Error(exp); MessageBox.Show(exp.Message); } }
public DirectoryStructureViewModel() { var children = DirectoryStructure.GetLogicalDrives(); this.Items = new ObservableCollection <DirectoryItemViewModel>( children.Select(drive => new DirectoryItemViewModel(drive.FullPath, drive.Type))); }
public SelectPathViewModel(DirectoryItemType searchToLevel, string startPath = "", string fileExtantion = "") { this.searchToLevel = searchToLevel; this.selectedPath = startPath; this.newFolderCommand = new RelayCommand <object>(OnNewFolderClick); this.renameFolderCommand = new RelayCommand <object>(OnRenameFolderClick); this.deleteFolderCommand = new RelayCommand <object>(OnDeleteFolderClick); this.okCommand = new RelayCommand <object>(OkCommandClick); this.closeCommand = new RelayCommand <object>(OnCloseCliked); this.pathChangeCommand = new RelayCommand <object>(OnPathChange); this.SelectionChanged += OnFolderPathChange; this.DirectoryItems = new ObservableCollection <DirectoryItemViewModel>(); var children = DirectoryStructure.GetLogicalDrives(); foreach (DirectoryItem drive in children) { var childViewModel = new DirectoryItemViewModel(drive.FullPath, drive.Type, searchToLevel, fileExtantion); childViewModel.SelectDirectoryItem += OnSelectDirectoryItem; this.DirectoryItems.Add(childViewModel); } if (!string.IsNullOrEmpty(startPath) && (System.IO.Directory.Exists(startPath) || File.Exists(startPath))) { var pathList = startPath.Split(Path.DirectorySeparatorChar).ToList(); Navigate(this.DirectoryItems, pathList); } //TODO: navigate to path }
/// <summary> /// Default constructor /// </summary> public DirectoryStructureViewModel() { //Get the logical drives var children = DirectoryStructure.GetLogicalDrives(); //Create view models from data Items = new ObservableCollection <DirectoryItemViewModel>(children.Select(drive => new DirectoryItemViewModel(drive.FullPath, DirectoryItemType.Drive))); }
public DirectoryStructureViewModel() { var children = DirectoryStructure.GetLogicalDrives(); Selected = new List <DirectoryItemVievModel>(); Items = new ObservableCollection <DirectoryItemVievModel>( children.Select(drive => new DirectoryItemVievModel(drive.FullPath, DirectoryItemType.Drive))); }
private void Expand() { if (!this.CanExpand) return; this.Children = new ObservableCollection<DirectoryItemViewModel>(DirectoryStructure.GetDirectoryContents(this.FullPath) .Select(content => new DirectoryItemViewModel(content.FullPath, content.Type))); }
public void GetChildren() { if (FullPath != null && Type != DirectoryType.File) { List <DirectoryItem> item = DirectoryStructure.GetDirectoryItems(this.FullPath); Children = new ObservableCollection <InspectViewModel>(item.Select(x => new InspectViewModel(x.FullPath, x.Type, x.Name, x.Hidden))); } }
private void expand() { if (this.type == DirectoryItemType.File) { return; } this.children = new ObservableCollection <DirectoryItemVM>(DirectoryStructure.getDirectoryContents(FullPath).Select(content => new DirectoryItemVM(content.FullPath, content.type))); }
private void Expand() { if (this.Type == DirectoryItemType.File) return; // Find all chuldren when expand this.Children = new ObservableCollection<DirectoryItemViewModel> (DirectoryStructure.GetDirectoryContents(this.FullPath).Select(content => new DirectoryItemViewModel(content.FullPath, content.Type))); }
public DirectoryStructureViewModel() { _directoryStructure = new DirectoryStructure(); Items = new ObservableCollection <DirectoryItemViewModel>(_directoryStructure.Items.Select(drive => new DirectoryItemViewModel(drive.FullPath))); foreach (var item in Items) { item.Selected += (s, e) => Selected?.Invoke(s, e); } }
public Build GetBuild(DirectoryStructure directory) { var parent = directory.GetBuild(Parent); var changelog = directory.GetChangelog(Changelog); var version = directory.GetVersion(Version); var metadata = Metadata.GetBuildMetadata(); return(new Build(parent, changelog, version, metadata)); }
private void Expand() { if (this.Type == DirectoryType.File) { return; } List <DirectoryItem> items = DirectoryStructure.GetDirectoryFolders(this.FullPath); Children = new ObservableCollection <DirectoryItemViewModel>(items.Select(x => new DirectoryItemViewModel(x.FullPath, x.Type, x.Name, x.Hidden))); }
private void initMembers() { source = new Filepath(); destination = new Filepath(); nameOfSeries = ""; nameOfEpisode = ""; season = -1; episode = -1; isVideofile = false; isSubtitle = false; processingRequested = true; isMovie = false; umlautUsage = UmlautAction.Unset; casing = Case.Unset; createDirectoryStructure = DirectoryStructure.Unset; language = Helper.Languages.None; ExtractedNameLevel = 0; }
private void loadSettingCreateDirectory() { createDirectoryStructure = (Helper.ReadBool(Config.CreateDirectoryStructure)) ? DirectoryStructure.CreateDirectoryStructure : DirectoryStructure.NoDirectoryStructure; }