/// <summary> /// OfficeFileの状態をチェックし、アラート表示、ToolTipの設定を行う。 /// </summary> /// <param name="officeNode"></param> private void RefreshOfficeNode(OfficeFileTreeNode officeNode) { OfficeFile file = officeNode.TargetFile; bool alert = file.Status != OfficeFileStatus.Normal; officeNode.ImageIndex = officeNode.SelectedImageIndex = (alert ? IMG_EXCEL_ALERT : IMG_EXCEL); officeNode.ToolTipText = file.StatusMessage; }
private void LibraryPropertyDialog_TargetFolderChanged(object sender, EventArgs <LibraryFolder> e) { if (this.TargetFolder != null) { this.TargetOfficeFile = null; this.RefreshDisplay(); } }
public void AccdbGetAuthorTest() { var file = new OfficeFile(@"..\..\SampleFiles\Test.Accdb"); file.OpenFile(); Assert.AreEqual("Test Author", file.Author); file.CloseFile(); }
public void AccdbGetModifiedTimeUtcTest() { var file = new OfficeFile(@"..\..\SampleFiles\Test.Accdb"); file.OpenFile(); Assert.AreEqual(new DateTime(2016, 3, 1, 16, 03, 02, DateTimeKind.Utc), file.ModifiedTimeUtc); file.CloseFile(); }
public void AccdbGetCompanyTest() { var file = new OfficeFile(@"..\..\SampleFiles\Test.Accdb"); file.OpenFile(); Assert.AreEqual("Test Company", file.Company); file.CloseFile(); }
public void MdbGetCreatedTimeUtcTest() { var file = new OfficeFile(@"..\..\SampleFiles\Test.Mdb"); file.OpenFile(); Assert.AreEqual(new DateTime(2016, 3, 1, 15, 24, 25, DateTimeKind.Utc), file.CreatedTimeUtc); file.CloseFile(); }
public void AccdbGetCustomPropertiesTest() { var file = new OfficeFile(@"..\..\SampleFiles\Test.Accdb"); file.OpenFile(); var expectedValue = new Dictionary<string, object>() { { "Test1", "Test" }, { "Test2", 1 } }; CollectionAssert.AreEqual((ICollection)expectedValue, (ICollection)file.CustomProperties); file.CloseFile(); }
/// <summary> /// ファイルの場所を開く /// </summary> private void OpenFileLocation() { if (this.historyListView1.SelectedItems.Count != 1) { return; } string name = this.historyListView1.SelectedItems[0].Text; OfficeFile relatedFile = this.Project?.ExcelFiles.Where(file => file.BackupPathList.Contains(name)).FirstOrDefault(); string filename = relatedFile?.FileName ?? ""; if (File.Exists(filename)) { string folderName = Path.GetDirectoryName(filename); //explorerの起動 this.RunExplorer(folderName); } }
private void RefreshFilesDisplay() { //Filesに存在しないNodeを削除 //Libraryに存在しないNodeを削除 //リストの複製を用意し、複製で削除判定。複製のForEach内で本体から削除する。(本体のForEachではないので、列挙中の削除例外は発生しない) List <OfficeFileTreeNode> cloneList = this.m_FileRootNode.Nodes.Cast <OfficeFileTreeNode>().ToList(); cloneList.Where(node => !this.m_TargetProject.ExcelFiles.Any(file => file.FileName == node.TargetFile.FileName)).ToList() //このToListの時点で、Librariesに存在しないノードがリストアップされている .ForEach(node => this.m_FileRootNode.Nodes.Remove(node)); //for (int i = this.m_FileRootNode.Nodes.Count - 1; i >= 0; i--) { // OfficeFileTreeNode node = (OfficeFileTreeNode)this.m_FileRootNode.Nodes[i]; // if (!this.m_TargetProject.ExcelFiles.Any(x => x.FileName == node.TargetFile.FileName)) { // this.m_FileRootNode.Nodes.Remove(node); // } //} //FilesとNodeを同期 for (int i = 0; i < this.m_TargetProject.ExcelFiles.Count; i++) { OfficeFile file = this.m_TargetProject.ExcelFiles[i]; AppMain.logger.Debug($"{this.GetType().Name}.RefreshDisplay / Show File. Path={file.FileName}"); OfficeFileTreeNode node = this.m_FileRootNode.Nodes.Cast <OfficeFileTreeNode>().FirstOrDefault(x => x.TargetFile.FileName == file.FileName); if (node == null) { node = new OfficeFileTreeNode(file) { ImageIndex = IMG_EXCEL, SelectedImageIndex = IMG_EXCEL }; this.m_FileRootNode.Nodes.Add(node); } node.TargetFile = file; //ファイルのエラー状態のチェックなど this.RefreshOfficeNode(node); } if (this.m_FileRootNode.Nodes.Count != 0) { this.m_FileRootNode.Nodes[0].EnsureVisible(); } }
public async Task Process(BlobLoaded blob) { var fileId = NewId.NextGuid(); var blobInfo = blob.BlobInfo; Guid userId = blobInfo.UserId.HasValue ? blobInfo.UserId.Value : new Guid(blobInfo.Metadata[nameof(userId)].ToString()); Guid?parentId = blobInfo.Metadata != null?blobInfo.Metadata.ContainsKey(nameof(parentId)) ? (Guid?)new Guid(blobInfo.Metadata[nameof(parentId)].ToString()) : null : null; var file = new OfficeFile(fileId, userId, parentId, blobInfo.FileName, FileStatus.Loaded, blobInfo.Bucket, blobInfo.Id, blobInfo.Length, blobInfo.MD5); await _session.Add(file); await _session.Commit(); await _bus.Publish <ProcessOfficeFile>(new { Id = fileId, Bucket = blobInfo.Bucket, BlobId = blobInfo.Id, UserId = userId }); }
/// <summary> /// 削除 /// </summary> private void DeleteFolder() { DialogResult result = MessageBox.Show("選択されたフォルダを削除します。よろしいですか?", "削除確認", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (result == DialogResult.OK) { foreach (ListViewItem item in this.historyListView1.SelectedItems) { string name = item.Text; //関連ファイルの登録を削除 OfficeFile relatedFile = this.Project?.ExcelFiles.Where(file => file.BackupPathList.Contains(name)).FirstOrDefault(); relatedFile.BackupPathList.Remove(name); //実フォルダの削除 string folderName = Path.Combine(AppMain.g_AppMain.HistoryFolderPath, name); if (Directory.Exists(folderName)) { Directory.Delete(folderName, true); } } this.RefreshDisplay(); } }
/// <summary> /// 表示を更新します。 /// </summary> public void RefreshDisplay(bool keep = false) { string path = AppMain.g_AppMain.HistoryFolderPath; try { this.historyListView1.SuspendLayout(); this.historyListView1.Items.Clear(); foreach (string folder in Directory.GetDirectories(path)) { string folderName = Path.GetFileName(folder); OfficeFile relatedFile = this.Project?.ExcelFiles.Where(file => file.BackupPathList.Contains(folderName)).FirstOrDefault(); string fileName = Path.GetFileName(relatedFile?.FileName ?? ""); ListViewItem item = new ListViewItem(new string[] { folderName, fileName }); this.historyListView1.Items.Add(item); } } finally { this.historyListView1.ResumeLayout(); } }
/// <summary> /// ExportModuleRequestEventArgsオブジェクトの新しいインスタンスを初期化します。 /// </summary> /// <param name="targetFile"></param> public ExportModuleRequestEventArgs(OfficeFile targetFile) : this(targetFile, "") { }
/// <summary> /// ShowOfficeFilePropertyRequestDataオブジェクトの新しいインスタンスを初期化します。 /// </summary> /// <param name="targetFile"></param> public ShowOfficeFilePropertyRequestData(OfficeFile targetFile) { this.m_TargetFile = targetFile; }
/// <summary> /// ShowOfficeFilePropertyRequestEventArgsオブジェクトの新しいインスタンスを初期化します。 /// </summary> /// <param name="targetFile"></param> /// <param name="ownerName"></param> public ShowOfficeFilePropertyRequestEventArgs(OfficeFile targetFile, string ownerName) : base(new ShowOfficeFilePropertyRequestData(targetFile), ownerName) { }
/// <summary> /// ShowOfficeFilePropertyRequestEventArgsオブジェクトの新しいインスタンスを初期化します。 /// </summary> /// <param name="targetFile"></param> public ShowOfficeFilePropertyRequestEventArgs(OfficeFile targetFile) : this(targetFile, "") { }
public void AccdbOpenAndCloseFileTest() { var file = new OfficeFile(@"..\..\SampleFiles\Test.Accdb"); file.OpenFile(); file.CloseFile(); }
public static void EntityShouldBeEquivalentTo(this GenericDictionaryAssertions <string, object> assertions, OfficeFile file) { assertions.Subject.Should().BeEquivalentTo(new Dictionary <string, object> { { "_id", file.Id }, { "Blob", new Dictionary <string, object>() { { "_id", file.BlobId }, { "Bucket", file.Bucket }, { "Length", file.Length }, { "Md5", file.Md5 } } }, { "SubType", FileType.Office.ToString() }, { "OwnedBy", file.OwnedBy }, { "CreatedBy", file.CreatedBy }, { "CreatedDateTime", file.CreatedDateTime.UtcDateTime }, { "UpdatedBy", file.UpdatedBy }, { "UpdatedDateTime", file.UpdatedDateTime.UtcDateTime }, { "ParentId", file.ParentId }, { "Name", file.FileName }, { "Status", file.Status.ToString() }, { "Version", file.Version }, { "Pdf", new Dictionary <string, object>() { { "BlobId", file.PdfBlobId }, { "Bucket", file.PdfBucket } } }, { "Images", file.Images.Select(i => new Dictionary <string, object> { { "_id", i.Id }, { "Bucket", file.Bucket }, { "Height", i.Height }, { "Width", i.Height }, { "MimeType", i.MimeType }, { "Scale", i.GetScale() } }) }, { "Properties", new Dictionary <string, object>() { { "Metadata", file.Metadata.Select(p => new Dictionary <string, object> { { "Name", p.Name }, { "Value", p.Value }, { "Error", p.Error } }) } } } }); }
/// <summary> /// NotifyFileChangedRequestEventArgsオブジェクトの新しいインスタンスを初期化します。 /// </summary> /// <param name="targetFile"></param> /// <param name="args"></param> public NotifyFileChangedRequestEventArgs(OfficeFile targetFile, FileSystemEventArgs args) : this(targetFile, args, "") { }
/// <summary> /// OfficeFileTreeNodeオブジェクトの新しいインスタンスを初期化します。 /// </summary> /// <param name="file"></param> public OfficeFileTreeNode(OfficeFile file) : this() { this.TargetFile = file; }
/// <summary> /// ExportModuleRequestEventArgsオブジェクトの新しいインスタンスを初期化します。 /// </summary> /// <param name="targetFile"></param> /// <param name="ownerName"></param> public ExportModuleRequestEventArgs(OfficeFile targetFile, string ownerName) : base(new ExportModuleRequestData(targetFile), ownerName) { }
/// <summary> /// NotifyFileChangedRequestDataオブジェクトの新しいインスタンスを初期化します。 /// </summary> /// <param name="targetFile"></param> /// <param name="args"></param> public NotifyFileChangedRequestData(OfficeFile targetFile, FileSystemEventArgs args) { this.m_TargetFile = targetFile; this.m_FileSyatemEventArgs = args; }
private void metadataBgWorker_DoWork(object sender, DoWorkEventArgs e) { metadataBgWorker.ReportProgress(1); string extension = Path.GetExtension(filePath).ToLower(); string[] extensions = new string[] { ".doc", ".docx", ".xls", ".xlsx", ".mdb", ".accdb", ".ppt", ".pptx" }; if (!extensions.Contains(extension)) { MessageBox.Show("Format is not supported (" + extension + ")\nSupported formats:\nMicrosoft Word (.doc, .docx)\nMicrosoft Excel (.xls, .xlsx)\nMicrosoft Access (.mdb, .accdb)\nMicrosoft PowerPoint (.ppt, .pptx)"); return; } var fsFile = new OfficeFile(filePath); var fsProperties = fsFile.GetFileProperties(); try { propList.Add("Author: " + fsProperties.Author.ToString()); } catch { errorList.Add("Could not read Author property"); } try { propList.Add("Comments: " + fsProperties.Comments.ToString()); } catch { errorList.Add("Could not read Comments property"); } try { propList.Add("Company: " + fsProperties.Company.ToString()); } catch { errorList.Add("Could not read Company property"); } try { propList.Add("Created Time: " + fsProperties.CreatedTimeLocal.ToString()); } catch { errorList.Add("Could not read Created Time property"); } try { propList.Add("Modified Time: " + fsProperties.ModifiedTimeLocal.ToString()); } catch { errorList.Add("Could not read Modified Time property"); } try { propList.Add("File Type: " + fsProperties.FileType.ToString()); } catch { errorList.Add("Could not read File Type property"); } try { propList.Add("Title: " + fsProperties.Title.ToString()); } catch { errorList.Add("Could not read Title property"); } try { foreach (var item in fsProperties.CustomProperties) { propList.Add("Custom property: " + item.ToString()); } } catch { errorList.Add("Could not read Custom property"); } List <string> emptyValues = new List <string>(); foreach (string item in propList) { if (item.Replace(" ", "")[item.Replace(" ", "").Length - 1] == ':') { emptyValues.Add(item); } } foreach (string item in emptyValues) { propList.Remove(item); } }
/// <summary> /// NotifyFileChangedRequestEventArgsオブジェクトの新しいインスタンスを初期化します。 /// </summary> /// <param name="targetFile"></param> /// <param name="args"></param> /// <param name="ownerName"></param> public NotifyFileChangedRequestEventArgs(OfficeFile targetFile, FileSystemEventArgs args, string ownerName) : base(new NotifyFileChangedRequestData(targetFile, args), ownerName) { }
/// <summary> /// ExportModuleRequestDataオブジェクトの新しいインスタンスを初期化します。 /// </summary> /// <param name="targetFile"></param> public ExportModuleRequestData(OfficeFile targetFile) { this.m_TargetFile = targetFile; }