示例#1
0
        public List<CiRegistroUploadConfirmationModel> Upload_CiRegistro(CiRegistroUploadModel param)
        {
            List<CiRegistroUploadConfirmationModel> response = null;
            try
            {
                if (param != null && param.CiRegistro != null && param.CiRegistro.Count > 0)
                {
                    CiRegistroRepository crr = new CiRegistroRepository();
                    response=crr.UpsertUploaded(param.CiRegistro);
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return response;
        }
        /// <summary>
        /// Logica de subida de informacion
        /// </summary>
        /// <returns></returns>
        public bool Upload()
        {
            SQLLogger.Instance.log("", "CiRegistroRepository.Upload (1)");
            bool responseService = false;

            string jsonResponse = "";
            string webMethodName = "Upload_CiRegistro";

            CiRegistroUploadResponseModel response = new CiRegistroUploadResponseModel();

            //Obtener datos
            List<CiRegistroPOCO> registros = this.GetIsModified();
            SQLLogger.Instance.log("", "CiRegistroRepository.Upload (2)");
            if (registros != null && registros.Count > 0)
            {
                SQLLogger.Instance.log("", "CiRegistroRepository.Upload (3)");
                CiRegistroUploadModel crum = new CiRegistroUploadModel();
                crum.CiRegistro = registros;
                //crum.UserData = new UserDataSync();

                //crum.CiRegistro = null;
                //crum.UserData = null;
                SQLLogger.Instance.log("", "CiRegistroRepository.Upload (4)");
                CiRegistroUploadServiceInputWrapper wrapperServiceParameter = new CiRegistroUploadServiceInputWrapper();
                wrapperServiceParameter.param = crum;

                SQLLogger.Instance.log("", "CiRegistroRepository.Upload (5)");
                jsonResponse = DownloadFactory.Instance.CallUploadWebService(webMethodName, wrapperServiceParameter);
                SQLLogger.Instance.log("", "CiRegistroRepository.Upload (6)");
                if (!String.IsNullOrEmpty(jsonResponse))
                {
                    SQLLogger.Instance.log("", "CiRegistroRepository.Upload (7)");
                    JavaScriptSerializer js = new JavaScriptSerializer();
                    js.MaxJsonLength = Int32.MaxValue;
                    response = js.Deserialize<CiRegistroUploadResponseModel>(jsonResponse);

                    SQLLogger.Instance.log("", "CiRegistroRepository.Upload (8)");
                    if (response != null && response.Upload_CiRegistroResult != null && response.Upload_CiRegistroResult.Count > 0)
                    {
                        SQLLogger.Instance.log("", "CiRegistroRepository.Upload (9)");
                        this.PrepareBulkUpdateConfirmation();
                        this.BulkUpdateConfirmation(response.Upload_CiRegistroResult);
                        this.CommitBulkUpdateConfirmation();
                        SQLLogger.Instance.log("", "CiRegistroRepository.Upload (10)");
                    }
                }//endif
                else
                {
                    //No hubo respuesta de confirmacion; probablemente un error en la llamda del servicio
                    responseService = true;
                }
            }//endif
            else
            {
                SQLLogger.Instance.log("", "CiRegistroRepository.Upload (2.1)");
                //no hay registros para subir al servidor
                responseService = true;
            }
            SQLLogger.Instance.log("", "CiRegistroRepository.Upload (1.1)");
            return responseService;
        }