示例#1
0
        public static void CloneAndCopy(IEnumerable <ExternalResource> resources)
        {
            foreach (var resource in resources)
            {
                if (!ContinueFlow(resource))
                {
                    continue;
                }

                clone(resource);

                if (resource.OnlyThisFiles.IsAny())
                {
                    foreach (var item in resource.OnlyThisFiles)
                    {
                        var pathSource      = Path.Combine(resource.ResourceLocalPathFolderExecuteCloning, resource.ResouceRepositoryName, item);
                        var fileSource      = new FileInfo(pathSource);
                        var fileDestination = Path.Combine(resource.ResourceLocalPathDestinationFolrderApplication, item);

                        var directoryBaseDestination = Path.GetDirectoryName(fileDestination);
                        if (!Directory.Exists(directoryBaseDestination))
                        {
                            Directory.CreateDirectory(directoryBaseDestination);
                        }

                        fileSource.CopyTo(fileDestination, true);
                    }
                }
                else if (resource.ReplaceLocalFilesApplication)
                {
                    HelperCmd.ExecuteCommand(string.Format("robocopy {0} {1}  /s /e /xd *\"bin\" *\"obj\" *\".git\" /xf *\".sln\" *\".md\" ", resource.ResourceLocalPathFolderCloningRepository, resource.ResourceLocalPathDestinationFolrderApplication), 10000);
                }
            }
        }
        private static void Clone(ExternalResource resource)
        {
            bool isWindows = System.Runtime.InteropServices.RuntimeInformation
                             .IsOSPlatform(OSPlatform.Windows);

            if (Directory.Exists(resource.ResourceLocalPathFolderCloningRepository))
            {
                if (isWindows)
                {
                    HelperCmd.ExecuteCommand(string.Format("RMDIR {0} /S /Q", resource.ResourceLocalPathFolderCloningRepository), 10000);
                }
                else
                {
                    string.Format("rm -rf {0} ", resource.ResourceLocalPathFolderCloningRepository).Bash();
                }
            }

            var command = string.Format("git clone {0} {1}", resource.ResourceUrlRepository, resource.ResourceLocalPathFolderCloningRepository);

            if (isWindows)
            {
                HelperCmd.ExecuteCommand(command, 10000);
            }
            else
            {
                command.Bash();
            }
        }
        public static void UpdateLocalRepository(IEnumerable <ExternalResource> resources)
        {
            foreach (var resource in resources)
            {
                if (resource.Seed)
                {
                    continue;
                }

                if (resource.OnlyFoldersContainsThisName.IsNotNullOrEmpty())
                {
                    var foldersActual = new DirectoryInfo(resource.ResourceLocalPathDestinationFolrderApplication).GetDirectories()
                                        .Where(_ => _.Name.Contains(resource.OnlyFoldersContainsThisName));

                    foreach (var folderActual in foldersActual)
                    {
                        HelperCmd.ExecuteCommand(string.Format("robocopy {0} {1} /s /e /xd *\"bin\" *\"obj\"", folderActual.FullName, string.Format("{0}\\{1}", resource.ResourceLocalPathFolderCloningRepository, folderActual.Name)), 10000);
                    }
                }
                else
                {
                    HelperCmd.ExecuteCommand(string.Format("robocopy {0} {1} /s /e", resource.ResourceLocalPathDestinationFolrderApplication, resource.ResourceLocalPathFolderCloningRepository), 10000);
                }
            }
        }
        private static void Bkp(ExternalResource resource)
        {
            bool isWindows = System.Runtime.InteropServices.RuntimeInformation
                             .IsOSPlatform(OSPlatform.Windows);

            var bkpPathFolder = string.Format("{0}\\{1}-BKP", AppDomain.CurrentDomain.BaseDirectory, resource.ResouceRepositoryName);

            if (resource.OnlyFoldersContainsThisName.IsNotNullOrEmpty())
            {
                var foldersActual = new DirectoryInfo(resource.ResourceLocalPathDestinationFolrderApplication).GetDirectories()
                                    .Where(_ => _.Name.Contains(resource.OnlyFoldersContainsThisName));

                foreach (var folderActual in foldersActual)
                {
                    if (Directory.Exists(folderActual.FullName))
                    {
                        if (isWindows)
                        {
                            HelperCmd.ExecuteCommand(string.Format("robocopy {0} {1} /s /e /xd *\"bin\" *\"obj\"", folderActual.FullName, string.Format("{0}\\{1}", bkpPathFolder, folderActual.Name)), 10000);
                        }

                        else
                        {
                            if (!Directory.Exists(Path.Combine(bkpPathFolder, folderActual.Name)))
                            {
                                Directory.CreateDirectory(Path.Combine(bkpPathFolder, folderActual.Name));
                            }
                            string.Format("rsync -arv {0}/ {1}", folderActual.FullName, Path.Combine(bkpPathFolder, folderActual.Name)).Bash();
                        }
                    }
                }
            }
            else
            {
                if (Directory.Exists(resource.ResourceLocalPathDestinationFolrderApplication))
                {
                    if (isWindows)
                    {
                        HelperCmd.ExecuteCommand(string.Format("robocopy {0} {1} /s /e", resource.ResourceLocalPathDestinationFolrderApplication, bkpPathFolder), 10000);
                    }
                    else
                    {
                        if (!Directory.Exists(bkpPathFolder))
                        {
                            Directory.CreateDirectory(bkpPathFolder);
                        }

                        string.Format("rsync -arv {0}/ {1}", resource.ResourceLocalPathDestinationFolrderApplication, bkpPathFolder).Bash();
                    }
                }
            }
        }
        public static void CloneAndCopy(IEnumerable <ExternalResource> resources)
        {
            if (resources.IsAny())
            {
                foreach (var resource in resources.Where(_ => !_.SolutionBase))
                {
                    if (!ContinueFlow(resource))
                    {
                        continue;
                    }

                    Clone(resource);

                    if (resource.OnlyThisFiles.IsAny())
                    {
                        foreach (var item in resource.OnlyThisFiles)
                        {
                            var pathSource      = Path.Combine(resource.ResourceLocalPathFolderExecuteCloning, resource.ResouceRepositoryName, item);
                            var fileSource      = new FileInfo(pathSource);
                            var fileDestination = Path.Combine(resource.ResourceLocalPathDestinationFolrderApplication, item);

                            var directoryBaseDestination = Path.GetDirectoryName(fileDestination);
                            if (!Directory.Exists(directoryBaseDestination))
                            {
                                Directory.CreateDirectory(directoryBaseDestination);
                            }

                            fileSource.CopyTo(fileDestination, true);
                        }
                    }
                    else if (resource.ReplaceLocalFilesApplication)
                    {
                        bool isWindows = System.Runtime.InteropServices.RuntimeInformation
                                         .IsOSPlatform(OSPlatform.Windows);

                        if (isWindows)
                        {
                            HelperCmd.ExecuteCommand(string.Format("robocopy {0} {1}  /s /e /xd *\"bin\" *\"obj\" *\".git\" /xf *\".sln\" *\".md\" ", resource.ResourceLocalPathFolderCloningRepository, resource.ResourceLocalPathDestinationFolrderApplication), 10000);
                        }
                        else
                        {
                            if (!Directory.Exists(resource.ResourceLocalPathDestinationFolrderApplication))
                            {
                                Directory.CreateDirectory(resource.ResourceLocalPathDestinationFolrderApplication);
                            }
                            string.Format("rsync -arv --exclude='bin' --exclude='obj' --exclude='*.git' --exclude='*.sln' --exclude='*.md' {0}/ {1}", resource.ResourceLocalPathFolderCloningRepository, resource.ResourceLocalPathDestinationFolrderApplication).Bash();
                        }
                    }
                }
            }
        }
        private static bool FlowOptionsClassic(string[] args, HelperSysObjectsBase sysObject, string flow)
        {
            var result = false;

            if (flow == ((int)Eflows.GerarCodigo).ToString())
            {
                PrinstScn.WriteLine("Gerar direto na pasta dos projetos? [S=Sim, N=Não]");
                var usePathProjects = Console.ReadLine();

                MainWithOutConfirmation(args, usePathProjects.ToLower() == "s", sysObject);

                result = true;
            }

            if (flow == ((int)Eflows.GerarCodigoEspecifico).ToString())
            {
                if (args.Count() == 3)
                {
                    MainEspecificClass(args, args.LastOrDefault().ToLower() == "s", sysObject);
                }
                else
                {
                    PrinstScn.WriteLine("Gerar direto na pasta dos projetos? [S=Sim, N=Não]");
                    var usePathProjects = Console.ReadLine();
                    MainWithConfirmation(args, usePathProjects.ToLower() == "s", sysObject);
                }

                result = true;
            }

            if (flow == ((int)Eflows.AbrirLocalDoProjeto).ToString())
            {
                HelperCmd.ExecuteCommand(string.Format("explorer {0}", "."), 10000);
                result = true;
            }



            if (flow == ((int)Eflows.Sair).ToString())
            {
                Environment.Exit(0);
                result = true;
            }

            return(result);
        }
        public static void CloneAndCopy(IEnumerable <ExternalResource> resources)
        {
            foreach (var resource in resources)
            {
                if (!resource.UpdateContinuos)
                {
                    continue;
                }

                clone(resource);

                if (resource.ReplaceLocalFilesApplication)
                {
                    HelperCmd.ExecuteCommand(string.Format("robocopy {0} {1}", resource.ResourceLocalPathFolderCloningRepository, resource.ResourceLocalPathDestinationFolrderApplication), 10000);
                }
            }
        }
