/// <summary> /// Save Aggregation Group by Hour /// </summary> /// <param name="Element_ID"></param> protected void Save_Hour_Aggregation(long Element_ID) { try { _db_datawarehouse_context = new InnonAnalyticsWarehouseEntities(); //Get last inserted record in the table Point_Agg_Hour Point_Agg_Hour tbl_point_Agg_Hour = _db_datawarehouse_context.Point_Agg_Hour.Where(point_hour => point_hour.Point_ID == Element_ID).OrderByDescending(point_hour => point_hour.Hour_ID).AsEnumerable().FirstOrDefault(); List <Aggregate_Raw_Data> _list_aggregation = new List <Aggregate_Raw_Data>(); if (tbl_point_Agg_Hour != null) { _list_aggregation = Get_Aggregate_Raw_Data(Element_ID, Helper.Get_Last_Hour(tbl_point_Agg_Hour.Hour_ID), AggerationType.Hour); } else { _list_aggregation = Get_Aggregate_Raw_Data(Element_ID, null, AggerationType.Hour); } Save_Aggregate_To_WareHouse(_list_aggregation, AggerationType.Hour, Element_ID); } catch (Exception ex) { File_Log.SaveLog_ToFile(ex, Common.Enums.LoggingActions.Error, "Save_Hour_Aggregation passing parameter element_id:- " + Element_ID); } }
public static Warehouse_DTO Convert(Point_Agg_Hour pointagghr) { Warehouse_DTO warehouse_dto = new Warehouse_DTO(); warehouse_dto.Aggregation_Type = AggerationType.Hour; warehouse_dto.Avg_Value = pointagghr.Avg_Value; warehouse_dto.Count = pointagghr.Hour_Count; warehouse_dto.Cum_Value = pointagghr.Cum_Value; warehouse_dto.Max_Value = pointagghr.Max_Value; warehouse_dto.Min_Value = pointagghr.Min_Value; warehouse_dto.Point_ID = pointagghr.Point_ID; warehouse_dto.Sum_Value = pointagghr.Sum_Value; warehouse_dto.Date_Time = pointagghr.Hour_ID.ToString(); return(warehouse_dto); }
public static Point_Agg_Hour Convert_Aggregate_Raw_Data_To_Point_Agg_Hour(Aggregate_Raw_Data dto_Aggregate_Raw_Data) { var dto_Point_Hour_tbl = new Point_Agg_Hour(); try { if (dto_Aggregate_Raw_Data != null) { try { dto_Point_Hour_tbl.Avg_Value = dto_Aggregate_Raw_Data.AverageValue; dto_Point_Hour_tbl.Client_ID = dto_Aggregate_Raw_Data.Client_ID; dto_Point_Hour_tbl.Cum_Value = dto_Aggregate_Raw_Data.Cummulative; dto_Point_Hour_tbl.Date_ID = dto_Aggregate_Raw_Data.Date_ID; dto_Point_Hour_tbl.Hour_ID = dto_Aggregate_Raw_Data.Hour_ID; dto_Point_Hour_tbl.Max_Value = dto_Aggregate_Raw_Data.MaxValue; dto_Point_Hour_tbl.Min_Value = dto_Aggregate_Raw_Data.MinValue; dto_Point_Hour_tbl.Point_ID = dto_Aggregate_Raw_Data.Point_ID; dto_Point_Hour_tbl.Sum_Value = dto_Aggregate_Raw_Data.SumValue; dto_Point_Hour_tbl.Hour_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_Hour_tbl); }