Example #1
0
        public object Get(AssembliesRequest r)
        {
            TaskUniversum.ISourceManager sourceManager = QueueService.ModProducer.broker.GetSourceManager();
            string _na = "not available";

            if (r.Statuses)
            {
                lock (_lock)
                {
                    List <AssemblyStatus> resp = new List <AssemblyStatus>();
                    foreach (var asm in QueueService.ModProducer.broker.GetSourceStatuses())
                    {
                        List <TaskUniversum.SourceControllerJobs> scj = sourceManager.GetAllowedCommands(asm.Key);
                        TaskUniversum.IRevision rev     = asm.Value.PackageRev;
                        AssemblyStatus          expStat = new AssemblyStatus
                        {
                            Name        = asm.Key,
                            state       = asm.Value.State,
                            revisionTag = rev.Revision,

                            loaded         = asm.Value.Loaded,
                            packaged       = asm.Value.packagedDate,
                            loadedRevision = asm.Value.LoadedRevision,
                            loadedRemarks  = asm.Value.LoadedRemarks,

                            revCommitComment = rev.CommitMessage,
                            revCommiter      = rev.Commiter,
                            revCommitTime    = rev.CommitTime,

                            revisionSourceTag = _na,
                            revSCommitComment = _na,
                            revSCommiter      = _na,
                            revSCommitTime    = DateTime.MinValue,

                            allowedBuild  = scj.Contains(TaskUniversum.SourceControllerJobs.buildBS),
                            allowedFetch  = scj.Contains(TaskUniversum.SourceControllerJobs.fetchBS),
                            allowedUpdate = scj.Contains(TaskUniversum.SourceControllerJobs.updatePackageFromBuild)
                        };
                        if (asm.Value.BuildServerRev != null)
                        {
                            TaskUniversum.IRevision bsrev = asm.Value.BuildServerRev;
                            expStat.revisionSourceTag = bsrev.Revision;
                            expStat.revSCommitComment = bsrev.CommitMessage;
                            expStat.revSCommiter      = bsrev.Commiter;
                            expStat.revSCommitTime    = bsrev.CommitTime;
                        }
                        resp.Add(expStat);
                    }
                    return(resp);
                }
            }
            else if (r.Build)
            {
                QueueService.ModProducer.broker.
                //sourceManager.
                DoPackageCommand(r.Name,
                                 TaskUniversum.SourceControllerJobs.buildBS);
            }
            else if (r.Fetch)
            {
                QueueService.ModProducer.broker.
                //sourceManager.
                DoPackageCommand(r.Name,
                                 TaskUniversum.SourceControllerJobs.fetchBS);
            }
            else if (r.Package)
            {
                QueueService.ModProducer.broker.
                //sourceManager.
                DoPackageCommand(r.Name,
                                 TaskUniversum.SourceControllerJobs.updatePackageFromBuild);
            }
            else if (r.CheckBS)
            {
                Dictionary <string, object> bsParameters = JsonConvert.DeserializeObject <Dictionary <string, object> >(r.BSParameters);
                string explain = null;
                bool   result  = sourceManager.CheckBuildServerParameters(r.BSName, bsParameters, out explain);
                return(new
                {
                    CheckResult = result,
                    Remark = explain
                });
            }
            return(new ServiceStack.HttpResult()
            {
                StatusCode = HttpStatusCode.OK
            });
        }
Example #2
0
        public object Get(AssembliesRequest r)
        {
            TaskUniversum.ISourceManager sourceManager = QueueService.ModProducer.broker.GetSourceManager();
            string _na = "not available";
            if (r.Statuses)
            {
                lock (_lock)
                {
                    List<AssemblyStatus> resp = new List<AssemblyStatus>();
                    foreach (var asm in QueueService.ModProducer.broker.GetSourceStatuses())
                    {
                        List<TaskUniversum.SourceControllerJobs> scj = sourceManager.GetAllowedCommands(asm.Key);
                        TaskUniversum.IRevision rev = asm.Value.PackageRev;
                        AssemblyStatus expStat = new AssemblyStatus
                        {
                            Name = asm.Key,
                            state = asm.Value.State,
                            revisionTag = rev.Revision,

                            loaded = asm.Value.Loaded,
                            packaged = asm.Value.packagedDate,
                            loadedRevision = asm.Value.LoadedRevision,
                            loadedRemarks = asm.Value.LoadedRemarks,

                            revCommitComment = rev.CommitMessage,
                            revCommiter = rev.Commiter,
                            revCommitTime = rev.CommitTime,

                            revisionSourceTag = _na,
                            revSCommitComment = _na,
                            revSCommiter = _na,
                            revSCommitTime = DateTime.MinValue,

                            allowedBuild = scj.Contains(TaskUniversum.SourceControllerJobs.buildBS),
                            allowedFetch = scj.Contains(TaskUniversum.SourceControllerJobs.fetchBS),
                            allowedUpdate = scj.Contains(TaskUniversum.SourceControllerJobs.updatePackageFromBuild)
                        };
                        if (asm.Value.BuildServerRev != null)
                        {
                            TaskUniversum.IRevision bsrev = asm.Value.BuildServerRev;
                            expStat.revisionSourceTag = bsrev.Revision;
                            expStat.revSCommitComment = bsrev.CommitMessage;
                            expStat.revSCommiter = bsrev.Commiter;
                            expStat.revSCommitTime = bsrev.CommitTime;
                        }
                        resp.Add(expStat);
                    }
                    return resp;
                }
            }
            else if (r.Build)
            {
                QueueService.ModProducer.broker.
                    //sourceManager.
                DoPackageCommand(r.Name,
                    TaskUniversum.SourceControllerJobs.buildBS);
            }
            else if (r.Fetch)
            {
                QueueService.ModProducer.broker.
                    //sourceManager.
                DoPackageCommand(r.Name,
                    TaskUniversum.SourceControllerJobs.fetchBS);
            }
            else if (r.Package)
            {
                QueueService.ModProducer.broker.
                    //sourceManager.
                DoPackageCommand(r.Name,
                    TaskUniversum.SourceControllerJobs.updatePackageFromBuild);
            }
            else if (r.CheckBS)
            {
                Dictionary<string, object> bsParameters = JsonConvert.DeserializeObject<Dictionary<string, object>>(r.BSParameters);
                string explain = null;
                bool result = sourceManager.CheckBuildServerParameters(r.BSName, bsParameters, out explain);
                return new
                {
                    CheckResult = result,
                    Remark = explain
                };
            }
            return new ServiceStack.HttpResult()
            {
                StatusCode = HttpStatusCode.OK
            };
        }