Example #1
0
        public FolderDetail GetFolderDetail(string path)
        {
            FolderDetail ret = new FolderDetail();

            ret.Path = path;

            string command = "ls -al " + path;
            var    result  = conn.ExecuteSimple(command, 5000, true);

            string[] allLogs = result.Split(new string[] { "\n" }, StringSplitOptions.None);


            for (int x = 1; x < allLogs.Length; x++)
            {
                string s        = allLogs[x];
                string filename = s.Substring(57);
                if (filename != "." && filename != "..")
                {
                    if (s[0] == 'd')
                    {
                        ret.Folders.Add(filename);
                    }
                    else
                    {
                        ret.Files.Add(filename);
                    }
                }
            }

            return(ret);
        }
Example #2
0
        public void Execute()
        {
            do
            {
                Console.WriteLine("\nDo you want to have the detail of a folder (Y/N)?");
                var answer = Console.ReadLine();

                if (answer.ToUpper() == "Y")
                {
                    try
                    {
                        Console.WriteLine("\nWhat is the folder you would like to inspect ?");
                        var path = Console.ReadLine();

                        FolderDetail detail = reader.GetFolderDetail(path);
                        Console.WriteLine(detail.ToString());
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Une erreur est survenue: {0}", ex.Message);
                    }
                }
                else if (answer.ToUpper() == "N")
                {
                    break;
                }
            } while (true);
        }
Example #3
0
        public FolderDetail GetFolderById(int id)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Folders
                    .Single(e => e.FolderID == id);

                List <ImageListItem> imageListItems = new List <ImageListItem>();
                foreach (var image in entity.ImagesInFolder)
                {
                    var meme = new ImageListItem()
                    {
                        ImageID    = image.ImageID,
                        Title      = image.Image.Title,
                        ImagePath  = image.Image.ImagePath,
                        ImageFile  = image.Image.ImageFile,
                        TopText    = image.Image.TopText,
                        BottomText = image.Image.BottomText
                    };
                    imageListItems.Add(meme);
                }

                var image1 = new FolderDetail
                {
                    FolderID       = entity.FolderID,
                    Name           = entity.Name,
                    ImagesInFolder = imageListItems,
                };
                return(image1);
            }
        }
        public void FolderDetail_Should_Contain_The_Number_OF_Files()
        {
            string pathFolderTest = Path.Combine(Assembly.GetEntryAssembly().Location, @"..\..\..\..\..\FolderForTest");
            string pathTest       = Path.GetFullPath(pathFolderTest);

            FolderDetailReader reader = new FolderDetailReader();

            FolderDetail result = reader.GetFolderDetail(pathTest);

            Assert.AreEqual(result.Files.Count, result.NbFiles);
        }
Example #5
0
        public FolderDetailModel GetFullFolderInfo(int folderId)
        {
            var folderDetailModel = new FolderDetailModel();

            try
            {
                string repoDomain = ConfigurationManager.AppSettings["ImageRepository"];
                using (var db = new OggleBoobleMySqlContext())
                {
                    var    dbFolder     = db.CategoryFolders.Where(f => f.Id == folderId).First();
                    string fullPathName = "";
                    if (dbFolder.FolderImage != null)
                    {
                        var dbImageFile = db.ImageFiles.Where(i => i.Id == dbFolder.FolderImage).FirstOrDefault();
                        if (dbImageFile != null)
                        {
                            var imgFolderPath = db.CategoryFolders.Where(f => f.Id == dbImageFile.FolderId).First().FolderPath;
                            //string fileName = dbImageFile.FileName;
                            bool nw = (imgFolderPath == dbFolder.FolderPath);
                            fullPathName = repoDomain + "/" + imgFolderPath + "/" + dbImageFile.FileName;
                        }
                    }

                    folderDetailModel.FolderId      = folderId;
                    folderDetailModel.FolderType    = dbFolder.FolderType;
                    folderDetailModel.FolderName    = dbFolder.FolderName;
                    folderDetailModel.RootFolder    = dbFolder.RootFolder;
                    folderDetailModel.FolderImage   = fullPathName;
                    folderDetailModel.InternalLinks = (from l in db.CategoryImageLinks
                                                       join f in db.CategoryFolders on l.ImageCategoryId equals f.Id
                                                       where l.ImageCategoryId == folderId && l.ImageCategoryId != folderId
                                                       select new { folderId = f.Id, folderName = f.FolderName })
                                                      .ToDictionary(i => i.folderId, i => i.folderName);
                    FolderDetail FolderDetails = db.FolderDetails.Where(d => d.FolderId == folderId).FirstOrDefault();
                    if (FolderDetails != null)
                    {
                        folderDetailModel.HomeCountry    = FolderDetails.HomeCountry;
                        folderDetailModel.HomeTown       = FolderDetails.HomeTown;
                        folderDetailModel.FolderComments = FolderDetails.FolderComments;
                        folderDetailModel.Birthday       = FolderDetails.Birthday;
                        folderDetailModel.Measurements   = FolderDetails.Measurements;
                        folderDetailModel.FakeBoobs      = FolderDetails.FakeBoobs;
                    }
                    folderDetailModel.Success = "ok";
                }
            }
            catch (Exception ex)
            {
                folderDetailModel.Success = Helpers.ErrorDetails(ex);
            }
            return(folderDetailModel);
        }
        public void FolderDetail_Should_Contain_The_Total_Size()
        {
            string pathFolderTest = Path.Combine(Assembly.GetEntryAssembly().Location, @"..\..\..\..\..\FolderForTest");
            string pathTest       = Path.GetFullPath(pathFolderTest);

            FolderDetailReader reader = new FolderDetailReader();

            FolderDetail result = reader.GetFolderDetail(pathTest);

            long totalSize = result.Folders.Sum(folder => folder.Size);

            Assert.AreEqual(totalSize, result.TotalSize);
        }
        public void Files_Should_OrderBy_Size()
        {
            string pathFolderTest = Path.Combine(Assembly.GetEntryAssembly().Location, @"..\..\..\..\..\FolderForTest");
            string pathTest       = Path.GetFullPath(pathFolderTest);

            FolderDetailReader reader = new FolderDetailReader();

            FolderDetail result = reader.GetFolderDetail(pathTest);

            Assert.IsTrue((result.Files[0].Size > result.Files[1].Size), "The first is bigger than the second");
            Assert.IsTrue((result.Files[1].Size > result.Files[2].Size), "The second is bigger than the third");
            Assert.IsTrue((result.Files[2].Size > result.Files[3].Size), "The third is bigger than the fourth");
        }
        public async Task CreateFolderDetail(CreateFolderDetailDto input)
        {
            var header = _operationPoolRepository.Get(input.OperationPoolId);

            var @folderDetail = input.MapTo <FolderDetail>();

            @folderDetail.TenantId = AbpSession.GetTenantId();

            @folderDetail = FolderDetail.Create(input.FolderType, input.Remark);

            header.FolderDetails.Add(@folderDetail);

            await CurrentUnitOfWork.SaveChangesAsync();
        }
