private void GetTotalNumberOfRequests(ShoppingAnalysisViewModel shoppingAnalysisViewModel)
        {
            try
            {
                using (var connection = new SqlConnection(this.connectionString))
                {
                    connection.Open();
                    var command = new SqlCommand(GetTotalNumberOfRequestsSql(), connection);
                    command.Parameters.Add("ShopEndDate", SqlDbType.Date).Value = shoppingAnalysisViewModel.ShopEndDate.AddDays(1);
                    command.Parameters.Add("ShopStartDate", SqlDbType.Date).Value = shoppingAnalysisViewModel.ShopStartDate;
                    command.Parameters.Add("Threshold", SqlDbType.Int).Value = shoppingAnalysisViewModel.Threshold;

                    using (var reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            shoppingAnalysisViewModel.TotalNumberOfOneOffRequests =
                                Convert.ToInt32(reader["TotalNumberOfOneOffRequests"]);

                            shoppingAnalysisViewModel.TotalNumberOfRequests =
                                Convert.ToInt32(reader["TotalNumberOfRequests"]);
                        }

                        reader.Close();
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw new Exception("Could not get total number of  requests", e);
            }
        }
Beispiel #2
0
        public List <ShoppingProgram> Build(ShoppingAnalysisViewModel shoppingAnalysisViewModel)
        {
            var ds = GetTopProgramList(
                shoppingAnalysisViewModel.ShopStartDate,
                shoppingAnalysisViewModel.ShopEndDate,
                shoppingAnalysisViewModel.MaxNoOfProgramsToReportOn,
                shoppingAnalysisViewModel.Threshold);

            var shoppingProgramList = new List <ShoppingProgram>();
            var dataTable           = ds.Tables[0];

            foreach (DataRow row in dataTable.Rows)
            {
                var shoppingProgram = new ShoppingProgram
                {
                    AttributeValue = Convert.ToString(row["attributevalue"]),
                    ProgramName    = Convert.ToString(row["programname"]),
                    TotalCount     = Convert.ToInt32(row["totalcount"]),
                    PackageName    = Convert.ToString(row["packagename"])
                };

                shoppingProgramList.Add(shoppingProgram);
            }

            return(shoppingProgramList);
        }
        private void GetTotalNumberOfRequests(ShoppingAnalysisViewModel shoppingAnalysisViewModel)
        {
            try
            {
                using (var connection = new SqlConnection(this.connectionString))
                {
                    connection.Open();
                    var command = new SqlCommand(GetTotalNumberOfRequestsSql(), connection);
                    command.Parameters.Add("ShopEndDate", SqlDbType.Date).Value   = shoppingAnalysisViewModel.ShopEndDate.AddDays(1);
                    command.Parameters.Add("ShopStartDate", SqlDbType.Date).Value = shoppingAnalysisViewModel.ShopStartDate;
                    command.Parameters.Add("Threshold", SqlDbType.Int).Value      = shoppingAnalysisViewModel.Threshold;

                    using (var reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            shoppingAnalysisViewModel.TotalNumberOfOneOffRequests =
                                Convert.ToInt32(reader["TotalNumberOfOneOffRequests"]);

                            shoppingAnalysisViewModel.TotalNumberOfRequests =
                                Convert.ToInt32(reader["TotalNumberOfRequests"]);
                        }

                        reader.Close();
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw new Exception("Could not get total number of  requests", e);
            }
        }
        public List<ShoppingProgram> Build(ShoppingAnalysisViewModel shoppingAnalysisViewModel)
        {
            var ds = GetTopProgramList(
                shoppingAnalysisViewModel.ShopStartDate,
                shoppingAnalysisViewModel.ShopEndDate,
                shoppingAnalysisViewModel.MaxNoOfProgramsToReportOn,
                shoppingAnalysisViewModel.Threshold);

            var shoppingProgramList = new List<ShoppingProgram>();
            var dataTable = ds.Tables[0];
            foreach (DataRow row in dataTable.Rows)
            {
                var shoppingProgram = new ShoppingProgram
                    {
                        AttributeValue = Convert.ToString(row["attributevalue"]),
                        ProgramName = Convert.ToString(row["programname"]),
                        TotalCount = Convert.ToInt32(row["totalcount"]),
                        PackageName = Convert.ToString(row["packagename"])
                    };

                shoppingProgramList.Add(shoppingProgram);
            }

            return shoppingProgramList;
        }
        internal ShoppingAnalysisViewModel Build()
        {
            Log.Info("Building shopping analysis data.");

            var shoppingAnalysisResults = new ShoppingAnalysisViewModel
            {
                CostPerRequest = this.shoppingInputModel.CostPerRequest,
                ShopEndDate = this.shoppingInputModel.ShopEndDate,
                ManHourSavings = this.shoppingInputModel.ManHourSavings,
                NumberOfActiveMachines = this.shoppingInputModel.NumberOfActiveMachines,
                Period = this.shoppingInputModel.Period,
                ShopStartDate = this.shoppingInputModel.ShopStartDate,
                Threshold = this.shoppingInputModel.Threshold,
                MaxNoOfProgramsToReportOn = this.shoppingInputModel.MaxNoOfProgramsToReportOn
            };

            // Total number of requests
            GetTotalNumberOfRequests(shoppingAnalysisResults);

            Log.Info("Analysis data building completed.");

            return shoppingAnalysisResults;
        }
        internal ShoppingAnalysisViewModel Build()
        {
            Log.Info("Building shopping analysis data.");

            var shoppingAnalysisResults = new ShoppingAnalysisViewModel
            {
                CostPerRequest         = this.shoppingInputModel.CostPerRequest,
                ShopEndDate            = this.shoppingInputModel.ShopEndDate,
                ManHourSavings         = this.shoppingInputModel.ManHourSavings,
                NumberOfActiveMachines = this.shoppingInputModel.NumberOfActiveMachines,
                Period                    = this.shoppingInputModel.Period,
                ShopStartDate             = this.shoppingInputModel.ShopStartDate,
                Threshold                 = this.shoppingInputModel.Threshold,
                MaxNoOfProgramsToReportOn = this.shoppingInputModel.MaxNoOfProgramsToReportOn
            };

            // Total number of requests
            GetTotalNumberOfRequests(shoppingAnalysisResults);

            Log.Info("Analysis data building completed.");

            return(shoppingAnalysisResults);
        }