Пример #1
0
 public List<CiTrackingUploadConfirmationModel> Upload_CiTracking(CiTrackingUploadModel param)
 {
     List<CiTrackingUploadConfirmationModel> response = null;
     try
     {
         if(param!=null && param.Items!=null &&param.Items.Count>0)
         {
             using (var repository=new TrakingRepository())
             {
                 response = repository.Upsert(param.Items);
             }
         }
     }
     catch (Exception ex)
     {
     }
     return response;
 }
        /// <summary>
        /// Logica de subida de informacion
        /// </summary>
        /// <returns></returns>
        public bool Upload()
        {
            bool responseService = false;

            string jsonResponse = "";
            string webMethodName = "Upload_CiTracking";
            CiTrackingUploadResponseModel response = new CiTrackingUploadResponseModel();

            //Obtener datos
            List<TrackingModel> registros = GetIsModified();
            if (registros != null && registros.Count > 0)
            {
                CiTrackingUploadModel crum = new CiTrackingUploadModel();
                crum.Items = registros;

                CiTrackingUploadServiceInputWrapper wrapperServiceParameter = new CiTrackingUploadServiceInputWrapper();
                wrapperServiceParameter.param = crum;

                jsonResponse = DownloadFactory.Instance.CallUploadWebService(webMethodName, wrapperServiceParameter);
                if (!String.IsNullOrEmpty(jsonResponse))
                {
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    js.MaxJsonLength = Int32.MaxValue;
                    response = js.Deserialize<CiTrackingUploadResponseModel>(jsonResponse);

                    if (response != null && response.Upload_CiTrackingResult != null && response.Upload_CiTrackingResult.Count > 0)
                    {
                        ConfirmationUpload(response.Upload_CiTrackingResult);
                    }
                }//endif
                else
                {
                    //No hubo respuesta de confirmacion; probablemente un error en la llamda del servicio
                    responseService = true;
                }
            }//endif
            else
            {
                //no hay registros para subir al servidor
                responseService = true;
            }

            return responseService;
        }