コード例 #1
0
ファイル: AchFile.cs プロジェクト: nunyaa/NachaClassLibrary
        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());
        }
コード例 #2
0
        public ActionResult AddNewEntry(int cameraid)
        {
            try
            {
                _logger.LogInformation("AddNewEntry() called from: " + HttpContext.Connection.RemoteIpAddress.ToString());
                DateTime dateTime = DateTime.UtcNow.ToTimezone(Configuration["Timezone"]);

                lock (lockEntryObject)
                {
                    EntryRecord entryRecord = new EntryRecord();
                    entryRecord.Timestamp = dateTime;
                    entryRecord.CameraId  = cameraid;

                    Context.EntryRecords.Add(entryRecord);

                    var entryCount = Context.EntryCounts
                                     .Where(x => x.CameraId == cameraid && x.Date == dateTime.Date)
                                     ?.Select(x => x)
                                     ?.FirstOrDefault();

                    if (entryCount == null)
                    {
                        EntryCount newEntryCount = new EntryCount();
                        newEntryCount.Date     = dateTime.Date;
                        newEntryCount.CameraId = cameraid;
                        newEntryCount.Count    = 1;

                        Context.EntryCounts.Add(newEntryCount);
                        Context.SaveChangesAsync();
                    }
                    else
                    {
                        entryCount.Count = entryCount.Count + 1;
                        Context.SaveChangesAsync();
                    }

                    SignalRHubConnection.GetInstance(Configuration["SignalRHubUrl"])
                    .SendAsync("BroadcastEntry", cameraid);
                }

                return(new JsonResult(new
                {
                    respcode = ResponseCodes.Successful,
                }));
            }
            catch (Exception e)
            {
                _logger.LogError($"Generic exception handler invoked. {e.Message}: {e.StackTrace}");

                return(new JsonResult(new
                {
                    respcode = ResponseCodes.SystemError,
                    description = ResponseCodes.SystemError.DisplayName(),
                    Error = e.Message
                }));
            }
        }
コード例 #3
0
        public override bool Equals(object other)
        {
            bool result = false;

            if (other is DBFileHeader)
            {
                DBFileHeader header2 = (DBFileHeader)other;
                result  = GUID.Equals(header2.GUID);
                result &= Version.Equals(header2.Version);
                result &= EntryCount.Equals(header2.EntryCount);
            }
            return(result);
        }
コード例 #4
0
        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());
        }
コード例 #5
0
        public IterativeList(string bucket, string prefix)
        {
            this.bucket = bucket;
            this.prefix = prefix;
            this.regex  = null;
            iterator    = iterativeList();
            resp        = FetchBatch();

            if (resp.Entries.Count == 0)
            {
                Count = EntryCount.zero;
            }
            else if (resp.Entries.Count == 1)
            {
                Count = EntryCount.one;
            }
            else
            {
                Count = EntryCount.some;
            }
        }
コード例 #6
0
ファイル: AchFile.cs プロジェクト: nunyaa/NachaClassLibrary
        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());
        }
コード例 #7
0
        public override void OnRebuild(VoidPtr address, int length, bool force)
        {
            base.OnRebuild(address, length, force);

            lightAddress    = null;
            specularAddress = null;

            SCN0Light *header = (SCN0Light *)address;

            if (_name != "<null>")
            {
                header->_nonSpecLightId = NonSpecularLightID;
                header->_part2Offset    = _part2Offset;
                header->_visOffset      = _enableOffset;
                header->_distFunc       = _distFunc;
                header->_spotFunc       = _spotFunc;

                int newFlags = 0;

                if (_lightColor.Count > 1)
                {
                    lightAddress = lightAddr;
                    if (match2 == null)
                    {
                        *((bint *)header->_lightColor.Address) = (int)lightAddr - (int)header->_lightColor.Address;
                        for (int x = 0; x <= FrameCount; x++)
                        {
                            if (x < _lightColor.Count)
                            {
                                *lightAddr++ = _lightColor[x];
                            }
                            else
                            {
                                *lightAddr++ = new RGBAPixel();
                            }
                        }
                    }
                    else
                    {
                        *((bint *)header->_lightColor.Address) = (int)match1.lightAddress - (int)header->_lightColor.Address;
                    }
                }
                else
                {
                    newFlags           |= (int)FixedFlags.ColorConstant;
                    header->_lightColor = _solidColors[0];
                }
                if (_specColor.Count > 1)
                {
                    specularAddress = lightAddr;
                    if (match2 == null)
                    {
                        *((bint *)header->_specularColor.Address) = (int)lightAddr - (int)header->_specularColor.Address;
                        for (int x = 0; x <= FrameCount; x++)
                        {
                            if (x < _specColor.Count)
                            {
                                *lightAddr++ = _specColor[x];
                            }
                            else
                            {
                                *lightAddr++ = new RGBAPixel();
                            }
                        }
                    }
                    else
                    {
                        *((bint *)header->_specularColor.Address) = (int)match2.specularAddress - (int)header->_specularColor.Address;
                    }
                }
                else
                {
                    newFlags |= (int)FixedFlags.SpecColorConstant;
                    header->_specularColor = _solidColors[1];
                }
                if (!SetConstant && _entryCount != 0)
                {
                    header->_visOffset = (int)visAddr - (int)header->_visOffset.Address;
                    Marshal.Copy(_data, 0, (IntPtr)visAddr, _data.Length);
                    visAddr = ((VoidPtr)visAddr + EntryCount.Align(32) / 8);
                }
                else
                {
                    newFlags |= (int)FixedFlags.EnabledConstant;
                }

                bint *values = (bint *)&header->_startPoint;
                int   index  = 0;
                for (int i = 0; i < 14; i++)
                {
                    if (!(i == 3 || i == 7 || i == 10 || i == 12))
                    {
                        EncodeFrames(GetKeys(index), ref keyframeAddr, &values[i], ref newFlags, (int)_ordered[index++]);
                    }
                }

                header->_fixedFlags = _flags1 = (ushort)newFlags;
                header->_usageFlags = _flags2;
            }
        }
