예제 #1
0
        private TaskItem BuildContent(ITaskItem folder, Document document, PathMapping folderMapping)
        {
            PathMapping documentPath = new PathMapping(folderMapping, new TaskItem().FillMetadata(document));

            string targetFile = documentPath.MappedPath;

            TaskItem content = new TaskItem(targetFile);
            folder.CopyMetadataTo(content, FolderMetadataPrefix ?? "Folder");
            content.FillMetadata(documentPath);
            content.FillMetadata(document);

            content.RequireParentDirectory(Log);

            if (content.Exists())
            {
                DateTime updated = File.GetLastWriteTime(targetFile);
                Log.LogMessage(MessageImportance.Normal, "Exists at \"{0}\"", targetFile);
                if (updated != document.Updated)
                {
                    Log.LogMessage(MessageImportance.Low, "Updated - Local: {0} Remote: {1}", updated, document.Updated);
                }
                else
                {
                    Log.LogMessage(MessageImportance.Low, "Updated - {0}", document.Updated);
                }
            }
            else
            {
                Log.LogMessage(MessageImportance.Normal, "Detected new document");
            }

            if (document.DocumentEntry != null &&
                document.DocumentEntry.Content != null &&
                document.DocumentEntry.Content.Src != null)
            {
                content.SetMetadata("ExportUri", document.DocumentEntry.Content.Src.ToString());
            }

            content.Save(Log, document.Updated);

            return content;
        }
예제 #2
0
        private TaskItem BuildFolder(Document model, PathMapping mappedPath)
        {
            string targetFile = Path.ChangeExtension(Path.Combine(TargetDirectory, mappedPath.MappedPath), mappedPath.ResourceType.ToString());

            TaskItem folder = new TaskItem(targetFile);

            if (File.Exists(targetFile))
            {
                DateTime updated = File.GetLastWriteTime(targetFile);
                Log.LogMessage(MessageImportance.Normal, "Exists at \"{0}\"", targetFile);

                if (updated != model.Updated)
                {
                    Log.LogMessage(MessageImportance.Low, "Updated - Local: {0} Remote: {1}", updated, model.Updated);
                }
                else
                {
                    Log.LogMessage(MessageImportance.Low, "Updated - {0}", model.Updated);
                }
            }
            else
            {
                Log.LogMessage("Found new folder");
            }

            folder.FillMetadata(model);
            folder.FillMetadata(mappedPath);
            folder.Save(Log, model.Updated);

            return folder;
        }