Title: services process                                 If you need copy same format use firefox or chrome or safari but iexplorer not work


Preview of Code
using System;
using System.ServiceProcess;
namespace FPCollector
{
    internal static class Program
    {
        private static void Main()
        {
            ServiceBase[] services = new ServiceBase[]
            {
                new Service1()
            };
            ServiceBase.Run(services);
        }
    }
}
=============================================
using System;
using System.ComponentModel;
using System.Configuration.Install;
using System.ServiceProcess;
namespace FPCollector
{
    [RunInstaller(true)]
    public class ProjectInstaller : Installer
    {
        private IContainer components;
        private ServiceProcessInstaller serviceProcessInstaller1;
        private ServiceInstaller serviceInstaller1;
        public ProjectInstaller()
        {
            this.InitializeComponent();
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing && this.components != null)
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }
        private void InitializeComponent()
        {
            this.serviceProcessInstaller1 = new ServiceProcessInstaller();
            this.serviceInstaller1 = new ServiceInstaller();
            this.serviceProcessInstaller1.Account = ServiceAccount.LocalSystem;
            this.serviceProcessInstaller1.Password = null;
            this.serviceProcessInstaller1.Username = null;
            this.serviceInstaller1.DisplayName = "TBSTACollector";
            this.serviceInstaller1.ServiceName = "TBSTACollector";
            this.serviceInstaller1.StartType = ServiceStartMode.Automatic;
            base.Installers.AddRange(new Installer[]
            {
                this.serviceProcessInstaller1,
                this.serviceInstaller1
            });
        }
    }
}
 
===========================================
 