コード例 #8
0
        public ValidationOutcome Compute()
        {
            List <MetaTable> MetaTables = new List <MetaTable>();
            List <TableExtractionTaskScoreEntry> ValidationRuns = new List <TableExtractionTaskScoreEntry>();



            foreach (TableExtractionTaskScoreEntry run in task.score.TaskRuns)
            {
                executionCalls.Count(run.executionMode);
                switch (run.executionMode)
                {
                default:
                    break;

                case ExtractionTaskEngineMode.Validation:
                    ValidationRunCount++;
                    ValidationRuns.Add(run);
                    if (run.MetaTableCreated)
                    {
                        MetaTables.AddRange(run.metaTable.Where(x => x.IsValid));
                    }
                    else
                    {
                    }
                    break;
                }
            }

            if (!MetaTables.Any())
            {
                return(SetOutcome(ValidationOutcome.Invalid, "Failed to produce any meta table"));
            }

            ValidMetaTables = MetaTables.Count;

            foreach (MetaTable table in MetaTables)
            {
                PropertyCount.Learn(table.properties.Count);
                EntryCount.Learn(table.entries.Count);
                PropertyValidation.CollectProperties(table);

                var unresolved = PropertyValidation.GetUnresolved();

                foreach (MetaTableEntry entry in table.entries.items)
                {
                    foreach (MetaTableProperty property in table.properties.items)
                    {
                        metaPropertyNameCounter.Count(property.PropertyName);

                        if (unresolved.ContainsKey(property.PropertyName))
                        {
                            var prop_validation = unresolved[property.PropertyName];

                            if (property.PropertyName.isStartWithNumber())
                            {
                                prop_validation.SetOutcome(ValidationOutcome.Invalid, "Property name [" + property.PropertyName + "] starts with number");
                                continue;
                            }

                            prop_validation.ValueCounter.Count(entry.GetStoredValue(property));

                            if (entry.HasLinkedCell(property))
                            {
                                var sourceCell = entry.GetLinkedCell(property);
                                if (sourceCell.SourceNode != null)
                                {
                                    if (prop_validation.XPath.isNullOrEmpty())
                                    {
                                        prop_validation.XPath = sourceCell.SourceNode.XPath;
                                    }
                                    if (sourceCell.SourceNode.HasChildNodes)
                                    {
                                        List <HtmlNode> descendant = sourceCell.SourceNode.DescendantNodes().ToList();


                                        if (descendant.Count(x => !x.Name.StartsWith("#")) > 1)
                                        {
                                            String signature = descendant.Select(x => x.Name).toCsvInLine();

                                            prop_validation.reporter.AppendLine(sourceCell.SourceCellXPath);
                                            prop_validation.reporter.AppendLine(sourceCell.SourceNode.OuterHtml);

                                            prop_validation.SetOutcome(ValidationOutcome.Invalid, "Source cell contains [" + descendant.Count + "] descendant nodes: " + signature);
                                            continue;
                                        }
                                        else
                                        {
                                        }
                                    }
                                }
                                else
                                {
                                    prop_validation.LinkedNodes++;
                                }
                            }
                        }
                    }
                }
            }

            OutputType = TaskOutputType.data;
            if (EntryCount.Range == 0)
            {
                OutputType |= TaskOutputType.fixedEntityCount;
                if (EntryCount.Maximum == 1)
                {
                    OutputType |= TaskOutputType.singleEntity;
                }
            }
            else
            {
                OutputType |= TaskOutputType.variableEntityCount;
            }

            if (PropertyCount.Range == 0)
            {
                OutputType |= TaskOutputType.fixedPropertyCount;
            }
            else
            {
                OutputType |= TaskOutputType.variablePropertyCount;
            }

            if (OutputType.HasFlag(TaskOutputType.unstableEntityAndPropertyCounts))
            {
                SetOutcome(ValidationOutcome.Invalid, "Extraction result is unstable");
            }

            var prop_unresolved = PropertyValidation.GetUnresolved().Values.ToList();

            foreach (var prop_validation in prop_unresolved)
            {
                prop_validation.Frequency           = metaPropertyNameCounter.GetFrequencyForItem(prop_validation.item.PropertyName);
                prop_validation.DistinctValues      = prop_validation.ValueCounter.DistinctCount();
                prop_validation.SpamPropertyMeasure = 1 - prop_validation.Frequency.GetRatio(metaPropertyNameCounter.GetTopFrequency());

                /*
                 * if (prop_validation.DistinctValues == 1)
                 * {
                 *  prop_validation.SetOutcome(ValidationOutcome.Invalid, "Property had only one distinct value");
                 *  continue;
                 * }*/

                prop_validation.SetOutcome(ValidationOutcome.Validated, "");
            }



            var prop_resulrs = PropertyValidation.GetResults();



            if (prop_resulrs[ValidationOutcome.Invalid].Any())
            {
                SetOutcome(ValidationOutcome.Invalid, "[" + prop_resulrs[ValidationOutcome.Invalid].Count + "] invalid properties detected");
            }

            task.PropertyDictionary.CollectProperties(prop_resulrs[ValidationOutcome.Validated]);


            Outcome = ValidationOutcome.Validated;

            return(Outcome);
        }
