コード例 #1
0
 public Publisher(PublisherInfo pinfo) : this()
 {
     if (pinfo != null)
     {
         Publications.Add(pinfo);
     }
 }
コード例 #2
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
                    });
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Generates all actions where the source type is directory
        /// </summary>
        /// <param name="pinfo">PublisherInfo representing the source</param>
        public void GenerateActionsForDirectories(PublisherInfo pinfo)
        {
            if (pinfo.Destinations != null)
            {
                foreach (PublisherDestination dest in pinfo.Destinations)
                {
                    if (dest.TargetType.Equals(PublisherTypes.PublisherTargetType.Directory))
                    {
                        if (dest.Modes.Contains(PublisherTypes.PublisherMode.Archive) || pinfo.Modes.Contains(PublisherTypes.PublisherMode.Archive))
                        {
                            Actions.Add(new PublisherAction
                            {
                                Type       = PublisherTypes.ActionType.ArchiveDirectory,
                                SourcePath = dest.TargetPath,
                                TargetPath = null
                            });
                        }

                        if (dest.Modes.Contains(PublisherTypes.PublisherMode.SubOnly) || pinfo.Modes.Contains(PublisherTypes.PublisherMode.SubOnly))
                        {
                            GenerateActionsForDirectorySubOnly(pinfo, dest);
                        }
                        else
                        {
                            GenerateActionsForDirectoryFull(pinfo, dest);
                        }
                    }
                    else if (dest.TargetType.Equals(PublisherTypes.PublisherTargetType.Archive))
                    {
                        GenerateActionsForDirectoryToArchive(pinfo, dest);
                    }
                }
            }
        }
コード例 #4
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
         });
     }
 }
コード例 #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
         });
     }
 }
コード例 #6
0
 /// <summary>
 /// Generates all actions for file sources
 /// </summary>
 /// <param name="pinfo">PublisherInfo representing the source</param>
 public void GenerateActionsForFiles(PublisherInfo pinfo)
 {
     if (pinfo.Destinations != null)
     {
         foreach (PublisherDestination dest in pinfo.Destinations)
         {
             if (dest.TargetType.Equals(PublisherTypes.PublisherTargetType.File))
             {
                 GenerateActionsForFilesToFile(pinfo, dest);
             }
             else if (dest.TargetType.Equals(PublisherTypes.PublisherTargetType.Directory))
             {
                 GenerateActionsForFilesToDirectory(pinfo, dest);
             }
             else if (dest.TargetType.Equals(PublisherTypes.PublisherTargetType.Archive))
             {
                 GenerateActionsForFilesToArchive(pinfo, dest);
             }
         }
     }
 }