Example #1
0
        public List <Ami_Token_Failure> convertFailure(dynamic endpointFailureResult, string token)
        {
            Ami_Token_Failure        ami_Token_Failure      = null;
            List <Ami_Token_Failure> list_Ami_Token_Failure = null;
            dynamic dyObj = null;
            var     json  = "";
            bool    n     = false;
            var     param = endpointFailureResult;

            if (param is Ami_Diagnostic_Service.EndpointFailureResult)
            {
                n = true;
                Ami_Diagnostic_Service.EndpointFailureResult obj = new Ami_Diagnostic_Service.EndpointFailureResult();
                obj   = param;
                dyObj = obj;
            }
            else if (param is Ami_Control_Service.EndpointFailureResult)
            {
                n = true;
                Ami_Control_Service.EndpointFailureResult obj = new Ami_Control_Service.EndpointFailureResult();
                obj   = param;
                dyObj = obj;
            }
            else if (param is Ami_Control_Service.EndpointFailure)
            {
                Ami_Control_Service.EndpointFailure obj = new Ami_Control_Service.EndpointFailure();
                obj   = param;
                dyObj = obj;
            }
            else if (param is Ami_Data_Service.EndpointFailureResult)
            {
                n = true;
                Ami_Data_Service.EndpointFailureResult obj = new Ami_Data_Service.EndpointFailureResult();
                obj   = param;
                dyObj = obj;
            }
            else if (param is Ami_Data_Service.EndpointFailure)
            {
                Ami_Data_Service.EndpointFailure obj = new Ami_Data_Service.EndpointFailure();
                obj   = param;
                dyObj = obj;
            }


            if (dyObj != null)
            {
                list_Ami_Token_Failure = new List <Ami_Token_Failure>();

                json = JsonConvert.SerializeObject(dyObj);
                json = help.Base64Encode(json);
                if (n)
                {
                    for (int i = 0; i < dyObj.Failures.Length; i++)
                    {
                        ami_Token_Failure             = new Ami_Token_Failure();
                        ami_Token_Failure.token       = token;
                        ami_Token_Failure.reason      = dyObj.Failures[i].FailureReason.ToString();
                        ami_Token_Failure.description = dyObj.Failures[i].Description.ToString();
                        ami_Token_Failure.jsonData    = json;

                        list_Ami_Token_Failure.Add(ami_Token_Failure);
                    }
                }
                else
                {
                    ami_Token_Failure             = new Ami_Token_Failure();
                    ami_Token_Failure.token       = token;
                    ami_Token_Failure.reason      = dyObj.FailureReason.ToString();
                    ami_Token_Failure.description = dyObj.Description.ToString();
                    ami_Token_Failure.jsonData    = json;

                    list_Ami_Token_Failure.Add(ami_Token_Failure);
                }
            }
            return(list_Ami_Token_Failure);
        }
Example #2
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);
        }