/// <summary> /// Save Aggregation Group by Week /// </summary> /// <param name="Element_ID"></param> protected void Save_Week_Aggregation(long Element_ID) { try { _db_datawarehouse_context = new InnonAnalyticsWarehouseEntities(); //Get last inserted record in the table Point_Agg_Week Point_Agg_Week tbl_point_Agg_Week = _db_datawarehouse_context.Point_Agg_Week.Where(point_week => point_week.Point_ID == Element_ID).OrderByDescending(point_week => point_week.Week_ID).AsEnumerable().FirstOrDefault(); List <Aggregate_Raw_Data> _list_aggregation = new List <Aggregate_Raw_Data>(); if (tbl_point_Agg_Week != null) { _list_aggregation = Get_Aggregate_Raw_Data(Element_ID, Helper.LastDateOfWeekISO8601(tbl_point_Agg_Week.Week_ID), AggerationType.Week); } else { _list_aggregation = Get_Aggregate_Raw_Data(Element_ID, null, AggerationType.Week); } //Finally Save Aggregation in to the warehouse Save_Aggregate_To_WareHouse(_list_aggregation, AggerationType.Week, Element_ID); } catch (Exception ex) { File_Log.SaveLog_ToFile(ex, Common.Enums.LoggingActions.Error, "passing parameter element_id:- " + Element_ID); } }
public static Point_Agg_Week Convert_Aggregate_Raw_Data_To_Point_Agg_Week(Aggregate_Raw_Data dto_Aggregate_Raw_Data) { var dto_Point_Week_tbl = new Point_Agg_Week(); try { if (dto_Aggregate_Raw_Data != null) { try { dto_Point_Week_tbl.Avg_Value = dto_Aggregate_Raw_Data.AverageValue; dto_Point_Week_tbl.Client_ID = dto_Aggregate_Raw_Data.Client_ID; dto_Point_Week_tbl.Cum_Value = dto_Aggregate_Raw_Data.Cummulative; // dto_Point_Week_tbl.Week_ID = dto_Aggregate_Raw_Data.Date_ID; dto_Point_Week_tbl.Max_Value = dto_Aggregate_Raw_Data.MaxValue; dto_Point_Week_tbl.Min_Value = dto_Aggregate_Raw_Data.MinValue; dto_Point_Week_tbl.Point_ID = dto_Aggregate_Raw_Data.Point_ID; dto_Point_Week_tbl.Sum_Value = dto_Aggregate_Raw_Data.SumValue; dto_Point_Week_tbl.Week_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_Week_tbl); }