private static ResponseMessageServerFileSync GetSyncResourceFileStream(RequestMessageServerFileSync request) { var response = new ResponseMessageServerFileSync(); try { string path; using (var repository = new ResourceRepository()) { path = repository.GetResourcePath(request.FileName); } if (String.IsNullOrWhiteSpace(path)) { response.HasError = true; response.Message = String.Format("La ruta para el archivo {0} no se encuentra. Por favor revise de nuevo", request.FileName); return(response); } var pathFileName = Path.Combine(path, request.FileName); if (File.Exists(pathFileName) == false) { response.HasError = true; response.Message = String.Format("El archivo {0} no se encuentra. Por favor revise de nuevo", request.FileName); return(response); } response.File = File.OpenRead(pathFileName); var clientContext = OperationContext.Current; clientContext.OperationCompleted += delegate { if (response.File != null) { response.File.Dispose(); } }; response.HasError = false; return(response); } catch (Exception ex) { response.HasError = true; response.Message = ex.Message + " - " + ex.StackTrace; return(response); } }
private static ResponseMessageServerFileSync GetSyncDataFileStream(RequestMessageServerFileSync request) { var response = new ResponseMessageServerFileSync(); try { var pathFileName = Path.Combine(SettingsData.Server.PathToSaveSyncFiles, request.UidVersion.ToString(), request.FileName); if (File.Exists(pathFileName) == false) { response.HasError = true; response.Message = String.Format("El archivo {0} no se encuentra. Por favor revise de nuevo", request.FileName); return(response); } response.File = File.OpenRead(pathFileName); var clientContext = OperationContext.Current; clientContext.OperationCompleted += delegate { if (response.File != null) { response.File.Dispose(); } }; response.HasError = false; return(response); } catch (Exception ex) { response.HasError = true; response.Message = ex.Message + " - " + ex.StackTrace; return(response); } }