示例#1
0
        /// <summary>
        /// Returns a sorted list of all existing application jobs.
        /// </summary>
        public static ApplicationJob[] GetJobs()
        {
            Dictionary <Guid, List <UrlVariable> > allVariables = new Dictionary <Guid, List <UrlVariable> >();

            using (IDbCommand command = Connection.CreateCommand())
            {
                command.CommandText = "SELECT * FROM variables";

                using (IDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        UrlVariable variable = new UrlVariable();
                        variable.Hydrate(reader);

                        Guid jobGuid = new Guid(reader["JobGuid"] as string);

                        if (!allVariables.ContainsKey(jobGuid))
                        {
                            allVariables[jobGuid] = new List <UrlVariable>();
                        }

                        allVariables[jobGuid].Add(variable);
                    }
                }
            }

            using (IDbCommand command = Connection.CreateCommand())
            {
                command.CommandText = "SELECT * FROM jobs ORDER BY ApplicationName";

                List <ApplicationJob> result = new List <ApplicationJob>();

                using (IDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        ApplicationJob job = new ApplicationJob();
                        job.Hydrate(reader);

                        if (allVariables.ContainsKey(job.Guid))
                        {
                            foreach (UrlVariable var in allVariables[job.Guid])
                            {
                                job.Variables[var.Name] = var;
                            }
                        }

                        result.Add(job);
                    }
                }

                return(result.ToArray());
            }
        }
示例#2
0
        /// <summary>
        /// Returns an application from the database which has the specified GUID.
        /// </summary>
        public static ApplicationJob GetJob(Guid appGuid)
        {
            ApplicationJob job = null;

            using (IDbCommand command = Connection.CreateCommand())
            {
                command.CommandText = "SELECT * FROM jobs WHERE JobGuid = @JobGuid";
                command.Parameters.Add(new SQLiteParameter("@JobGuid", FormatGuid(appGuid)));

                using (IDataReader reader = command.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        job = new ApplicationJob();
                        job.Hydrate(reader);
                    }
                }
            }

            if (job != null)
            {
                using (IDbCommand command = Connection.CreateCommand())
                {
                    command.CommandText = @"SELECT * FROM variables WHERE JobGuid = @JobGuid";
                    command.Parameters.Add(new SQLiteParameter("@JobGuid", FormatGuid(appGuid)));
                    using (IDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            UrlVariable variable = new UrlVariable(job.Variables);
                            variable.Hydrate(reader);
                            job.Variables.Add(variable.Name, variable);
                        }
                    }
                }
            }

            return(job);
        }
示例#3
0
        /// <summary>
        /// Returns an application from the database which has the specified GUID.
        /// </summary>
        public static ApplicationJob GetJob(Guid appGuid)
        {
            ApplicationJob job = null;

            using (IDbCommand command = Connection.CreateCommand())
            {
                command.CommandText = "SELECT * FROM jobs WHERE JobGuid = @JobGuid";
                command.Parameters.Add(new SQLiteParameter("@JobGuid", FormatGuid(appGuid)));

                using (IDataReader reader = command.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        job = new ApplicationJob();
                        job.Hydrate(reader);
                    }
                }
            }

            if (job != null)
            {
                using (IDbCommand command = Connection.CreateCommand())
                {
                    command.CommandText = @"SELECT * FROM variables WHERE JobGuid = @JobGuid";
                    command.Parameters.Add(new SQLiteParameter("@JobGuid", DbManager.FormatGuid(appGuid)));
                    using (IDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            UrlVariable variable = new UrlVariable(job.Variables);
                            variable.Hydrate(reader);
                            job.Variables.Add(variable.Name, variable);
                        }
                    }
                }
            }

            return job;
        }
示例#4
0
        /// <summary>
        /// Returns a sorted list of all existing application jobs.
        /// </summary>
        public static ApplicationJob[] GetJobs()
        {
            Dictionary<Guid, List<UrlVariable>> allVariables = new Dictionary<Guid, List<UrlVariable>>();
            using (IDbCommand command = Connection.CreateCommand())
            {
                command.CommandText = "SELECT * FROM variables";

                using (IDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        UrlVariable variable = new UrlVariable();
                        variable.Hydrate(reader);

                        Guid jobGuid = new Guid(reader["JobGuid"] as string);

                        if (!allVariables.ContainsKey(jobGuid))
                        {
                            allVariables[jobGuid] = new List<UrlVariable>();
                        }

                        allVariables[jobGuid].Add(variable);
                    }
                }
            }

            using (IDbCommand command = Connection.CreateCommand())
            {
                command.CommandText = "SELECT * FROM jobs ORDER BY ApplicationName";

                List<ApplicationJob> result = new List<ApplicationJob>();

                using (IDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        ApplicationJob job = new ApplicationJob();
                        job.Hydrate(reader);

                        if (allVariables.ContainsKey(job.Guid))
                        {
                            foreach (UrlVariable var in allVariables[job.Guid])
                            {
                                job.Variables[var.Name] = var;
                            }
                        }

                        result.Add(job);
                    }
                }

                return result.ToArray();
            }
        }