Example #1
0
        /// <summary>
        /// Given a Site Name, a Gateway Name, and possibly a date and time range, return the summaires for that Site Gateway.
        /// If a date and time range was not specified, a default date and time range will be constructed with a one year before, starting from DateTime.Now.
        /// By default the data won't be grouped by, unless specified.
        /// </summary>
        /// <param name="siteName">Site Name</param>
        /// <param name="gatewayName">The Gateway Name / IP (string).</param>
        /// <param name="startingDate">Optional. The Starting Date Range.</param>
        /// <param name="endingDate">Optional. The Ending Date Range.</param>
        /// <param name="groupBy">Optional. By default it is set to DontGroup. Can be Set to any values of the same class of enums.</param>
        /// <returns>List of CallsSummaryForGateway objects for that Site Gateway.</returns>
        public List <CallsSummaryForGateway> GetBySiteAndGateway(string siteName, string gatewayName, DateTime?startingDate = null, DateTime?endingDate = null, Globals.CallsSummaryForGateway.GroupBy groupBy = Globals.CallsSummaryForGateway.GroupBy.DontGroup)
        {
            try
            {
                var summaries = GetBySite(siteName, startingDate, endingDate, groupBy);

                if (summaries.Any())
                {
                    summaries = summaries.Where(item => String.Equals(item.GatewayName, gatewayName, StringComparison.CurrentCultureIgnoreCase)).ToList();
                    return(summaries.OrderBy(item => item.Year).ThenBy(item => item.Month).ToList());
                }

                return(summaries);
            }
            catch (Exception ex)
            {
                throw ex.InnerException;
            }
        }
Example #2
0
        public List <CallsSummaryForGateway> GetBySite(string siteName, DateTime?startingDate = null, DateTime?endingDate = null, Globals.CallsSummaryForGateway.GroupBy groupBy = Globals.CallsSummaryForGateway.GroupBy.DontGroup)
        {
            DateTime fromDate, toDate;

            if (startingDate == null || endingDate == null)
            {
                fromDate = new DateTime(DateTime.Now.Year - 1, DateTime.Now.Month, 1);
                toDate   = DateTime.Now;
            }
            else
            {
                //Assign the beginning of date. Month to the startingDate and the end of it to the endingDate.
                fromDate = (DateTime)startingDate;
                toDate   = (DateTime)endingDate;
            }

            try
            {
                var sql = _summariesSqlQueries.GetCallsSummariesForSite(
                    siteName,
                    fromDate.ConvertDate(true),
                    toDate.ConvertDate(true),
                    _dbTables
                    );

                var summaries = base.GetAll(sql) ?? (new List <CallsSummaryForGateway>());

                if (summaries.Any())
                {
                    if (groupBy == Globals.CallsSummaryForGateway.GroupBy.GatewayNameOnly)
                    {
                        GroupByGateway(ref summaries);
                    }
                }

                return(summaries.ToList());
            }
            catch (Exception ex)
            {
                throw ex.InnerException;
            }
        }