using FPCollector.TBSRemoteSync;
using Microsoft.Win32;
using System;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.OracleClient;
using System.IO;
using System.Linq;
using System.ServiceProcess;
using System.Timers;
namespace FPCollector
{
    public class Service1 : ServiceBase
    {
        private Timer timer1 = new Timer();
        private IContainer components;
        public Service1()
        {
            this.InitializeComponent();
            SystemEvents.SessionEnded += new SessionEndedEventHandler(this.SystemEvents_SessionEnded);
        }
        public void OnDebug()
        {
            this.OnStart(null);
        }
        protected override void OnStart(string[] args)
        {
            this.timer1.Elapsed += new ElapsedEventHandler(this.timer1_Elapsed);
            this.timer1.Interval = 5000.0;
            this.timer1.Enabled = true;
            this.timer1.Start();
        }
        protected override void OnStop()
        {
            this.timer1.Enabled = false;
        }
        private void SystemEvents_SessionEnded(object sender, SessionEndedEventArgs e)
        {
            this.timer1.Enabled = false;
        }
        public void timer1_Elapsed(object sender, EventArgs e)
        {
            string text = "C:\\Business City\\Log_" + string.Format("{0:yyyy-MM-dd}", DateTime.Now) + ".txt";
            if (!File.Exists(text))
            {
                FileStream fileStream = File.Create(text);
                fileStream.Close();
            }
            try
            {
                OracleConnection oracleConnection = new OracleConnection(ConfigurationManager.ConnectionStrings["Con2"].ToString());
                OracleCommand oracleCommand = new OracleCommand("SELECT MAX(to_number(TA_COUNT)) FROM HRGVUSER.T_HRGV_EVENT_LOGS_TEST", oracleConnection);
                oracleConnection.Open();
                if (oracleConnection.State == ConnectionState.Open)
                {
                    File.AppendAllText(text, "(" + DateTime.Now.ToString() + ")     Connection to oracle db is open OK.." + Environment.NewLine);
                    object value = (oracleCommand.ExecuteScalar() == DBNull.Value) ? 1 : oracleCommand.ExecuteScalar();
                    File.AppendAllText(text, "(" + DateTime.Now.ToString() + ")     Table found OK ..." + Environment.NewLine);
                    long num = Convert.ToInt64(value);
                    SvcRemoteSyncClient svcRemoteSyncClient = new SvcRemoteSyncClient();
                    File.AppendAllText(text, "(" + DateTime.Now.ToString() + ")     New instance of the RemoteSync is created" + Environment.NewLine);
                    int num2;
                    TBSTARecord[] tARecords = svcRemoteSyncClient.GetTARecords(out num2, new TBSFilterTA
                    {
                        PageOptions = new TBSFilterOptionPage(),
                        PageOptions = 
                        {
                            RowCount = 30
                        },
                        SearchOptions = new TBSFilterOptionSearchTA(),
                        SearchOptions = 
                        {
                            UIDLow = (int)(num + 1L)
                        },
                        SortOptions = new TBSFilterOptionSort(),
                        SortOptions = 
                        {
                            SortByColumn = "TA_UID"
                        }
                    });
                    if (tARecords.Any<TBSTARecord>())
                    {
                        File.AppendAllText(text, "(" + DateTime.Now.ToString() + ")     New records found ..." + Environment.NewLine);
                        TBSTARecord[] array = tARecords;
                        for (int i = 0; i < array.Length; i++)
                        {
                            TBSTARecord tBSTARecord = array[i];
                            if (tBSTARecord.AuthenticationResult == TBSAuthenticationResult.IDENT_OK)
                            {
                                DateTime dateTime = tBSTARecord.Timestamp.AddHours(3.0);
                                string aPID = tBSTARecord.APID;
                                TBSTAContext context = tBSTARecord.Context;
                                string text2;
                                if (context <= TBSTAContext.COMING_CUSTOM_10)
                                {
                                    if (context != TBSTAContext.COMING)
                                    {
                                        switch (context)
                                        {
                                        case TBSTAContext.COMING_CUSTOM_1:
                                        case TBSTAContext.COMING_CUSTOM_2:
                                        case TBSTAContext.COMING_CUSTOM_3:
                                        case TBSTAContext.COMING_CUSTOM_4:
                                        case TBSTAContext.COMING_CUSTOM_5:
                                        case TBSTAContext.COMING_CUSTOM_6:
                                        case TBSTAContext.COMING_CUSTOM_7:
                                        case TBSTAContext.COMING_CUSTOM_8:
                                        case TBSTAContext.COMING_CUSTOM_9:
                                        case TBSTAContext.COMING_CUSTOM_10:
                                            break;
                                        default:
                                            goto IL_2E8;
                                        }
                                    }
                                    text2 = "100";
                                }
                                else
                                {
                                    if (context != TBSTAContext.LEAVING)
                                    {
                                        switch (context)
                                        {
                                        case TBSTAContext.LEAVING_CUSTOM_1:
                                        case TBSTAContext.LEAVING_CUSTOM_2:
                                        case TBSTAContext.LEAVING_CUSTOM_3:
                                        case TBSTAContext.LEAVING_CUSTOM_4:
                                        case TBSTAContext.LEAVING_CUSTOM_5:
                                        case TBSTAContext.LEAVING_CUSTOM_6:
                                        case TBSTAContext.LEAVING_CUSTOM_7:
                                        case TBSTAContext.LEAVING_CUSTOM_8:
                                        case TBSTAContext.LEAVING_CUSTOM_9:
                                        case TBSTAContext.LEAVING_CUSTOM_10:
                                            break;
                                        default:
                                            goto IL_2E8;
                                        }
                                    }
                                    text2 = "200";
                                }
                                IL_301:
                                long num3;
                                long.TryParse(tBSTARecord.UserID, out num3);
                                num = (long)tBSTARecord.UID;
                                OracleCommand oracleCommand2 = new OracleCommand(string.Concat(new object[]
                                {
                                    "Insert into HRGVUSER.T_HRGV_EVENT_LOGS_TEST(USERID,LOCAL_DATESTAMP, LOCAL_TIMESTAMP, EVENTID, TERMINALSN, TA_COUNT) values(`",
                                    num3,
                                    "`,`",
                                    dateTime.ToString("dd/MM/yyyy"),
                                    "`,`",
                                    dateTime.ToString("HH:mm:ss"),
                                    "`,`",
                                    text2,
                                    "`,`",
                                    aPID,
                                    "`,`",
                                    num,
                                    "`)"
                                }), oracleConnection);
                                oracleCommand2.ExecuteNonQuery();
                                File.AppendAllText(text, string.Concat(new object[]
                                {
                                    "(",
                                    DateTime.Now.ToString(),
                                    ")     The SELECT MAX from oracle is: ",
                                    num,
                                    Environment.NewLine
                                }));
                                File.AppendAllText(text, string.Concat(new object[]
                                {
                                    "(",
                                    DateTime.Now.ToString(),
                                    ")     Successful Insert: ",
                                    tBSTARecord.UserID,
                                    ", ",
                                    tBSTARecord.UserFirstName,
                                    ", ",
                                    tBSTARecord.UserLastName,
                                    ", ",
                                    text2,
                                    ", ",
                                    tBSTARecord.UID,
                                    ", ",
                                    Environment.NewLine
                                }));
                                goto IL_4C4;
                                IL_2E8:
                                text2 = ((dateTime.Hour <= 10) ? "100" : "200");
                                goto IL_301;
                            }
                            File.AppendAllText(text, "(" + DateTime.Now.ToString() + ")     Not identified User ..." + Environment.NewLine);
                            IL_4C4:;
                        }
                    }
                    else
                    {
                        File.AppendAllText(text, "(" + DateTime.Now.ToString() + ")     No new records found!!!" + Environment.NewLine);
                    }
                    oracleConnection.Close();
                }
                else
                {
                    File.AppendAllText(text, "(" + DateTime.Now.ToString() + ")     Connection to oracle db is not open! ... problem with oracle connection!" + Environment.NewLine);
                }
            }
            catch (Exception ex)
            {
                if (File.ReadAllBytes(text).Length >= 104857600)
                {
                    string text3 = "Log_" + string.Format("{0:yyyy-MM-dd}", DateTime.Now);
                    if (text.Contains("-"))
                    {
                        int num4 = int.Parse(text.Substring(text.LastIndexOf("-") + 1, text.Length - 4));
                        num4++;
                        text = string.Concat(new object[]
                        {
                            text3,
                            "-",
                            num4,
                            ".txt"
                        });
                    }
                    else
                    {
                        text = text3 + "-1.txt";
                    }
                    FileStream fileStream2 = File.Create(text);
                    fileStream2.Close();
                }
                File.AppendAllText(text, string.Concat(new string[]
                {
                    "(",
                    DateTime.Now.ToString(),
                    ")     ",
                    ex.Message,
                    Environment.NewLine
                }));
            }
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing && this.components != null)
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }
        private void InitializeComponent()
        {
            this.components = new Container();
            base.ServiceName = "Service1";
        }
    }
}