示例#1
0
文件: Program.cs 项目: jokalee/Tuto
        static void Recursive(DirectoryInfo currentDirectory, DirectoryInfo inputRoot, DirectoryInfo newModelsDirectory, string prefix)
        {
            Console.WriteLine("Processing " + currentDirectory.FullName);
            var files = currentDirectory.GetFiles();

            if (!files.Any(z => z.Name == Names.FaceFileName))
            {
                foreach (var d in currentDirectory.GetDirectories())
                {
                    Recursive(d, inputRoot, newModelsDirectory, prefix);
                }
                return;
            }
            var tutoFile = files.Where(z => z.Name == "local.tuto").FirstOrDefault();

            if (tutoFile == null)
            {
                Console.WriteLine("No tuto file is found. Press any key");
                Console.ReadKey();
                return;
            }

            var hash      = Videotheque.ComputeHash(currentDirectory, Names.FaceFileName, Names.HashFileName, true);
            var container = HeadedJsonFormat.Read <FileContainer>(tutoFile, "Tuto local file", 3);

            container.MontageModel.SetHash(hash);
            var relativePath = prefix + MyPath.RelativeTo(tutoFile.Directory.FullName, inputRoot.FullName);

            container.MontageModel.DisplayedRawLocation = relativePath;
            var fname = Path.Combine(newModelsDirectory.FullName, MyPath.CreateHierarchicalName(relativePath) + "." + Names.ModelExtension);

            HeadedJsonFormat.Write(new FileInfo(fname), container);
        }
示例#2
0
        public static CourseTreeData Load(DirectoryInfo directory)
        {
            var result = new CourseTreeData();

            result.Videos = HeadedJsonFormat.Read <List <VideoPublishSummary> >(
                new FileInfo(Path.Combine(directory.FullName, VideoListName)));
            result.Structure = HeadedJsonFormat.Read <CourseStructure>(directory);
            return(result);
        }
示例#3
0
        public static void PullFromFile <TData>(Item root, DirectoryInfo directory)
        {
            var fileName = GetFileName <TData>();
            var file     = directory.GetFiles(fileName).FirstOrDefault();

            if (file == null)
            {
                return;
            }
            var layer = HeadedJsonFormat.Read <DataLayer <TData> >(file, GetHeader <TData>(), 1);

            Pull(root, item => layer.Records.Where(z => z.Guid == item.Guid).Select(z => z.Data).FirstOrDefault());
        }
示例#4
0
文件: Program.cs 项目: jokalee/Tuto
        static void Main(string[] args)
        {
            const string Path = @"C:\Users\Yura\Desktop\TestMontage\Models";
            var          dir  = new DirectoryInfo(Path);

            foreach (var e in dir.GetFiles())
            {
                FileContainer model = null;
                try
                {
                    model = HeadedJsonFormat.Read <FileContainer>(e);
                }
                catch
                {
                    continue;
                }
                var times = StartGit(dir, e);
                model.MontageModel.Information.LastModificationTime = times.First();
                model.MontageModel.Information.CreationTime         = times.Last();
                HeadedJsonFormat.Write <FileContainer>(e, model);
            }
        }