Exemple #1
0
        public bool ReadDisconnectStateByMeters(string key)//string[] arrKey
        {
            bool            r               = true;
            string          resultado       = "";
            TokenController tokenController = new TokenController();

            Ami_Diagnostic_Service.DiagnosticServiceClient            diagnosticServiceClient            = new Ami_Diagnostic_Service.DiagnosticServiceClient();
            Ami_Diagnostic_Service.RequestToken                       requestToken                       = new Ami_Diagnostic_Service.RequestToken();
            Ami_Diagnostic_Service.ReadDisconnectStateByMetersRequest readDisconnectStateByMetersRequest = new Ami_Diagnostic_Service.ReadDisconnectStateByMetersRequest();
            Ami_Diagnostic_Service.ReadDisconnectStateByMetersResult  readDisconnectStateByMetersResult  = new Ami_Diagnostic_Service.ReadDisconnectStateByMetersResult();
            Ami_Diagnostic_Service.EndpointCollectionRequest          endpointCollectionRequest          = new Ami_Diagnostic_Service.EndpointCollectionRequest();

            Ami_Diagnostic_Service.EndpointCollectionRequestResult endpointCollectionResult = new Ami_Diagnostic_Service.EndpointCollectionRequestResult();
            string[] ElectronicSerialNumbersCollection = null;
            ElectronicSerialNumbersCollection    = new string[1];
            ElectronicSerialNumbersCollection[0] = "2.16.840.1.114416.15.243." + key;//arrKey[0];


            endpointCollectionRequest.ElectronicSerialNumbers            = ElectronicSerialNumbersCollection;
            readDisconnectStateByMetersRequest.EndpointCollectionRequest = endpointCollectionRequest;

            try
            {
                requestToken = diagnosticServiceClient.ReadDisconnectStateByMeters(readDisconnectStateByMetersRequest);
                r            = tokenController.insert(requestToken, key, "ReadDisconnectStateByMeters");
            }
            catch (Exception e)
            {
            }
            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);
        }
        public bool insert(dynamic resulToken, string meter, string tokenType)
        {
            dynamic dyObj = null;
            var     json  = "";
            bool    g     = true;
            bool    r     = false;
            var     param = resulToken;

            if (param is Ami_Diagnostic_Service.RequestToken)
            {
                Ami_Diagnostic_Service.RequestToken obj = new Ami_Diagnostic_Service.RequestToken();
                obj   = param;
                dyObj = obj;
            }
            else if (param is Ami_Control_Service.RequestToken)
            {
                Ami_Control_Service.RequestToken obj = new Ami_Control_Service.RequestToken();
                obj   = param;
                dyObj = obj;
            }
            else if (param is Ami_Data_Service.RequestToken)
            {
                Ami_Data_Service.RequestToken obj = new Ami_Data_Service.RequestToken();
                obj   = param;
                dyObj = obj;
            }
            else
            {
                g = false;
            }
            if (g)
            {
                model.Ami_Token ami_Token = new model.Ami_Token();
                ami_Token.token     = dyObj.Id.ToString();
                ami_Token.status    = 0;
                ami_Token.meter     = meter;
                ami_Token.tokenType = tokenType;
                ami_Token.period    = 1;
                r = ami_Token.insert();
            }
            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);
        }