/// <summary> /// Closes the stream. We used the close method to transfer /// the file via ftp. /// </summary> public void Close() { DataStream.WriteLine("]}"); DataStream.Flush(); DataStream.Close(); // transfer the file to the sftp service if (!HasUsers) { Logger.Debug("No Users to update. Skipping sftp process."); } else { var host = StreamConfig.Settings["host"]; var username = StreamConfig.Settings["username"]; var password = StreamConfig.Settings["password"]; var destinationPath = StreamConfig.Settings["destinationPath"]; SftpService.SendFile(FileName, host, username, password, destinationPath); } // clean up the temp file try { File.Delete(FileName); } catch (Exception ex) { Logger.Error(ex); throw; } }
public PharmacyHttp(MyDbContext context) { SftpService = new SftpService(); HttpRequests = new HttpRequests(); SmptServerService = new SmptServerService(); ReportText = new ReportText(context); }
public bool SendReport(DateOfOrder date) { try { String report = ReportText.CreateReport(date); String[] reportParts = report.Split('\\'); SftpService.UploadFile(report, @"\pub\" + reportParts[1]); SmptServerService.SendEMailNotification(report, "report"); return(true); } catch (Exception e) { return(false); } }
private App() { EmailVerificationService = new EmailVerificationService(); SftpService = new SftpService(); HttpService = new HttpService(); TenderService = new TenderService(); MedicalExaminationService = new MedicalExaminationService( new MedicalExaminationRepository(new MySQLStream <MedicalExamination>(), new IntSequencer())); PatientFeedbackService = new PatientFeedbackService( new PatientFeedbackRepository(new MySQLStream <PatientFeedback>(), new IntSequencer())); MedicalExaminationReportService = new MedicalExaminationReportService( new MedicalExaminationReportRepository(new MySQLStream <MedicalExaminationReport>(), new IntSequencer())); PrescriptionService = new PrescriptionService( new PrescriptionRepository(new MySQLStream <Prescription>(), new IntSequencer())); MedicalRecordService = new MedicalRecordService( new MedicalRecordRepository(new MySQLStream <MedicalRecord>(), new IntSequencer()), EmailVerificationService); QuestionService = new QuestionService( new QuestionRepository(new MySQLStream <Question>(), new IntSequencer())); AnswerService = new AnswerService( new AnswerRepository(new MySQLStream <Answer>(), new IntSequencer()), QuestionService); AllergiesService = new AllergiesService( new AllergiesRepository(new MySQLStream <Allergies>(), new IntSequencer())); PatientService = new PatientService( new PatientRepository(new MySQLStream <Patient>(), new IntSequencer())); SurveyService = new SurveyService( new SurveyRepository(new MySQLStream <Survey>(), new IntSequencer()), MedicalExaminationService, AnswerService); DoctorService = new DoctorService( new DoctorRepository(new MySQLStream <Doctor>(), new IntSequencer())); ReportService = new ReportService( new ReportRepository(new MySQLStream <Report>(), new IntSequencer()), SftpService); DoctorWorkDayService = new DoctorWorkDayService( new DoctorWorkDayRepository(new MySQLStream <DoctorWorkDay>(), new IntSequencer()), DoctorService); SpetialitationService = new SpetialitationService( new SpecialitationRepository(new MySQLStream <Specialitation>(), new IntSequencer())); AppointmentService = new AppointmentService( new AppointmentRepository(new MySQLStream <Appointment>(), new IntSequencer()), PatientService); EPrescriptionService = new EPrescriptionService( new EPrescriptionRepository(new MySQLStream <EPrescription>(), new IntSequencer()), SftpService); PharmacyService = new PharmacyService( new PharmacyRepository(new MySQLStream <Pharmacies>(), new IntSequencer())); RoomService = new RoomService( new RoomRepository(new MySQLStream <Room>(), new IntSequencer())); ManagerService = new ManagerService( new ManagerRepository(new MySQLStream <Manager>(), new IntSequencer())); SecretaryService = new SecretaryService( new SecretaryRepository(new MySQLStream <Secretary>(), new IntSequencer())); SystemAdministratorService = new SystemAdministratorService( new SystemAdministratorRepository(new MySQLStream <SystemAdministrator>(), new IntSequencer())); UserService = new UserService( new UserRepository(new MySQLStream <User>(), new IntSequencer()), PatientService, SystemAdministratorService); }
private static void Main() { var config = new SftpConfig { Host = "test.rebex.net", Port = 22, UserName = "******", Password = "******" }; var sftpService = new SftpService(new NullLogger <SftpService>(), config); // list files var files = sftpService.ListAllFiles("/pub/example"); foreach (var file in files) { if (file.IsDirectory) { Console.WriteLine($"Directory: [{file.FullName}]"); } else if (file.IsRegularFile) { Console.WriteLine($"File: [{file.FullName}]"); } } // download a file const string pngFile = @"hi.png"; File.Delete(pngFile); sftpService.DownloadFile(@"/pub/example/imap-console-client.png", pngFile); if (File.Exists(pngFile)) { Console.WriteLine($"file {pngFile} downloaded"); } // upload a file // not working for this demo SFTP server due to readonly permission var testFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test.txt"); sftpService.UploadFile(testFile, @"/pub/test.txt"); sftpService.DeleteFile(@"/pub/test.txt"); }