public CreateFolder(List <ClassFolder> folder) { InitializeComponent(); display(); //FolderController.getListFolder() = new List<ClassFolder>(); //List<string> listfilename = new List<string>(); //ClassFile file = new ClassFile(); //ClassFolder fol = new ClassFolder(); //ReadPDF = new ReadPDF(file, fol); //FolderController.getListFolder() = folder; //foreach (ClassFolder f in FolderController.getListFolder()) //{ // lstFolder.Items.Add(f.namefolder); //} //if (txtNameFolder.Text == "") //{ // txtNameFolder.Text = FolderController.getListFolder()[0].namefolder; //} //listfolder = new List<ClassFolder>(); BindingSource source = new BindingSource(); source.DataSource = FolderController.getListFolder(); this.lstFolder.DataSource = source; }
public void TestAllFoldersView() { FolderController controller = new FolderController(); ViewResult view = controller.List() as ViewResult; Assert.IsNotNull(view); }
// Thêm tên Folder private void btnAddFolder_Click(object sender, EventArgs e) { // if (txtNameFolder.Text != "" && FolderController.getListFolder().Where(x=> x.namefolder == txtNameFolder.Text).Count()<1) // { // ClassFolder folder = new ClassFolder(); // folder.namefolder = txtNameFolder.Text; // //folder.listfile = new List<ClassFile>(); // FolderController.AddFolder(folder); // //lstFolder.Items.Add(txtNameFolder.Text); // //FolderController.getListFolder().Add(folder); // } // else // { // MessageBox.Show("Nhập tên thư mục không hợp lệ","Lỗi", MessageBoxButtons.OK, // MessageBoxIcon.Error); // return; // } // thêm folder vào database ClassFolder f = new ClassFolder(); f.namefolder = this.txtNameFolder.Text.Trim(); if (FolderController.AddFolder(f) == false) { MessageBox.Show("thư mục không hợp lệ", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } txtNameFolder.Clear(); ((CurrencyManager)lstFolder.BindingContext[lstFolder.DataSource]).Refresh(); }
public void TestCreateFolderPartial() { FolderController controller = new FolderController(); PartialViewResult partial = controller.Create() as PartialViewResult; Assert.IsNotNull(partial); }
public void TestChangeFolderPartial() { FolderController controller = new FolderController(); PartialViewResult partial = controller.ChangeFolderPartial(2, "Ocio", 3) as PartialViewResult; Assert.IsNotNull(partial); }
/// <summary> /// Serializes all Files /// </summary> /// <param name="xmlTemplate">Reference to XmlDocument context</param> /// <param name="nodeFiles">Node to add the serialized objects</param> /// <param name="objportal">Portal to serialize</param> /// <param name="folderPath">The folder containing the files</param> /// <param name="zipFile"></param> /// <remarks> /// The serialization uses the xml attributes defined in FileInfo class. /// </remarks> /// <history> /// [cnurse] 11/08/2004 Created /// [cnurse] 05/20/2004 Extracted adding of file to zip to new FileSystemUtils method /// </history> public void SerializeFiles(XmlDocument xmlTemplate, XmlNode nodeFiles, PortalInfo objportal, string folderPath, ref ZipOutputStream zipFile) { FolderController objFolders = new FolderController(); FolderInfo objFolder = objFolders.GetFolder(objportal.PortalID, folderPath); ArrayList arrFiles = FileSystemUtils.GetFilesByFolder(objportal.PortalID, objFolder.FolderID); XmlSerializer xser = new XmlSerializer(typeof(FileInfo)); foreach (FileInfo objFile in arrFiles) { // verify that the file exists on the file system string filePath = objportal.HomeDirectoryMapPath + folderPath + objFile.FileName; if (File.Exists(filePath)) { StringWriter sw = new StringWriter(); xser.Serialize(sw, objFile); //Add node to template XmlDocument xmlFile = new XmlDocument(); xmlFile.LoadXml(sw.GetStringBuilder().ToString()); XmlNode nodeFile = xmlFile.SelectSingleNode("file"); nodeFile.Attributes.Remove(nodeFile.Attributes["xmlns:xsd"]); nodeFile.Attributes.Remove(nodeFile.Attributes["xmlns:xsi"]); nodeFiles.AppendChild(xmlTemplate.ImportNode(nodeFile, true)); FileSystemUtils.AddToZip(ref zipFile, filePath, objFile.FileName, folderPath); } } }
/// <summary> /// Serializes all Folders including Permissions /// </summary> /// <param name="xmlTemplate">Reference to XmlDocument context</param> /// <param name="nodeFolders"></param> /// <param name="objportal">Portal to serialize</param> /// <param name="zipFile"></param> /// <remarks> /// The serialization uses the xml attributes defined in FolderInfo class. /// </remarks> /// <history> /// [cnurse] 11/08/2004 Created /// </history> public void SerializeFolders(XmlDocument xmlTemplate, XmlNode nodeFolders, PortalInfo objportal, ref ZipOutputStream zipFile) { // Sync db and filesystem before exporting so all required files are found FileSystemUtils.Synchronize(objportal.PortalID, objportal.AdministratorRoleId, objportal.HomeDirectoryMapPath); FolderController objFolders = new FolderController(); ArrayList arrFolders = objFolders.GetFoldersByPortal(objportal.PortalID); XmlSerializer xser = new XmlSerializer(typeof(FolderInfo)); foreach (FolderInfo objFolder in arrFolders) { StringWriter sw = new StringWriter(); xser.Serialize(sw, objFolder); XmlDocument xmlFolder = new XmlDocument(); xmlFolder.LoadXml(sw.GetStringBuilder().ToString()); XmlNode nodeFolder = xmlFolder.SelectSingleNode("folder"); nodeFolder.Attributes.Remove(nodeFolder.Attributes["xmlns:xsd"]); nodeFolder.Attributes.Remove(nodeFolder.Attributes["xmlns:xsi"]); //Serialize Folder Permissions XmlNode nodePermissions = xmlTemplate.CreateElement("folderpermissions"); SerializeFolderPermissions(xmlTemplate, nodePermissions, objportal, objFolder.FolderPath); nodeFolder.AppendChild(xmlFolder.ImportNode(nodePermissions, true)); // Serialize files XmlNode nodeFiles = xmlTemplate.CreateElement("files"); SerializeFiles(xmlTemplate, nodeFiles, objportal, objFolder.FolderPath, ref zipFile); nodeFolder.AppendChild(xmlFolder.ImportNode(nodeFiles, true)); nodeFolders.AppendChild(xmlTemplate.ImportNode(nodeFolder, true)); } }
public async Task Get_ReturnsAIActionResult_WithAListOfFoldersInDatabase() { // Arrange var expected = 2;//Number of folders in list var mockDb = new Mock <IEFFileFolderContext>(); mockDb.Setup(repo => repo.GetFolders()) .ReturnsAsync(GetAllTestSessions()); var mockHub = new Mock <IHubContext <FolderHub> >(); var controller = new FolderController(mockDb.Object, mockHub.Object); // Act var result = await controller.Get(); // Assert //var okObjectResult = result as OkObjectResult; var okObjectResult = Assert.IsType <OkObjectResult>(result); Assert.NotNull(okObjectResult); var model = okObjectResult.Value as IEnumerable <FolderResponse>; Assert.NotNull(model); var actual = model.Count(); Assert.Equal(expected, actual); }
void Awake() { folderFacade.Register(); settingsFacade.Register(); workBenchFacade.Register(); this.initialize(); folderModel = new FolderModel(); this.framework.modelCenter.Register(FolderModel.NAME, folderModel); folderView = new FolderView(); this.framework.viewCenter.Register(FolderView.NAME, folderView); folderController = new FolderController(); this.framework.controllerCenter.Register(FolderController.NAME, folderController); mouseController = new MouseController(); this.framework.controllerCenter.Register(MouseController.NAME, mouseController); SettingsView viewSettings = new SettingsView(); this.framework.viewCenter.Register(SettingsView.NAME, viewSettings); WorkBenchView viewWorkBench = new WorkBenchView(); this.framework.viewCenter.Register(WorkBenchView.NAME, viewWorkBench); WorkBenchController controllerWorkBench = new WorkBenchController(); this.framework.controllerCenter.Register(WorkBenchController.NAME, controllerWorkBench); workBenchModel = new WorkBenchModel(); this.framework.modelCenter.Register(WorkBenchModel.NAME, workBenchModel); }
public async Task GetById_ReturnsAIActionResult_WithAFolderFromDatabase() { // Arrange var expected = "Test One";//Name of folder var mockDb = new Mock <IEFFileFolderContext>(); mockDb.Setup(repo => repo.GetFolderByIdAsync(1)) .ReturnsAsync(GetOneTestSessions()); var mockHub = new Mock <IHubContext <FolderHub> >(); var controller = new FolderController(mockDb.Object, mockHub.Object); // Act var result = await controller.Get(1); // Assert //var okObjectResult = result as OkObjectResult; var okObjectResult = Assert.IsType <OkObjectResult>(result); Assert.NotNull(okObjectResult); var model = okObjectResult.Value as FolderResponse; Assert.NotNull(model); var actual = model.FolderName; Assert.Equal(expected, actual); }
//Chọn file private void lstFile_DoubleClick(object sender, EventArgs e) { if (Result == 0) { File = allfile.Where(x => x.namefile == lstFile.SelectedItems[0].SubItems[0].Text).Single(); if (Folder.listfile.Where(x => x.namefile == File.namefile).Count() >= 1) { MessageBox.Show("Đã có File này trong danh sách", "Thông Báo"); } else { Folder.listfile.Add(File); FolderController.UpdateFolder(Folder); } } else if (Result == 1) { ClassFile file = new ClassFile(); file = allfile.Where(x => x.namefile == lstFile.SelectedItems[0].SubItems[0].Text).Single(); File.linkedfilein = file.ID; file.linkedfileout = File.ID; FileController.UpdateFile(File); FileController.UpdateFile(file); } else { ClassFile file = new ClassFile(); file = allfile.Where(x => x.namefile == lstFile.SelectedItems[0].SubItems[0].Text).Single(); File.linkedfileout = file.ID; file.linkedfilein = File.ID; FileController.UpdateFile(File); FileController.UpdateFile(file); } this.Close(); }
//Hiển thị tất cả các file trên database(Huy) private void displayFile() { allfile = FileController.getListFiles(); foreach (ClassFile file in allfile) { ListViewItem item = new ListViewItem(file.namefile); List <ClassFolder> lstfolders = FolderController.GetAllFolder(); string s = ""; foreach (ClassFolder folder in lstfolders) { if (folder.listfile.Where(x => x.ID == file.ID).Count() > 0) { s = s + " " + folder.namefolder; } } item.SubItems.Add(s); if (file.linkedfileout > 0) { item.SubItems.Add(FileController.getFile(file.linkedfileout).namefile); } else { item.SubItems.Add("Chưa có tập sau"); } if (file.linkedfilein > 0) { item.SubItems.Add(FileController.getFile(file.linkedfilein).namefile); } else { item.SubItems.Add("Chưa có tập trước"); } lstFile.Items.Add(item); } }
public async Task PostFolder_ReturnsAIActionResult_WithAFolder() { // Arrange var expected = "Test One";//Name of folder var mockDb = new Mock <IEFFileFolderContext>(); //SignalRHubMock var mockHub = new Mock <IHubContext <FolderHub> >(); var mockClients = new Mock <IHubClients>(); Mock <IClientProxy> mockClientProxy = new Mock <IClientProxy>(); mockClients.Setup(clients => clients.All).Returns(mockClientProxy.Object); mockHub.Setup(repo => repo.Clients).Returns(mockClients.Object); var controller = new FolderController(mockDb.Object, mockHub.Object); // Act var result = await controller.PostFolder(GetOneTestSessions()); // Assert var okObjectResult = Assert.IsType <OkObjectResult>(result); Assert.NotNull(okObjectResult); var model = okObjectResult.Value as Folder; Assert.NotNull(model); var actual = model.Name; Assert.Equal(expected, actual); }
void OnTriggerExit(Collider collider) { if (collider.CompareTag("Folder")) { activeFolder = null; folderController = null; } }
void OnTriggerEnter(Collider collider) { if (collider.CompareTag("Folder")) { activeFolder = collider.gameObject; folderController = activeFolder.GetComponent <FolderController>(); } }
//Hiển thị folder lên từ database cho ListBox lstFolder(Hùng) private void displayFolder() { lstFolder.Items.Clear(); listfolder = FolderController.GetAllFolder(); foreach (ClassFolder folder in listfolder) { this.lstFolder.Items.Add(folder.namefolder); } }
public CreateFolder() { InitializeComponent(); listfolder = new List <ClassFolder>(); listfolder = FolderController.GetAllFolder(); displayFolder(); displayFile(listfolder[0]); txtNameFolder.Text = listfolder[0].namefolder; }
//Thêm File private void btnAddFile_Click(object sender, EventArgs e) { if (txtNameFolder.Text == "") { return; } else { string filename = ""; OpenFileDialog ChooseFile = new OpenFileDialog(); ChooseFile.Filter = "PDF|*.pdf"; if (ChooseFile.ShowDialog() == DialogResult.OK) { filename = ChooseFile.FileName; } int index = FolderController.getListFolder().FindIndex(x => x.namefolder == txtNameFolder.Text); if (FolderController.getListFolder()[index].listfile != null) //giải thích ??? { if (FolderController.getListFolder()[index].listfile.ToList <ClassFile>().Where( //giải thích ??? x => x.namefile == filename).Count() < 1) { AddFileItem(ChooseFile.FileName); //ngân: khắc phục addfile lỗi ClassFile file = new ClassFile(); file.namefile = filename; file.folder.Add(lstFolder.SelectedItem as ClassFolder); //ngân:bổ sung thêm lấy mấy thông tin để đủ 1 hàng bảng file if (FileController.AddFile(file) == false) { //file đã có trong bảng //định xóa file trong bảng, rồi tạo thêm liên kết với folder mới(k bt ảnh hưởng liên kết cũ k- xóa cmnr) ClassFile f = FileController.getFile(file.namefile); if (FileController.DeleteFile(f) == false) { MessageBox.Show("Remove Task Error"); return; } FileController.AddFile(file); } //FolderController.AddFile(FolderController.getListFolder()[index], file); } else { MessageBox.Show("Đã có File này trong danh sách", "Thông Báo"); } } else//giải thích ??? { //AddFileItem(ChooseFile.FileName); //ClassFile file = new ClassFile(); //file.namefile = filename; //FolderController.AddFile(FolderController.getListFolder()[index], file); } } }
public async void GetFolderByIdFailedAsync() { // Arrange mockFolderService.Setup(service => service.GetDetail(It.IsAny <int>())).Throws(new CurrentEntryNotFoundException("Specified Folder not found")); FolderController controller = new FolderController(mockFolderService.Object); var ex = await Assert.ThrowsAsync <CurrentEntryNotFoundException>(() => controller.Detail(It.IsAny <int>())); Assert.Equal("Specified Folder not found", ex.Message); }
//Nháy chuột 2 lần mở File private void lstFileName_DoubleClick(object sender, EventArgs e) { ClassFile files = new ClassFile(); files = FileController.getFile(int.Parse(lstFileName.SelectedItems[0].SubItems[3].Text)); ClassFolder folder = new ClassFolder(); folder = FolderController.getFolder(txtNameFolder.Text); ReadPDF = new ReadPDF(files, folder); ReadPDF.Show(); }
private void SelectDirs_DoubleClick(object sender, EventArgs e) { if (SelectDirs.SelectedItem != null) // Если пользователь выбрал папку для изменения { var path = $"{selectedPath}/{SelectDirs.SelectedItem}"; controller = new FolderController(); //Создаем контроллер controller.SetSelectDir(@path); //Передаем в контроллер выбранную папку // ListFoldersUpdate(); // ОБновляем списки с файлами в выбранной папке textOld.Enabled = true; // Активируем поле для ввода меняемой части } }
//Mở File private void lstFileName_DoubleClick(object sender, EventArgs e) { int indexfolder = FolderController.getListFolder().FindIndex(x => x.namefolder == txtNameFolder.Text); List <ClassFile> files = new List <ClassFile>(); files = FolderController.getListFolder()[indexfolder].listfile.ToList <ClassFile>(); int index = files.FindIndex(x => x.namefile == lstFileName.SelectedItems[0].SubItems[1].Text + "\\" + lstFileName.SelectedItems[0].SubItems[0].Text); ReadPDF = new ReadPDF(files[index], FolderController.getListFolder()[indexfolder]); ReadPDF.Show(); }
//Chọn folder, và hiển thị tất cả các file của folder trên listview(lstFileName) private void lstFolder_Click(object sender, EventArgs e) { if (lstFolder.SelectedItem != null) { btnAddFile.Visible = true; btnAddFileDB.Visible = true; txtNameFolder.Text = lstFolder.SelectedItem.ToString(); ClassFolder folder = new ClassFolder(); folder.listfile = FolderController.getListFile(txtNameFolder.Text); displayFile(folder); return; } }
private static void CacheMappedDirectory() { //This code is only retained for binary compatability. #pragma warning disable 612,618 var objFolderController = new FolderController(); ArrayList arrPortals = PortalController.Instance.GetPortals(); int i; for (i = 0; i <= arrPortals.Count - 1; i++) { var objPortalInfo = (PortalInfo)arrPortals[i]; objFolderController.SetMappedDirectory(objPortalInfo, HttpContext.Current); } #pragma warning restore 612,618 }
//Hiển thị folder lên từ database cho ListBox lstFolder(Hùng) private void display() { List <ClassFolder> lstfolders = FolderController.getListFolder(); foreach (ClassFolder folder in lstfolders) { foreach (ClassFile file in folder.listfile) { ListViewItem row = new ListViewItem(file.namefile); row.SubItems.Add(file.path); row.SubItems.Add(file.size); } this.lstFolder.Items.Add(folder); } }
private void btnDelete_Click(object sender, EventArgs e) { if (this.lstFolder.SelectedItems.Count <= 0) { return; } ClassFolder f = FolderController.getFolder(lstFolder.Items[lstFolder.SelectedIndex].ToString()); FolderController.DeleteFolder(f); BindingSource source = new BindingSource(); source.DataSource = FolderController.getListFolder(); this.lstFolder.DataSource = source; }
// Thêm Folder vào database(Huy) private void btnAddFolder_Click(object sender, EventArgs e) { if (txtNameFolder.Text != "" && listfolder.Where(x => x.namefolder == txtNameFolder.Text).Count() < 1) { ClassFolder folder = new ClassFolder(); folder.namefolder = txtNameFolder.Text; FolderController.AddFolder(folder); displayFolder(); } else { MessageBox.Show("Nhập tên thư mục không hợp lệ", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public void GetFolderContent_Method_Test_GetContent_Call_Once_Return_Not_Null_Result() { // Arrange var returnModel = new ContentDto(); _contentService.Setup(f => f.GetContent(null)).Returns(returnModel); var controller = new FolderController(_contentService.Object, _mapper); // Act var result = controller.GetFolderContent(); // Assert Assert.IsNotNull(result); _contentService.Verify(f => f.GetContent(null), Times.Once); }
public async Task GetFolderByIdAsync() { // Arrange int id = 2; mockFolderService.Setup(service => service.GetDetail(id)).ReturnsAsync((await GetTestFolders()).FirstOrDefault(p => p.Id == 2)); FolderController controller = new FolderController(mockFolderService.Object); // Act var result = await controller.Detail(id); var okResult = Assert.IsType <OkObjectResult>(result); var model = Assert.IsType <FolderBaseDto>(okResult.Value); // Assert Assert.Equal((await GetTestFolders()).FirstOrDefault(f => f.Id == id).Title, model.Title); }
//Tìm file trên Folder bằng từ khóa private void txtSearchFile_TextChanged(object sender, EventArgs e) { ClassFolder folder = new ClassFolder(); folder = FolderController.getFolder(txtNameFolder.Text); List <ClassFile> files = folder.listfile.ToList <ClassFile>().Where(x => x.namefile.Contains(txtSearchFile.Text)).ToList(); lstFileName.Items.Clear(); foreach (ClassFile file in files) { ListViewItem item = new ListViewItem(file.namefile); item.SubItems.Add(file.path); item.SubItems.Add(file.size); item.SubItems.Add(file.ID.ToString()); lstFileName.Items.Add(item); } }