示例#8
0
        public static void UpdateLocalRepository(IEnumerable <ExternalResource> resources)
        {
            foreach (var resource in resources)
            {
                if (!ContinueFlow(resource))
                {
                    continue;
                }

                if (resource.OnlyFoldersContainsThisName.IsNotNullOrEmpty())
                {
                    var foldersActual = new DirectoryInfo(resource.ResourceLocalPathDestinationFolrderApplication).GetDirectories()
                                        .Where(_ => _.Name.Contains(resource.OnlyFoldersContainsThisName));

                    foreach (var folderActual in foldersActual)
                    {
                        HelperCmd.ExecuteCommand(string.Format("robocopy {0} {1} /s /e /xd *\"bin\" *\"obj\"", folderActual.FullName, string.Format("{0}\\{1}", resource.ResourceLocalPathFolderCloningRepository, folderActual.Name)), 10000);
                    }
                }
                else if (resource.OnlyThisFiles.IsAny())
                {
                    foreach (var item in resource.OnlyThisFiles)
                    {
                        var pathSource      = Path.Combine(resource.ResourceLocalPathDestinationFolrderApplication, item);
                        var fileSource      = new FileInfo(pathSource);
                        var fileDestination = Path.Combine(resource.ResourceLocalPathFolderExecuteCloning, resource.ResouceRepositoryName, item);

                        var directoryBaseDestination = Path.GetDirectoryName(fileDestination);
                        if (!Directory.Exists(directoryBaseDestination))
                        {
                            Directory.CreateDirectory(directoryBaseDestination);
                        }

                        fileSource.CopyTo(fileDestination, true);
                    }
                }
                else
                {
                    HelperCmd.ExecuteCommand(string.Format("robocopy {0} {1} /s /e", resource.ResourceLocalPathDestinationFolrderApplication, resource.ResourceLocalPathFolderCloningRepository), 10000);
                }
            }
        }
