Пример #1
0
        /// <summary>
        /// Generates all actions where the source type is directory, and the whole directory is copied
        /// </summary>
        /// <param name="pinfo">PublisherInfo representing the source</param>
        /// <param name="dest">PublisherDestination represeting the target</param>
        public void GenerateActionsForDirectoryFull(PublisherInfo pinfo, PublisherDestination dest)
        {
            if (Directory.Exists(pinfo.SourcePath) && Directory.Exists(Directory.GetParent(pinfo.SourcePath).FullName) &&
                _CurrentUserSecurity.HasAccess(new DirectoryInfo(pinfo.SourcePath), FileSystemRights.Read))
            {
                foreach (string folder in Directory.EnumerateDirectories(pinfo.SourcePath, "*",
                                                                         SearchOption.AllDirectories).Select(s => s.Replace(pinfo.SourcePath, String.Empty)))
                {
                    Actions.Add(new PublisherAction
                    {
                        Type       = PublisherTypes.ActionType.CreateDirectory,
                        TargetPath = PublisherIO.AppendDirectorySeparatorToDirectoryPath(Path.Combine(dest.TargetPath, Path.GetFileName(Path.GetDirectoryName(pinfo.SourcePath)), folder))
                    });
                }
                foreach (string file in Directory.EnumerateFiles(pinfo.SourcePath, "*", SearchOption.AllDirectories))
                {
                    string targetfile = Path.Combine(
                        dest.TargetPath,
                        Path.GetFileName(
                            Path.GetDirectoryName(pinfo.SourcePath)),
                        file.Replace(pinfo.SourcePath, String.Empty).Replace(Path.GetFileName(file), String.Empty),
                        Path.GetFileName(file));

                    Actions.Add(new PublisherAction
                    {
                        Type = (dest.Modes.Contains(PublisherTypes.PublisherMode.Overwrite) || pinfo.Modes.Contains(PublisherTypes.PublisherMode.Overwrite)) ?
                               PublisherTypes.ActionType.CopyFileToFileOverwrite : PublisherTypes.ActionType.CopyFileToFile,
                        SourcePath = file,
                        TargetPath = targetfile
                    });
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Generates all actions where the source type is file, and the target type is diretory
 /// </summary>
 /// <param name="pinfo">PublisherInfo representing the source</param>
 /// <param name="dest">PublisherDestination represeting the target</param>
 private void GenerateActionsForFilesToDirectory(PublisherInfo pinfo, PublisherDestination dest)
 {
     if (dest.Modes.Contains(PublisherTypes.PublisherMode.Archive) || pinfo.Modes.Contains(PublisherTypes.PublisherMode.Archive))
     {
         Actions.Add(new PublisherAction
         {
             Type       = PublisherTypes.ActionType.ArchiveFile,
             SourcePath = Path.Combine(dest.TargetPath, Path.GetFileName(pinfo.SourcePath)),
             TargetPath = null
         });
     }
     if (dest.Modes.Contains(PublisherTypes.PublisherMode.Overwrite) || pinfo.Modes.Contains(PublisherTypes.PublisherMode.Overwrite))
     {
         Actions.Add(new PublisherAction
         {
             Type       = PublisherTypes.ActionType.CopyFileToDirectoryOverwrite,
             SourcePath = pinfo.SourcePath,
             TargetPath = dest.TargetPath
         });
     }
     else
     {
         Actions.Add(new PublisherAction
         {
             Type       = PublisherTypes.ActionType.CopyFileToDirectory,
             SourcePath = pinfo.SourcePath,
             TargetPath = dest.TargetPath
         });
     }
 }
Пример #3
0
        public PublisherInfo(XElement element) : this()
        {
            if (element != null && element.Name.ToString().Equals("source"))
            {
                if (element.Attribute("name") != null)
                {
                    Name = element.Attribute("name").Value;
                }
                if (element.Attribute("path") != null)
                {
                    SourcePath = element.Attribute("path").Value;
                }
                if (element.Attribute("type") != null)
                {
                    switch (element.Attribute("type").Value)
                    {
                    case "file":
                        Type = PublisherTypes.PublisherSourceType.File;
                        break;

                    case "folder":
                        Type = PublisherTypes.PublisherSourceType.Directory;
                        break;
                    }
                }
                if (element.Attribute("mode") != null)
                {
                    foreach (string mode in element.Attribute("mode").Value.Split(' '))
                    {
                        switch (mode)
                        {
                        case "overwrite":
                            Modes.Add(PublisherTypes.PublisherMode.Overwrite);
                            break;

                        case "archive":
                            Modes.Add(PublisherTypes.PublisherMode.Archive);
                            break;

                        case "subonly":
                            Modes.Add(PublisherTypes.PublisherMode.SubOnly);
                            break;
                        }
                    }
                }
                if (element.Elements("destination") != null)
                {
                    foreach (XElement destelement in element.Elements("destination"))
                    {
                        PublisherDestination destination = PublisherDestination.Create(destelement);

                        if (destination != null)
                        {
                            Destinations.Add(destination);
                        }
                    }
                }
            }
        }
        public static PublisherDestination Create(XElement destelement)
        {
            if (destelement.Attribute("path") != null)
            {
                PublisherDestination destination = new PublisherDestination
                {
                    TargetPath = destelement.Attribute("path").Value
                };
                if (destelement.Attribute("mode") != null)
                {
                    foreach (string mode in destelement.Attribute("mode").Value.Split(' '))
                    {
                        switch (mode)
                        {
                        case "overwrite":
                            destination.Modes.Add(PublisherTypes.PublisherMode.Overwrite);
                            break;

                        case "archive":
                            destination.Modes.Add(PublisherTypes.PublisherMode.Archive);
                            break;

                        case "subonly":
                            destination.Modes.Add(PublisherTypes.PublisherMode.SubOnly);
                            break;
                        }
                    }
                }
                if (destelement.Attribute("type") != null)
                {
                    switch (destelement.Attribute("type").Value)
                    {
                    case "file":
                        destination.TargetType = PublisherTypes.PublisherTargetType.File;
                        break;

                    case "folder":
                        destination.TargetType = PublisherTypes.PublisherTargetType.Directory;
                        break;

                    case "archive":
                        destination.TargetType = PublisherTypes.PublisherTargetType.Archive;
                        break;
                    }
                }
                return(destination);
            }
            else
            {
                return(null);
            }
        }
Пример #5
0
 /// <summary>
 /// Generates all actions where the source type is directory, and the target type is archive
 /// </summary>
 /// <param name="pinfo">PublisherInfo representing the source</param>
 /// <param name="dest">PublisherDestination represeting the target</param>
 public void GenerateActionsForDirectoryToArchive(PublisherInfo pinfo, PublisherDestination dest)
 {
     if (dest.Modes.Contains(PublisherTypes.PublisherMode.Overwrite) || pinfo.Modes.Contains(PublisherTypes.PublisherMode.Overwrite))
     {
         Actions.Add(new PublisherAction
         {
             Type       = PublisherTypes.ActionType.ArchiveDirectoryOverwrite,
             SourcePath = pinfo.SourcePath,
             TargetPath = dest.TargetPath
         });
     }
     else
     {
         Actions.Add(new PublisherAction
         {
             Type       = PublisherTypes.ActionType.ArchiveDirectory,
             SourcePath = pinfo.SourcePath,
             TargetPath = dest.TargetPath
         });
     }
 }