Example #1
0
        public ICollection <string> Search(int enviromentId, int applicationId)
        {
            var repos = db.DeploTasks
                        .Where(x => x.EnviromentId == enviromentId && x.ApplicationId == applicationId)
                        .Select(x => x.Repository)
                        .Union(db.TemplatedTasks.Where(x => x.EnviromentId == enviromentId && x.ApplicationId == applicationId && x.Repository != null)
                               .Select(x => x.Repository))
                        .ToList();

            var package = db.DeploTasks
                          .Where(x => x.EnviromentId == enviromentId && x.ApplicationId == applicationId)
                          .Select(x => x.PackageName)
                          .Union(db.TemplatedTasks.Where(x => x.EnviromentId == enviromentId && x.ApplicationId == applicationId && x.PackageName != null)
                                 .Select(x => x.PackageName))
                          .First();

            return(PackageSearcher.Search(repos, package));
        }
Example #2
0
        /// <summary>
        ///     Clean a specific package removing all nmon necessary versions
        /// </summary>
        /// <param name="package">Package to remove</param>
        /// <param name="gallery">gallery to remove the package from</param>
        public static void CleanPackage(string package, string gallery)
        {
            using (var dc = new ReadContext())
            {
                var allVersion = PackageSearcher.Search(new List <string> {
                    gallery
                }, package).ToList().Select(x => x.Trim()).ToList();
                var currentlyInstalledVersions = dc.DeploTasks.Where(x => x.PackageName == package && x.CurrentlyDeployedVersion != null).ToList().Select(x => x.CurrentlyDeployedVersion.Trim()).ToList();

                var toDelete = allVersion.Where(x => !currentlyInstalledVersions.Contains(x)).ToList();
                toDelete.RemoveRange(0, 10);

                foreach (var pack in toDelete)
                {
                    RemovePackage(package, pack, gallery);
                }
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            var loc = new ServiceLocator();

            loc.NuGetFeedUri = "https://www.myget.org/F/fcepacks/api/v3/index.json";
            var search     = new PackageSearcher(loc);
            var downloader = new PackageDownloader(loc);

            var nugetpreproc = new NugetPreProcessor(new NuGetProcessorSettings(), downloader, search);

            var runner = new ScriptRunner(new IScriptPreCompileHandler[] { new ScriptBootStrap(), new ExtensionMethodHandler(), nugetpreproc });


            try
            {
                var script = new StringBuilder();

                //script.AppendLine("#n nuget:?package=FlexibleConfigEngine&version=0.1.0-unstable.2&prerelease");
                script.AppendLine("#n nuget:?file=D:\\Sandpit\\testbucketofdoom\\semver\\2.0.4\\semver.2.0.4.nupkg");
                script.AppendLine("using Semver;");
                script.AppendLine("Echo(Sum(1, 2).ToString());");
                script.AppendLine("var v = SemVersion.Parse(\"1.1.0-rc.1+nightly.2345\");");
                script.AppendLine("Echo(v.ToString());");
                script.AppendLine("Echo(\"Hey {0} {1}\", \"1\", 2);");

                //var builder = new ScriptBuilder();
                //builder.AppendScriptFile("test.csx");
                //runner.ExecuteString(builder.ToString()).Wait();
                runner.ExecuteString(script.ToString()).Wait();

                Console.WriteLine(runner.Script);

                //foreach(var asm in AppDomain.CurrentDomain.GetAssemblies())
                //    Console.WriteLine($"{asm.CodeBase} - {asm.FullName}");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.ToString());
                Console.WriteLine(runner.Script);
            }

            Console.Read();
        }
Example #4
0
        public void WebHookLatest(int enviromentId, int applicationId, string secret)
        {
            var app = db.Applications.SingleOrDefault(x => x.Id == applicationId);

            if (app == null || app.Secret != Guid.Parse(secret))
            {
                throw new UnauthorizedAccessException("Application secret invalid");
            }

            var repos = db.DeploTasks
                        .Where(x => x.EnviromentId == enviromentId && x.ApplicationId == applicationId)
                        .Select(x => x.Repository)
                        .ToList();

            var package = db.DeploTasks
                          .Where(x => x.EnviromentId == enviromentId && x.ApplicationId == applicationId)
                          .Select(x => x.PackageName)
                          .First();

            var version = PackageSearcher.Search(repos, package).First();

            using (var session = WebApiApplication.Store.OpenSession())
            {
                var deploy = new Deployment()
                {
                    EnviromentId  = enviromentId,
                    ApplicationId = applicationId,
                    Status        = Status.Queud,
                    Version       = version,
                    UserId        = new Guid().ToString()
                };

                session.Save(deploy);
                session.Flush();

                BackgroundJob.Enqueue(() => DeployJob.Execute(deploy.Id));
            };
        }