public FormFileStateSet() { InitializeComponent(); this.SuspendLayout(); // Create data for combobox StringCollection grades = new StringCollection(); grades.AddRange(new string[] { FileStates.Init.ToString(), FileStates.WorkInProcess.ToString(), FileStates.Release.ToString() }); // Set the combobox this.listViewMain.AddComboBoxCell(-1, 1, grades); if (Globals.SourceDirectoryPath != null && Globals.TargetDirectoryPath != null) { newList = new FileInfoList(Globals.SourceDirectoryPath, Globals.TargetDirectoryPath); newList.GetFiles(Globals.SourceDirectoryPath, true); var row = 0; foreach (FileInfoEx file in newList) { var lvItem = new ListViewItem(file.FileName); lvItem.SubItems.Add(((FileStates)(file.FileState)).ToString()); this.listViewMain.Items.Insert(0, lvItem); row++; } } this.ResumeLayout(); }
public override FileInfoList FindFileInfo(string pattern, bool recursive) { var fil = new FileInfoList(); _files.ForEach((file) => { var ext = Path.GetExtension(file); if (pattern == "*" || pattern.Contains(ext)) { fil.Add(new FileInfo { Archive = this, CompressedSize = 0, Basename = file, Filename = file, ModifiedTime = DateTime.Now, Path = _basePath, UncompressedSize = 0 }); } }); return(fil); //return base.FindFileInfo( pattern, recursive ); }
public override Result DecodeRequest() { var decodeRequest = base.DecodeRequest(); if (decodeRequest.Failure) { return(decodeRequest); } var readIndex = 1; var remoteServerIpLen = BitConverter.ToInt32(RequestBytes, readIndex); readIndex += remoteServerIpLen + (Constants.SizeOfInt32InBytes * 3); var targetFolderLen = BitConverter.ToInt32(RequestBytes, readIndex); readIndex += targetFolderLen + Constants.SizeOfInt32InBytes; var fileInfoLen = BitConverter.ToInt32(RequestBytes, readIndex); readIndex += Constants.SizeOfInt32InBytes; var fileInfo = Encoding.UTF8.GetString(RequestBytes, readIndex, fileInfoLen); FileInfoList = FileInfoList.Parse(fileInfo); return(Result.Ok()); }
public void CopyFromWithBarcode(VoucherItem itemHasBarcode) { Debug.Assert(itemHasBarcode != null); Debug.Assert(itemHasBarcode.HasBarcode); JobID = itemHasBarcode.JobID; CountryID = itemHasBarcode.CountryID; RetailerID = itemHasBarcode.RetailerID; VoucherID = itemHasBarcode.VoucherID; Barcode = itemHasBarcode.Barcode; //Don't copy site code SiteCode = itemHasBarcode.SiteCode ?? SiteCode; State = itemHasBarcode.State; HasBarcode = itemHasBarcode.HasBarcode; //Don't delete SessionID //SessionID = item.SessionID; FileInfoList.Clear(); FileInfoList.AddRange(itemHasBarcode.FileInfoList); Thumbnail = itemHasBarcode.Thumbnail; Selected = itemHasBarcode.Selected; Message = itemHasBarcode.Message; }
public void CopyFromNoBarcode(VoucherItem itemNoBarcode) { Debug.Assert(itemNoBarcode != null); //Debug.Assert(!itemNoBarcode.HasBarcode); //Debug.Assert(HasBarcode); //JobID = itemNoBarcode.JobID; //CountryID = item.CountryID; //RetailerID = item.RetailerID; //VoucherID = item.VoucherID; //Barcode = item.Barcode; //Don't copy site code //SiteCode = item.SiteCode; State = itemNoBarcode.State; HasBarcode = true; //Don't delete SessionID //SessionID = item.SessionID; FileInfoList.Clear(); FileInfoList.AddRange(itemNoBarcode.FileInfoList); Thumbnail = itemNoBarcode.Thumbnail; Selected = itemNoBarcode.Selected; Message = itemNoBarcode.Message; }
private void DoUnrarFiles() { stopEvent.Reset(); OnUnrarStart(); try { foreach (var fileInfo in FileInfoList.Where(fileInfo => fileInfo.Checked)) { UnRarFile(fileInfo); } } /*catch (StopException) * { * //ex.ToString(); * // do nothing, it's normal * }*/ /*catch * { * //if (stopEvent.WaitOne(0)) ; * //ex.ToString(); * // do nothing, it's normal * }*/ finally { OnUnrarComplete(); } }
private void DoDownloadFiles() { if (OnDownloadStart != null) { OnDownloadStart(); } try { stopEvent.Reset(); foreach (var fi in FileInfoList.Where(fi => fi.Checked)) { DownloadFile(fi); } } catch (StopException ex) { ex.ToString();// do nothing, it's normal } finally { if (OnDownloadComplete != null) { OnDownloadComplete(); } } }
private void DoUpdate() { stopEvent.Reset(); if (OnUpdateStart != null) { OnUpdateStart(); } try { dbCache.RebuildCache(); //var databaseMap = FiasDatabaseMap.LoadFromFile(RootFolder + "\\Fias.Mapping.xml"); foreach (var fInfo in from date in FileInfoList.Select(a => a.Description).Distinct() from fInfo in FileInfoList.Where(a => (a.Description == date) && (a.Url == string.Empty) && (a.Checked)).OrderBy(a => a.Length) where !stopEvent.WaitOne(0) select fInfo) { ProcessXmlFile(fInfo); } } catch (StopException ex) { ex.ToString();// do nothing, it's normal } finally { if (OnUpdateComplete != null) { OnUpdateComplete(); } } }
// プロセスの終了を捕捉する Exited イベントハンドラ private void Process_Exited(object sender, EventArgs e) { var proc = (System.Diagnostics.Process)sender; var process = DisplayFileInfoList.Where(x => x?.Process?.Id == proc?.Id); if (process.Any()) { foreach (var item in process) { item.Process = null; item.Processing = false; } } process = FileInfoList.Where(x => x?.Process?.Id == proc?.Id); if (!process.Any()) { return; } foreach (var item in process) { item.Process = null; item.Processing = false; } }
private bool CanProcessStart() { if (SelectedFileInfo == null) { return(false); } return(FileInfoList.Any() && SelectedFileInfo.Process == null); }
public override FileInfoList FindFileInfo(string pattern, bool recursive) { FileInfoList ret = new FileInfoList(); SafeDirectoryChange(_basePath, () => findFiles(pattern, recursive, null, ret)); return(ret); }
/// <summary> /// /// </summary> /// <param name="pattern"></param> /// <param name="recursive"></param> /// <returns></returns> public override FileInfoList FindFileInfo(string pattern, bool recursive) { var ret = new FileInfoList(); findFiles(pattern, recursive, null, ret); return(ret); }
public void FilterByKeyword(string keyword) { if (!FileInfoList.Any()) { return; } CanFilterByKeywordInternal(keyword); }
protected void ChangeItemOrderLower() { var index = FileInfoList.IndexOf(SelectedFileInfo); SelectedFileInfo = null; FileInfoList.Move(index, index + 1); SynchronizeDisplayFileList(); SelectedFileInfo = DisplayFileInfoList[index + 1]; }
FileInfoList fileInfo) ReadFileListResponse(byte[] requestData) { var nextReadIndex = 1; var remoteServerIpLen = BitConverter.ToInt32(requestData, nextReadIndex); nextReadIndex += Constants.SizeOfInt32InBytes; var remoteIp = Encoding.UTF8.GetString(requestData, nextReadIndex, remoteServerIpLen); nextReadIndex += remoteServerIpLen + Constants.SizeOfInt32InBytes; var remotePort = BitConverter.ToInt32(requestData, nextReadIndex); nextReadIndex += Constants.SizeOfInt32InBytes; var targetFolderLen = BitConverter.ToInt32(requestData, nextReadIndex); nextReadIndex += Constants.SizeOfInt32InBytes; var targetFolder = Encoding.UTF8.GetString(requestData, nextReadIndex, targetFolderLen); nextReadIndex += targetFolderLen; var fileInfoLen = BitConverter.ToInt32(requestData, nextReadIndex); nextReadIndex += Constants.SizeOfInt32InBytes; var fileInfo = Encoding.UTF8.GetString(requestData, nextReadIndex, fileInfoLen); var fileInfoList = new FileInfoList(); foreach (var infoString in fileInfo.Split(FileInfoList.FileSeparator)) { var infoSplit = infoString.Split(FileInfoList.FileInfoSeparator); if (infoSplit.Length != 3) { continue; } var fileName = infoSplit[0]; var folderPath = infoSplit[1]; if (!long.TryParse(infoSplit[2], out var fileSizeBytes)) { continue; } var fi = (fileName : fileName, folderPath : folderPath, fileSizeBytes : fileSizeBytes); fileInfoList.Add(fi); } return( remoteIp, remotePort, targetFolder, fileInfoList); }
protected void RemoveItem() { var index = DisplayFileInfoList.IndexOf(SelectedFileInfo); FileInfoList.Remove(SelectedFileInfo); DisplayFileInfoList.Remove(SelectedFileInfo); //選択アイテムの更新 if (DisplayFileInfoList.Count == 0) { //表示対象がない index = -1; } else if (DisplayFileInfoList.Count <= index) { index = DisplayFileInfoList.Count - 1; } else { //何もしない } if (index >= 0) { DisplayFileInfoList.ElementAt(index).IsSelected = true; } //フィルタの更新 var missingKeywordList = new List <Extension>(); foreach (var item in ExtensionList) { missingKeywordList.Add(item); } missingKeywordList.RemoveAt(0); foreach (var item in DisplayFileInfoList) { var extension = Path.GetExtension(item.FilePath); var extensionItems = ExtensionList.Where(x => x.Name == extension); if (extensionItems.Any()) { foreach (var extItem in extensionItems) { missingKeywordList.Remove(extItem); } } } foreach (var item in missingKeywordList) { ExtensionList.Remove(item); } HasItem = FileInfoList.Any(); }
private void AddListItem(FiasFileInfo aFileInfo) { if (Dispatcher == null) { FileInfoList.Add(aFileInfo); } else { Dispatcher.BeginInvoke(new ThreadStart(() => FileInfoList.Add(aFileInfo))); } }
private void ClearList() { if (Dispatcher == null) { FileInfoList.Clear(); } else { Dispatcher.BeginInvoke(new ThreadStart(() => FileInfoList.Clear())); } }
private void ScanFolder(string aRoot) { foreach (var folder in Directory.GetDirectories(aRoot)) { ScanFolder(folder); } foreach (var file in Directory.GetFiles(aRoot, "fias_delta_xml.rar")) { FileInfoList.Add(new FiasFileInfo { FileName = file }); } }
private bool CreateFileList(List <string> files) { Log.Logger.Information("Creating file and folder list ..."); // Trim quotes from input paths files = files.Select(file => file.Trim('"')).ToList(); // Process all entries foreach (string fileOrFolder in files) { // File or a directory FileAttributes fileAttributes; try { fileAttributes = File.GetAttributes(fileOrFolder); } catch (Exception e) when(Log.Logger.LogAndHandle(e, MethodBase.GetCurrentMethod()?.Name)) { return(false); } if (fileAttributes.HasFlag(FileAttributes.Directory)) { // Add this directory DirectoryInfo dirInfo = new(fileOrFolder); DirectoryInfoList.Add(dirInfo); FolderList.Add(fileOrFolder); // Create the file list from the directory Log.Logger.Information("Getting files and folders from {Directory} ...", dirInfo.FullName); if (!FileEx.EnumerateDirectory(fileOrFolder, out List <FileInfo> fileInfoList, out List <DirectoryInfo> directoryInfoList)) { Log.Logger.Error("Failed to enumerate directory {Directory}", fileOrFolder); return(false); } FileInfoList.AddRange(fileInfoList); DirectoryInfoList.AddRange(directoryInfoList); } else { // Add this file FileInfoList.Add(new FileInfo(fileOrFolder)); } } // Report Log.Logger.Information("Discovered {DirectoryInfoListCount} directories and {FileInfoListCount} files", DirectoryInfoList.Count, FileInfoList.Count); return(true); }
public virtual void Zero() { JobID = 0; CountryID = 0; State = eState.NA; //Don't delete SessionID //SessionID = Guid.Empty; FileInfoList.Clear(); Thumbnail = null; Selected = false; Message = null; }
public void AddFileInfo(string[] pPathList) { foreach (string file in pPathList) { if (!File.Exists(file)) { if (Directory.Exists(file)) { DirectoryInfo dir = new DirectoryInfo(file); string[] names = dir.GetFiles().Select(u => u.FullName).ToArray(); string[] dirs = dir.GetDirectories().Select(u => u.FullName).ToArray(); AddFileInfo(names); AddFileInfo(dirs); } continue; } //중복 제거 foreach (FileDetail item in FileInfoList) { if ((item.FileDirectory + @"\" + item.FileName).ToUpper().Equals(file.ToUpper())) { FileInfoList.Remove(item); break; } } //파일 추가 FileDetail newFile = new FileDetail(file); if (newFile == null || newFile.Text.Length < 0) { continue; } this.FileInfoList.Add(newFile); OnPropertyChanged("TotalCount"); OnPropertyChanged("TotalSize"); OnPropertyChanged("TotalLengh"); OnPropertyChanged("TotalWords"); OnPropertyChanged("TotalCharacter"); OnPropertyChanged("TotalFullBytes"); } }
public void DeleteFileInfo(object item) { FileDetail file = item as FileDetail; if (item != null) { FileInfoList.Remove(file); } OnPropertyChanged("TotalCount"); OnPropertyChanged("TotalSize"); OnPropertyChanged("TotalLengh"); OnPropertyChanged("TotalWords"); OnPropertyChanged("TotalCharacter"); OnPropertyChanged("TotalFullBytes"); }
private void DelFile(object obj) { try { DataGrid dataGrid = obj as DataGrid; FileInfo = dataGrid.SelectedItem as FileInfo; FileHelper.DelFile(fileInfo); FileInfoList.Remove(FileInfo); } catch (Exception ex) { ErrorDialogViewModel.getInstance().show(ex); return; } }
public AppState(ServerSettings settings) { Settings = settings; WaitingForServerInfoResponse = true; WaitingForFileListResponse = true; UserEntryPortNumber = 0; UserEntryIpAddress = IPAddress.None; UserEntryRemoteServerName = string.Empty; LocalServer = new AsyncServer(Settings); SelectedServerInfo = new ServerInfo(); RemoteServerFileList = new FileInfoList(); SignalReturnToMainMenu = new AutoResetEvent(false); _localServerState = new ServerState(LocalServer); }
/// <summary> /// Retrieve the modification time of a given file /// </summary> /// <param name="fileName"></param> /// <returns></returns> virtual public DateTime GetModifiedTime(string fileName) { FileInfoList list = this.ListFileInfo(); foreach (FileInfo currentInfo in list) { if (currentInfo.Basename.ToLower() != fileName.ToLower()) { continue; } return(currentInfo.ModifiedTime); } return(DateTime.MinValue); }
public void DoUpdate(UpdateMgr UpdateManager) { CloseLauncher(); var res = UpdateManager.GetUpdateResult(); var fn = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), UpdatePath); cancleSource = new CancellationTokenSource(); UpdateCount = res.Count; UpdateNow = 0; if (!Directory.Exists(fn)) { Directory.CreateDirectory(fn); } UpdateTask = Task.Factory.StartNew(() => { SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Application.Current.Dispatcher)); foreach (var file in res) { if (cancleSource.IsCancellationRequested) { break; } var url = UpdateManager.GetDownloadUrl(file.Name); HttpDownload.HttpDownloadFile(url, fn + file.Name + ".cozy_update"); SynchronizationContext.Current.Send(x => { FileInfoList.Add(file.Name); UpdateNow++; }, null); } MoveFile(); OkEnable = true; CancleEnable = false; }, cancleSource.Token); CancleEnable = true; OkEnable = false; }
public void FileInfoList_SortByLastWriteTime() { FileInfoList list = new FileInfoList(files); list.SortByLastWriteTime(false); for (int i = 0; i < list.Count - 1; i++) { Assert.IsTrue(list[i].LastWriteTime >= list[i + 1].LastWriteTime); } list.SortByLastWriteTime(true); for (int i = 0; i < list.Count - 1; i++) { Assert.IsTrue(list[i].LastWriteTime <= list[i + 1].LastWriteTime); } }
public void FileInfoList_SortBySize() { FileInfoList list = new FileInfoList(files); list.SortByLength(false); for (int i = 0; i < list.Count - 1; i++) { Assert.IsTrue(list[i].Length >= list[i + 1].Length); } list.SortByLength(true); for (int i = 0; i < list.Count - 1; i++) { Assert.IsTrue(list[i].Length <= list[i + 1].Length); } }
public void FileInfoList_SortByPath() { FileInfoList list = new FileInfoList(files); list.SortByPath(false); for (int i = 0; i < list.Count - 1; i++) { Assert.IsTrue(String.Compare(list[i].FullName, list[i + 1].FullName, true) >= 0); } list.SortByPath(true); for (int i = 0; i < list.Count - 1; i++) { Assert.IsTrue(String.Compare(list[i].FullName, list[i + 1].FullName, true) <= 0); } }
protected override void findFiles( string pattern, bool recursive, List<string> simpleList, FileInfoList detailList, string currentDir ) { if ( pattern == "" ) { pattern = "*"; } if ( currentDir == "" ) { currentDir = _basePath; } var files = getFilesRecursively( currentDir, pattern ); foreach ( var file in files ) { if ( simpleList != null ) { simpleList.Add( file ); } if ( detailList != null ) { detailList.Add( new FileInfo { Archive = this, Filename = file, Basename = file.Substring( currentDir.Length ), Path = currentDir, CompressedSize = 0, UncompressedSize = 0, ModifiedTime = DateTime.Now } ); } } }
/// <overloads><summary> /// Utility method to retrieve all files in a directory matching pattern. /// </summary> /// <param name="pattern">File pattern</param> /// <param name="recursive">Whether to cascade down directories</param> /// <param name="simpleList">Populated if retrieving a simple list</param> /// <param name="detailList">Populated if retrieving a detailed list</param> /// </overloads> protected void findFiles( string pattern, bool recursive, List<string> simpleList, FileInfoList detailList ) { findFiles( pattern, recursive, simpleList, detailList, "" ); }
/// <summary> /// /// </summary> /// <param name="pattern"></param> /// <param name="recursive"></param> /// <returns></returns> public override FileInfoList FindFileInfo( string pattern, bool recursive ) { var ret = new FileInfoList(); findFiles( pattern, recursive, null, ret ); return ret; }
/// <param name="detailList"></param> /// <param name="currentDir">The current directory relative to the base of the archive, for file naming</param> /// <param name="pattern"></param> /// <param name="recursive"></param> /// <param name="simpleList"></param> protected void findFiles( string pattern, bool recursive, List<string> simpleList, FileInfoList detailList, string currentDir ) { if ( currentDir == "" ) { currentDir = this._zipDir; } Load(); if ( pattern.Contains( "*" ) ) { pattern = pattern.Replace( ".", @"\." ).Replace( "*", ".*" ) + "$"; } var ex = new Regex( pattern ); foreach ( var entry in this._zipStream ) { // get the full path for the output file var file = entry.FileName; if ( ex.IsMatch( file ) ) { if ( simpleList != null ) { simpleList.Add( file ); } if ( detailList != null ) { FileInfo fileInfo; fileInfo.Archive = this; fileInfo.Filename = entry.FileName; fileInfo.Basename = Path.GetFileName( entry.FileName ); fileInfo.Path = Path.GetDirectoryName( entry.FileName ) + Path.DirectorySeparatorChar; fileInfo.CompressedSize = entry.CompressedSize; fileInfo.UncompressedSize = entry.UncompressedSize; fileInfo.ModifiedTime = entry.CreationTime; detailList.Add( fileInfo ); } } } }
public override FileInfoList FindFileInfo( string pattern, bool recursive ) { var fil = new FileInfoList(); _files.ForEach( ( file ) => { var ext = Path.GetExtension( file ); if ( pattern == "*" || pattern.Contains( ext ) ) { fil.Add( new FileInfo { Archive = this, CompressedSize = 0, Basename = file, Filename = file, ModifiedTime = DateTime.Now, Path = _basePath, UncompressedSize = 0 } ); } } ); return fil; //return base.FindFileInfo( pattern, recursive ); }
/// <param name="detailList"></param> /// <param name="currentDir">The current directory relative to the base of the archive, for file naming</param> /// <param name="pattern"></param> /// <param name="recursive"></param> /// <param name="simpleList"></param> protected void findFiles( string pattern, bool recursive, List<string> simpleList, FileInfoList detailList, string currentDir ) { if ( currentDir == "" ) currentDir = _zipDir; Load(); ZipEntry entry = _zipStream.GetNextEntry(); if ( pattern[ 0 ] == '*' ) pattern = pattern.Substring( 1 ); Regex ex = new Regex( pattern ); while ( entry != null ) { // get the full path for the output file string file = entry.Name; if ( ex.IsMatch( file ) ) { if ( simpleList != null ) { simpleList.Add( file ); } if ( detailList != null ) { FileInfo fileInfo; fileInfo.Archive = this; fileInfo.Filename = entry.Name; fileInfo.Basename = Path.GetFileName( entry.Name ); fileInfo.Path = Path.GetDirectoryName( entry.Name ) + Path.DirectorySeparatorChar; fileInfo.CompressedSize = entry.CompressedSize; fileInfo.UncompressedSize = entry.Size; fileInfo.ModifiedTime = entry.DateTime; detailList.Add( fileInfo ); } } entry = _zipStream.GetNextEntry(); } }
public override FileInfoList FindFileInfo( string pattern, bool recursive ) { FileInfoList ret = new FileInfoList(); SafeDirectoryChange( _basePath, () => findFiles( pattern, recursive, null, ret ) ); return ret; }
/// <param name="detailList"></param> /// <param name="currentDir">The current directory relative to the base of the archive, for file naming</param> /// <param name="pattern"></param> /// <param name="recursive"></param> /// <param name="simpleList"></param> protected void findFiles( string pattern, bool recursive, List<string> simpleList, FileInfoList detailList, string currentDir ) { if ( pattern == "" ) pattern = "*"; if ( currentDir == "" ) currentDir = _basePath; string[] files; #if !( XBOX || XBOX360 || ANDROID ) files = Directory.GetFiles( currentDir, pattern, recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly ); #else files = recursive ? this.getFilesRecursively(currentDir, pattern) : Directory.GetFiles(currentDir, pattern); #endif foreach ( string file in files ) { System.IO.FileInfo fi = new System.IO.FileInfo( file ); if ( simpleList != null ) { simpleList.Add( fi.Name ); } if ( detailList != null ) { FileInfo fileInfo; fileInfo.Archive = this; fileInfo.Filename = fi.FullName; fileInfo.Basename = fi.FullName.Substring( Path.GetFullPath(currentDir).Length ); fileInfo.Path = currentDir; fileInfo.CompressedSize = fi.Length; fileInfo.UncompressedSize = fi.Length; fileInfo.ModifiedTime = fi.LastWriteTime; detailList.Add( fileInfo ); } } }
/// <param name="detailList"></param> /// <param name="currentDir">The current directory relative to the base of the archive, for file naming</param> /// <param name="pattern"></param> /// <param name="recursive"></param> /// <param name="simpleList"></param> protected virtual void findFiles( string pattern, bool recursive, List<string> simpleList, FileInfoList detailList, string currentDir ) { if ( pattern == "" ) { pattern = "*"; } if ( currentDir == "" ) { currentDir = this._basePath; } var files = getFiles( currentDir, pattern, recursive ); foreach ( var file in files ) { var fi = new System.IO.FileInfo( file ); if ( simpleList != null ) { simpleList.Add( fi.Name ); } if ( detailList != null ) { FileInfo fileInfo; fileInfo.Archive = this; fileInfo.Filename = fi.FullName; fileInfo.Basename = fi.FullName.Substring( Path.GetFullPath( currentDir ).Length ); fileInfo.Path = currentDir; fileInfo.CompressedSize = fi.Length; fileInfo.UncompressedSize = fi.Length; fileInfo.ModifiedTime = fi.LastWriteTime; detailList.Add( fileInfo ); } } }