示例#9
0
        private static bool FlowOptionsClassic(string[] args, HelperSysObjectsBase sysObject, string flow)
        {
            var result = false;

            if (flow == ((int)Eflows.GerarCodigo).ToString())
            {
                PrinstScn.WriteLine("Gerar direto na pasta dos projetos? [S=Sim, N=Não]");
                var usePathProjects = Console.ReadLine();

                MainWithOutConfirmation(args, usePathProjects.ToLower() == "s", sysObject);

                result = true;
            }

            if (flow == ((int)Eflows.GerarCodigoEspecifico).ToString())
            {
                PrinstScn.WriteLine("Gerar direto na pasta dos projetos? [S=Sim, N=Não]");
                var usePathProjects = Console.ReadLine();

                MainWithConfirmation(args, usePathProjects.ToLower() == "s", sysObject);

                result = true;
            }

            if (flow == ((int)Eflows.AbrirLocalDoProjeto).ToString())
            {
                HelperCmd.ExecuteCommand(string.Format("explorer '{0}'", AppDomain.CurrentDomain.BaseDirectory.Replace("\\Gerador.Gen\\", "").Replace("bin\\Debug\\", "").Replace("bin\\Release\\", "")), 10000);
                result = true;
            }

            if (flow == ((int)Eflows.Sair).ToString())
            {
                Environment.Exit(0);
                result = true;
            }

            return(result);
        }