6 using System.Collections.Generic;
14 internal class OfflineUpAndDownOneDrive_Impl : IOfflineUpAndDown
25 public OfflineUpAndDownOneDrive_Impl(
int idConf = 0)
28 EW_GLOBAL.ValorEnClave_VarGlob(
"wn_offlineIdConf365", idConf);
35 #endregion Constructores 37 public bool Comprobar_Conexion(FtpUserData toFtpUserData,
bool lbAsistConfSig)
42 var nombreDirectorio =
@"od:\UnitTestBorrar\";
43 var resultado =
false;
44 if (_oFileDialog365._DirectoryExists(nombreDirectorio))
46 _oFileDialog365._DeleteFolder(nombreDirectorio);
48 resultado =_oFileDialog365._CreateFolder(nombreDirectorio);
49 resultado = resultado && _oFileDialog365._DeleteFolder(nombreDirectorio);
55 toFtpUserData.error_message =
"Se ha producido un error al obtener datos del OneDrive.";
59 toFtpUserData.error_message =
"Para avanzar al siguiente paso debe definir una configuración de conexión. Configure Servidor FTP o OneDrive para poder continuar.";
77 public bool Descargar_Fichero(
string path,
string fileName,
string carpeta,
int idConf,
bool deleteSource)
82 var rutaServidor = Convert.ToString(EW_GLOBAL._GetVariable(
"wc_iniservidor")).Trim();
83 rutaServidor = Path.Combine(rutaServidor,
"MODULOS\\offline\\descargas");
85 string rutaFicherosServidor = Path.Combine(rutaServidor, path);
86 string fullLocalFileName = Path.Combine(rutaFicherosServidor, fileName);
88 if (Directory.Exists(rutaFicherosServidor))
90 if (File.Exists(fullLocalFileName))
91 File.Delete(fullLocalFileName);
95 Directory.CreateDirectory(path);
98 var oneDriveFileName = Path.Combine(carpeta, fileName);
100 var llOk = DescargarArchivoOneDrive(oneDriveFileName, fullLocalFileName,
true, deleteSource);
105 catch (Exception loEx)
107 string error =
"Se ha producido un error al obtener datos de OneDrive (" + loEx.Message +
").";
122 private bool DescargarArchivoOneDrive(
string oneDriveFileName,
string fullLocalFileName,
bool uncompressZip,
bool deleteSource)
125 var llOk = _oFileDialog365._DownLoadFile(oneDriveFileName, fullLocalFileName);
127 if (uncompressZip && File.Exists(fullLocalFileName))
129 clsOffLine utilsOffline =
new clsOffLine();
130 utilsOffline.Fichero_Descomprimir(fullLocalFileName, Path.GetDirectoryName(fullLocalFileName),
false);
135 _oFileDialog365._DeleteFile(oneDriveFileName);
150 public bool Subir_Fichero(
string archivo,
string zipFilename,
string carpeta,
int idConf, ref
long uploadedFileSize)
158 if (!
string.IsNullOrWhiteSpace(zipFilename))
160 if (File.Exists(archivo))
162 clsOffLine utilsOffline =
new clsOffLine();
163 string pathArchivoComprimido = utilsOffline.Fichero_Comprimir(archivo, zipFilename);
165 archivo = Path.Combine(Path.GetDirectoryName(archivo), pathArchivoComprimido);
166 archivo = Path.Combine(archivo, zipFilename);
171 llOk = GarantizarDirectorioDestino(carpeta);
177 var destino = Path.Combine(carpeta, Path.GetFileName(archivo));
178 llOk = _oFileDialog365._UploadFile(archivo, destino);
179 if(!llOk && !
string.IsNullOrWhiteSpace(_oFileDialog365._ErrorMessage))
186 uploadedFileSize =
new FileInfo(archivo).Length;
190 catch (Exception loEx)
192 string error =
"Se ha producido un error al enviar datos a OneDrive (" + loEx.Message +
").";
198 #region Métodos privados 205 private bool GarantizarDirectorioDestino(
string tcFolderUpload)
209 if (!_oFileDialog365._DirectoryExists(tcFolderUpload))
211 llOk = _oFileDialog365._CreateFolder(tcFolderUpload);
213 llOk = _oFileDialog365._DirectoryExists(tcFolderUpload);
224 public List<string> GetListFiles(
string carpetaserv,
int idConf)
226 if (_oFileDialog365._DirectoryExists(carpetaserv))
228 var ficheros = _oFileDialog365._GetFolderFilenamesList(carpetaserv);
233 return new List<string>();
238 #endregion Métodos privados Interficie del gestor de ficheros o365
Interfície de la clase de instanciación de objetos y clases O365
object Retrieve(Type T)
Resuelve objeto de tipo T
Es como el tipo de entrada asientos pero por negocio, sin formulario, pq quiero que me haga las propu...
static DependencyInjector Instance
Instancia
TipoOneDrive
Tipos de OneDrive dentro de Sage50
IFileDialog365 _NewFileDialog365(TipoConexion conexion, TipoOneDrive tipoOneDrive)
Obtiene una nueva instancia de tipo IFileDialog365 con los parámetros indicados
TipoConexion
Tipo de conexión
Clase Inyector de dependencias para resolver las dependencias