Exemplo n.º 1
0
        public void TestConnectionWithServer1()
        {
            try
            {
                MeterPingStatusEntity lst            = GenusMeterService.GetLatestPingTimeForMeter("304562");
                JavaScriptSerializer  jsonSerializer = new JavaScriptSerializer();
                string s1 = jsonSerializer.Serialize(lst);
                //MeterPingQ pingAttribute = jsonSerializer.Deserialize<MeterPingQ>(s);

                DateTime dt = DateTime.ParseExact("27-09-2016 09:00", "dd-MM-yyyy HH:mm", CultureInfo.InvariantCulture);

                DateTime         d = DateTime.Parse("09-18-2016 09:54");
                string           s = d.ToString("MM-dd-yyyy hh:mm");
                MeterStatusAmiV1 meterStatusAmi = new MeterStatusAmiV1()
                {
                    MeterId = lst.MeterID,
                    Status  = (int)lst.Status,
                    LastCommunicationTime = dt
                                            // LastCommunicationTime = Convert.ToDateTime(DateTime.Now)
                };
                //msg.MeterStatuses.Add(meterStatusAmi);
                // msg.Sequence = _sequence++;
                //callIndex++;  // mark the next call Index
                // callConnector.SendMessageToIdms(msg);
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 2
0
        public void MeterPingQuery(List <MeterIdType> meterids)
        {
            try
            {
                MeterPingResponseAmiV1 msg = new MeterPingResponseAmiV1();
                if (callIndex >= meterids.Count)
                {
                    callIndex = 0;
                    // sts = false;
                    // return;
                }
                for (int i = 0; i < meterids.Count; i++)
                {
                    try
                    {
                        string meterno = meterids[i].value.ToString();

                        createTestLogFile("MeterPingRequestAmiV1 - sending meter ping request to the Genus Service.Meter No :" + meterno);

                        MeterPingStatusEntity lst = GenusMeterService.GetLatestPingTimeForMeter(meterno);

                        if (lst == null)
                        {
                            createTestLogFile("MeterPingRequestAmiV1 - meter ping response from genus service is null ");
                        }
                        else
                        {
                            createTestLogFile("MeterPingRequestAmiV1 - meter ping response from genus service is : Status -" + lst.Status);
                        }

                        if (lst.LastCommunication.Trim() == "")
                        {
                            lst.LastCommunication = DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss");
                        }

                        DateTime dt = DateTime.ParseExact(lst.LastCommunication, "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture);

                        MeterStatusAmiV1 meterStatusAmi = new MeterStatusAmiV1()
                        {
                            MeterId = lst.MeterID,
                            Status  = (int)lst.Status,
                            LastCommunicationTime = dt
                                                    // LastCommunicationTime = Convert.ToDateTime(DateTime.Now)
                        };
                        msg.MeterStatuses.Add(meterStatusAmi);
                        msg.Sequence = _sequence++;
                        callIndex++;  // mark the next call Index
                    }
                    catch (Exception ex)
                    {
                    }
                }

                callConnector.SendMessageToIdms(msg);
                createTestLogFile("MeterPingRequestAmiV1 - meter ping response sent to the call server");

                //Console.WriteLine("MeterPingResponse");
                //Console.WriteLine("==========================================================");
                //Console.WriteLine(Environment.NewLine + "Meter ID=" + pingAttribute.MeterID);
                //Console.WriteLine(Environment.NewLine + "Last Comm=" + pingAttribute.LastCommunication);
                //Console.WriteLine(Environment.NewLine + "Status=" + pingAttribute.Status);
                //Console.WriteLine("==========================================================");

                //Console.WriteLine("{0}","Meter ID=" +pingAttribute.MeterID + "Last Comm=" + pingAttribute.LastCommunication + "Status=" + pingAttribute.Status);
                // Console.ReadLine();
                //MeterPingResponseAmiV1 msg = new MeterPingResponseAmiV1();
                //MeterStatusAmiV1 meterStatusAmi = new MeterStatusAmiV1()
                //{

                //    MeterId = ConfigurationManager.AppSettings["MeterId"].ToString(),
                //    Status = (int)eAmiQueryResult.Out,
                //    LastCommunicationTime = DateTime.Now
                //};

                //msg.MeterStatuses.Add(meterStatusAmi);
                //msg.Sequence = _sequence++;
                //callConnector.SendMessageToIdms(msg);   // Call the CallConnector to send the message to server
            }
            catch (Exception ex)
            {
            }
        }