Exemple #1
0
        /// <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());
            }
        }
Exemple #2
0
        /// <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 _HeatStartStopReportDependencyDependency_Changed(object sender, RecordChangedEventArgs <ENT.HeatStartStopReport> 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("HeatStartStopReport : " + e.ChangeType);
            WriteLog("HeatStartStopReport : " + e.ChangeType);

            // write log in to file and console window
            Console.WriteLine(e.ChangeType + " = > ID : " + e.Entity.ID);
            WriteLog(e.ChangeType + " = > ID : " + e.Entity.ID);

            string jsonNotification = string.Empty;

            ENT.ResponseHeatReport            objResponse = new ENT.ResponseHeatReport();
            ENT.ResponseHeatReport            objDryrun   = new ENT.ResponseHeatReport();
            List <ENT.HeatStartStopReportApi> lstResult   = new List <ENT.HeatStartStopReportApi>();
            List <ENT.DryrunHeatReportApi>    lstDryRun   = new List <ENT.DryrunHeatReportApi>();

            // if getting INSERT flag from dependency then we process for insert in live database
            if (e.ChangeType.ToString().ToUpper() == "UPDATE")
            {
                // get data from local database
                lstResult = new DAL.HeatStartStopReport().GetHeatStartStopReportByDate(DateTime.Now.ToString("dd-MMM-yyyy"), e.Entity.ID);
                if (lstResult.Count > 0)
                {
                    Console.WriteLine("Record Found : " + lstResult.Count);
                    WriteLog("Record Found : " + lstResult.Count);

                    // heat timming data
                    objResponse.ReportName     = "HeatReport";
                    objResponse.PowerOn        = Convert.ToString(lstResult[0].StartDataTime);
                    objResponse.SuperHeat      = Convert.ToString(lstResult[0].StartDataTime);
                    objResponse.HeatTapped     = Convert.ToString(lstResult[0].EndDataTime);
                    objResponse.TapToTapHrsMin = Convert.ToString(lstResult[0].HrsMin);

                    // heat unit consumption data
                    objResponse.KwhrAtStart = Convert.ToString(lstResult[0].DataValue2); // Datavalue Start Unit
                    objResponse.KwhrAtEnd   = Convert.ToString(lstResult[0].DataValue);  // Datavalue End Unit
                    objResponse.TotalKwhr   = Convert.ToString(lstResult[0].UnitDifference);
                    objResponse.KwhrHeat    = Convert.ToString(lstResult[0].UnitDifference * 10);

                    lstDryRun = new DAL.HeatStartStopReport().GetHeatDryrunReportByDate(DateTime.Now.ToString("dd-MMM-yyyy"), e.Entity.ID);
                    if (lstDryRun.Count > 0)
                    {
                        Console.WriteLine("Dryrun Record Found : " + lstDryRun.Count);
                        WriteLog("Dryrun Record Found : " + lstDryRun.Count);

                        // 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);
                    }

                    ENT.HeatReport objHR = new ENT.HeatReport();
                    objHR.ReportType       = "1";
                    objHR.HeatUnitReport   = objResponse;
                    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(e.Entity, jsonNotification);

                    // write log of return response from API
                    Console.WriteLine(result);
                    WriteLog(result);
                }
                else
                {
                    Console.WriteLine("Record Not Found For Notification : " + lstResult.Count + ". Heat Started Now.");
                    WriteLog("Record Not Found For Notification : " + lstResult.Count + ". Heat Started Now.");
                }
            }

            Console.WriteLine("*************************************************");
            Console.WriteLine("Waiting for receiving new notifications...");
            Console.WriteLine("*************************************************");
            WriteLog("*************************************************");
        }