private List <ImportProcessState> GetImportProcesses(int?id) { IDbCommand cmd; string strSQL; Tebaldi.MarketData.Models.State.ImportProcessState obj = new ImportProcessState(); strSQL = "procGetProcess"; cmd = DataLayer.CreateCommand(strSQL, mstrConnectString); cmd.CommandType = CommandType.StoredProcedure; if (id != null) { cmd.Parameters.Add(DataLayer.CreateParameter("@Id", DbType.Int32, id, mstrConnectString)); } DataSet ds = DataLayer.GetDataSet(cmd, mstrConnectString); List <ImportProcessState> lst = (from dr in ds.Tables[0].AsEnumerable() select new State.ImportProcessState() { Id = Convert.ToInt32(dr[obj.Schema.Id]), Name = Convert.ToString(dr[obj.Schema.Name]), Feed = new FeedState { ID = Convert.ToInt32(dr[obj.Schema.FeedId]) }, AutoQueue = Convert.ToBoolean(dr[obj.Schema.AutoQueue]), Active = Convert.ToBoolean(dr[obj.Schema.Active]) }).ToList(); FeedHandler feed_handller = new FeedHandler(mstrConnectString); foreach (ImportProcessState item in lst) { item.Feed = feed_handller.GetFeed(item.Feed.ID); } return(lst); }
public List <ProcessQueueState> GetQueue(DateTime?dtAgendadaMax, bool?executado, bool?activeFeeds) { IDbCommand cmd; string strSQL; Tebaldi.MarketData.Models.State.ProcessQueueState obj = new ProcessQueueState(); strSQL = "procGetProcessQueue"; cmd = DataLayer.CreateCommand(strSQL, mstrConnectString); cmd.CommandType = CommandType.StoredProcedure; if (dtAgendadaMax != null) { cmd.Parameters.Add(DataLayer.CreateParameter("@dt_agd_max", DbType.DateTime, dtAgendadaMax, mstrConnectString)); } if (executado != null) { cmd.Parameters.Add(DataLayer.CreateParameter("@executado", DbType.Boolean, executado, mstrConnectString)); } if (activeFeeds != null) { cmd.Parameters.Add(DataLayer.CreateParameter("@activeFeeds", DbType.Boolean, activeFeeds, mstrConnectString)); } DataSet ds = DataLayer.GetDataSet(cmd, mstrConnectString); List <ProcessQueueState> lstQueue = (from dr in ds.Tables[0].AsEnumerable() select new State.ProcessQueueState() { QueueId = Convert.ToInt32(dr[obj.Schema.QueueId]), Process = new ImportProcessState { Id = Convert.ToInt32(dr[obj.Schema.ProcessId]), Active = Convert.ToBoolean(dr[obj.Process.Schema.ObjectName + "." + obj.Process.Schema.Active]), AutoQueue = Convert.ToBoolean(dr[obj.Process.Schema.ObjectName + "." + obj.Process.Schema.AutoQueue]), Feed = new FeedState { ID = Convert.ToInt32(dr[obj.Process.Schema.ObjectName + "." + obj.Process.Schema.FeedId]), }, Name = Convert.ToString(dr[obj.Process.Schema.ObjectName + "." + obj.Process.Schema.Name]) }, DataAgendada = Convert.ToDateTime(dr[obj.Schema.DataAgendada]), DataExecucao = dr[obj.Schema.DataExecucao] == DBNull.Value ? DateTime.MinValue : Convert.ToDateTime(dr[obj.Schema.DataExecucao]), DataReferencia = Convert.ToDateTime(dr[obj.Schema.DataReferencia]), Executado = Convert.ToBoolean(dr[obj.Schema.Executado]), Success = Convert.ToBoolean(dr[obj.Schema.Success]) }).ToList(); FeedHandler feed_handller = new FeedHandler(mstrConnectString); foreach (ProcessQueueState item in lstQueue) { item.Process.Feed = feed_handller.GetFeed(item.Process.Feed.ID); } return(lstQueue); }