private void GetValuesFromProperty(object obj, AnalysisDictionary dictionaryUsedForAnalysis)
        {
            PropertyInfo[] properties = obj.GetType().GetProperties();

            foreach (PropertyInfo property in properties)
            {
                object o = property.GetValue(obj, null);

                var objAnalysisAttribute = new AnalysisAttribute {
                    Value = Convert.ToString(o)
                };

                dictionaryUsedForAnalysis.Add(property.Name, objAnalysisAttribute);
            }
        }
Esempio n. 2
0
        private void CreateSQLParameterArray(AnalysisDictionary values, out SqlParameter[] sqlParamArray)
        {
            // Period
            var period = new AnalysisAttribute();

            if (values.ContainsKey("Period"))
            {
                period = values["Period"];
            }

            // Start Date
            var startDate = new AnalysisAttribute();

            if (values.ContainsKey("StartDate"))
            {
                startDate = values["StartDate"];
            }

            // End Date
            var endDate = new AnalysisAttribute();

            if (values.ContainsKey("EndDate"))
            {
                endDate = values["EndDate"];
            }

            sqlParamArray = new[]
            {
                new SqlParameter("@Period", SqlDbType.Int)
                {
                    Value = period.Value
                },
                new SqlParameter("@StartDate", SqlDbType.DateTime)
                {
                    Value = startDate.Value
                },
                new SqlParameter("@EndDate", SqlDbType.DateTime)
                {
                    Value = endDate.Value
                }
            };
        }
        private void CreateSQLParameterArray(AnalysisDictionary values, out SqlParameter[] sqlParamArray)
        {
            int startTimeInMns = 420;
            int endTimeInMns   = 1140;

            if (values.ContainsKey("Startofworkingday"))
            {
                AnalysisAttribute startTimeValue = values["Startofworkingday"];
                string[]          startTimeVal = startTimeValue.Value.Split(':');
                int hourResult, minuteResult;
                if (int.TryParse(startTimeVal[0], out hourResult) && int.TryParse(startTimeVal[1], out minuteResult))
                {
                    startTimeInMns = (hourResult * 60) + minuteResult;
                }
            }

            if (values.ContainsKey("Endofworkingday"))
            {
                AnalysisAttribute endTimeValue = values["Endofworkingday"];
                string[]          endTimeVal   = endTimeValue.Value.Split(':');

                int hourResult, minuteResult;
                if (int.TryParse(endTimeVal[0], out hourResult) && int.TryParse(endTimeVal[1], out minuteResult))
                {
                    endTimeInMns = (hourResult * 60) + minuteResult;
                }
            }

            sqlParamArray = new[]
            {
                new SqlParameter("@starttime", SqlDbType.Int)
                {
                    Value = startTimeInMns
                },
                new SqlParameter("@endtime", SqlDbType.Int)
                {
                    Value = endTimeInMns
                }
            };
        }
        private void GetValuesFromProperty(object obj, AnalysisDictionary dictionaryUsedForAnalysis)
        {
            PropertyInfo[] properties = obj.GetType().GetProperties();

            foreach (PropertyInfo property in properties)
            {
                object o = property.GetValue(obj, null);

                var objAnalysisAttribute = new AnalysisAttribute { Value = Convert.ToString(o) };

                dictionaryUsedForAnalysis.Add(property.Name, objAnalysisAttribute);
            }
        }
Esempio n. 5
0
        private void GetTotalNumberOfRequests(
            AnalysisDictionary analysisResult,
            string exclusionFilter,
            DateTime startDate,
            DateTime endDate,
            int period,
            int threshold,
            int costPerRequest,
            string currencySymbol)
        {
            try
            {
                using (var connection = new SqlConnection(this.ConnectionString))
                {
                    connection.Open();
                    var command = new SqlCommand(GetTotalNumberOfRequestsSql(exclusionFilter), connection);
                    command.Parameters.Add("EndDate", SqlDbType.Date).Value   = endDate.AddDays(1);
                    command.Parameters.Add("StartDate", SqlDbType.Date).Value = startDate;
                    command.Parameters.Add("Threshold", SqlDbType.Int).Value  = threshold;

                    using (var reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            // Total Number Of One Off Requests
                            var totalNumberOfOneOffRequest = Convert.ToInt32(reader["TotalNumberOfOneOffRequest"]);
                            var analysisAttribute          = new AnalysisAttribute
                            {
                                Value = string.Format("{0:n0}", totalNumberOfOneOffRequest)
                            };

                            analysisResult.Add("TotalNumberOfOneOffRequest", analysisAttribute);

                            // Total Number Of Requests
                            var totalNumberOfRequests = Convert.ToInt32(reader["TotalNumberOfRequests"]);
                            analysisAttribute = new AnalysisAttribute
                            {
                                Value = string.Format("{0:n0}", totalNumberOfRequests)
                            };
                            analysisResult.Add("TotalNumberOfRequests", analysisAttribute);

                            // Total Number Of Requests in a year
                            analysisAttribute = new AnalysisAttribute
                            {
                                Value = string.Format("{0:n0}", 365 * totalNumberOfRequests / period)
                            };
                            analysisResult.Add("TotalNumberOfRequestsInAYear", analysisAttribute);

                            // Total Number Of One Off Requests in a year
                            var totalNumberOfOneOffRequestInAYear = 365 * totalNumberOfOneOffRequest / period;
                            analysisAttribute = new AnalysisAttribute
                            {
                                Value = string.Format("{0:n0}", 365 * totalNumberOfOneOffRequest / period)
                            };
                            analysisResult.Add("TotalNumberOfOneOffRequestInAYear", analysisAttribute);

                            // Total Number Of One Off Requests Cost
                            analysisAttribute = new AnalysisAttribute
                            {
                                Value = string.Format("{0}{1:n0}", currencySymbol, totalNumberOfOneOffRequestInAYear * costPerRequest)
                            };

                            analysisResult.Add("TotalNumberOfOneOffRequestCost", analysisAttribute);

                            // Total Number Of One Off Requests in a year Cost
                            analysisAttribute = new AnalysisAttribute
                            {
                                Value = string.Format("{0}{1:n0}", currencySymbol, totalNumberOfOneOffRequest * costPerRequest)
                            };

                            analysisResult.Add("TotalNumberOfOneOffRequestInAYearCost", analysisAttribute);
                        }

                        reader.Close();
                    }
                }
            }
            catch (Exception e)
            {
                // Need logging
                throw new Exception("Could not get total number of  requests", e);
            }
        }