Esempio n. 1
0
        public void DoParsingFlow(string fileFullName)
        {
            int lineCount = 0;

            try
            {
                using (FileStream fs = File.Open(fileFullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    using (BufferedStream bs = new BufferedStream(fs))
                        using (StreamReader sr = new StreamReader(bs))
                        {
                            string line;
                            while ((line = sr.ReadLine()) != null)
                            {
                                lineCount++;

                                if (line.Contains("_PIN ENTER"))
                                {
                                    JournalPart   = "";
                                    CardTaken     = "No";
                                    CashTaken     = "No";
                                    CashPresented = "No";
                                    CardEjected   = "No";
                                }

                                //var newLine = line.Remove(0, 8);
                                if (line.Contains("_new transaction"))
                                {
                                    NewTransaction = "Yes";
                                }
                                if (line.Contains("_CARD ENTERED"))
                                {
                                    CardEntered = "Yes";
                                }

                                if (line.Contains("_Pickup AC"))
                                {
                                    NoteBills = line.Remove(0, 38).Trim();
                                }
                                if (line.Contains("_CASH PRESENTED"))
                                {
                                    CashPresented = "Yes";
                                }

                                if (line.Contains("_CASH TAKEN"))
                                {
                                    CashTaken = "Yes";
                                }
                                if (line.Contains("_JOUR"))
                                {
                                    _journalPath = line + Environment.NewLine;
                                    while (!line.Equals("----------------------------------------"))
                                    {
                                        string nextLine = sr.ReadLine();

                                        _journalPath += nextLine + Environment.NewLine;
                                        if (nextLine != null && nextLine.StartsWith("-------------------"))
                                        {
                                            break;
                                        }
                                    }
                                    JournalPart = _journalPath;
                                }
                                if (JournalPart != "")
                                {
                                    try
                                    {
                                        _sessTa = new SessionsTableAdapter();
                                        int a = _sessTa.Insert("DIEBOLD", JournalPart, CardTaken, CashTaken, NoteBills, CashPresented, CardEjected);

                                        JournalPart   = "";
                                        CardTaken     = "No";
                                        CashTaken     = "No";
                                        NoteBills     = "";
                                        CashPresented = "No";
                                        CardEjected   = "No";
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.Message);
                                    }
                                }


                                //Thread.Sleep(2000);
                            }
                        }
            }
            catch (Exception ex)
            {
                Console.WriteLine("DoParsingFlow err : " + ex.Message);
            }
        }
Esempio n. 2
0
        public void DoParsingFlow(string fileFullName)
        {
            int lineCount = 0;

            try
            {
                using (FileStream fs = File.Open(fileFullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    using (BufferedStream bs = new BufferedStream(fs))
                        using (StreamReader sr = new StreamReader(bs))
                        {
                            string line;
                            while ((line = sr.ReadLine()) != null)
                            {
                                lineCount++;

                                if (line.Contains("PIN ENTERED"))
                                {
                                    JournalPart   = "";
                                    CardTaken     = "No";
                                    CashTaken     = "No";
                                    CashPresented = "No";
                                    CardEjected   = "No";
                                }


                                if (line.Contains("TVR:"))
                                {
                                    _journalPath = line + Environment.NewLine;
                                    while (!line.Contains("TRANSACTION END") || !line.Contains("PIN ENTERED"))
                                    {
                                        string nextLine = sr.ReadLine();

                                        _journalPath += nextLine + Environment.NewLine;
                                        if (nextLine != null && nextLine.Contains("PIN ENTERED"))
                                        {
                                            break;
                                        }
                                    }
                                    JournalPart = _journalPath;

                                    if (JournalPart != "")
                                    {
                                        try
                                        {
                                            _sessTa = new SessionsTableAdapter();
                                            int a = _sessTa.Insert("WINCOR", JournalPart, CardTaken, CashTaken, NoteBills, CashPresented, CardEjected);

                                            JournalPart   = "";
                                            CardTaken     = "No";
                                            CashTaken     = "No";
                                            NoteBills     = "";
                                            CashPresented = "No";
                                            CardEjected   = "No";
                                        }
                                        catch (Exception ex)
                                        {
                                            Console.WriteLine(ex.Message);
                                        }
                                    }
                                }

                                //Thread.Sleep(2000);
                            }
                        }
            }
            catch (Exception ex)
            {
                Console.WriteLine("DoParsingFlow err : " + ex.Message);
            }
        }