Exemple #1
0
        private List <ServiceInformations> fetchData(SqlCommand cmd)
        {
            SqlConnection con = cmd.Connection;
            List <ServiceInformations> serviceinformations = null;

            con.Open();
            using (con)
            {
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    serviceinformations = new List <ServiceInformations>();
                    while (dr.Read())
                    {
                        ServiceInformations uServiceInformations = new ServiceInformations();
                        uServiceInformations.ServiceName = Convert.ToString(dr["Service_Name"]);
                        uServiceInformations.CreatedOn   = Convert.ToString(dr["Created_On"]);
                        uServiceInformations.NoOfErrors  = Convert.ToString(dr["No_of_Errors"]);
                        uServiceInformations.NoOfSuccess = Convert.ToString(dr["No_of_Success"]);
                        serviceinformations.Add(uServiceInformations);
                    }
                    serviceinformations.TrimExcess();
                }
            }
            return(serviceinformations);
        }
        public PopulationService(
            IHttpClientFactory httpClientFactory,
            IOptions <ServiceInformations> serviceInformations
            ) : base(httpClientFactory)
        {
            if (serviceInformations.Value == null)
            {
                throw new Exception("Define service informations in appsetting.json");
            }

            this._serviceInformations = serviceInformations.Value;
        }