Beispiel #1
0
        /// <summary>
        /// the event handler for all picture boxes in the table layout panel calendar that allows the user to toggle back and forth between having a day be a planting day or not
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CommonClick_TogglePlantingDay(object sender, EventArgs e)
        {
            ResponseBusiness responseBusiness = new ResponseBusiness(_responseRepository);
            Response         response;

            using (responseBusiness)
            {
                response = responseBusiness.SelectAll();
            }

            PictureBox picture = sender as PictureBox;

            TogglePlantingDay(sender, response);

            responseBusiness = null;

            responseBusiness = new ResponseBusiness(_responseRepository);

            using (responseBusiness)
            {
                response = responseBusiness.SelectAll();
            }

            FillWeatherDays(response, AppEnum.ManagerAction.TogglePlantingDay);
        }
        private void TestingMethods()
        {
            ResponseBusiness responseBusiness = new ResponseBusiness(responseRepository);

            Response response;

            using (responseBusiness)
            {
                response = responseBusiness.SelectAll();
            }

            foreach (var fd in response.Forecast.Simpleforecast.Forecastdays.Forecastday)
            {
                Console.WriteLine(fd.Period);
                Console.WriteLine(fd.Date.Weekday);
                Console.WriteLine(fd.Pop);
                Console.WriteLine(fd.IsPlantingDay);
            }

            ResponseBusiness responseBusiness2 = new ResponseBusiness(responseRepository);
            Forecastday      forecastDay;

            using (responseBusiness2)
            {
                forecastDay = responseBusiness2.SelectByPeriod(1);
            }

            Console.WriteLine($"We found the first day! {forecastDay.Date.Weekday}, {forecastDay.Date.Monthname} {forecastDay.Date.Day}");

            Console.WriteLine("Press any key to exit");

            Console.ReadKey();
        }
        private void TestingAChange()
        {
            ResponseBusiness responseBusiness = new ResponseBusiness(responseRepository);

            Response response;

            using (responseBusiness)
            {
                response = responseBusiness.SelectAll();
            }

            long lengthOfForecast = response.Forecast.Simpleforecast.Forecastdays.Forecastday.LongCount();

            long oneLessThanFullList = lengthOfForecast - 1;

            for (long index = 0; index < oneLessThanFullList; index++)
            {
                if (response.Forecast.Simpleforecast.Forecastdays.Forecastday[(int)index + 1].Pop >= 50)
                {
                    response.Forecast.Simpleforecast.Forecastdays.Forecastday[(int)index].IsPlantingDay = true;
                }
            }

            foreach (var fd in response.Forecast.Simpleforecast.Forecastdays.Forecastday)
            {
                Console.WriteLine(fd.Date.Weekday);
                Console.WriteLine(fd.Pop);
                Console.WriteLine(fd.IsPlantingDay);
                Console.WriteLine();
            }
        }
Beispiel #4
0
        /// <summary>
        /// Calls the AssignRainyDay() method from the business class repository
        /// </summary>
        private void AssignRainyDays()
        {
            ResponseBusiness responseBusiness = new ResponseBusiness(_responseRepository);

            using (responseBusiness)
            {
                responseBusiness.AssignIsRainyDay();
            }
        }
Beispiel #5
0
        /// <summary>
        /// removes all images from the table layout panel for the calendar, but keeps the days of the week visible
        /// </summary>
        private void ClearTable()
        {
            ResponseBusiness responseBusiness = new ResponseBusiness(_responseRepository);
            Response         response;

            using (responseBusiness)
            {
                response = responseBusiness.SelectAll();
            }

            FillWeatherDays(response, AppEnum.ManagerAction.CalendarOnly);
        }
Beispiel #6
0
        /// <summary>
        /// instantiates a business repository and uses that to apply the business logic for planting days, and saves that business repository to a reponse object, and passes that into the method that fills the table layout panel calendar with weather and planting days both
        /// </summary>
        private void AutoFillPlantingDays()
        {
            ResponseBusiness responseBusiness = new ResponseBusiness(_responseRepository);
            Response         response;

            using (responseBusiness)
            {
                responseBusiness.AutoFillPlantingDays();
                response = responseBusiness.SelectAll();
            }

            FillWeatherDays(response, AppEnum.ManagerAction.AutoFillPlantingDays);
        }
