private List<string> getProcessedForHour(DateTime schedDtTm) { List<string> serversProcessed = new List<string>(); sccm_collection_data retVal = new sccm_collection_data(); string cnStr = Properties.Settings.Default.dbConnString; try { using (SqlConnection cn = new SqlConnection(cnStr)) { cn.Open(); string sqltxt = @"SELECT [svc_id] ,[created_dt] ,[scheduled_dt] ,[submitted_dt] ,[month_code] ,[patch_engine] ,[action] ,[server_name] ,[collection_name] ,[submit_status_msg] ,[patch_status_msg] ,[compliance_status] FROM [dbo].[apss_patch_history_log] where scheduled_dt=@schedDt"; using (SqlCommand cmd = new SqlCommand(sqltxt, cn)) { cmd.Parameters.AddWithValue("@schedDt", schedDtTm); using (SqlDataAdapter sda = new SqlDataAdapter(cmd)) { DataSet ds = new DataSet(); sda.Fill(ds); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count == 1) { } foreach (DataRow dr in ds.Tables[0].Rows) { serversProcessed.Add(dr["server_name"].ToString()); } } } } } } catch (Exception ex) { WriteVerbose(ex.Message); throw ex; //MessageBox.Show(recins + " Records processed. Error: " + ex.Message); } return serversProcessed; }
private sccm_collection_data getCollectionData(string startTime, string dow) { sccm_collection_data retVal = new sccm_collection_data(); string cnStr = Properties.Settings.Default.dbConnString; try { using (SqlConnection cn = new SqlConnection(cnStr)) { cn.Open(); using (SqlCommand cmd = new SqlCommand("select * from apss_sccm_collection_xref where sched_start_time =@schedStart and dow_name = @dow ", cn)) { cmd.Parameters.AddWithValue("@schedStart", startTime); cmd.Parameters.AddWithValue("@dow", dow); using (SqlDataAdapter sda = new SqlDataAdapter(cmd)) { DataSet ds = new DataSet(); sda.Fill(ds); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count == 1) { } foreach (DataRow dr in ds.Tables[0].Rows) { retVal.dow_name = dow; retVal.sccm_collection_name = dr["sccm_collection_name"].ToString(); retVal.sched_start_time = startTime; } } } } } } catch (Exception ex) { WriteVerbose(ex.Message); throw ex; //MessageBox.Show(recins + " Records processed. Error: " + ex.Message); } return retVal; }