Пример #1
0
        private void addRecord(
            string name,
            DateTime dateCreated,
            bool isCrawler,
            DateParameter dateParam,
            string groupBy,
            string showDataFor,
            string belongsToGroup)
        {
            //if (groupBy.IsNullOrWhiteSpace())
            //    groupBy = DashBoardConstants.YEAR;

            string _userName = string.Format("{0}", name);

            DashBoardSingle ds = new DashBoardSingle(
                _userName,
                dateCreated,
                isCrawler,
                showDataFor,
                0,
                dateParam.BeginDate,
                dateParam.EndDate,
                groupBy,
                showDataFor,
                belongsToGroup);

            DataAll.DataDetail.Add(ds);
        }
Пример #2
0
 /// <summary>
 /// This groups the child item
 /// </summary>
 /// <param name="dbs"></param>
 /// <param name="nextDataType"></param>
 /// <param name="nextDataTypeAfterNext"></param>
 private void groupTheChild(DashBoardSingle dbs, string nextDataType, string nextDataTypeAfterNext)
 {
     foreach (var item in dbs.DataGrouped)
     {
         item.DataGrouped = sql(item, nextDataType, nextDataTypeAfterNext);
     }
 }
Пример #3
0
        /// <summary>
        /// Note. After this, the DataGroup will contain the groups of DataDetail
        /// </summary>
        /// <param name="fixedData"></param>
        /// <param name="nextGroupBy"></param>
        /// <param name="noOfReccursions"></param>
        /// <param name="thisGroupDataType">Eg. Year, Year-Month etc the constants listed to identify where you are coming from</param>
        /// <returns></returns>
        private List <DashBoardSingle> sql(DashBoardSingle dbs, string currGroupBy, string nextGroupBy)
        {
            if (dbs.IsNull())
            {
                return(null);
            }

            var listOfDataGrouped = dbs
                                    .DataDetail
                                    .OrderBy(x => x.Key)
                                    .GroupBy(x => x.Key)
                                    .Select(y =>
                                            new DashBoardSingle
            {
                Amount = GetDataFor(y.First().Key,
                                    dbs.DataDetail)
                         .Count(),

                //we need to give a new key each time
                Key = makeKey(nextGroupBy,
                              y.First().DateOfTrx,
                              y.First().GroupBy,
                              y.First().Name),

                Name = y.First().Name,

                NameCalculated = makeName(y.First().DateOfTrx,
                                          currGroupBy,
                                          y.First().ShowDataFor,
                                          y.First().Name),
                NameForSorting = makeNameForSorting(y.First().DateOfTrx,
                                                    currGroupBy,
                                                    y.First().ShowDataFor,
                                                    y.First().Name),

                TotalAmount = dbs.DataDetail.Count(),

                //Percent = y.Count() == 0 ? 0 : (y.Count() / count) & 100,

                DataDetail = GetChildData(
                    y.First().Key,
                    dbs.DataDetail,
                    nextGroupBy,
                    dbs.BeginDate,
                    dbs.EndDate,
                    y.First().BelongsToGroup),                     //this is all the detail for this particular year.

                BeginDate      = dbs.BeginDate,
                EndDate        = dbs.EndDate,
                GroupBy        = currGroupBy,
                ShowDataFor    = y.First().ShowDataFor,
                BelongsToGroup = y.First().BelongsToGroup,
            })
                                    .ToList();


            return(listOfDataGrouped);
        }
Пример #4
0
 private DashBoardSingle FixDataForMain(DashBoardSingle theData)
 {
     if (!theData.DataDetail.IsNullOrEmpty())
     {
         foreach (var item in theData.DataDetail)
         {
             item.Key = makeKey(GroupByConstants.MAIN, item.DateOfTrx, item.ShowDataFor, item.Name);
         }
     }
     return(theData);
 }
