Exemple #1
0
        public override string ToString()
        {
            var sb = new StringBuilder(AchFile.CharactersPerLine);

            sb.Append(RecordType);

            sb.Append((int)ServiceClass);

            sb.Append(EntryCount.ToString().TrimAndPadLeft(6, '0'));

            sb.Append(EntryHash.TrimAndPadLeft(10, '0'));

            sb.Append((TotalDebits * 100).ToString("0").TrimAndPadLeft(12, '0'));

            sb.Append((TotalCredits * 100).ToString("0").TrimAndPadLeft(12, '0'));

            sb.Append(CompanyId.TrimAndPadRight(10));

            sb.Append(MessageAuthenticationCode.TrimAndPadRight(19));

            sb.Append(Reserved.TrimAndPadRight(6));

            sb.Append(OriginatingDfiId.TrimAndPadRight(8));

            sb.Append(BatchNumber.ToString().TrimAndPadLeft(7, '0'));

            sb.AppendLine();

            return(sb.ToString());
        }
        public override string ToString()
        {
            StringBuilder xml = new StringBuilder();

            xml.Append(base.ToString()); // <box>
            xml.Append("<entryCount>").Append(EntryCount.ToString()).Append("</entryCount>");
            xml.Append("<sampleNumbers>");

            for (int i = 0; i < EntryCount && SampleNumbers != null && SampleNumbers.Length > i; i++)
            {
                xml.Append(SampleNumbers[i].ToString()).Append(" ");
            }

            xml.Append("</sampleNumbers>");
            xml.Append("</box>");

            return(xml.ToString());
        }
Exemple #3
0
        public override string ToString()
        {
            var sb = new StringBuilder(AchFile.CharactersPerLine);

            sb.Append(RecordType);

            sb.Append(BatchCount.ToString().TrimAndPadLeft(6, '0'));

            sb.Append(BlockCount.ToString().TrimAndPadLeft(6, '0'));

            sb.Append(EntryCount.ToString().TrimAndPadLeft(8, '0'));

            sb.Append(EntryHash.TrimAndPadLeft(10, '0'));

            sb.Append((TotalDebits * 100).ToString("0").TrimAndPadLeft(12, '0'));  // 123.45 => 000000012345

            sb.Append((TotalCredits * 100).ToString("0").TrimAndPadLeft(12, '0')); // 123.45 => 000000012345

            sb.Append(Reserved.TrimAndPadRight(39));

            sb.AppendLine();

            return(sb.ToString());
        }
Exemple #4
0
        /// <summary>
        /// Initialise les infos avec le contenu du fichier
        /// </summary>
        protected override sealed void _ReadData()
        {
            FileInfo     fileInfo = new FileInfo(_FileName);
            BinaryReader reader   = null;

            try
            {
                reader    = new BinaryReader(new FileStream(_FileName, FileMode.Open, FileAccess.Read));
                _FileSize = (uint)fileInfo.Length;

                reader.BaseStream.Seek(0x0L, SeekOrigin.Begin);

                // TAG
                _Tag = new string(reader.ReadChars((int)_TAG_LENGTH));

                // Lecture des entrées  (attention, tout est en Big Endian ici !)
                uint  count    = 0;
                bool  finished = false;
                Entry newEntry;

                _IsMagicMap = true;

                while (!finished)
                {
                    newEntry = new Entry {
                        entryNumber = count
                    };

                    // 1 octet inutilisé
                    reader.BaseStream.Seek(1, SeekOrigin.Current);

                    // Adresse
                    newEntry.address = (uint)reader.BaseStream.Position;

                    // Id du fichier : 4 octets
                    newEntry.fileId = BinaryTools.ToBigEndian(reader.ReadUInt32());

                    // Taille 1
                    newEntry.firstSize = BinaryTools.ToBigEndian(reader.ReadUInt32());

                    // Non utilisé : 4 octets
                    reader.BaseStream.Seek(4, SeekOrigin.Current);

                    // Taille 2
                    newEntry.secondSize = BinaryTools.ToBigEndian(reader.ReadUInt32());

                    // Non utilisé : 5 octets
                    reader.BaseStream.Seek(5, SeekOrigin.Current);

                    // Marqueur de fin d'entrée
                    if (finishMarker == null)
                    {
                        finishMarker = Encoding.ASCII.GetString(reader.ReadBytes(2));
                    }
                    else
                    {
                        reader.BaseStream.Seek(2, SeekOrigin.Current);
                    }

                    // Ajout de l'entrée à la collection
                    entryList.Add(newEntry.fileId, newEntry);

                    // Is it a magic map ?
                    if ((newEntry.firstSize != 0 || newEntry.secondSize != 0) && _IsMagicMap)
                    {
                        _IsMagicMap = false;
                    }

                    if (reader.BaseStream.Position >= _FileSize)
                    {
                        finished = true;
                    }

                    count++;
                }
            }
            catch (EndOfStreamException)
            {
                // Fin du fichier atteinte, on ne fait rien
            }
            finally
            {
                if (reader != null)
                {
                    reader.BaseStream.Seek(0, SeekOrigin.Begin);
                    reader.Close();
                }
            }

            // EVO_65: Properties
            Property.ComputeValueDelegate entryCountDelegate = () => EntryCount.ToString();
            Property.ComputeValueDelegate magicDelegate      = () => IsMagicMap ? "Yes" : "No";

            Properties.Add(new Property("Entry count", "Mapping", entryCountDelegate));
            Properties.Add(new Property("Magic Map?", "Mapping", magicDelegate));
        }
Exemple #5
0
        /// <summary>
        /// Checks each entry inside the package and throws an error if any record is damaged.
        /// </summary>
        /// <param name="errorsAsWarnings">True to continue in case of errors, otherwise false</param>
        public virtual void ScanPackage(bool errorsAsWarnings)
        {
            Log.WriteLine("Pre-Scanning package for RIR %@ with %@ entries...", LogLevel.Message, RirName, EntryCount.ToString("N0"));

            Func <string, RirFileReaderException, bool> onErrorFunc = (input, ex) =>
            {
                if (errorsAsWarnings)
                {
                    Log.WriteLine("An error occurred while processing line %@. %@. Ignoring...", LogLevel.Warning, ex.LineNumber.ToString("N0"), ex.Message);
                    return(true); // Handled
                }
                else
                {
                    Log.WriteLine("An error occurred while processing line %@. %@. Aborting!", LogLevel.Error, ex.LineNumber.ToString("N0"), ex.Message);
                    return(false); // Not handled
                }
            };

            foreach (RirPackageEntry entry in Entries)
            {
                if (entry.IsScanned)
                {
                    Log.WriteLine("Entry %@ for RIR package %@ is already scanned. %@ records. Skipping...", LogLevel.Debug, entry.Identifier, RirName, entry.RecordCount.ToString("N0"));
                    continue;
                }

                Log.WriteLine("Pre-Scanning entry %@ for RIR Package %@...", LogLevel.Debug, entry.Identifier, RirName);
                entry.Scan(onErrorFunc);
                Log.WriteLine("Pre-Scanning found %@ records for entry %@ inside RIR Package %@...", LogLevel.Debug, entry.RecordCount.ToString("N0"), entry.Identifier, RirName);
            }

            Log.WriteLine("Pre-Scanning completed for RIR Package %@. %@ total records.", LogLevel.Debug, RirName, TotalRecordCount.ToString("N0"));
        }