Ejemplo n.º 1
0
 public void Push(DateTime mailDate, string mailTo, string mailFrom, string mailSubject, string mailBody)
 {
     Query q = new Query("insert into EmailQueue (MailDate, MailTo, MailFrom, MailSubject, MailBody) values (?MailDate, ?MailTo, ?MailFrom, ?MailSubject, ?MailBody)", "PushIntoEmailQueue", _emailConnection);
     q.Parameters.Add("?MailDate", mailDate, ParameterCollection.FieldType.DateTime);
     q.Parameters.Add("?MailTo", mailTo, ParameterCollection.FieldType.Text);
     q.Parameters.Add("?MailFrom", mailFrom, ParameterCollection.FieldType.Text);
     q.Parameters.Add("?MailSubject", mailSubject, ParameterCollection.FieldType.Text);
     q.Parameters.Add("?MailBody", mailBody, ParameterCollection.FieldType.Text);
     q.RunQueryNoResult();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the compiler queue entry that has a NextRuntime in the past that is not currently running.
        /// </summary>
        /// <returns>ICompilerQueue entity for the next eligible job to run</returns>
        public IQueueEntity GetActiveJobQueueEntryRuntimeNow()
        {
            Query q = new Query("select * from ActiveJobQueue where NextRunTime < ?CurrentDateTime_ and AgentId = '' order by NextRunTime asc limit 1", "GetCompilerQueueEntry", _compilerQueueConnection);
            q.Parameters.Add("?CurrentDateTime_", DateTime.Now, ParameterCollection.FieldType.DateTime);
            DataTable Dt = q.RunQuery();

            if (Dt.Rows.Count == 0)
            {
                return null;
            }

            return QueueEntity.Bind(Dt.Rows[0]);
        }
Ejemplo n.º 3
0
        public Entities.ISystemLoad GetSystemLoad(string nodeName)
        {
            Query q = new Query("select * from SystemLoad where NodeName = ?NodeName", "GetSystemLoad", GS.MonitorConnection);
            q.Parameters.Add("?NodeName", nodeName, ParameterCollection.FieldType.Text);
            DataTable Dt = q.RunQuery();

            if (Dt.Rows.Count == 0)
            {
                return null;
            }

            return Entities.SystemLoad.Bind(Dt.Rows[0], GS);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the compiler queue entry that has the specified job id and agent id.
        /// </summary>
        /// <param name="jobId">Id of the Job to get</param>
        /// <param name="agentId">Agent Id of the job to get</param>
        /// <returns>ICompilerQueue entity</returns>
        public IQueueEntity GetActiveJobQueueEntry(int jobId, string agentId)
        {
            Query q = new Query("select * from ActiveJobQueue where JobId = ?JobId and AgentId = ?AgentId", "GetCompilerQueueEntry", _compilerQueueConnection);
            q.Parameters.Add("?JobId", jobId, ParameterCollection.FieldType.Numeric);
            q.Parameters.Add("?AgentId", agentId, ParameterCollection.FieldType.Text);
            DataTable Dt = q.RunQuery();

            if (Dt.Rows.Count == 0)
            {
                return null;
            }

            return QueueEntity.Bind(Dt.Rows[0]);
        }
Ejemplo n.º 5
0
        public IEmailQueueEntity Pop()
        {
            Query q = new Query("select * from EmailQueue order by MailDate asc limit 1", "PopFromEmailQueue", _emailConnection);
            DataTable Dt = q.RunQuery();

            if (Dt.Rows.Count == 0)
            {
                return null;
            }

            IEmailQueueEntity queueItem = EmailQueueEntity.Bind(Dt.Rows[0]);

            DeleteItem(queueItem);

            return queueItem;
        }
Ejemplo n.º 6
0
        public void WriteToServer(IEnumerable data)
        {
            StringBuilder cmdText = new StringBuilder(_baseQueryString);

            IEnumerator ie = data.GetEnumerator();
            ie.MoveNext();

            object first = ie.Current;

            Type objectType = first.GetType();
            for (int j = 0; j < _parameters.Count; j++ )
            {
                MappedParameter mp = _parameters[j];
                mp.PropertyInfo = objectType.GetProperty(mp.PropertName);
            }

            int i = 0;
            foreach (object o in data)
            {
                string row = _valueRow;

                foreach (MappedParameter mp in _parameters)
                {
                    row = row.Replace(mp.QueryName, mp.QueryName + i.ToString());
                }

                cmdText.Append(row + ", ");
                i++;
            }

            cmdText = cmdText.Remove(cmdText.Length - 2,2);

            Query q = new Query(cmdText.ToString(), _conString);

            i = 0;
            foreach (object o in data)
            {
                foreach (MappedParameter mp in _parameters)
                {
                    q.Parameters.Add(mp.QueryName + i.ToString(), mp.PropertyInfo.GetValue(o, null), mp.Type);
                }
                i++;
            }

            q.RunQueryNoResult();
        }
Ejemplo n.º 7
0
        public int GetHtmlQueueNumEntries()
        {
            //TODO: fix connection string
            Query q = new Query("select count(*) from HtmlQueue", "GetHtmlQueueNumEntries", "server=192.168.1.225;database=GazaroAdamB;uid=root;charset=utf8;pwd=1q2w3e4r!;");
            DataTable Dt = q.RunQuery();

            if (Dt.Rows.Count == 0)
            {
                return 0;
            }

            string htmlQueueCount = Dt.Rows[0][0].ToString();
            if (string.IsNullOrEmpty(htmlQueueCount))
            {
                return 0;
            }
            return int.Parse(htmlQueueCount);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Update a compiler queue job in the database.
        /// </summary>
        /// <param name="jobId">Id of the Job to update</param>
        /// <param name="oldStatus">Current status of the job</param>
        /// <param name="newStatus">New status for the job</param>
        /// <param name="nextRunTime">Next time that this job should be run</param>
        /// <param name="newAgentId">New agent id for this job</param>
        /// <returns>Boolean indicating if a job was updated</returns>
        public bool UpdateAgentId(int jobId, string oldStatus, string newStatus, DateTime nextRunTime, string newAgentId)
        {
            Query q = new Query("update ActiveJobQueue set AgentId = ?AgentId, NextRunTime = ?NextRunTime, Status = ?NewStatus, LastStatusUpdate = ?LastStatusUpdate where JobId = ?JobId and Status = ?OldStatus", "UpdateAgentId", _compilerQueueConnection);
            q.Parameters.Add("?AgentId", newAgentId, ParameterCollection.FieldType.Text);
            q.Parameters.Add("?NextRunTime", nextRunTime, ParameterCollection.FieldType.DateTime);
            q.Parameters.Add("?NewStatus", newStatus, ParameterCollection.FieldType.Text);
            q.Parameters.Add("?OldStatus", oldStatus, ParameterCollection.FieldType.Text);
            q.Parameters.Add("?LastStatusUpdate", DateTime.Now, ParameterCollection.FieldType.DateTime);
            q.Parameters.Add("?JobId", jobId, ParameterCollection.FieldType.Numeric);
            int numRowsAffected = q.RunQueryNoResult();

            return numRowsAffected == 1;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Gets the compiler queue entry that has a NextRuntime in the past that is not currently running.
        /// </summary>
        /// <returns>ICompilerQueue entity for the next eligible job to run</returns>
        public List<IQueueEntity> GetExpiredActiveJobQueueEntries()
        {
            Query q = new Query("select * from ActiveJobQueue where LastStatusUpdate < ?CurrentDateTime_ and AgentId != '' order by NextRunTime asc limit 1", "GetCompilerQueueEntry", _compilerQueueConnection);
            q.Parameters.Add("?CurrentDateTime_", DateTime.Now.AddHours(-5), ParameterCollection.FieldType.DateTime);
            DataTable Dt = q.RunQuery();

            List<IQueueEntity> expiredQueueEntries = new List<IQueueEntity>();

            foreach (DataRow dr in Dt.Rows)
            {
                expiredQueueEntries.Add(QueueEntity.Bind(dr));
            }

            return expiredQueueEntries;
        }
Ejemplo n.º 10
0
        public Collections.ISystemLoad GetSystemLoadAliveNodes()
        {
            Query q = new Query("select SystemLoad.* from SystemLoad, Node where SystemLoad.NodeName = Node.NodeName and Node.Status = 'ALIVE'", "GetSystemLoadAliveNodes", GS.MonitorConnection);
            DataTable Dt = q.RunQuery();

            if (Dt.Rows.Count == 0)
            {
                return null;
            }

            return Entities.SystemLoad.Bind(Dt, GS);
        }
Ejemplo n.º 11
0
        public void UpdateSystemLoad(string nodeName, double load1Min, double load5Min, double load15Min, long freeMemory, int processorCount)
        {
            Query q = new Query("update SystemLoad set LastUpdated = ?LastUpdated, Load1Min = ?Load1Min, Load5Min = ?Load5Min, Load15Min = ?Load15Min, FreeMemory = ?FreeMemory, ProcessorCount = ?ProcessorCount where NodeName = ?NodeName", "UpdateSystemLoad", GS.MonitorConnection);
            q.Parameters.Add("?NodeName", nodeName, ParameterCollection.FieldType.Text);
            q.Parameters.Add("?LastUpdated", DateTime.Now, ParameterCollection.FieldType.DateTime);
            q.Parameters.Add("?Load1Min", load1Min, ParameterCollection.FieldType.Numeric);
            q.Parameters.Add("?Load5Min", load5Min, ParameterCollection.FieldType.Numeric);
            q.Parameters.Add("?Load15Min", load15Min, ParameterCollection.FieldType.Numeric);
            q.Parameters.Add("?FreeMemory", freeMemory, ParameterCollection.FieldType.Numeric);
            q.Parameters.Add("?ProcessorCount", processorCount, ParameterCollection.FieldType.Numeric);
            int numRowsAffected = q.RunQueryNoResult();

            //the row may not exist in the table causing the update to fail, try to insert instead
            if (numRowsAffected == 0)
            {
                q = new Query("insert into SystemLoad (NodeName, LastUpdated, Load1Min, Load5Min, Load15Min, FreeMemory, ProcessorCount) values (?NodeName, ?LastUpdated, ?Load1Min, ?Load5Min, ?Load15Min, ?FreeMemory, ?ProcessorCount)", "InsertSystemLoad", GS.MonitorConnection);
                q.Parameters.Add("?NodeName", nodeName, ParameterCollection.FieldType.Text);
                q.Parameters.Add("?LastUpdated", DateTime.Now, ParameterCollection.FieldType.DateTime);
                q.Parameters.Add("?Load1Min", load1Min, ParameterCollection.FieldType.Numeric);
                q.Parameters.Add("?Load5Min", load5Min, ParameterCollection.FieldType.Numeric);
                q.Parameters.Add("?Load15Min", load15Min, ParameterCollection.FieldType.Numeric);
                q.Parameters.Add("?FreeMemory", freeMemory, ParameterCollection.FieldType.Numeric);
                q.Parameters.Add("?ProcessorCount", processorCount, ParameterCollection.FieldType.Numeric);
                q.RunQueryNoResult();
            }
        }
Ejemplo n.º 12
0
        //TODO: Gazaro specific implementation, need to generalize
        public DateTime GetUrlQueueMinProcessDate()
        {
            //TODO: fix connection string
            Query q = new Query("select min(ProcessDate) from UrlQueue", "GetUrlQueueMinProcessDate", "server=192.168.1.225;database=GazaroAdamB;uid=root;charset=utf8;pwd=1q2w3e4r!;");
            DataTable Dt = q.RunQuery();

            if (Dt.Rows.Count == 0)
            {
                return DateTime.Now;
            }

            string minProcessDate = Dt.Rows[0][0].ToString();
            if (string.IsNullOrEmpty(minProcessDate))
            {
                return DateTime.Now;
            }
            return DateTime.Parse(minProcessDate);
        }
Ejemplo n.º 13
0
 private void DeleteItem(IEmailQueueEntity queueItem)
 {
     Query q = new Query("delete from EmailQueue where MailId = ?MailId", "DeleteFromEmailQueue", _emailConnection);
     q.Parameters.Add("?MailId", queueItem.MailId, ParameterCollection.FieldType.Numeric);
     q.RunQueryNoResult();
 }