/// <summary> /// Insert Update Dryrun report data /// </summary> /// <param name="objENT"></param> /// <returns></returns> public bool InsertUpdateDeleteDryrunHeatReport(ENT.DryrunHeatReport objENT) { bool row = false; try { sqlCMD = new SqlCommand(); sqlCMD.CommandText = "InsertUpdateDeleteDryrunHeatReport"; sqlCMD.Parameters.AddWithValue("@ID", objENT.ID); sqlCMD.Parameters.AddWithValue("@LineCountEnd", objENT.LineCountEnd); sqlCMD.Parameters.AddWithValue("@EndDataTime", objENT.EndDataTime); sqlCMD.Parameters.AddWithValue("@DataValueLast", objENT.DataValueLast); sqlCMD.Parameters.AddWithValue("@EntryDate", objENT.EntryDate); sqlCMD.Parameters.AddWithValue("@Mode", objENT.Mode); row = objCRUD.InsertUpdateDelete(sqlCMD); } catch (Exception ex) { throw ex; } return(row); }
/// <summary> /// this event is called when any of the change found in database table of MeterSlaveMaster /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void _MeterSlaveMasterDependencyDependency_Changed(object sender, RecordChangedEventArgs <ENT.MeterSlaveMaster> e) { // write log in to file and console window Console.WriteLine("Date Time : " + DateTime.Now.ToString("dd-MMM-yyyy hh:mm:ss tt")); Console.WriteLine("MeterSlaveMaster : " + e.ChangeType); WriteLog("MeterSlaveMaster : " + e.ChangeType); // if getting INSERT flag from dependency then we process for insert in live database if (e.ChangeType.ToString().ToUpper() == "INSERT") { // For Dryrun Report get top one record from meter slave master table List <ENT.MeterSlaveMaster> lstMSM = new List <ENT.MeterSlaveMaster>(); lstMSM = new DAL.DryrunHeatReport().GetMeterSlaveMasterTop1ByDate(DateTime.Now.ToString("dd-MMM-yyyy")); if (lstMSM.Count > 0) { List <ENT.DryrunHeatReport> lstDryrun = new List <ENT.DryrunHeatReport>(); lstDryrun = new DAL.DryrunHeatReport().GetDryrunHeatReportTop1ByDate(DateTime.Now.ToString("dd-MMM-yyyy")); decimal dcmUnit = lstMSM[0].DataValue - lstMSM[0].DataValue2; Console.WriteLine("Unit Is : " + dcmUnit + " => Last Record Found : " + lstDryrun.Count); if (dcmUnit > 5 && lstDryrun.Count > 0) { WriteLog("Dryrun unit greater then five found at line of " + lstMSM[0].LineCount + " And Unit Is : " + dcmUnit); ENT.DryrunHeatReport objHDRH = new ENT.DryrunHeatReport(); // Insert First record for dryrun heat report try { objHDRH.ID = lstDryrun[0].ID; objHDRH.LineCountEnd = lstMSM[0].LineCount; objHDRH.EndDataTime = lstMSM[0].DataTime; objHDRH.DataValueLast = lstMSM[0].DataValue; objHDRH.EntryDate = DateTime.Now; objHDRH.Mode = "UPDATE"; if (new DAL.DryrunHeatReport().InsertUpdateDeleteDryrunHeatReport(objHDRH)) { WriteLog("Dryrun Unit Updated Suucessfully."); // send dryrun report notification string response = SendDryrunHeatReport(lstDryrun[0].ID); // write log of return response from API Console.WriteLine(response); WriteLog(response); } } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); WriteLog(ex.Message); } } } // here, call the function for send data from local to live database string result = SendMeterSlaveMasterData(e.Entity); // write log of return response from API Console.WriteLine(result); WriteLog(result); } // write log in to file and console window Console.WriteLine(e.ChangeType + " = > ID : " + e.Entity.ID); WriteLog(e.ChangeType + " = > ID : " + e.Entity.ID); Console.WriteLine("*************************************************"); Console.WriteLine("Waiting for receiving new notifications..."); Console.WriteLine("*************************************************"); WriteLog("*************************************************"); }