Example #9
0
        private int PrintFolders(string folderPath)
        {
            var dirInfo = new DirectoryInfo(folderPath);

            var folderCount = 0;

            foreach (var directoryInfo in dirInfo.GetDirectories())
            {
                var folderDetail = new FolderDetail(directoryInfo, folderDelimiterToolStripMenuItem.Checked);

                outputTextBox.PrintLine(folderDetail.ToString());
                folderCount++;
            }

            return(folderCount);
        }
Example #10
0
        public GameFolder GetGameFolder(string physicalPath, bool folderOnly = false)
        {
            GameFolder   ret = new GameFolder();
            FolderDetail fd  = GetFolderDetail(physicalPath);

            for (int x = 0; x < fd.Folders.Count(); x++)
            {
                string s = fd.Folders[x];
                if (s.ToLower().StartsWith("clv"))
                {
                    EntryInfo ei = new EntryInfo();
                    ei.DesktopFilePath = physicalPath + s + "/" + s + ".desktop";
                    if (!folderOnly || s.Contains("-S-"))
                    {
                        string desktopFile = GetFileAsString(physicalPath + s + "/" + s + ".desktop");
                        ei.DesktopFileContent = desktopFile;
                        string[] splitted = desktopFile.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);

                        foreach (string ss in splitted)
                        {
                            if (ss.StartsWith("Name="))
                            {
                                ei.FullName = ss.Substring(5);
                            }
                            if (ss.StartsWith("Exec="))
                            {
                                ei.Exec = ss.Substring(5);
                            }
                            if (ss.StartsWith("Icon="))
                            {
                                ei.Icon = ss.Substring(5);
                            }
                        }
                        if (ei.Exec.StartsWith("/bin/chmenu"))
                        {
                            ret.subFolders.Add(ei);
                        }
                        else
                        {
                            ret.games.Add(ei);
                        }
                    }
                }
            }

            return(ret);
        }
        public FolderDetail GetFolderDetail(string path)
        {
            if (!Directory.Exists(path))
            {
                throw new ArgumentException("Target directory doesn't exist");
            }
            FolderPath = path;

            FolderDetail detail = new FolderDetail(FolderPath);

            string[] files = Directory.GetFiles(FolderPath, "*", SearchOption.AllDirectories);
            detail.Files = InitFilesDetail(files);

            DirectoryInfo[] folders = new DirectoryInfo(FolderPath).GetDirectories("*", SearchOption.AllDirectories);
            detail.Folders = InitFoldersDetail(folders);

            return(detail);
        }
