public MappingCollectionTest()
        {
            testDB = new DAL("MappingCollectionTest" + ".cruise", true);
            Random rand = new Random(0);

            List<CuttingUnitDO> units = new List<CuttingUnitDO>();
            for (int i = 1; i <= 10; i++)
            {
                CuttingUnitDO cu = new CuttingUnitDO(testDB);
                cu.Code = i.ToString();
                cu.Area = rand.Next(9) + 1.0f;
                cu.Save();
                units.Add(cu);
            }

            List<StratumDO> strata = new List<StratumDO>();
            for (int i = 0; i <= 10; i++)
            {
                StratumDO st = new StratumDO(testDB);
                st.Code = i.ToString();
                st.Method = "something";
                st.Save();
                strata.Add(st);
            }

            foreach (CuttingUnitDO cu in units)
            {
                for (int i = 0; i < cu.Area; i++)
                {
                    CuttingUnitStratumDO cust = new CuttingUnitStratumDO(testDB);
                    cust.CuttingUnit_CN = cu.CuttingUnit_CN;
                    cust.Stratum_CN = strata[i].Stratum_CN;
                    cust.Save();
                }
            }

            testDB.FlushCache();
        }
Exemplo n.º 2
0
        private CruiseDAL.DAL CreateDatastore(string cruiseMethod, int freqORkz, int insuranceFreq)
        {
            var ds = new CruiseDAL.DAL();

            try
            {
                var sale = new SaleDO()
                {
                    DAL               = ds,
                    SaleNumber        = "12345",
                    Region            = "1",
                    Forest            = "1",
                    District          = "1",
                    Purpose           = "something",
                    LogGradingEnabled = true
                };
                sale.Save();

                var stratum = new StratumDO()
                {
                    DAL    = ds,
                    Code   = "01",
                    Method = cruiseMethod
                };
                stratum.Save();

                var cuttingUnit = new CuttingUnitDO()
                {
                    DAL  = ds,
                    Code = "01"
                };
                cuttingUnit.Save();

                var cust = new CuttingUnitStratumDO()
                {
                    DAL         = ds,
                    CuttingUnit = cuttingUnit,
                    Stratum     = stratum
                };
                cust.Save();

                var sampleGroup = new SampleGroupDO()
                {
                    DAL                = ds,
                    Stratum            = stratum,
                    Code               = "01",
                    PrimaryProduct     = "01",
                    UOM                = "something",
                    CutLeave           = "something",
                    InsuranceFrequency = insuranceFreq
                };

                if (CruiseMethods.THREE_P_METHODS.Contains(cruiseMethod))
                {
                    sampleGroup.KZ = freqORkz;
                }
                else
                {
                    sampleGroup.SamplingFrequency = freqORkz;
                }

                sampleGroup.Save();

                var tally = new TallyDO()
                {
                    DAL         = ds,
                    Hotkey      = "A",
                    Description = "something"
                };
                tally.Save();

                var count = new CountTreeDO()
                {
                    DAL         = ds,
                    CuttingUnit = cuttingUnit,
                    SampleGroup = sampleGroup,
                    Tally       = tally
                };
                count.Save();

                return(ds);
            }
            catch
            {
                ds.Dispose();
                throw;
            }
        }