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;
        }
        public void LoadPuntoMedicion(PuntoMedicionModel model)
        {
            try
            {
                CiRegistroRepository crr = new CiRegistroRepository();
                SyncRepository sync = new SyncRepository();
                this.SelectetPuntoMedicionItem = (model != null) ? model : SelectetPuntoMedicionItem;
                long fechaActual = sync.GetCurrentDate();
                this.Registros = new ObservableCollection<RegistroModel>(crr.GetCiRegistro(SelectetPuntoMedicionItem.IdPuntoMedicion, fechaActual));

            }
            catch (Exception)
            {

            }
        }
Ejemplo n.º 3
0
 //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);
 }