Exemple #1
0
        public bool GetDisconnectMeterResult(string token)
        {
            bool                   r                      = true;
            var                    json                   = "";
            string                 result                 = "";
            TokenController        tokenController        = null;
            List <string>          tranList               = null;
            TokenFailureController tokenFailureController = null;

            model.Ami_Control ami_Control = null;
            model.Ami_Period  ami_Period  = null;
            model.Ami_Token   ami_Token   = null;
            Ami_Control_Service.EndpointFailure       service_endpointFailure = new Ami_Control_Service.EndpointFailure();
            Ami_Control_Service.ControlServiceClient  controlServiceClient    = new Ami_Control_Service.ControlServiceClient();
            Ami_Control_Service.RequestToken          requestToken            = new Ami_Control_Service.RequestToken();
            Ami_Control_Service.EndpointRequestResult endpointRequestResult   = new Ami_Control_Service.EndpointRequestResult();
            Guid d = new Guid(token);

            requestToken.Id = d;
            try
            {
                ami_Control           = new model.Ami_Control();
                endpointRequestResult = controlServiceClient.GetDisconnectMeterResult(requestToken);
                result   = endpointRequestResult.Result.ToString();
                tranList = new List <string>();
                if (result == "Success")//3
                {
                    json = JsonConvert.SerializeObject(endpointRequestResult);
                    ami_Control.jsonData = help.Base64Encode(json);
                    ami_Control.meter    = endpointRequestResult.ElectronicSerialNumber;
                    ami_Control.status   = endpointRequestResult.Result.ToString();
                    ami_Control.token    = token;
                    tranList.Add(ami_Control.qInsert());
                    tokenController = new TokenController();
                    tranList.Add(tokenController.qSuccsess(token));
                    r = ami_Control.transaction(tranList);
                }
                else if (result == "Failure")//5
                {
                    EndpointFailure endpointFailure = new EndpointFailure();
                    service_endpointFailure = endpointRequestResult.MeterFailure;
                    tranList        = endpointFailure.qInsert(service_endpointFailure, token);
                    tokenController = new TokenController();
                    tranList.Add(tokenController.qFailure(token));
                    r = ami_Control.transaction(tranList);
                }
                else if (result == "Cancell")//4
                {
                    tokenController = new TokenController();
                    tranList.Add(tokenController.qCancell(token));
                    r = ami_Control.transaction(tranList);
                }
            }
            catch (Exception e)
            {
                //GetDisconnectMeterResult(token);
            }

            return(r);
        }
Exemple #2
0
        public bool GetPingByEndpointsResult(string token)
        {
            bool   r      = true;
            var    json   = "";
            string result = "";

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

            Ami_Diagnostic_Service.DiagnosticServiceClient         diagnosticServiceClient         = new Ami_Diagnostic_Service.DiagnosticServiceClient();
            Ami_Diagnostic_Service.RequestToken                    requestToken                    = new Ami_Diagnostic_Service.RequestToken();
            Ami_Diagnostic_Service.EndpointCollectionRequestResult endpointCollectionRequestResult = new Ami_Diagnostic_Service.EndpointCollectionRequestResult();

            Guid d = new Guid(token);

            requestToken.Id = d;
            try
            {
                endpointCollectionRequestResult = diagnosticServiceClient.GetPingByEndpointsResult(requestToken);
                json                   = JsonConvert.SerializeObject(endpointCollectionRequestResult);
                ami_Diagnostic         = new model.Ami_Diagnostic();
                tokenController        = new TokenController();
                tokenFailureController = new TokenFailureController();
                tranList               = new List <string>();
                result                 = endpointCollectionRequestResult.Result.ToString();
                if (result == "Success")//3
                {
                    ami_Diagnostic.meter    = "";
                    ami_Diagnostic.status   = result;
                    ami_Diagnostic.token    = token;
                    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(endpointCollectionRequestResult.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);
        }
Exemple #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);
        }
Exemple #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);
        }