public static void SaveToFile(string strDownloadLine, string pathToSave, bool append_file)
        {
            ScreenKeyDataLoad temp = new ScreenKeyDataLoad(strDownloadLine);

            if (append_file == true)
            {
                FileInfo stateDB = new FileInfo(pathToSave);
                if (!stateDB.Exists)
                {
                    return;
                }
                StreamWriter append = stateDB.AppendText();

                for (int i = 0; i < temp.ScreenData.Length; i++)
                {
                    append.Write(temp.ScreenNumber[i]);
                    append.WriteLine(temp.ScreenData[i]);
                }
                append.Close();
            }
            else
            {
                FileInfo     stateDB = new FileInfo(pathToSave);
                StreamWriter append  = stateDB.CreateText();

                for (int i = 0; i < temp.ScreenData.Length; i++)
                {
                    append.Write(temp.ScreenNumber[i]);
                    append.WriteLine(temp.ScreenData[i]);
                }
                append.Close();
            }
        }
Ejemplo n.º 2
0
        private void buttonSplitSelect_Click(object sender, EventArgs e)
        {
            ScreenKey.ScreenKeys.Clear();
            StateTable.ListOfStateTables.Clear();
            StateTable.ViewStateTables.Clear();
            StateTable.RefreshViewStatesTables(comboBoxViewStates);

            StreamReader sr = new StreamReader(pathFile + @"\SplitIn\MessageIn.anl");

            // terminal commands
            sr.BaseStream.Position = 0;
            if (checkBoxTerminalCommands.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Terminal Commands.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();

                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        if (line[0] == '1' && line[2] == (char)28)
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // screen/keyboard data
            sr.BaseStream.Position = 0;
            if (checkBoxScreenKeyboard.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Screen Keyboard.tdb");
                StreamWriter writer = f.CreateText();
                writer.Close();

                f      = new FileInfo(pathFile + @"\SplitIn\Screen Keyboard.anl");
                writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == '1')  // 3.....11
                        {
                            ScreenKeyDataLoad.SaveToFile(line, pathFile + @"\SplitIn\Screen Keyboard.tdb", true);
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();

                ScreenKey.LoadScreenKeys(pathFile + @"\SplitIn\Screen Keyboard.tdb");
            }

            // state tables
            sr.BaseStream.Position = 0;
            if (checkBoxStateTables.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\State Tables.anl");
                StreamWriter writer = f.CreateText();

                FileInfo     stateDB = new FileInfo(pathFile + @"\SplitIn\State Tables.tdb");
                StreamWriter writer2 = stateDB.CreateText();
                writer2.Close();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == '2')  // 3.....12
                        {
                            writer.WriteLine(line);
                            StateTablesLoad stl = new StateTablesLoad(line);
                            stl.SaveToFile(pathFile + @"\SplitIn\State Tables.tdb");
                        }
                    }
                    line = sr.ReadLine();
                }
                writer.Close();

                StateTable.LoadListOfStateTables(pathFile + @"\SplitIn\State Tables.tdb");
                // load list
                comboBoxViewStateTabel.Text = "ALL";
                listBoxStateTabels.Items.Clear();
                for (int i = 0; i < StateTable.ListOfStateTables.Count; i++)
                {
                    listBoxStateTabels.Items.Add(StateTable.ListOfStateTables[i].textTable);
                }
            }

            // configuration parameters
            sr.BaseStream.Position = 0;
            if (checkBoxConfigurationParameters.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Configuration Parameters.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == '3')  // 3.....13
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // FIT data
            sr.BaseStream.Position = 0;
            if (checkBoxFIT.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\FIT.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == '5')  // 3.....15
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // Configuration ID Number Load
            sr.BaseStream.Position = 0;
            if (checkBoxConfigurationIDNumber.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Configuration ID Number.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == '6')  // 3.....16
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // Enhanced Configuration Parameters Load
            sr.BaseStream.Position = 0;
            if (checkBox1EnhancedConfigurationParameters.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Enhanced Configuration Parameters.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == 'A')  // 3.....16
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // MAC Field Selection Load
            sr.BaseStream.Position = 0;
            if (checkBoxMACFieldSelection.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\MAC Field Selection.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == 'B')  // 3.....1B
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // Date and Time
            sr.BaseStream.Position = 0;
            if (checkBoxDateAndTime.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Date and Time.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == 'C')  // 3.....1C
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // Dispenser Currency Cassette Mapping Table
            sr.BaseStream.Position = 0;
            if (checkBoxDispencerCurrencyCassetteMapp.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Dispenser Currency Cassette Mapping Table.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == 'E')  // 3.....1E
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // XML Configuration Download
            sr.BaseStream.Position = 0;
            if (checkBoxXMLConfigurationDownload.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\XML Configuration Download.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '1' && line[posSep3 + 2] == 'I')  // 3.....1I
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // Interactive Transaction Response
            sr.BaseStream.Position = 0;
            if (checkBoxInteractiveTransactionResponse.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Interactive Transaction Response.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '2' && (line[posSep3 + 2] >= '0' && line[posSep3 + 2] <= '9'))   // 3.....2(0-9)
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // Encryption Key Change
            sr.BaseStream.Position = 0;
            if (checkBoxEncryptionKeyChange.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Encryption Key Change.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '3' && (line[posSep3 + 2] >= '1' && line[posSep3 + 2] <= '9'))  // 3.....3(1-9)
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // Extended Encryption Key Change
            sr.BaseStream.Position = 0;
            if (checkBoxExtendedEncryptionKeyChange.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Extended Encryption Key Change.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '3' && line[posSep3 + 1] == '3' && ((line[posSep3 + 2] >= '1' && line[posSep3 + 2] <= '9') || (line[posSep3 + 2] >= 'A' && line[posSep3 + 2] <= 'K')))  // 4.....2(1-9)|(A-K)
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // HostToExitMessages
            sr.BaseStream.Position = 0;
            if (checkBoxHostToExitMessages.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Host to Exit Messages.anl");
                StreamWriter writer = f.CreateText();

                string line = sr.ReadLine();
                while (line != null)
                {
                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 1);
                        if (posSep3 > 0 && line[0] == '7' && line[posSep3 + 1] == '1')  // 7.....1
                        {
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            // Transaction Reply Command
            sr.BaseStream.Position = 0;
            if (checkBoxTransactionReplyCommand.Checked == true)
            {
                if (!Directory.Exists(pathFile + @"\SplitIn"))
                {
                    Directory.CreateDirectory(pathFile + @"\SplitIn");
                }

                FileInfo     f      = new FileInfo(pathFile + @"\SplitIn\Transaction Reply Command.anl");
                StreamWriter writer = f.CreateText();

                string line     = sr.ReadLine();
                bool   mutiline = false;

                while (line != null)
                {
                    if (mutiline == true)
                    {
                        if (line.Contains(stopSeparatorMessage) && line[0] == stopSeparatorMessage[0]) // sfarsitul mesajului
                        {
                            mutiline = false;
                            writer.WriteLine(stopSeparatorMessage);
                        }
                        else
                        {
                            writer.WriteLine(line);
                        }
                    }

                    if (line.Length > 5)
                    {
                        int posSep3 = Utils.StrIndexOf((char)28, line, 2);
                        if (posSep3 > 0 && line[0] == '4')  // 4.....
                        {
                            mutiline = true;
                            writer.WriteLine(startSeparatorMessage);
                            writer.WriteLine(line);
                        }
                    }

                    line = sr.ReadLine();
                }
                writer.Close();
            }

            sr.Close();
        }
Ejemplo n.º 3
0
        public static void SaveToFile(string strDownloadLine, string pathToSave, bool append_file)
        {
            ScreenKeyDataLoad temp = new ScreenKeyDataLoad( strDownloadLine );
            if( append_file == true )
            {
                FileInfo stateDB = new FileInfo(pathToSave);
                if (!stateDB.Exists)
                    return;
                StreamWriter append = stateDB.AppendText();

                for (int i = 0; i < temp.ScreenData.Length; i++)
                {
                    append.Write(temp.ScreenNumber[i]);
                    append.WriteLine(temp.ScreenData[i]);
                }
                append.Close();
            }
            else
            {
                FileInfo stateDB = new FileInfo(pathToSave);
                StreamWriter append = stateDB.CreateText();

                for (int i = 0; i < temp.ScreenData.Length; i++)
                {
                    append.Write(temp.ScreenNumber[i]);
                    append.WriteLine(temp.ScreenData[i]);
                }
                append.Close();
            }
        }