public bool print(string value, string d) { string line = value; if (d == null) { } else if (d == "lectura") { File.WriteAllText(@"C:\Users\TI\Documents\AMI\lectura.txt", line); } else if (d == "token") { File.WriteAllText(@"C:\Users\TI\Documents\AMI\token.txt", line); } model.cnx cnx = new model.cnx(); if (cnx.abrir()) { string hola = "abireto"; } //File.WriteAllText(@"C:\Users\Administrator\Desktop\print\record.txt", line); return(true); }
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); }