Example #12
0
        public string AddUpdate(FolderDetailModel model)
        {
            string success = "";

            try
            {
                using (var db = new OggleBoobleMySqlContext())
                {
                    CategoryFolder categoryFolder = db.CategoryFolders.Where(f => f.Id == model.FolderId).First();
                    if (categoryFolder.FolderName != model.FolderName)
                    {
                        categoryFolder.FolderName = model.FolderName;
                    }

                    FolderDetail dbFolderDetail = db.FolderDetails.Where(d => d.FolderId == model.FolderId).FirstOrDefault();
                    if (dbFolderDetail == null)
                    {
                        dbFolderDetail = new FolderDetail {
                            FolderId = model.FolderId
                        };
                        db.FolderDetails.Add(dbFolderDetail);
                        db.SaveChanges();
                        dbFolderDetail = db.FolderDetails.Where(d => d.FolderId == model.FolderId).First();
                    }
                    dbFolderDetail.Birthday       = model.Birthday;
                    dbFolderDetail.FakeBoobs      = model.FakeBoobs;
                    dbFolderDetail.HomeCountry    = model.HomeCountry;
                    dbFolderDetail.HomeTown       = model.HomeTown;
                    dbFolderDetail.FolderComments = model.FolderComments;
                    dbFolderDetail.Measurements   = model.Measurements;
                    //dbFolderDetail.LinkStatus = model.LinkStatus;
                    db.SaveChanges();
                    success = "ok";
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
        //
        //====================================================================================================
        /// <summary>
        /// Return the collectionList file stored in the root of the addon folder.
        /// </summary>
        /// <returns></returns>
        public static string getCollectionFolderConfigXml(CoreController core)
        {
            string returnXml = "";

            try {
                string LastChangeDate             = "";
                string FolderName                 = null;
                string collectionFilePathFilename = null;
                string CollectionGuid             = null;
                string Collectionname             = null;
                //
                collectionFilePathFilename = AddonController.getPrivateFilesAddonPath() + "Collections.xml";
                returnXml = core.privateFiles.readFileText(collectionFilePathFilename);
                if (string.IsNullOrWhiteSpace(returnXml))
                {
                    //
                    LogController.logInfo(core, "Collection Folder XML is blank, rebuild start");
                    //
                    List <FolderDetail> FolderList = core.privateFiles.getFolderList(AddonController.getPrivateFilesAddonPath());
                    //
                    LogController.logInfo(core, "Collection Folder XML rebuild, FolderList.count [" + FolderList.Count + "]");
                    //
                    if (FolderList.Count > 0)
                    {
                        var collectionsFound = new List <string>();
                        foreach (FolderDetail folder in FolderList)
                        {
                            FolderName = folder.Name;
                            if (FolderName.Length > 34)
                            {
                                if (GenericController.toLCase(FolderName.left(4)) != "temp")
                                {
                                    CollectionGuid = FolderName.Substring(FolderName.Length - 32);
                                    Collectionname = FolderName.left(FolderName.Length - CollectionGuid.Length - 1);
                                    CollectionGuid = CollectionGuid.left(8) + "-" + CollectionGuid.Substring(8, 4) + "-" + CollectionGuid.Substring(12, 4) + "-" + CollectionGuid.Substring(16, 4) + "-" + CollectionGuid.Substring(20);
                                    CollectionGuid = "{" + CollectionGuid + "}";
                                    if (collectionsFound.Contains(CollectionGuid))
                                    {
                                        //
                                        // -- folder with duplicate Guid not allowed. throw;ception and block the folder
                                        LogController.logError(core, new GenericException("Add-on Collection Folder contains a mulitple collection folders with the same guid, [" + CollectionGuid + "], duplicate folder ignored [" + folder.Name + "]. Remove or Combine the mulitple instances. Then delete the collections.xml file and it will regenerate without the duplicate."));
                                    }
                                    else
                                    {
                                        collectionsFound.Add(CollectionGuid);
                                        List <FolderDetail> SubFolderList = core.privateFiles.getFolderList(AddonController.getPrivateFilesAddonPath() + FolderName + "\\");
                                        if (SubFolderList.Count > 0)
                                        {
                                            FolderDetail lastSubFolder = SubFolderList.Last <FolderDetail>();
                                            FolderName     = FolderName + "\\" + lastSubFolder.Name;
                                            LastChangeDate = lastSubFolder.Name.Substring(4, 2) + "/" + lastSubFolder.Name.Substring(6, 2) + "/" + lastSubFolder.Name.left(4);
                                            if (!GenericController.isDate(LastChangeDate))
                                            {
                                                LastChangeDate = "";
                                            }
                                        }
                                        returnXml += Environment.NewLine + "\t<Collection>";
                                        returnXml += Environment.NewLine + "\t\t<name>" + Collectionname + "</name>";
                                        returnXml += Environment.NewLine + "\t\t<guid>" + CollectionGuid + "</guid>";
                                        returnXml += Environment.NewLine + "\t\t<lastchangedate>" + LastChangeDate + "</lastchangedate>";
                                        returnXml += Environment.NewLine + "\t\t<path>" + FolderName + "</path>";
                                        returnXml += Environment.NewLine + "\t</Collection>";
                                    }
                                }
                            }
                        }
                    }
                    returnXml = "<CollectionList>" + returnXml + Environment.NewLine + "</CollectionList>";
                    core.privateFiles.saveFile(collectionFilePathFilename, returnXml);
                    //
                    LogController.logInfo(core, "Collection Folder XML is blank, rebuild finished and saved");
                    //
                }
            } catch (Exception ex) {
                LogController.logError(core, ex);
                throw;
            }
            return(returnXml);
        }