I have my service code already ready, but inside it, I should get the first file containing the extension .cpv, in case I read this file, inside the file it contains several vouchers with its due information, however, I need to save the data it contains on each voucher, such as date and time, document value, as soon as I finish processing this file, I have to move those files to another folder. How could I be initiating this coding of this application? Because in my windows service project, I already have two classes LogService and Program.cs, already ready, as it is a windows service, how could I apply these requirements in this windows functionality, to read those files in that directory? Would you kindly help me, friend?
Here's my service code:
Service1.cs
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using System.ServiceProcess;
- using System.Text;
- using System.Threading.Tasks;
- using System.Timers;
-
- namespace ServicoProcessamentoComprovantes
- {
- public partial class Service1: ServiceBase
- {
- private Timer timer1 = null;
- public Service1 ()
- {
- InitializeComponent ();
- }
-
- protected override void OnStart (string [] args)
- {
- LogService.writeEventLog ("The timer is set to 10 seconds");
- timer1 = new Timer ();
-
- this.timer1.Interval = 1000;
- this.timer1.Elapsed + = new ElapsedEventHandler (this.timer_tick);
- this.timer1.Enabled = true;
- LogService.writeEventLog ("Starting Banestes service");
- }
-
- private void timer_tick (object sender, ElapsedEventArgs e)
- {
-
- LogService.writeEventLog ("The timer and some operations are running ...");
-
-
- LogService.writeEventLog ("Operation completed successfully");
- }
- protected override void OnStop ()
- {
- LogService.writeEventLog ("******** --Event: Idle-- ********");
- LogService.writeEventLog ("Attempt to Stop Service");
- timer1.Stop ();
- timer1 = null;
- LogService.writeEventLog ("Service stopped by user");
- }
- private void ListArchives ()
- {
- string extension = Path.GetExtension ("");
- DirectoryInfo Dir = new DirectoryInfo (@ "\\ S3A601 \ ftp @ sefaz \ BANESTES \ Output_SDPJ \ test");
- }
- }
- }