Пример #1
0
    public Rpt303_DataObject(int bornInYear, string strain, int herdSN, string reportStyle)
    {
        if (herdSN > 0)
            _bbHerd = new BBDataHelper().GetHerd(herdSN);
        else
            _bbHerd = null;

        _strain = strain;
        _yearBorn = bornInYear;
        _reportStyle = reportStyle;
    }
    //public Rpt021_WeaningSummary(string strain, int herdSN, int yearBorn, char sex, bool hasWeaningData, string reportMode)
    public Rpt021_WeaningSummary(string strain, int herdSN, int yearBorn)
    {
        _strain = strain;
        if ( herdSN > 0 )
            _bbHerd = new BBDataHelper().GetHerd(herdSN);
        else
            _bbHerd = null;
        _yearBorn = yearBorn;

        //_sex = sex;

        //_hasWeaningData = hasWeaningData;

        //_reportMode = reportMode;
    }
        public static IEnumerable<BBHerd> GetHerds(string inStrain)
        {
            List<BBHerd> herdList;
            HttpContext objContext = HttpContext.Current;
            // if we have it in cache
            if (objContext.Cache[CacheStaticValues.HerdList] != null)
            {
                // return it
                herdList = (List<BBHerd>) (HttpContext.Current.Cache[CacheStaticValues.HerdList]);
                return FilterBBHerdsByStrain(herdList, inStrain);
            }

            // it its not in cache then we need to query the db
            //   build the list
            //   and store it in cache
            herdList = new List<BBHerd>();
            SqlDataReader objDataReader = null;
            string sqlString =
                "SELECT Herd_SN, Herd_Code, Strain_Code, Person_Name, GeneticHerd_Name FROM vwHerd_Strain_Person WHERE ";
            sqlString += " (Disabled_Flag=0) ORDER BY Herd_Code";
            try
            {
                objDataReader =
                    DataAccess.GetDataReader(WebConfigSettings.Configurations.CowCalf_ConnectionString,
                                             sqlString, null, objDataReader);
                if (objDataReader.HasRows)
                {
                    int ordHerd_SN = objDataReader.GetOrdinal("Herd_SN");
                    int ordHerd_Code = objDataReader.GetOrdinal("Herd_Code");
                    int ordStrainCode = objDataReader.GetOrdinal("Strain_Code");
                    int ordPerson_Name = objDataReader.GetOrdinal("Person_Name");
                    int ordGeneticHerd_Name = objDataReader.GetOrdinal("GeneticHerd_Name");
                    while (objDataReader.Read())
                    {
                        int sn = objDataReader.GetInt32(ordHerd_SN);
                        var code = (string) objDataReader.GetSqlString(ordHerd_Code);
                        var strain = (string) objDataReader.GetSqlString(ordStrainCode);
                        var breederName = (string) objDataReader.GetSqlString(ordPerson_Name);
                        var ranchName = (string) objDataReader.GetSqlString(ordGeneticHerd_Name);
                        var h = new BBHerd(sn, code, strain, breederName, ranchName);
                        herdList.Add(h);
                    }
                }
                if (!objDataReader.IsClosed)
                    objDataReader.Close();
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Failed to read Beefbooster herd codes from the database", ex);
            }
            HttpContext.Current.Cache.Add(CacheStaticValues.HerdList, herdList, null,
                                          DateTime.Now.AddDays(Convert.ToInt32(1)), TimeSpan.Zero,
                                          CacheItemPriority.Normal, null);
            return FilterBBHerdsByStrain(herdList, inStrain);
        }
Пример #4
0
    public Rpt304_DataObject(int bornInYear, string strain, int herdSN, string reportStyle, int sortOrder, decimal medRel, decimal highRel)
    {
        _bbHerd = herdSN > 0 ? new BBDataHelper().GetHerd(herdSN) : null;

        _strain = strain;
        _yearBorn = bornInYear;
        _reportStyle = reportStyle;
        _sortOrder = sortOrder;
        _medReliability = medRel;
        _highReliability = highRel;
    }
 // Make sure you have a default constructor or this won't show up as a valid datasource
 //public Rpt022_CowPerformance() { }
 public Rpt022_CowPerformance(int herdSN, int yearBorn, int sortOrder)
 {
     _yearBorn = yearBorn;
     _sortOrder = sortOrder;
     _bbHerd = new BBDataHelper().GetHerd(herdSN);
 }