Beispiel #7
0
        /// <summary>
        /// Fills the calendar with icons for the weather
        /// </summary>
        private void SetWeatherIcons()
        {
            ResponseBusiness responseBusiness = new ResponseBusiness(_responseRepository);
            Response         response;


            using (responseBusiness)
            {
                response = responseBusiness.SelectAll();
            }

            FillWeatherDays(response, AppEnum.ManagerAction.GetWeather);
        }
        private void AutoFillPlantingDays()
        {
            //
            // instantiate a responseBusiness class and pass the repository into it
            //
            ResponseBusiness responseBusiness = new ResponseBusiness(responseRepository);

            using (responseBusiness)
            {
                responseBusiness.AutoFillPlantingDays();
            }

            //TODO: View: display the updated planting days dynamically
        }
Beispiel #9
0
        /// <summary>
        /// Define a response object from the repository and use it to fill the calendar with the names of the days of the week, but nothing else
        /// </summary>
        private void SetBlankCalendar()
        {
            // get the weather, but only display the days for now
            // b/c more fun for a user to see the process from blank calendar to
            // a calendar filled with weather icons
            ResponseBusiness responseBusiness = new ResponseBusiness(_responseRepository);
            Response         response;

            using (responseBusiness)
            {
                response = responseBusiness.SelectAll();
            }

            FillWeatherDays(response, AppEnum.ManagerAction.CalendarOnly);
        }
        private void GetWeather()
        {
            //
            // instantiate a responseBusiness class and pass the repository into it
            //
            ResponseBusiness responseBusiness = new ResponseBusiness(responseRepository);
            Response         response;

            using (responseBusiness)
            {
                responseBusiness.AssignIsRainyDay();
                response = responseBusiness.SelectAll();
                //TODO: View: display fresh API pull form
            }
        }
        private void TogglePlantingDay()
        {
            //
            // instantiate a responseBusiness class and pass the repository into it
            //
            ResponseBusiness responseBusiness = new ResponseBusiness(responseRepository);
            Response         response;

            using (responseBusiness)
            {
                //TODO: View: update the planting day according to which day was clicked
                //responseBusiness.TogglePlantingDay(event handler?);
                responseBusiness.TogglePlantingDay(1);
                responseBusiness.Save();
            }

            //TODO: View: display the updated planting days dynamically
        }
Beispiel #12
0
        public static void Initialize()
        {
            if (!_bInitialized)
            {
                _bRunThread   = true;
                _prcoessEvent = new ManualResetEventSlim(true);
                _waitTime     = Convert.ToInt32(ConfigurationManager.AppSettings["WaitTime"].ToString());
                iMaxRows      = Convert.ToInt32(ConfigurationManager.AppSettings["MaxRows"].ToString());

                _exchangeClient = new ExchangeClient();
                _exchangeClient.InitialiseExchange(0);
                m_SectorData = new Sector203Data();

                objResponseBusiness = ResponseBusiness.ResponseBusinessInstance;
                _processThread      = new Thread(ProcessMessages);
                _processThread.Start();
            }
        }
Beispiel #13
0
        /// <summary>
        /// Iterate through the calendar and find the picture box that matches the sender (the clicked object), and then change that forecast day's IsPlantingDay bool, and updates the picture to reflect that change
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="response"></param>
        private void TogglePlantingDay(object sender, Response response)
        {
            int indexR = 0;

            for (int r = 0; r < tblFreshAPI.RowCount; r++)
            {
                for (int c = 0; c < tblFreshAPI.ColumnCount; c++)
                {
                    Control control = tblFreshAPI.GetControlFromPosition(c, r);

                    Forecastday fd = response.Forecast.Simpleforecast.Forecastdays.Forecastday[indexR];

                    if (control is PictureBox)
                    {
                        PictureBox currentPB = control as PictureBox;

                        if (currentPB == sender)
                        {
                            ResponseBusiness responseBusiness = new ResponseBusiness(_responseRepository);

                            using (responseBusiness)
                            {
                                responseBusiness.TogglePlantingDay(fd.Period);
                            }
                        }
                    }

                    indexR += 1;

                    if (c == 4)
                    {
                        if (r == 0)
                        {
                            indexR = 0;
                        }
                        else if (r == 2)
                        {
                            indexR = 5;
                        }
                    }
                }
            }
        }
