public string ImportaCondomini(string inputPathFileName, string prefixConto, bool importaContiStudio, TipoSaldi tipoSaldi, string password, SoftwareInput importType) { string message; var fullPathFileName = compressFile(inputPathFileName, importType == SoftwareInput.Excel || importType == SoftwareInput.Summa); // get some info about the input file var fileInfo = new FileInfo(fullPathFileName); // open input stream using (var stream = new FileStream(fullPathFileName, FileMode.Open, FileAccess.Read)) { var key = Guid.NewGuid(); using (var uploadStreamWithProgress = new StreamWithProgress(stream)) { //uploadStreamWithProgress.ProgressChanged += uploadStreamWithProgress_ProgressChanged; // start service client var client = new FileTransferServiceClient(); // upload file client.UploadFile(key.ToString(), fileInfo.Length, uploadStreamWithProgress); // close service client //client.Close(); } message = GetServiceClient().ImportazioneCondomini(key.ToString(), prefixConto, importaContiStudio, tipoSaldi, password, importType, GetUserInfo()); // Aggiorno le lista di condomini, unità immobiliari e persone _cacheService.LoadPersone(); _cacheService.LoadCondomini(); _cacheService.LoadUI(); _cacheService.LoadEsercizi(); CloseService(); } return message; }
public CondominiImportabili GetCondomini(string inputPathFileName, string password, SoftwareInput importType) { try { var fullPathFileName = compressFile(inputPathFileName, importType == SoftwareInput.Excel || importType == SoftwareInput.Summa); // get some info about the input file var fileInfo = new FileInfo(fullPathFileName); // open input stream using (var stream = new FileStream(fullPathFileName, FileMode.Open, FileAccess.Read)) { var key = Guid.NewGuid(); using (var uploadStreamWithProgress = new StreamWithProgress(stream)) { //uploadStreamWithProgress.ProgressChanged += uploadStreamWithProgress_ProgressChanged; // start service client var client = new FileTransferServiceClient(); // upload file client.UploadFile(key.ToString(), fileInfo.Length, uploadStreamWithProgress); // close service client //client.Close(); } var result = GetServiceClient().GetCondominiDaImportare(key.ToString(), password, importType, GetUserInfo()); CloseService(); return result; } } catch (CommunicationObjectAbortedException ex) { _log.DebugFormat("Errore nella chiamata al servizio - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Login.Instance.CurrentLogin().Azienda); } catch (CommunicationObjectFaultedException ex) { _log.DebugFormat("Errore nella chiamata al servizio - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Login.Instance.CurrentLogin().Azienda); } catch (CommunicationException ex) { _log.DebugFormat("Errore nella chiamata al servizio - {0} - azienda:{1}", ex, Utility.GetMethodDescription(), Login.Instance.CurrentLogin().Azienda); } catch (IOException ex) { _log.ErrorFormat("Errore nella lettura del file da importare - {0} - file:{1} - password:{2} - importType:{3} - azienda:{4}", ex, Utility.GetMethodDescription(), inputPathFileName, password, importType, Login.Instance.CurrentLogin().Azienda); var message = $"Non è possibile accedere al file: {inputPathFileName}"; return new CondominiImportabili { Message = message, Condomini = null}; } catch (Exception ex) { _log.ErrorFormat("Errore nella lettura del file da importare - {0} - file:{1} - password:{2} - importType:{3} - azienda:{4}", ex, Utility.GetMethodDescription(), inputPathFileName, password, importType, Login.Instance.CurrentLogin().Azienda); var message = $"Errore inaspettato nell'importazione del file: {inputPathFileName}{Environment.NewLine}Si prega di riprovare."; return new CondominiImportabili { Message = message, Condomini = null }; } return new CondominiImportabili { Message = "Errore nella chiamata al servizio", Condomini = null }; }
public IList<BollettaMessaggioDTO> GetBolletteDaImportare(string inputPathFileName) { IList<BollettaMessaggioDTO> result; var fullPathFileName = inputPathFileName + ".zip"; using (var zipFile = new ZipFile()) { zipFile.AddFile(inputPathFileName); zipFile.Save(fullPathFileName); } // get some info about the input file var fileInfo = new FileInfo(fullPathFileName); // open input stream using (var stream = new FileStream(fullPathFileName, FileMode.Open, FileAccess.Read)) { var key = Guid.NewGuid(); using (var uploadStreamWithProgress = new StreamWithProgress(stream)) { //uploadStreamWithProgress.ProgressChanged += uploadStreamWithProgress_ProgressChanged; // start service client var client = new FileTransferServiceClient(); // upload file client.UploadFile(key.ToString(), fileInfo.Length, uploadStreamWithProgress); } result = GetServiceClient().GetBolletteDaImportare(key.ToString(), GetUserInfo()); CloseService(); } return result; }