public bool CallDownloadCiRegistroOnDemand(long idPuntoMedicion, long lastModifiedDate, long serverLastModifiedDate) { bool responseService = false; string webMethodName = "Download_CIRegistroOnDemand"; string tableName = "CI_REGISTRO"; loadProperties(); try { var client = new RestClient(routeDownload); //client.Authenticator = new HttpBasicAuthenticator(basicAuthUser, basicAuthPass); var request = new RestRequest(Method.POST); request.Resource = webMethodName; request.RequestFormat = RestSharp.DataFormat.Json; request.AddHeader("Content-type", "application/json"); //Body MaxTableModel maximos= new MaxTableModel(); IRestResponse response = null; RegistroRepository registroRepository = new RegistroRepository(); using (var repository = new SyncRepository()) { try { maximos = repository.GetMaxCiRegistro(idPuntoMedicion); request.AddBody(new { currentDate=20140403,//repository.GetCurrentDate(), idPuntoMedicion=idPuntoMedicion //lastModifiedDate=maximos.LastModifiedDate, //serverLastModifiedDate=maximos.ServerLastModifiedDate, //dias=repository.GetDaysToSync(idPuntoMedicion) }); } catch (Exception) { maximos = null; } } if (maximos != null) { response = client.Execute(request); CiRegistroResultModel list = new CiRegistroResultModel(); list = new JavaScriptSerializer().Deserialize<CiRegistroResultModel>(response.Content); if (list.Download_CIRegistroResult!=null && list.Download_CIRegistroResult.Count>0 ) { registroRepository.LoadSyncLocal(list.Download_CIRegistroResult); } } } catch (Exception ex) { InsertLog(ex.Source.ToString(), ex.Message); } return responseService; }
//Para todas menos CI_REGISTRO public string CallWebService(string webMethodName, string tableName) { MaxTableModel maximos = new MaxTableModel(); object bodyContent = null; try { using (var repository = new SyncRepository()) { maximos = repository.GetMaxTable(tableName); bodyContent = maximos; } } catch (Exception ex) { AppBitacoraRepository.Insert(new AppBitacoraModel() { Fecha = DateTime.Now, Metodo = ex.StackTrace, Mensaje = ex.Message }); } return this.CallWebService(webMethodName, bodyContent); }
public MaxTableModel GetMaxTable(string tableName) { MaxTableModel maximos = new MaxTableModel(); try { using (var entity = new db_SeguimientoProtocolo_r2Entities()) { ( from res in entity.spGetMaxTable(tableName) select res ).ToList().ForEach(row => { maximos.LastModifiedDate = row.LastModifiedDate; maximos.ServerLastModifiedDate = row.ServerLastModifiedDate; }); } } catch (Exception ex) { maximos = null; } return maximos; }
public MaxTableModel GetMaxCiRegistro(long idPuntoMedicion) { MaxTableModel maximos= new MaxTableModel(); try { using(var entity=new db_SeguimientoProtocolo_r2Entities()) { (from res in entity.spGetMaxTableCiRegistro(idPuntoMedicion) select res).ToList().ForEach(row => { maximos.LastModifiedDate = row.LastModifiedDate; maximos.ServerLastModifiedDate = row.ServerLastModifiedDate; }); } } catch (Exception) { maximos = null; } return maximos; }
public AppRolResultModel Serialize() { AppRolResultModel send = new AppRolResultModel(); string webMethodName = "Upload_AppRol"; try { //send.UploadAppRolResult = GetIsModified(); var client = new RestClient(SyncProperties.routeUpload); //client.Authenticator = new HttpBasicAuthenticator(basicAuthUser, basicAuthPass); var request = new RestRequest(Method.POST); request.Resource = webMethodName; request.RequestFormat = RestSharp.DataFormat.Json; request.AddHeader("Content-type", "application/json"); //Body MaxTableModel maximos = new MaxTableModel(); IRestResponse response = null; RegistroRepository registroRepository = new RegistroRepository(); request.AddBody(new { param = send }); response = client.Execute(request); string res = response.Content; } catch (Exception) { } return send; }