예제 #1
0
        public bool InterrogateByEndpoints(string key)
        {
            DateTime        date            = DateTime.Now;
            bool            r               = false;
            string          resultado       = "";
            TokenController tokenController = new TokenController();

            Ami_Data_Service.RequestToken                  requestToken                  = new Ami_Data_Service.RequestToken();
            Ami_Data_Service.DataServiceClient             dataServiceClient             = new Ami_Data_Service.DataServiceClient();
            Ami_Data_Service.InterrogateByEndpointsRequest interrogateByEndpointsRequest = new Ami_Data_Service.InterrogateByEndpointsRequest();
            Ami_Data_Service.InterrogationParameters       interrogationParameters       = new Ami_Data_Service.InterrogationParameters();

            interrogationParameters.ReadingStartTime          = Convert.ToDateTime("24/3/2020 10:25:35");
            interrogationParameters.ReadingEndTime            = Convert.ToDateTime("24/3/2020 13:25:35");
            interrogationParameters.RetrieveInstantaneousData = false;
            interrogationParameters.RetrievePriorSelfRead     = true;


            interrogationParameters.InterrogationWindowStartTime = Convert.ToDateTime("02/4/2020 10:25:35");
            interrogationParameters.InterrogationWindowEndTime   = Convert.ToDateTime("24/3/2021 13:25:35");

            Ami_Data_Service.EndpointCollectionRequest endpointCollectionRequest = new Ami_Data_Service.EndpointCollectionRequest();
            string[] electronicSerialNumbersCollection = new string[1];
            electronicSerialNumbersCollection[0] = "2.16.840.1.114416.15.243." + key;
            endpointCollectionRequest.ElectronicSerialNumbers = electronicSerialNumbersCollection;

            interrogateByEndpointsRequest.Parameters = interrogationParameters;
            interrogateByEndpointsRequest.EndpointCollectionRequest = endpointCollectionRequest;


            try
            {
                requestToken = dataServiceClient.InterrogateByEndpoints(interrogateByEndpointsRequest);
                r            = tokenController.insert(requestToken, "SEVERAL", "InterrogateByEndpoints");
            }
            catch (Exception e)
            {
            }
            return(r);
        }
예제 #2
0
        public bool DisconnectMeter(string key)
        {
            bool            r               = true;
            string          resultado       = "";
            TokenController tokenController = new TokenController();

            Ami_Control_Service.ControlServiceClient   controlServiceClient   = new Ami_Control_Service.ControlServiceClient();
            Ami_Control_Service.DisconnectMeterRequest disconnectMeterRequest = new Ami_Control_Service.DisconnectMeterRequest();
            Ami_Control_Service.RequestToken           requestToken           = new Ami_Control_Service.RequestToken();
            Ami_Control_Service.EndpointRequest        endpointRequest        = new Ami_Control_Service.EndpointRequest();
            endpointRequest.ElectronicSerialNumber = "2.16.840.1.114416.15.243." + key;
            disconnectMeterRequest.MeterRequest    = endpointRequest;
            try
            {
                requestToken = controlServiceClient.DisconnectMeter(disconnectMeterRequest);
                r            = tokenController.insert(requestToken, key, "DisconnectMeter");
            }
            catch (Exception e)
            {
            }
            return(r);
        }