Пример #5
0
        public DashBoardSingle AjaxData(DateTime beginDate, DateTime endDate, DateTime dateOfTrx, string showDataBelongingTo, string groupBy, string name)
        {
            DateParameter dateParam = new DateParameter();

            dateParam.BeginDate = beginDate;
            dateParam.EndDate   = endDate;

            DashBoardSingle dbs = GetFinalData(dateParam, dateOfTrx, showDataBelongingTo, groupBy, name);

            return(dbs);
        }
Пример #6
0
        private DashBoardSingle FixDataForYearMonthDayHour(DashBoardSingle theData)
        {
            if (!theData.DataDetail.IsNullOrEmpty())
            {
                foreach (var item in theData.DataDetail)
                {
                    item.Key = makeKey(GroupByConstants.YEAR_MONTH_DAY_HOUR, item.DateOfTrx, item.BelongsToGroup, item.Name);;
                }
            }

            return(theData);
        }
Пример #7
0
        /// <summary>
        /// This fixes the key of the main DataDetail
        /// </summary>
        /// <param name="dbs"></param>
        /// <param name="dataType"></param>
        /// <returns></returns>
        public DashBoardSingle Controller_FixKey(DashBoardSingle dbs, string dataType)
        {
            if (dbs.IsNull())
            {
                return(dbs);
            }

            if (dbs.DataDetail.IsNull())
            {
                return(dbs);
            }

            switch (dataType)
            {
            case GroupByConstants.MAIN:
                dbs = FixDataForMain(dbs);
                break;

            case GroupByConstants.YEAR:
                dbs = FixDataForYear(dbs);
                break;

            case GroupByConstants.YEAR_MONTH:
                dbs = FixDataForYearMonth(dbs);
                break;

            case GroupByConstants.YEAR_MONTH_DAY:
                dbs = FixDataForYearMonthDay(dbs);
                break;

            case GroupByConstants.YEAR_MONTH_DAY_HOUR:
                dbs = FixDataForYearMonthDayHour(dbs);
                break;

            case GroupByConstants.YEAR_MONTH_DAY_HOUR_MINUTE:
                dbs = FixDataForYearMonthDayHourMinute(dbs);
                break;

            case GroupByConstants.YEAR_MONTH_DAY_HOUR_MINUTE_SECOND:
                dbs = FixDataForYearMonthDayHourMinuteSecond(dbs);
                break;


            default:
                break;
            }

            return(dbs);
        }
Пример #8
0
        private static void getDateForGroup(DashBoardSingle item)
        {
            if (item.DataDetail.IsNull())
            {
                return;
            }

            item.DateOfTrx = item.DataDetail.First().DateOfTrx;

            //Now fix the date for the Child
            foreach (var childGroupedData in item.DataGrouped)
            {
                childGroupedData.DateOfTrx = childGroupedData.DataDetail.First().DateOfTrx;
            }
        }