コード例 #9
0
ファイル: MAP.cs プロジェクト: djey47/tdumt
        /// <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));
        }
コード例 #10
0
        public override void OnRebuild(VoidPtr address, int length, bool force)
        {
            //Build common header
            base.OnRebuild(address, length, force);

            //Reset addresses
            _lightAddress    = null;
            _specularAddress = null;

            //Don't write anything if this node is null
            if (_name == "<null>")
            {
                return;
            }

            //Write header information
            SCN0Light *header = (SCN0Light *)address;

            header->_nonSpecLightId = NonSpecularLightID;
            header->_userDataOffset = 0;
            header->_distFunc       = _distFunc;
            header->_spotFunc       = _spotFunc;

            int newFlags = 0;

            //Encode keyframe data
            for (int i = 0, index = 0; i < 14; i++)
            {
                if (!(i == 3 || i == 7 || i == 10 || i == 12))
                {
                    _dataAddrs[0] += EncodeKeyframes(
                        Keyframes[index],
                        _dataAddrs[0],
                        header->_startPoint._x.Address + i * 4,
                        ref newFlags,
                        (int)_ordered[index++]);
                }
            }

            _dataAddrs[1] += WriteColors(
                ref newFlags,
                (int)FixedFlags.ColorConstant,
                _solidColors[0],
                _lightColor,
                _constants[0],
                FrameCount,
                header->_lightColor.Address,
                ref _lightAddress,
                _matches[0] == null ? null : _matches[0]._lightAddress,
                (RGBAPixel *)_dataAddrs[1]);

            //Only bother writing if specular is enabled
            if (SpecularEnabled)
            {
                _dataAddrs[1] += WriteColors(
                    ref newFlags,
                    (int)FixedFlags.SpecColorConstant,
                    _solidColors[1],
                    _specColor,
                    _constants[1],
                    FrameCount,
                    header->_specularColor.Address,
                    ref _specularAddress,
                    _matches[1] == null ? null : _matches[1]._specularAddress,
                    (RGBAPixel *)_dataAddrs[1]);
            }
            else
            {
                //The value is set to 0
                header->_specularColor = new RGBAPixel();

                //The flag, while unused, seems to be set to the same state as the color constant flag
                if (_constants[0])
                {
                    newFlags |= (int)FixedFlags.SpecColorConstant;
                }
                else
                {
                    newFlags &= (int)~FixedFlags.SpecColorConstant;
                }
            }

            if (!ConstantVisibility && _entryCount != 0)
            {
                header->_visOffset = (int)_dataAddrs[2] - (int)header->_visOffset.Address;
                Marshal.Copy(_data, 0, (IntPtr)_dataAddrs[2], _data.Length);
                _dataAddrs[2] = ((VoidPtr)_dataAddrs[2] + EntryCount.Align(32) / 8);
            }
            else
            {
                newFlags |= (int)FixedFlags.EnabledConstant;
            }

            //Set newly calculated flags
            header->_fixedFlags = (ushort)(_fixedFlags = (FixedFlags)newFlags);
            header->_usageFlags = _typeUsageFlags._data;
        }
コード例 #11
0
 public static ObjectAssertions HaveEntryCount(this ObjectAssertions objectAssertions, int count)
 {
     (objectAssertions.Subject as CacheStatistics) !.EntryCount.Should().Be(count);
     return(objectAssertions);
 }
コード例 #12
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"));
        }