Ejemplo n.º 1
0
        public EndOfDay BuildFromRow(DataRow row)
        {
            var returnRecord = EndOfDay.BuildEndOfDayFromRow(row);

            returnRecord = this.BuildExtraFromRow <EndOfDay>(returnRecord, row);
            return(returnRecord);
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <EndOfDay> > PostEndOfDay(EndOfDay endOfDay)
        {
            _context.EndOfDays.Add(endOfDay);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetEndOfDay", new { id = endOfDay.EndOfDayId }, endOfDay));
        }
Ejemplo n.º 3
0
        // GET: EndOfDays/Create
        public ActionResult Create()
        {
            EndOfDay day = new EndOfDay();

            day.EOD_Date = DateTime.Today;
            return(View(day));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> PutEndOfDay(int id, EndOfDay endOfDay)
        {
            if (id != endOfDay.EndOfDayId)
            {
                return(BadRequest());
            }

            _context.Entry(endOfDay).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EndOfDayExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public ActionResult DeleteConfirmed(int id)
        {
            EndOfDay endOfDay = db.EndOfDays.Find(id);

            db.EndOfDays.Remove(endOfDay);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        private EndofDayDetails ProcessEndOfDay(EndOfDay day)
        {
            // Process opening & closing balance of day.
            // Utils.ProcessOpenningClosingBalance(db, day.EOD_Date, true);
            // Utils.ProcessOpenningClosingBankBalance(db, day.EOD_Date, true); //TODO: Check in future

            //Create Next day openning Balance
            Utils.CreateNextDayOpenningBalance(db, day.EOD_Date, true);
            // process for a report to be sms

            var     todaySale = db.DailySales.Where(c => DbFunctions.TruncateTime(c.SaleDate) == DbFunctions.TruncateTime(day.EOD_Date));
            decimal totalExp  = 0;
            decimal tRec      = 0;
            decimal tPay      = 0;

            totalExp  = (decimal?)db.Expenses.Where(c => DbFunctions.TruncateTime(c.ExpDate) == DbFunctions.TruncateTime(day.EOD_Date)).Sum(c => (decimal?)c.Amount) ?? 0;
            totalExp += (decimal?)db.CashExpenses.Where(c => DbFunctions.TruncateTime(c.ExpDate) == DbFunctions.TruncateTime(day.EOD_Date)).Sum(c => (decimal?)c.Amount) ?? 0;

            tPay  = (decimal?)db.Payments.Where(c => DbFunctions.TruncateTime(c.PayDate) == DbFunctions.TruncateTime(day.EOD_Date)).Sum(c => (decimal?)c.Amount) ?? 0;
            tPay += (decimal?)db.CashPayments.Where(c => DbFunctions.TruncateTime(c.PaymentDate) == DbFunctions.TruncateTime(day.EOD_Date)).Sum(c => (decimal?)c.Amount) ?? 0;
            tPay += (decimal?)db.Salaries.Where(c => DbFunctions.TruncateTime(c.PaymentDate) == DbFunctions.TruncateTime(day.EOD_Date)).Sum(c => (decimal?)c.Amount) ?? 0;
            tPay += (decimal?)db.StaffAdvancePayments.Where(c => DbFunctions.TruncateTime(c.PaymentDate) == DbFunctions.TruncateTime(day.EOD_Date)).Sum(c => (decimal?)c.Amount) ?? 0;


            tRec  = (decimal?)db.Receipts.Where(c => DbFunctions.TruncateTime(c.RecieptDate) == DbFunctions.TruncateTime(day.EOD_Date)).Sum(c => (decimal?)c.Amount) ?? 0;
            tPay += (decimal?)db.CashReceipts.Where(c => DbFunctions.TruncateTime(c.InwardDate) == DbFunctions.TruncateTime(day.EOD_Date)).Sum(c => (decimal?)c.Amount) ?? 0;
            tPay += (decimal?)db.Withdrawals.Where(c => DbFunctions.TruncateTime(c.DepoDate) == DbFunctions.TruncateTime(day.EOD_Date)).Sum(c => (decimal?)c.Amount) ?? 0;
            tPay += (decimal?)db.StaffAdvanceReceipts.Where(c => DbFunctions.TruncateTime(c.ReceiptDate) == DbFunctions.TruncateTime(day.EOD_Date)).Sum(c => (decimal?)c.Amount) ?? 0;


            EndofDayDetails details = new EndofDayDetails()
            {
                TodaySale             = (decimal?)todaySale.Sum(c => (decimal?)c.Amount) ?? 0,
                TodayCardSale         = (decimal?)todaySale.Where(c => c.PayMode == PayModes.Card).Sum(c => (decimal?)c.Amount) ?? 0,
                TodayManualSale       = (decimal?)todaySale.Where(c => c.IsManualBill == true).Sum(c => (decimal?)c.Amount) ?? 0,
                TodayOtherSale        = (decimal?)todaySale.Where(c => c.PayMode != PayModes.Card && c.PayMode != PayModes.Cash).Sum(c => (decimal?)c.Amount) ?? 0,
                TodayTailoringSale    = (decimal?)todaySale.Where(c => c.IsTailoringBill == true).Sum(c => (decimal?)c.Amount) ?? 0,
                TodayCashInHand       = (decimal?)db.CashInHands.Where(c => DbFunctions.TruncateTime(c.CIHDate) == DbFunctions.TruncateTime(day.EOD_Date)).FirstOrDefault().InHand ?? 0,
                TodayTailoringBooking = (int?)db.Bookings.Where(c => DbFunctions.TruncateTime(c.BookingDate) == DbFunctions.TruncateTime(day.EOD_Date)).Count() ?? 0,
                TodayTotalUnit        = (int?)db.Bookings.Where(c => DbFunctions.TruncateTime(c.BookingDate) == DbFunctions.TruncateTime(day.EOD_Date)).Sum(c => (int?)c.TotalQty) ?? 0,
                TodayTotalExpenses    = totalExp,
                TotalPayments         = tPay,
                TotalReceipts         = tRec,
                Access     = day.Access,
                CashInHand = day.CashInHand,
                EOD_Date   = day.EOD_Date,
                FM_Arrow   = day.FM_Arrow,
                RWT        = day.RWT,
                Shirting   = day.Shirting,
                Suiting    = day.Suiting,
                USPA       = day.USPA
            };



            return(details);
        }
Ejemplo n.º 7
0
 private void AssertEndOfDay(EndOfDay endOfDay, DateTime date, decimal open, decimal high, decimal low, decimal close, long volume)
 {
     Assert.AreEqual(open, endOfDay.Open);
     Assert.AreEqual(high, endOfDay.High);
     Assert.AreEqual(low, endOfDay.Low);
     Assert.AreEqual(close, endOfDay.Close);
     Assert.AreEqual(volume, endOfDay.Volume);
     Assert.AreEqual(date, endOfDay.Date);
 }
Ejemplo n.º 8
0
        public EndOfDay Insert(EndOfDay record)
        {
            DataRow row = this.dataSet.ttblend_of_day.Newttblend_of_dayRow();

            this.UpdateToRow(ref row, record);
            this.ExtraUpdateToRow(ref row, record);
            this.dataSet.ttblend_of_day.Addttblend_of_dayRow((pdsend_of_dayDataSet.ttblend_of_dayRow)row);
            this.SaveChanges();
            return(this.dataSet.ttblend_of_day.Rows.Count > 0 ? this.BuildFromRow(this.dataSet.ttblend_of_day.Rows[0]) : null);
        }
 public ActionResult Edit([Bind(Include = "EndOfDayId,EOD_Date,Shirting,Suiting,USPA,FM_Arrow,RWT,Access,CashInHand")] EndOfDay endOfDay)
 {
     if (ModelState.IsValid)
     {
         db.Entry(endOfDay).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(endOfDay));
 }
Ejemplo n.º 10
0
        public async Task <IActionResult> Create([Bind("EndOfDayId,EOD_Date,Shirting,Suiting,USPA,FM_Arrow,RWT,Access,CashInHand")] EndOfDay endOfDay)
        {
            if (ModelState.IsValid)
            {
                _context.Add(endOfDay);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(endOfDay));
        }
Ejemplo n.º 11
0
        public EndOfDay GetByRowId(string rowId, string fldList)
        {
            var      row      = this.GetRowByRowId(rowId, fldList);
            EndOfDay endOfDay = null;

            if (row != null)
            {
                endOfDay = this.BuildFromRow(row);
            }
            return(endOfDay);
        }
Ejemplo n.º 12
0
        protected EndOfDay Fetch(string where, int batchsize, string fldList)
        {
            this.FetchWhere(where, batchsize, fldList);
            var      row      = this.dataSet.ttblend_of_day.AsEnumerable().SingleOrDefault();
            EndOfDay endOfDay = null;

            if (row != null)
            {
                endOfDay = this.BuildFromRow(row);
            }
            return(endOfDay);
        }
Ejemplo n.º 13
0
        public void Delete(EndOfDay record)
        {
            var row = this.GetRowByRowId(record.rowID, string.Empty);

            if (row == null)
            {
                row = this.dataSet.ttblend_of_day.Newttblend_of_dayRow();
                EndOfDay.BuildMinimalRow(ref row, record);
                this.dataSet.ttblend_of_day.Addttblend_of_dayRow((pdsend_of_dayDataSet.ttblend_of_dayRow)row);
            }
            row.Delete();
            this.SaveChanges();
        }
        public ActionResult Create([Bind(Include = "EndOfDayId,EOD_Date,Shirting,Suiting,USPA,FM_Arrow,RWT,Access,CashInHand")] EndOfDay endOfDay)
        {
            if (ModelState.IsValid)
            {
                db.EndOfDays.Add(endOfDay);
                db.SaveChanges();
                // EndofDayDetails eod = ProcessEndOfDay(endOfDay);

                return(RedirectToAction("DailySaleReport", ProcessEndOfDay(endOfDay)));
            }

            return(View(endOfDay));
        }
Ejemplo n.º 15
0
        public EndOfDay Update(EndOfDay record)
        {
            var row = this.GetRowByRowId(record.rowID, string.Empty);

            if (row != null)
            {
                this.UpdateToRow(ref row, record);
                this.ExtraUpdateToRow(ref row, record);
                this.SaveChanges();
                return(this.dataSet.ttblend_of_day.Rows.Count > 0 ? this.BuildFromRow(this.dataSet.ttblend_of_day.Rows[0]) : null);
            }
            ErrorReportingHelper.ReportErrors("global.update.doesnotexist", 421);
            return(null);
        }
        // GET: EndOfDays/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EndOfDay endOfDay = db.EndOfDays.Find(id);

            if (endOfDay == null)
            {
                return(HttpNotFound());
            }
            return(View(endOfDay));
        }
        // GET: EndOfDays/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EndOfDay endOfDay = db.EndOfDays.Find(id);

            if (endOfDay == null)
            {
                return(HttpNotFound());
            }
            return(RedirectToAction("DailySaleReport", ProcessEndOfDay(endOfDay)));
            //return View(endOfDay);
        }
Ejemplo n.º 18
0
        private async System.Threading.Tasks.Task AddEndOfDaysAsync()
        {
            //EndOfDayId	EOD_Date	Shirting	Suiting	USPA	FM_Arrow	RWT	Access	CashInHand	StoreId

            var ws = xS.GetWS("EndOfDays");
            var nonEmptyDataRows = ws.RowsUsed();
            int Row = 6;//Title;

            foreach (var dR in nonEmptyDataRows)
            {
                if (dR.RowNumber() > Row)
                {
                    EndOfDay eod = new EndOfDay
                    {
                        EOD_Date    = dR.Cell(2).GetDateTime(),
                        Shirting    = dR.Cell(3).GetValue <float>(),
                        Suiting     = dR.Cell(4).GetValue <float>(),
                        USPA        = dR.Cell(5).GetValue <int>(),
                        FM_Arrow    = dR.Cell(6).GetValue <int>(),
                        RWT         = dR.Cell(7).GetValue <int>(),
                        Access      = dR.Cell(8).GetValue <int>(),
                        CashInHand  = dR.Cell(9).GetValue <decimal>(),
                        StoreId     = 1,// dR.Cell(10).GetValue<int>(),
                        EntryStatus = 0,
                        IsReadOnly  = true,
                        UserId      = "Admin"
                    };
                    db.EndOfDays.Add(eod);

                    //try
                    //{


                    //}
                    //catch (Exception e)
                    //{


                    //}
                }
            }

            await db.SaveChangesAsync();
        }
Ejemplo n.º 19
0
 public void Delete(EndOfDay record)
 {
     this.adapter.Delete(record);
 }
Ejemplo n.º 20
0
 public void UpdateToRow(ref DataRow row, EndOfDay record)
 {
     EndOfDay.UpdateRowFromEndOfDay(ref row, record);
     this.ExtraUpdateToRow(ref row, record);
 }
Ejemplo n.º 21
0
        private void OnDoCommence(object sender, Simulation.CommenceArgs e)
        {
            if (DoInitialSummary != null)
            {
                DoInitialSummary.Invoke(this, args);
            }

            if (StartOfSimulation != null)
            {
                StartOfSimulation.Invoke(this, args);
            }

            while (Today <= EndDate)
            {
                // If this is being run on a background worker thread then check for cancellation
                if (e != null && e.workerThread != null && e.workerThread.CancellationPending)
                {
                    Summary.WriteMessage(this, "Simulation cancelled");
                    return;
                }

                if (DoWeather != null)
                {
                    DoWeather.Invoke(this, args);
                }

                if (DoDailyInitialisation != null)
                {
                    DoDailyInitialisation.Invoke(this, args);
                }

                if (StartOfDay != null)
                {
                    StartOfDay.Invoke(this, args);
                }

                if (Today.Day == 1 && StartOfMonth != null)
                {
                    StartOfMonth.Invoke(this, args);
                }

                if (Today.DayOfYear == 1 && StartOfYear != null)
                {
                    StartOfYear.Invoke(this, args);
                }

                if (Today.DayOfWeek == DayOfWeek.Sunday && StartOfWeek != null)
                {
                    StartOfWeek.Invoke(this, args);
                }

                if (Today.DayOfWeek == DayOfWeek.Saturday && EndOfWeek != null)
                {
                    EndOfWeek.Invoke(this, args);
                }

                if (DoManagement != null)
                {
                    DoManagement.Invoke(this, args);
                }

                if (DoEnergyArbitration != null)
                {
                    DoEnergyArbitration.Invoke(this, args);
                }

                if (DoSoilWaterMovement != null)
                {
                    DoSoilWaterMovement.Invoke(this, args);
                }

                if (DoSoilTemperature != null)
                {
                    DoSoilTemperature.Invoke(this, args);
                }

                if (DoSoilOrganicMatter != null)
                {
                    DoSoilOrganicMatter.Invoke(this, args);
                }

                if (DoSurfaceOrganicMatterDecomposition != null)
                {
                    DoSurfaceOrganicMatterDecomposition.Invoke(this, args);
                }
                if (Today.DayOfYear == 16)
                {
                }
                if (DoWaterArbitration != null)
                {
                    DoWaterArbitration.Invoke(this, args);
                }

                if (DoPhenology != null)
                {
                    DoPhenology.Invoke(this, args);
                }

                if (DoPotentialPlantGrowth != null)
                {
                    DoPotentialPlantGrowth.Invoke(this, args);
                }

                if (DoPotentialPlantPartioning != null)
                {
                    DoPotentialPlantPartioning.Invoke(this, args);
                }

                if (DoNutrientArbitration != null)
                {
                    DoNutrientArbitration.Invoke(this, args);
                }

                if (DoActualPlantPartioning != null)
                {
                    DoActualPlantPartioning.Invoke(this, args);
                }

                if (DoActualPlantGrowth != null)
                {
                    DoActualPlantGrowth.Invoke(this, args);
                }

                if (DoPlantGrowth != null)
                {
                    DoPlantGrowth.Invoke(this, args);
                }

                if (DoUpdate != null)
                {
                    DoUpdate.Invoke(this, args);
                }

                if (DoManagementCalculations != null)
                {
                    DoManagementCalculations.Invoke(this, args);
                }

                if (DoStock != null)
                {
                    DoStock.Invoke(this, args);
                }

                if (DoLifecycle != null)
                {
                    DoLifecycle.Invoke(this, args);
                }

                if (DoReportCalculations != null)
                {
                    DoReportCalculations.Invoke(this, args);
                }

                if (Today == EndDate && EndOfSimulation != null)
                {
                    EndOfSimulation.Invoke(this, args);
                }

                if (Today.Day == 31 && Today.Month == 12 && EndOfYear != null)
                {
                    EndOfYear.Invoke(this, args);
                }

                if (Today.AddDays(1).Day == 1 && EndOfMonth != null)                 // is tomorrow the start of a new month?
                {
                    // WholeFarm events performed before APSIM EndOfMonth
                    if (WFUpdatePasture != null)
                    {
                        WFUpdatePasture.Invoke(this, args);
                    }
                    if (WFDoCutAndCarry != null)
                    {
                        WFDoCutAndCarry.Invoke(this, args);
                    }
                    if (WFAnimalBreeding != null)
                    {
                        WFAnimalBreeding.Invoke(this, args);
                    }
                    if (WFPotentialIntake != null)
                    {
                        WFPotentialIntake.Invoke(this, args);
                    }
                    if (WFGetResourcesRequired != null)
                    {
                        WFGetResourcesRequired.Invoke(this, args);
                    }
                    if (WFAnimalMilkProduction != null)
                    {
                        WFAnimalMilkProduction.Invoke(this, args);
                    }
                    if (WFAnimalWeightGain != null)
                    {
                        WFAnimalWeightGain.Invoke(this, args);
                    }
                    if (WFAnimalDeath != null)
                    {
                        WFAnimalDeath.Invoke(this, args);
                    }
                    if (WFAnimalMilking != null)
                    {
                        WFAnimalMilking.Invoke(this, args);
                    }
                    if (WFAnimalManage != null)
                    {
                        WFAnimalManage.Invoke(this, args);
                    }
                    if (WFAnimalStock != null)
                    {
                        WFAnimalStock.Invoke(this, args);
                    }
                    if (WFAnimalSell != null)
                    {
                        WFAnimalSell.Invoke(this, args);
                    }
                    if (WFAgeResources != null)
                    {
                        WFAgeResources.Invoke(this, args);
                    }

                    EndOfMonth.Invoke(this, args);
                }

                if (EndOfDay != null)
                {
                    EndOfDay.Invoke(this, args);
                }

                if (DoReport != null)
                {
                    DoReport.Invoke(this, args);
                }

                Today = Today.AddDays(1);
            }

            Summary.WriteMessage(this, "Simulation terminated normally");
        }
Ejemplo n.º 22
0
        private void OnDoCommence(object sender, EventArgs e)
        {
            System.ComponentModel.BackgroundWorker bw = sender as System.ComponentModel.BackgroundWorker;

            if (DoInitialSummary != null)
            {
                DoInitialSummary.Invoke(this, args);
            }

            if (StartOfSimulation != null)
            {
                StartOfSimulation.Invoke(this, args);
            }

            while (Today <= EndDate)
            {
                // If this is being run on a background worker thread then check for cancellation
                if (bw != null && bw.CancellationPending)
                {
                    Summary.WriteMessage(this, "Simulation cancelled");
                    return;
                }

                if (DoWeather != null)
                {
                    DoWeather.Invoke(this, args);
                }

                if (DoDailyInitialisation != null)
                {
                    DoDailyInitialisation.Invoke(this, args);
                }

                if (StartOfDay != null)
                {
                    StartOfDay.Invoke(this, args);
                }

                if (Today.Day == 1 && StartOfMonth != null)
                {
                    StartOfMonth.Invoke(this, args);
                }

                if (Today.DayOfYear == 1 && StartOfYear != null)
                {
                    StartOfYear.Invoke(this, args);
                }

                if (Today.DayOfWeek == DayOfWeek.Sunday && StartOfWeek != null)
                {
                    StartOfWeek.Invoke(this, args);
                }

                if (Today.DayOfWeek == DayOfWeek.Saturday && EndOfWeek != null)
                {
                    EndOfWeek.Invoke(this, args);
                }

                if (DoManagement != null)
                {
                    DoManagement.Invoke(this, args);
                }

                if (DoEnergyArbitration != null)
                {
                    DoEnergyArbitration.Invoke(this, args);
                }

                if (DoSoilWaterMovement != null)
                {
                    DoSoilWaterMovement.Invoke(this, args);
                }

                if (DoSoilOrganicMatter != null)
                {
                    DoSoilOrganicMatter.Invoke(this, args);
                }

                if (DoSurfaceOrganicMatterDecomposition != null)
                {
                    DoSurfaceOrganicMatterDecomposition.Invoke(this, args);
                }
                if (Today.DayOfYear == 16)
                {
                }
                if (DoWaterArbitration != null)
                {
                    DoWaterArbitration.Invoke(this, args);
                }

                if (DoPhenology != null)
                {
                    DoPhenology.Invoke(this, args);
                }

                if (DoPotentialPlantGrowth != null)
                {
                    DoPotentialPlantGrowth.Invoke(this, args);
                }

                if (DoPotentialPlantPartioning != null)
                {
                    DoPotentialPlantPartioning.Invoke(this, args);
                }

                if (DoNutrientArbitration != null)
                {
                    DoNutrientArbitration.Invoke(this, args);
                }

                if (DoActualPlantPartioning != null)
                {
                    DoActualPlantPartioning.Invoke(this, args);
                }

                if (DoActualPlantGrowth != null)
                {
                    DoActualPlantGrowth.Invoke(this, args);
                }

                if (DoPlantGrowth != null)
                {
                    DoPlantGrowth.Invoke(this, args);
                }

                if (DoUpdate != null)
                {
                    DoUpdate.Invoke(this, args);
                }

                if (DoManagementCalculations != null)
                {
                    DoManagementCalculations.Invoke(this, args);
                }

                if (DoReportCalculations != null)
                {
                    DoReportCalculations.Invoke(this, args);
                }

                if (Today == EndDate && EndOfSimulation != null)
                {
                    EndOfSimulation.Invoke(this, args);
                }

                if (Today.Day == 31 && Today.Month == 12 && EndOfYear != null)
                {
                    EndOfYear.Invoke(this, args);
                }

                if (Today.AddDays(1).Day == 1 && EndOfMonth != null) // is tomorrow the start of a new month?
                {
                    EndOfMonth.Invoke(this, args);
                }

                if (EndOfDay != null)
                {
                    EndOfDay.Invoke(this, args);
                }

                if (DoReport != null)
                {
                    DoReport.Invoke(this, args);
                }

                Today = Today.AddDays(1);
            }

            Summary.WriteMessage(this, "Simulation terminated normally");
        }
Ejemplo n.º 23
0
        [Authorize(Roles = "Admin,PowerUser")][Authorize(Roles = "Admin,PowerUser")]     public async Task <IActionResult> Edit(int id, [Bind("EndOfDayId,EOD_Date,Shirting,Suiting,USPA,FM_Arrow,RWT,Access,CashInHand")] EndOfDay endOfDay)
        {
            if (id != endOfDay.EndOfDayId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(endOfDay);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EndOfDayExists(endOfDay.EndOfDayId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(endOfDay));
        }
Ejemplo n.º 24
0
        private void OnDoCommence(object sender, Core.Runners.RunSimulation.CommenceArgs e)
        {
            try
            {
                if (DoInitialSummary != null)
                {
                    DoInitialSummary.Invoke(this, args);
                }

                if (StartOfSimulation != null)
                {
                    StartOfSimulation.Invoke(this, args);
                }

                while (Today <= EndDate && !e.CancelToken.IsCancellationRequested)
                {
                    if (DoWeather != null)
                    {
                        DoWeather.Invoke(this, args);
                    }

                    if (DoDailyInitialisation != null)
                    {
                        DoDailyInitialisation.Invoke(this, args);
                    }

                    if (StartOfDay != null)
                    {
                        StartOfDay.Invoke(this, args);
                    }

                    if (Today.Day == 1 && StartOfMonth != null)
                    {
                        StartOfMonth.Invoke(this, args);
                    }

                    if (Today.DayOfYear == 1 && StartOfYear != null)
                    {
                        StartOfYear.Invoke(this, args);
                    }

                    if (Today.DayOfWeek == DayOfWeek.Sunday && StartOfWeek != null)
                    {
                        StartOfWeek.Invoke(this, args);
                    }

                    if (Today.DayOfWeek == DayOfWeek.Saturday && EndOfWeek != null)
                    {
                        EndOfWeek.Invoke(this, args);
                    }

                    if (DoManagement != null)
                    {
                        DoManagement.Invoke(this, args);
                    }

                    if (DoEnergyArbitration != null)
                    {
                        DoEnergyArbitration.Invoke(this, args);
                    }

                    if (DoSoilWaterMovement != null)
                    {
                        DoSoilWaterMovement.Invoke(this, args);
                    }

                    if (DoSoilTemperature != null)
                    {
                        DoSoilTemperature.Invoke(this, args);
                    }

                    if (DoSoilOrganicMatter != null)
                    {
                        DoSoilOrganicMatter.Invoke(this, args);
                    }

                    if (DoSurfaceOrganicMatterDecomposition != null)
                    {
                        DoSurfaceOrganicMatterDecomposition.Invoke(this, args);
                    }

                    if (DoWaterArbitration != null)
                    {
                        DoWaterArbitration.Invoke(this, args);
                    }

                    if (DoPhenology != null)
                    {
                        DoPhenology.Invoke(this, args);
                    }

                    if (DoPotentialPlantGrowth != null)
                    {
                        DoPotentialPlantGrowth.Invoke(this, args);
                    }

                    if (DoPotentialPlantPartioning != null)
                    {
                        DoPotentialPlantPartioning.Invoke(this, args);
                    }

                    if (DoNutrientArbitration != null)
                    {
                        DoNutrientArbitration.Invoke(this, args);
                    }

                    if (DoActualPlantPartioning != null)
                    {
                        DoActualPlantPartioning.Invoke(this, args);
                    }

                    if (DoActualPlantGrowth != null)
                    {
                        DoActualPlantGrowth.Invoke(this, args);
                    }

                    if (DoPlantGrowth != null)
                    {
                        DoPlantGrowth.Invoke(this, args);
                    }

                    if (DoUpdate != null)
                    {
                        DoUpdate.Invoke(this, args);
                    }

                    if (DoManagementCalculations != null)
                    {
                        DoManagementCalculations.Invoke(this, args);
                    }

                    if (DoStock != null)
                    {
                        DoStock.Invoke(this, args);
                    }

                    if (DoLifecycle != null)
                    {
                        DoLifecycle.Invoke(this, args);
                    }

                    if (DoReportCalculations != null)
                    {
                        DoReportCalculations.Invoke(this, args);
                    }

                    if (Today == EndDate && EndOfSimulation != null)
                    {
                        EndOfSimulation.Invoke(this, args);
                    }

                    if (Today.Day == 31 && Today.Month == 12 && EndOfYear != null)
                    {
                        EndOfYear.Invoke(this, args);
                    }

                    if (Today.AddDays(1).Day == 1 && EndOfMonth != null) // is tomorrow the start of a new month?
                    {
                        // WholeFarm events performed before APSIM EndOfMonth
                        if (WFUpdatePasture != null)
                        {
                            WFUpdatePasture.Invoke(this, args);
                        }
                        if (WFDoCutAndCarry != null)
                        {
                            WFDoCutAndCarry.Invoke(this, args);
                        }
                        if (WFAnimalBreeding != null)
                        {
                            WFAnimalBreeding.Invoke(this, args);
                        }
                        if (WFPotentialIntake != null)
                        {
                            WFPotentialIntake.Invoke(this, args);
                        }
                        if (WFGetResourcesRequired != null)
                        {
                            WFGetResourcesRequired.Invoke(this, args);
                        }
                        if (WFAnimalMilkProduction != null)
                        {
                            WFAnimalMilkProduction.Invoke(this, args);
                        }
                        if (WFAnimalWeightGain != null)
                        {
                            WFAnimalWeightGain.Invoke(this, args);
                        }
                        if (WFAnimalDeath != null)
                        {
                            WFAnimalDeath.Invoke(this, args);
                        }
                        if (WFAnimalMilking != null)
                        {
                            WFAnimalMilking.Invoke(this, args);
                        }
                        if (WFAnimalManage != null)
                        {
                            WFAnimalManage.Invoke(this, args);
                        }
                        if (WFAnimalStock != null)
                        {
                            WFAnimalStock.Invoke(this, args);
                        }
                        if (WFAnimalSell != null)
                        {
                            WFAnimalSell.Invoke(this, args);
                        }
                        if (WFAgeResources != null)
                        {
                            WFAgeResources.Invoke(this, args);
                        }

                        EndOfMonth.Invoke(this, args);
                    }

                    if (EndOfDay != null)
                    {
                        EndOfDay.Invoke(this, args);
                    }

                    if (DoReport != null)
                    {
                        DoReport.Invoke(this, args);
                    }

                    Today = Today.AddDays(1);
                }
                Summary.WriteMessage(this, "Simulation terminated normally");
            }
            catch (Exception ex)
            {
                Summary.WriteMessage(this, "Simulation terminated due to exception: " + ex.Message);
                // Is there a good mechanism for letting our invoker know that an error has occurred?
                // Throwing this back to the caller doesn't seem to work. This seems to be a consequence
                // of the Invoke method used to call us crossing the native/managed boundary. I'm not
                // sure why this is so...
                // throw ex;
            }
        }
Ejemplo n.º 25
0
 public EndOfDay Insert(EndOfDay record)
 {
     return(this.adapter.Insert(record));
 }
Ejemplo n.º 26
0
 public EndOfDay Update(EndOfDay record)
 {
     return(this.adapter.Update(record));
 }
Ejemplo n.º 27
0
 public void Delete(EndOfDay record)
 {
     this.repository.Delete(record);
 }
Ejemplo n.º 28
0
 public EndOfDay Insert(EndOfDay record)
 {
     return(this.repository.Insert(record));
 }
Ejemplo n.º 29
0
        private void OnDoCommence(object sender, CommenceArgs e)
        {
            Today = StartDate;

            if (DoInitialSummary != null)
            {
                DoInitialSummary.Invoke(this, args);
            }

            if (StartOfSimulation != null)
            {
                StartOfSimulation.Invoke(this, args);
            }

            if (CLEMInitialiseResource != null)
            {
                CLEMInitialiseResource.Invoke(this, args);
            }

            if (CLEMInitialiseActivity != null)
            {
                CLEMInitialiseActivity.Invoke(this, args);
            }

            if (FinalInitialise != null)
            {
                FinalInitialise.Invoke(this, args);
            }

            if (CLEMValidate != null)
            {
                CLEMValidate.Invoke(this, args);
            }

            while (Today <= EndDate && (e.CancelToken == null || !e.CancelToken.IsCancellationRequested))
            {
                if (DoWeather != null)
                {
                    DoWeather.Invoke(this, args);
                }

                if (DoDailyInitialisation != null)
                {
                    DoDailyInitialisation.Invoke(this, args);
                }

                if (StartOfDay != null)
                {
                    StartOfDay.Invoke(this, args);
                }

                if (Today.Day == 1 && StartOfMonth != null)
                {
                    StartOfMonth.Invoke(this, args);
                }

                if (Today.DayOfYear == 1 && StartOfYear != null)
                {
                    StartOfYear.Invoke(this, args);
                }

                if (Today.DayOfWeek == DayOfWeek.Sunday && StartOfWeek != null)
                {
                    StartOfWeek.Invoke(this, args);
                }

                if (DoManagement != null)
                {
                    DoManagement.Invoke(this, args);
                }

                if (DoPestDiseaseDamage != null)
                {
                    DoPestDiseaseDamage.Invoke(this, args);
                }

                if (DoEnergyArbitration != null)
                {
                    DoEnergyArbitration.Invoke(this, args);
                }

                if (DoSoilWaterMovement != null)
                {
                    DoSoilWaterMovement.Invoke(this, args);
                }

                if (DoSoilTemperature != null)
                {
                    DoSoilTemperature.Invoke(this, args);
                }

                if (DoSoilOrganicMatter != null)
                {
                    DoSoilOrganicMatter.Invoke(this, args);
                }

                if (DoSurfaceOrganicMatterDecomposition != null)
                {
                    DoSurfaceOrganicMatterDecomposition.Invoke(this, args);
                }

                if (DoUpdateWaterDemand != null)
                {
                    DoUpdateWaterDemand.Invoke(this, args);
                }

                if (DoWaterArbitration != null)
                {
                    DoWaterArbitration.Invoke(this, args);
                }

                if (PrePhenology != null)
                {
                    PrePhenology.Invoke(this, args);
                }

                if (DoPhenology != null)
                {
                    DoPhenology.Invoke(this, args);
                }

                if (DoPotentialPlantGrowth != null)
                {
                    DoPotentialPlantGrowth.Invoke(this, args);
                }

                if (DoPotentialPlantPartioning != null)
                {
                    DoPotentialPlantPartioning.Invoke(this, args);
                }

                if (DoNutrientArbitration != null)
                {
                    DoNutrientArbitration.Invoke(this, args);
                }

                if (DoActualPlantPartioning != null)
                {
                    DoActualPlantPartioning.Invoke(this, args);
                }

                if (DoActualPlantGrowth != null)
                {
                    DoActualPlantGrowth.Invoke(this, args);
                }

                if (DoStock != null)
                {
                    DoStock.Invoke(this, args);
                }

                if (DoLifecycle != null)
                {
                    DoLifecycle.Invoke(this, args);
                }

                if (DoUpdate != null)
                {
                    DoUpdate.Invoke(this, args);
                }

                if (DoManagementCalculations != null)
                {
                    DoManagementCalculations.Invoke(this, args);
                }

                if (DoReportCalculations != null)
                {
                    DoReportCalculations.Invoke(this, args);
                }

                if (Today.DayOfWeek == DayOfWeek.Saturday && EndOfWeek != null)
                {
                    EndOfWeek.Invoke(this, args);
                }

                if (Today.Day == 31 && Today.Month == 12 && EndOfYear != null)
                {
                    EndOfYear.Invoke(this, args);
                }

                if (Today.AddDays(1).Day == 1 && EndOfMonth != null) // is tomorrow the start of a new month?
                {
                    // CLEM events performed before APSIM EndOfMonth
                    if (CLEMStartOfTimeStep != null)
                    {
                        CLEMStartOfTimeStep.Invoke(this, args);
                    }
                    if (CLEMUpdateLabourAvailability != null)
                    {
                        CLEMUpdateLabourAvailability.Invoke(this, args);
                    }
                    if (CLEMUpdatePasture != null)
                    {
                        CLEMUpdatePasture.Invoke(this, args);
                    }
                    if (CLEMPastureReady != null)
                    {
                        CLEMPastureReady.Invoke(this, args);
                    }
                    if (CLEMDoCutAndCarry != null)
                    {
                        CLEMDoCutAndCarry.Invoke(this, args);
                    }
                    if (CLEMAnimalBreeding != null)
                    {
                        CLEMAnimalBreeding.Invoke(this, args);
                    }
                    if (CLEMAnimalMilkProduction != null)
                    {
                        CLEMAnimalMilkProduction.Invoke(this, args);
                    }
                    if (CLEMPotentialIntake != null)
                    {
                        CLEMPotentialIntake.Invoke(this, args);
                    }
                    if (CLEMGetResourcesRequired != null)
                    {
                        CLEMGetResourcesRequired.Invoke(this, args);
                    }
                    if (CLEMAnimalWeightGain != null)
                    {
                        CLEMAnimalWeightGain.Invoke(this, args);
                    }
                    if (CLEMCalculateManure != null)
                    {
                        CLEMCalculateManure.Invoke(this, args);
                    }
                    if (CLEMCollectManure != null)
                    {
                        CLEMCollectManure.Invoke(this, args);
                    }
                    if (CLEMAnimalDeath != null)
                    {
                        CLEMAnimalDeath.Invoke(this, args);
                    }
                    if (CLEMAnimalMilking != null)
                    {
                        CLEMAnimalMilking.Invoke(this, args);
                    }
                    if (CLEMCalculateEcologicalState != null)
                    {
                        CLEMCalculateEcologicalState.Invoke(this, args);
                    }
                    if (CLEMAnimalManage != null)
                    {
                        CLEMAnimalManage.Invoke(this, args);
                    }
                    if (CLEMAnimalStock != null)
                    {
                        CLEMAnimalStock.Invoke(this, args);
                    }
                    if (CLEMAnimalSell != null)
                    {
                        CLEMAnimalSell.Invoke(this, args);
                    }
                    if (CLEMDetachPasture != null)
                    {
                        CLEMDetachPasture.Invoke(this, args);
                    }
                    if (CLEMHerdSummary != null)
                    {
                        CLEMHerdSummary.Invoke(this, args);
                    }
                    if (CLEMAgeResources != null)
                    {
                        CLEMAgeResources.Invoke(this, args);
                    }
                    if (CLEMAnimalBuy != null)
                    {
                        CLEMAnimalBuy.Invoke(this, args);
                    }
                    if (CLEMEndOfTimeStep != null)
                    {
                        CLEMEndOfTimeStep.Invoke(this, args);
                    }
                    EndOfMonth.Invoke(this, args);
                }

                if (EndOfDay != null)
                {
                    EndOfDay.Invoke(this, args);
                }

                if (DoReport != null)
                {
                    DoReport.Invoke(this, args);
                }

                Today = Today.AddDays(1);
            }
            Today = EndDate;

            if (EndOfSimulation != null)
            {
                EndOfSimulation.Invoke(this, args);
            }

            Summary?.WriteMessage(this, "Simulation terminated normally");
        }
Ejemplo n.º 30
0
 public EndOfDay Update(EndOfDay record)
 {
     return(this.repository.Update(record));
 }