Пример #9
0
        //#region Old Code.


        ///// <summary>
        ///// This is the entery point to the reccurssion
        ///// </summary>
        ///// <param name="dashboradSingleList"></param>
        ///// <param name="forDataType"></param>
        ///// <returns></returns>
        //public DashBoardSingle GetDataGroupedMain(DashBoardSingle dashboradSingleList, string forDataGroup)
        //{

        //    if (dashboradSingleList.IsNull())
        //        return null;

        //    return getDataGrouped(dashboradSingleList, forDataGroup);
        //}


        //private DashBoardSingle getDataGrouped(DashBoardSingle dbs, string forDataGroup)
        //{
        //    dbs = groupData(dbs, DataTypeConstants.MAIN);
        //    return dbs;
        //}


        //private DashBoardSingle groupData(DashBoardSingle dbs, string dataType)
        //{
        //    //all the data has been initialized once you are here.
        //    if (!dbs.DataDetail.IsNullOrEmpty())
        //    {
        //        //this groups data by dataType. Eg. Controller, next is Year
        //        //dbs.DataGrouped is grouped by DataType/MainList
        //        groupDataByMainList(dbs);

        //        //now we walk through all the groups
        //        foreach (DashBoardSingle dataTypeItem in dbs.DataGrouped)
        //        {
        //            //a single DataType Data is passed through
        //            groupDataByYear(dataTypeItem);
        //            //now within the DataGroup/MainList the data is grouped by the year

        //            //this will ensure that when we are doing the main, we only get detailed
        //            //data up to the year.
        //            if (dataType == DataTypeConstants.MAIN)
        //                continue; //go to the next one

        //            if (dataTypeItem.DataGrouped.IsNullOrEmpty())
        //                continue;


        //            foreach (DashBoardSingle yearData in dataTypeItem.DataGrouped)
        //            {
        //                //a single year data is sent
        //                groupDataByMonth(yearData);
        //                //Now within the year, the Data is grouped by the month

        //                //this will ensure that when we are doing the main, we only get detailed
        //                //data up to the month.
        //                if (dataType == DataTypeConstants.YEAR)
        //                    continue; //go to the next one

        //                if (yearData.DataGrouped.IsNullOrEmpty())
        //                    continue;

        //                foreach (DashBoardSingle monthData in yearData.DataGrouped)
        //                {
        //                    //a single month data is sent
        //                    groupDataByDay(monthData);
        //                    //now with the month, the data is grouped by the day

        //                    //this will ensure that when we are doing the main, we only get detailed
        //                    //data up to the Day.
        //                    if (dataType == DataTypeConstants.YEAR_MONTH)
        //                        continue; //go to the next one

        //                    if (monthData.DataGrouped.IsNullOrEmpty())
        //                        continue;

        //                    foreach (DashBoardSingle dayData in monthData.DataGrouped)
        //                    {
        //                        //a single day data is sent
        //                        groupDataByHour(dayData);
        //                        //now within the day, the data is grouped by the hour

        //                        //this will ensure that when we are doing the main, we only get detailed
        //                        //data up to the Hour.
        //                        if (dataType == DataTypeConstants.YEAR_MONTH_DAY)
        //                            continue; //go to the next one

        //                        if (dayData.DataGrouped.IsNullOrEmpty())
        //                            continue;

        //                        foreach (DashBoardSingle hourData in dayData.DataGrouped)
        //                        {
        //                            //a single hours data is sent
        //                            groupDataByMinute(hourData);
        //                            //now within the Hour the data is grouped by the minute

        //                            //this will ensure that when we are doing the main, we only get detailed
        //                            //data up to the Minute.
        //                            if (dataType == DataTypeConstants.YEAR_MONTH_DAY_HOUR)
        //                                continue; //go to the next one

        //                            if (hourData.DataGrouped.IsNullOrEmpty())
        //                                continue;

        //                            foreach (DashBoardSingle minuteData in hourData.DataGrouped)
        //                            {
        //                                //a single minutes data is sent
        //                                groupDataBySecond(minuteData);
        //                                //Now within the minute the data is grouped by the second

        //                                //this will ensure that when we are doing the main, we only get detailed
        //                                //data up to the Minute.
        //                                if (dataType == DataTypeConstants.YEAR_MONTH_DAY_HOUR_MINUTE)
        //                                    continue; //go to the next one


        //                                if (hourData.DataGrouped.IsNullOrEmpty())
        //                                    continue;

        //                                foreach (DashBoardSingle secondData in minuteData.DataGrouped)
        //                                {
        //                                    //a single minutes data is sent
        //                                    groupDataBySecond(secondData);
        //                                    //Now within the minute the data is grouped by the second

        //                                    //this will ensure that when we are doing the main, we only get detailed
        //                                    //data up to the Minute.


        //                                    if (hourData.DataGrouped.IsNullOrEmpty())
        //                                        continue;
        //                                }
        //                            }
        //                        }

        //                    }
        //                }

        //            }
        //        }
        //    }
        //    return dbs;
        //}

        //private void groupDataBySecond(DashBoardSingle rawData)
        //{
        //    rawData.DataGrouped = sql(
        //        rawData,
        //        DataTypeConstants.YEAR_MONTH_DAY_HOUR_MINUTE_SECOND,
        //        DataTypeConstants.DETAIL);
        //}

        //private void groupDataByMinute(DashBoardSingle rawData)
        //{
        //    rawData.DataGrouped = sql(
        //        rawData,
        //        DataTypeConstants.YEAR_MONTH_DAY_HOUR_MINUTE,
        //        DataTypeConstants.YEAR_MONTH_DAY_HOUR_MINUTE_SECOND);
        //}

        //private void groupDataByHour(DashBoardSingle rawData)
        //{
        //    rawData.DataGrouped = sql(
        //        rawData,
        //        DataTypeConstants.YEAR_MONTH_DAY_HOUR,
        //        DataTypeConstants.YEAR_MONTH_DAY_HOUR_MINUTE);
        //}

        //private void groupDataByDay(DashBoardSingle rawData)
        //{
        //    rawData.DataGrouped = sql(
        //        rawData,
        //        DataTypeConstants.YEAR_MONTH_DAY,
        //        DataTypeConstants.YEAR_MONTH_DAY_HOUR);
        //}

        //private void groupDataByMonth(DashBoardSingle rawData)
        //{
        //    rawData.DataGrouped = sql(
        //        rawData,
        //        DataTypeConstants.YEAR_MONTH,
        //        DataTypeConstants.YEAR_MONTH_DAY);
        //}

        //private void groupDataByMainList(DashBoardSingle rawData)
        //{
        //    rawData.DataGrouped = sql(rawData, " ", DataTypeConstants.YEAR);
        //}

        //private void groupDataByYear(DashBoardSingle rawData)
        //{
        //    rawData.DataGrouped = sql(
        //        rawData,
        //        DataTypeConstants.YEAR,
        //        DataTypeConstants.YEAR_MONTH);
        //}


        ///// <summary>
        ///// This gets data for the main screen. Eg Controller, browser etc
        ///// </summary>
        //private void getForDataType(DashBoardSingle rawData)
        //{
        //    fixDataForYear(rawData);
        //    rawData.DataGrouped = sql(
        //        rawData,
        //        DataTypeConstants.MAIN,
        //        DataTypeConstants.YEAR);
        //}

        //#endregion



        /// <summary>
        /// This first sorts the DataDetail according to it's key, then groups the main DataDetail, and then the ChildDataDetail
        /// </summary>
        /// <param name="dbs"></param>
        /// <param name="groupBy"></param>
        /// <returns></returns>
        public DashBoardSingle Controller_SQL(DashBoardSingle dbs, string groupBy)
        {
            dbs.DataDetail = dbs.DataDetail.OrderBy(x => x.Key).ToList();


            string nextDataType = DashBoardSingle.NextGroupBy(groupBy);

            dbs.DataGrouped = sql(dbs, groupBy, nextDataType);



            string nextDataTypeAfterNext = DashBoardSingle.NextGroupBy(nextDataType);

            groupTheChild(dbs, nextDataType, nextDataTypeAfterNext);

            return(dbs);
        }
Пример #10
0
        private static long trimDataForNameAndBelongingTo(string showDataBelongingTo, string name, DashBoardSingle dbs, long noOfPageViews)
        {
            var iquiriable = dbs.DataDetail.AsQueryable();

            if (showDataBelongingTo != GroupByConstants.ALL)
            {
                iquiriable = iquiriable.Where(x => x.BelongsToGroup == showDataBelongingTo);
            }

            if (!name.IsNullOrWhiteSpace())
            {
                iquiriable = iquiriable.Where(x => x.Name == name);
            }

            dbs.DataDetail = iquiriable.ToList();
            noOfPageViews  = dbs.DataDetail.Count();

            return(noOfPageViews);
        }
Пример #11
0
 public DashBoardSingle FixDateInGroupAndChild(DashBoardSingle dbsGrouped, string groupBy)
 {
     addTrxDateToDataGroupsFor(dbsGrouped.DataGrouped, groupBy);
     return(dbsGrouped);
 }
Пример #12
0
 public PageViewData()
 {
     DataAll = new DashBoardSingle();
 }