Ejemplo n.º 1
0
        public static SCORunbook[] GetAllRunningRunbooks()
        {
            OrchestratorContext context = GetOrchestratorContext();

            Dictionary <Guid, SCORunbook> runbookDict = new Dictionary <Guid, SCORunbook>();
            var jobs = (from jb in context.Jobs
                        where jb.Status == "Running" || jb.Status == "Pending"
                        select jb);

            foreach (Job j in jobs)
            {
                var runbook = (from rb in context.Runbooks
                               where rb.Id == j.RunbookId
                               select rb).FirstOrDefault();

                if (!runbookDict.ContainsKey(runbook.Id))
                {
                    runbookDict.Add(runbook.Id, new SCORunbook(runbook));
                }
            }

            SCORunbook[] allRunbooks = new SCORunbook[runbookDict.Count];
            runbookDict.Values.CopyTo(allRunbooks, 0);
            return(allRunbooks);
        }
Ejemplo n.º 2
0
        public static SCORunbook[] GetAllRunbooksInFolder(String FolderPath)
        {
            OrchestratorContext context = GetOrchestratorContext();

            var folder = (from fol in context.Folders
                          where fol.Path == FolderPath
                          select fol).FirstOrDefault();

            if (folder == null)
            {
                var msg = string.Format(CultureInfo.InvariantCulture, "Runbooks Not Found in Folder:  ", FolderPath);
                throw new Exception(msg);
            }

            Guid folderId = folder.Id;

            var runbooks = (from rb in context.Runbooks
                            where rb.FolderId == folderId
                            select rb);

            if (runbooks == null)
            {
                var msg = string.Format(CultureInfo.InvariantCulture, "Runbooks Not Found in Folder:  ", FolderPath);
                throw new Exception(msg);
            }
            SCORunbook[] runbookArray = new SCORunbook[runbooks.Count()];
            int          i            = 0;

            foreach (Runbook r in runbooks)
            {
                runbookArray[i] = new SCORunbook(r);
                i++;
            }

            return(runbookArray);
        }
Ejemplo n.º 3
0
        public static SCORunbook[] GetAllRunbooks()
        {
            OrchestratorContext context = GetOrchestratorContext();

            var runbooks = from runbook in context.Runbooks
                           select runbook;

            //foreach (var item in runbooks)
            //{
            //    int index = Array.IndexOf(runbooks.ToArray(), item);
            //}

            List <SCORunbook> rbList = new List <SCORunbook>();

            foreach (Runbook rb in runbooks)
            {
                SCORunbook item = new SCORunbook();
                item.Name = rb.Name;
                item.Id   = rb.Id;
                rbList.Add(item);
            }

            return(rbList.ToArray());
        }