예제 #3
0
        public bool GetInteractiveReadByEndpointResult(string token)
        {
            var    json   = "";
            bool   r      = false;
            string result = "";

            Ami_Control_Service.EndpointFailure service_endpointFailure = new Ami_Control_Service.EndpointFailure();
            Ami_Data_Service.InteractiveReadByEndpointResult interactiveReadByEndpointResult = null;
            Ami_Data_Service.RequestToken requestToken = new Ami_Data_Service.RequestToken();
            Guid guid = new Guid(token);

            requestToken.Id = guid;
            Ami_Data_Service.DataServiceClient dataServiceClient = new Ami_Data_Service.DataServiceClient();
            model.Ami_Reads        ami_Reads              = null;
            model.Ami_Period       ami_Period             = null;
            model.Ami_Token        ami_Token              = null;
            model.cnx              cnx                    = null;
            TokenController        tokenController        = null;
            List <string>          tranList               = null;
            TokenFailureController tokenFailureController = null;

            try
            {
                tranList = new List <string>();
                interactiveReadByEndpointResult = new Ami_Data_Service.InteractiveReadByEndpointResult();
                ami_Reads  = new model.Ami_Reads();
                ami_Period = new model.Ami_Period();
                interactiveReadByEndpointResult = dataServiceClient.GetInteractiveReadByEndpointResult(requestToken);
                result = interactiveReadByEndpointResult.Result.ToString();

                if (result == "Success")//3
                {
                    json = JsonConvert.SerializeObject(interactiveReadByEndpointResult);
                    if (ami_Period.getLastPeriod() != null)
                    {
                        ami_Reads.period = ami_Period.getLastPeriod()[0].id;
                    }
                    else
                    {
                        ami_Reads.period = 0;
                    }
                    ami_Reads.readjson = help.Base64Encode(json);

                    ami_Reads.esn           = interactiveReadByEndpointResult.Identifier;
                    ami_Reads.token_request = interactiveReadByEndpointResult.RequestToken.Id.ToString();
                    ami_Reads.token_result  = interactiveReadByEndpointResult.Result.ToString();
                    if (interactiveReadByEndpointResult.ReadDataCollection.Length > 0)
                    {
                        ami_Reads.serialnumber = interactiveReadByEndpointResult.ReadDataCollection[0].DeviceSerialNumber.ToString();
                        ami_Reads.cod_medidor  = interactiveReadByEndpointResult.ReadDataCollection[0].DeviceSerialNumber.ToString();

                        /*
                         * ami_Reads.whd = int.Parse(interactiveReadByEndpointResult.ReadDataCollection[0].RegisterValues[0].Value.ToString());
                         * ami_Reads.whr = int.Parse(interactiveReadByEndpointResult.ReadDataCollection[0].RegisterValues[1].Value.ToString());
                         * ami_Reads.whnet = int.Parse(interactiveReadByEndpointResult.ReadDataCollection[0].RegisterValues[5].Value.ToString());
                         */
                        ami_Reads.fecha_lectura = interactiveReadByEndpointResult.ReadDataCollection[0].RegisterValues[0].Timestamp;
                        foreach (var item in interactiveReadByEndpointResult.ReadDataCollection[0].RegisterValues)
                        {
                            string itemTimLower = item.Quantity.Trim().TrimEnd().TrimStart().ToLower();
                            while (itemTimLower.Contains(" "))
                            {
                                itemTimLower = itemTimLower.Replace(" ", "");
                            }
                            if (itemTimLower == "whd")
                            {
                                ami_Reads.whd = int.Parse(item.Value.ToString());
                                string s = item.Timestamp.ToString();
                            }
                            else if (itemTimLower == "whr")
                            {
                                ami_Reads.whr = int.Parse(item.Value.ToString());
                            }
                            else if (itemTimLower == "whnet")
                            {
                                ami_Reads.whnet = int.Parse(item.Value.ToString());
                            }
                        }
                    }
                    tranList.Add(ami_Reads.qInsert());
                    tokenController = new TokenController();
                    tranList.Add(tokenController.qSuccsess(token));
                    r = ami_Reads.transaction(tranList);
                }
                else if (result == "Failure")//5
                {
                    EndpointFailure endpointFailure = new EndpointFailure();
                    tranList        = endpointFailure.qInsert(interactiveReadByEndpointResult.EndpointFailure, token);
                    tokenController = new TokenController();
                    tranList.Add(tokenController.qFailure(token));
                    r = ami_Reads.transaction(tranList);
                }
                else if (result == "Cancell")//4
                {
                    tokenController = new TokenController();
                    tranList.Add(tokenController.qCancell(token));
                    r = ami_Reads.transaction(tranList);
                }
                else if (result == "Pending")//4
                {
                }
            }
            catch (Exception e)
            {
            }
            return(r);
        }
예제 #4
0
        public bool GetReadDisconnectStateByMetersResult(string token)
        {
            bool   r      = false;
            var    json   = "";
            string result = "";

            model.Ami_Diagnostic   ami_Diagnostic         = null;
            TokenController        tokenController        = null;
            List <string>          tranList               = null;
            TokenFailureController tokenFailureController = null;

            Ami_Diagnostic_Service.EndpointFailureResult             service_endpointFailureResult = new Ami_Diagnostic_Service.EndpointFailureResult();
            Ami_Diagnostic_Service.DiagnosticServiceClient           diagnosticServiceClient       = new Ami_Diagnostic_Service.DiagnosticServiceClient();
            Ami_Diagnostic_Service.RequestToken                      requestToken = new Ami_Diagnostic_Service.RequestToken();
            Ami_Diagnostic_Service.ReadDisconnectStateByMetersResult readDisconnectStateByMetersResult = new Ami_Diagnostic_Service.ReadDisconnectStateByMetersResult();

            Guid d = new Guid(token);

            requestToken.Id = d;


            try
            {
                readDisconnectStateByMetersResult = diagnosticServiceClient.GetReadDisconnectStateByMetersResult(requestToken);
                json                   = JsonConvert.SerializeObject(readDisconnectStateByMetersResult);
                ami_Diagnostic         = new model.Ami_Diagnostic();
                tokenController        = new TokenController();
                tokenFailureController = new TokenFailureController();
                tranList               = new List <string>();
                result                 = readDisconnectStateByMetersResult.Result.ToString();
                if (result == "Success")//3
                {
                    if (readDisconnectStateByMetersResult.MeterDisconnectSwitchResults.Length > 0)
                    {
                        ami_Diagnostic.status              = readDisconnectStateByMetersResult.Result.ToString();
                        ami_Diagnostic.token               = token;
                        ami_Diagnostic.meter               = readDisconnectStateByMetersResult.MeterDisconnectSwitchResults[0].ElectronicSerialNumber;
                        ami_Diagnostic.switchState         = readDisconnectStateByMetersResult.MeterDisconnectSwitchResults[0].SwitchState.ToString();
                        ami_Diagnostic.extendedSwitchState = readDisconnectStateByMetersResult.MeterDisconnectSwitchResults[0].ExtendedSwitchState;
                        ami_Diagnostic.jsonData            = help.Base64Encode(json);
                        tranList.Add(ami_Diagnostic.qInsert());
                        tranList.Add(tokenController.qSuccsess(token));
                        r = ami_Diagnostic.transaction(tranList);
                    }
                }
                else if (result == "Failure")//5
                {
                    EndpointFailure endpointFailure = new EndpointFailure();
                    tranList        = endpointFailure.qInsert(readDisconnectStateByMetersResult.EndpointFailureResult, token);
                    tokenController = new TokenController();
                    tranList.Add(tokenController.qFailure(token));
                    r = ami_Diagnostic.transaction(tranList);
                }
                else if (result == "Cancell")//4
                {
                    tokenController = new TokenController();
                    tranList.Add(tokenController.qCancell(token));
                    r = ami_Diagnostic.transaction(tranList);
                }
            }
            catch (Exception e)
            {
            }
            return(r);
        }