/// <summary> /// this function is used to send data from local to live database. /// </summary> /// <param name="obj">object of HeatStartStopReport data</param> /// <returns></returns> private static string SendHeatStartStopReportData(ENT.HeatStartStopReport obj, string json) { string message = string.Empty; try { // this is our live api url for send data to live database WebRequest tRequest = WebRequest.Create("http://gisrv.appsmith.co.in/api/HeatReport/InsertHeatStartStopReportAPI"); tRequest.Method = "POST"; tRequest.ContentType = "application/json"; obj.heat_json = json; string jsonNotificationFormat = Newtonsoft.Json.JsonConvert.SerializeObject(obj); Byte[] byteArray = Encoding.UTF8.GetBytes(jsonNotificationFormat); tRequest.ContentLength = byteArray.Length; tRequest.ContentType = "application/json"; using (Stream dataStream = tRequest.GetRequestStream()) { dataStream.Write(byteArray, 0, byteArray.Length); using (WebResponse tResponse = tRequest.GetResponse()) { using (Stream dataStreamResponse = tResponse.GetResponseStream()) { using (StreamReader tReader = new StreamReader(dataStreamResponse)) { String responseFromFirebaseServer = tReader.ReadToEnd(); message = "HeatStartStopReport : " + responseFromFirebaseServer; } } } } } catch (Exception ex) { message = ex.Message; return(message); } return(message); }
/// <summary> /// this function is used to send dryrun heat unit report /// </summary> /// <param name="DryrunID"></param> /// <returns></returns> private static string SendDryrunHeatReport(Int64 DryrunID) { try { string jsonNotification = string.Empty; ENT.ResponseHeatReport objHeatReport = new ENT.ResponseHeatReport(); ENT.ResponseHeatReport objDryrun = new ENT.ResponseHeatReport(); ENT.HeatStartStopReport objHSSR = new ENT.HeatStartStopReport(); List <ENT.DryrunHeatReportApi> lstDryRun = new List <ENT.DryrunHeatReportApi>(); lstDryRun = new DAL.HeatStartStopReport().GetHeatDryrunReportByDate(DateTime.Now.ToString("dd-MMM-yyyy"), DryrunID); if (lstDryRun.Count > 0) { Console.WriteLine("Dryrun Record Found : " + lstDryRun.Count); WriteLog("Dryrun Record Found : " + lstDryRun.Count); // heat timming data for temp not in use objHeatReport.ReportName = "HeatReport"; objHeatReport.PowerOn = Convert.ToString(lstDryRun[0].StartDataTime); objHeatReport.SuperHeat = Convert.ToString(lstDryRun[0].StartDataTime); objHeatReport.HeatTapped = Convert.ToString(lstDryRun[0].StartDataTime); objHeatReport.TapToTapHrsMin = "0:0:0"; // heat unit consumption data for temp not in use objHeatReport.KwhrAtStart = "0.00"; objHeatReport.KwhrAtEnd = "0.00"; objHeatReport.TotalKwhr = "0.00"; objHeatReport.KwhrHeat = "0.00"; // dryrun heat timming data objDryrun.ReportName = "HeatDryrunReport"; objDryrun.PowerOn = Convert.ToString(lstDryRun[0].StartDataTime); objDryrun.SuperHeat = Convert.ToString(lstDryRun[0].StartDataTime); objDryrun.HeatTapped = Convert.ToString(lstDryRun[0].EndDataTime); objDryrun.TapToTapHrsMin = Convert.ToString(lstDryRun[0].HrsMin); // dryrun heat unit consumption data objDryrun.KwhrAtStart = Convert.ToString(lstDryRun[0].DataValueFirst); // Datavalue Start Unit objDryrun.KwhrAtEnd = Convert.ToString(lstDryRun[0].DataValueLast); // Datavalue End Unit objDryrun.TotalKwhr = Convert.ToString(lstDryRun[0].UnitDifference); objDryrun.KwhrHeat = Convert.ToString(lstDryRun[0].UnitDifference * 10); // This object value is non use but i have pass for api so created this temp objHSSR.ID = lstDryRun[0].ID; objHSSR.StartDataTime = lstDryRun[0].StartDataTime; objHSSR.EndDataTime = lstDryRun[0].EndDataTime; objHSSR.DataValue = lstDryRun[0].DataValueFirst; objHSSR.DataValue2 = lstDryRun[0].DataValueLast; } ENT.HeatReport objHR = new ENT.HeatReport(); objHR.ReportType = "2"; objHR.HeatUnitReport = objHeatReport; objHR.HeatDryrunReport = objDryrun; // create json for send data to mobile app jsonNotification = Newtonsoft.Json.JsonConvert.SerializeObject(objHR); WriteLog(jsonNotification); // here, call the function for send data from local to live database string result = SendHeatStartStopReportData(objHSSR, jsonNotification); return(result); } catch (Exception ex) { return("SendDryrunHeatReport(): " + ex.Message.ToString()); } }