Exemple #1
0
        /// <summary>
        /// Save Aggregation Group by Month
        /// </summary>
        /// <param name="Element_ID"></param>
        protected void Save_Month_Aggregation(long Element_ID)
        {
            try
            {
                _db_datawarehouse_context = new InnonAnalyticsWarehouseEntities();
                //Get last inserted record in the table Point_Agg_Month
                Point_Agg_Month           tbl_point_Agg_Month = _db_datawarehouse_context.Point_Agg_Month.Where(point_month => point_month.Point_ID == Element_ID).OrderByDescending(point_month => point_month.Month_ID).AsEnumerable().FirstOrDefault();
                List <Aggregate_Raw_Data> _list_aggregation   = new List <Aggregate_Raw_Data>();
                if (tbl_point_Agg_Month != null)
                {
                    _list_aggregation = Get_Aggregate_Raw_Data(Element_ID, Helper.Get_Last_Day_Of_Month(tbl_point_Agg_Month.Month_ID), AggerationType.Month);
                }
                else
                {
                    _list_aggregation = Get_Aggregate_Raw_Data(Element_ID, null, AggerationType.Month);
                }

                //Finally Save Aggregation in to the warehouse
                Save_Aggregate_To_WareHouse(_list_aggregation, AggerationType.Month, Element_ID);
            }
            catch (Exception ex)
            {
                File_Log.SaveLog_ToFile(ex, Common.Enums.LoggingActions.Error, "passing parameter element_id:- " + Element_ID);
            }
        }
        public static Point_Agg_Month Convert_Aggregate_Raw_Data_To_Point_Agg_Month(Aggregate_Raw_Data dto_Aggregate_Raw_Data)
        {
            var dto_Point_Month_tbl = new Point_Agg_Month();

            try
            {
                if (dto_Aggregate_Raw_Data != null)
                {
                    try
                    {
                        dto_Point_Month_tbl.Avg_Value   = dto_Aggregate_Raw_Data.AverageValue;
                        dto_Point_Month_tbl.Client_ID   = dto_Aggregate_Raw_Data.Client_ID;
                        dto_Point_Month_tbl.Cum_Value   = dto_Aggregate_Raw_Data.Cummulative;
                        dto_Point_Month_tbl.Month_ID    = Helper.Get_Month_ID(dto_Aggregate_Raw_Data.Month_Year_ID, dto_Aggregate_Raw_Data.Month_ID);
                        dto_Point_Month_tbl.Max_Value   = dto_Aggregate_Raw_Data.MaxValue;
                        dto_Point_Month_tbl.Min_Value   = dto_Aggregate_Raw_Data.MinValue;
                        dto_Point_Month_tbl.Point_ID    = dto_Aggregate_Raw_Data.Point_ID;
                        dto_Point_Month_tbl.Sum_Value   = dto_Aggregate_Raw_Data.SumValue;
                        dto_Point_Month_tbl.Month_Count = dto_Aggregate_Raw_Data.TotalCount;
                    }
                    catch (Exception ex)
                    {
                        File_Log.SaveLog_ToFile(ex, Common.Enums.LoggingActions.Error, "dto_Aggregate_Raw_Data Point_Id" + dto_Aggregate_Raw_Data.Point_ID);
                    }
                }
                else
                {
                    throw new Exception("dto_Aggregate_Raw_Data is null");
                }
            }
            catch (Exception ex)
            {
                File_Log.SaveLog_ToFile(ex, Common.Enums.LoggingActions.Error, "");
            }

            return(dto_Point_Month_tbl);
        }