Beispiel #14
0
        public IResponseBusiness <Entity.PaymentMethodDetail> Insert(Entity.PaymentMethodDetail entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("entity");
            }

            IResponseBusiness <Entity.PaymentMethodDetail> response = new ResponseBusiness <Entity.PaymentMethodDetail>()
            {
                Entity  = null,
                IsError = true,
                Message = string.Empty
            };

            IResponseValidate validatePayment = Validate(entity);

            if (validatePayment.IsValid)
            {
                _context.PaymentMethodDetails.Add(entity);
                try
                {
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException cex)
                {
                    response.Message = _resourceReacher.GetString("PaymentMethodDetailSaveDbUpdateConcurrencyException");
                }
                catch (DbUpdateException uex)
                {
                    response.Message = _resourceReacher.GetString("PaymentMethodDetailSaveDbUpdateException");
                }
                catch (DbEntityValidationException eex)
                {
                    response.Message = _resourceReacher.GetString("PaymentMethodDetailSaveDbEntityValidationException");
                }
                catch (NotSupportedException sex)
                {
                    response.Message = _resourceReacher.GetString("PaymentMethodDetailSaveNotSupportedException");
                }
                catch (ObjectDisposedException dex)
                {
                    response.Message = _resourceReacher.GetString("PaymentMethodDetailSaveObjectDisposedException");
                }
                catch (InvalidOperationException iex)
                {
                    response.Message = _resourceReacher.GetString("PaymentMethodDetailSaveInvalidOperationException");
                }
                finally
                {
                    if (string.IsNullOrEmpty(response.Message))
                    {
                        response.Entity  = entity;
                        response.IsError = false;
                    }
                }
            }
            else
            {
                response.Message = validatePayment.Message;
            }

            return(response);
        }
Beispiel #15
0
        /// <summary>
        /// Crea un movimiento a partir de una captura de imagen
        /// </summary>
        /// <param name="capture">Entidad que contiene la imagen capturada</param>
        /// <returns><c>IResponseBusiness<Entity.Payment></c></returns>
        /// <exception cref="System.ArgumentNullException">capture</exception>
        public IResponseBusiness <Entity.Payment> InsertCapture(Entity.Capture capture)
        {
            if (capture == null)
            {
                throw new ArgumentNullException("capture");
            }

            IResponseBusiness <Entity.Payment> response = new ResponseBusiness <Entity.Payment>()
            {
                Entity  = null,
                IsError = true,
                Message = string.Empty
            };

            Entity.Payment payment = null;

            if (capture.Payment == null)                //Se crea Payment con valores por defecto
            {
                capture.Payment = new Entity.Payment(); // Se instancia Payment para que la validación de la captura no de error por la falta de Payment
                Business.Capture  captureBusiness = new Business.Capture(_user);
                IResponseValidate validateCapture = captureBusiness.Validate(capture);
                if (validateCapture.IsValid)
                {
                    PaymentMethodDetail paymentMethodDetailBusiness = new PaymentMethodDetail(this._user, _context);
                    Status statusBusiness = new Status(_user, _context);

                    payment                     = new Entity.Payment();
                    payment.Date                = DateTime.Now;
                    payment.Description         = string.Empty;
                    payment.IsScheduled         = false;
                    payment.PaymentMethodDetail = paymentMethodDetailBusiness.GetDefault();
                    payment.PaymentType         = (int)Entity.Enums.PaymentTypes.None;
                    payment.Status              = statusBusiness.GetDefault();
                    payment.User                = this._user;
                    payment.Value               = 0;
                    payment.Captures.Add(capture);
                    capture.Payment = payment;

                    _context.Payments.Add(payment);
                }
                else
                {
                    response.Message = validateCapture.Message;
                }
            }
            else
            {
                payment = capture.Payment;
                _context.Captures.Add(capture);
            }

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException cex)
            {
                response.Message = _resourceReacher.GetString("PaymentSaveDbUpdateConcurrencyException");
            }
            catch (DbUpdateException uex)
            {
                response.Message = _resourceReacher.GetString("PaymentSaveDbUpdateException");
            }
            catch (DbEntityValidationException eex)
            {
                response.Message = _resourceReacher.GetString("PaymentSaveDbEntityValidationException");
            }
            catch (NotSupportedException sex)
            {
                response.Message = _resourceReacher.GetString("PaymentSaveNotSupportedException");
            }
            catch (ObjectDisposedException dex)
            {
                response.Message = _resourceReacher.GetString("PaymentSaveObjectDisposedException");
            }
            catch (InvalidOperationException iex)
            {
                response.Message = _resourceReacher.GetString("PaymentSaveInvalidOperationException");
            }
            finally
            {
                if (string.IsNullOrEmpty(response.Message))
                {
                    response.Entity  = payment;
                    response.IsError = false;
                }
            }

            return(response);
        }