예제 #1
0
        /// <summary>
        /// This function calulate the aggregate on the basis of provided parameters
        /// </summary>
        /// <param name="Element_ID"></param>
        /// <param name="Timestamp_From"></param>
        /// <param name="aggregate_type">Aggregate is for Group by</param>
        /// <returns></returns>
        private List <Aggregate_Raw_Data> Get_Aggregate_Raw_Data(long Element_ID, DateTime?Timestamp_From, AggerationType aggregate_type)
        {
            try
            {
                _db_datawarehouse_context = new InnonAnalyticsWarehouseEntities();
                IPoint_Measure_Fact_Service point_measure_fact_service = new Point_Measure_Fact_Service();
                IList <Point_Measure_Fact>  list = new List <Point_Measure_Fact>();

                if (Timestamp_From.HasValue)
                {
                    list = point_measure_fact_service.Get_Point_Measure_Fact_By_Element_ID_From_Date(Element_ID, Timestamp_From.GetValueOrDefault());
                }
                else
                {
                    list = point_measure_fact_service.Get_Point_Measure_Fact_By_Element_ID(Element_ID);
                }

                List <Aggregate_Raw_Data> _list_aggregation = new List <Aggregate_Raw_Data>();
                _list_aggregation.AddRange(CalculateAggregation(aggregate_type, list));
                return(_list_aggregation);
            }
            catch (Exception ex)
            {
                File_Log.SaveLog_ToFile(ex, Common.Enums.LoggingActions.Error, string.Format("passing parameter element_id:-{0},  Timestamp_From:- {1}, aggregate_type:- {2}", Element_ID, Timestamp_From, aggregate_type));
                return(null);
            }
        }
예제 #2
0
        private static bool Database_Update_Interpolated_Values(Point_Measure_Fact tbl_point_measure_fact)
        {
            Interpolated_Good_Value Good_Values = Get_Previous_and_Next_Good_Value(tbl_point_measure_fact.Timestamp_From, tbl_point_measure_fact.Point_ID);
            double?new_value = Get_Interpolated_Value(Good_Values);

            //Save into audit table (FactsRestatementAudit)
            if (new_value != null)
            {
                double final_new_value = Convert.ToDouble(new_value);
                //Save to Fact Audit
                if (Good_Values.Previous_Good_Value != null && Good_Values.Next_Good_Value != null)
                {
                    //For Interpolation when both previous and next value ((24-21)/3 = 1; 21+1; 22; 23)
                    final_new_value = Good_Values.Previous_Good_Value.Raw_Value + final_new_value;
                    Save_To_Fact_Audit_Table(tbl_point_measure_fact, final_new_value);
                }
                else
                {
                    Save_To_Fact_Audit_Table(tbl_point_measure_fact, final_new_value);
                }

                //Update the Table Point measure fact with new value
                IPoint_Measure_Fact_Service point_measure_fact = new Point_Measure_Fact_Service();
                tbl_point_measure_fact.Raw_Value    = Convert.ToDouble(final_new_value);
                tbl_point_measure_fact.Point_Status = good_status_code;
                point_measure_fact.Update_Point_Measure_Fact(tbl_point_measure_fact);
                return(true);
            }
            return(false);
        }