Exemplo n.º 1
0
 public override void Write()
 {
     Hdr.Write(_worldPacket);
     _worldPacket.WriteUInt32(Mapid);
     _worldPacket.WriteUInt32(ShutdownTimer);
     _worldPacket.WriteUInt32(StartTimer);
     _worldPacket.WriteBit(ArenaFaction);
     _worldPacket.WriteBit(LeftEarly);
     _worldPacket.FlushBits();
 }
Exemplo n.º 2
0
 public override void Write()
 {
     Hdr.Write(_worldPacket);
     _worldPacket.WriteUInt32(AverageWaitTime);
     _worldPacket.WriteUInt32(WaitTime);
     _worldPacket.WriteBit(AsGroup);
     _worldPacket.WriteBit(EligibleForMatchmaking);
     _worldPacket.WriteBit(SuspendedQueue);
     _worldPacket.FlushBits();
 }
Exemplo n.º 3
0
        public void Load3dDemo(string fileName, VideoCodec videoCodec, Hdr hdr, ColorSpace colorSpace, StereoMode stereoMode, ChromaSubSampling subSampling)
        {
            _mediaInfoWrapper = new MediaInfoWrapper(fileName, _logger);
            _mediaInfoWrapper.MediaInfoNotloaded.Should().BeFalse("InfoWrapper should be loaded");
            _mediaInfoWrapper.HasVideo.Should().BeTrue("Video stream must be detected");
            _mediaInfoWrapper.Is3D.Should().BeTrue("Video stream is 3D");
            var video = _mediaInfoWrapper.VideoStreams[0];

            video.Hdr.Should().Be(hdr);
            video.Codec.Should().Be(videoCodec);
            video.Stereoscopic.Should().Be(stereoMode);
            video.ColorSpace.Should().Be(colorSpace);
            video.SubSampling.Should().Be(subSampling);
        }
Exemplo n.º 4
0
        public TradesBlock(long i, int itemCount)
        {
            unchecked
            {
                Items  = new Item[itemCount];
                Header = new Hdr((ushort)(itemCount - i % (itemCount / 10)), _firstTimeStamp.AddMinutes(i));

                for (int j = 0; j < Header.ItemCount; j++)
                {
                    long tmp = i + j;
                    Items[j] = new Item((ushort)tmp, 1d / tmp, (int)tmp);
                }
            }
        }
Exemplo n.º 5
0
        public void LoadHdrDemo(string fileName, VideoCodec videoCodec, Hdr hdr, ColorSpace colorSpace, ChromaSubSampling subSampling, AudioCodec audioCodec, int channels)
        {
            _mediaInfoWrapper = new MediaInfoWrapper(fileName, _logger);
            _mediaInfoWrapper.MediaInfoNotloaded.Should().BeFalse("InfoWrapper should be loaded");
            _mediaInfoWrapper.HasVideo.Should().BeTrue("Video stream must be detected");
            _mediaInfoWrapper.IsBluRay.Should().BeFalse("Is not BluRay disk");
            _mediaInfoWrapper.IsDvd.Should().BeFalse("Is not DVD disk");
            _mediaInfoWrapper.IsInterlaced.Should().BeFalse("Video stream is progressive");
            _mediaInfoWrapper.Is3D.Should().BeFalse("Video stream is not 3D");
            _mediaInfoWrapper.AudioStreams.Count.Should().Be(1);
            var audio = _mediaInfoWrapper.AudioStreams[0];

            audio.Codec.Should().Be(audioCodec);
            audio.Channel.Should().Be(channels);
            var video = _mediaInfoWrapper.VideoStreams[0];

            video.Hdr.Should().Be(hdr);
            video.Codec.Should().Be(videoCodec);
            video.ColorSpace.Should().Be(colorSpace);
            video.SubSampling.Should().Be(subSampling);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Exports data from a database table to a file
        /// </summary>
        /// <param name="ServerName">The server name</param>
        /// <param name="DatabaseName">The database name</param>
        /// <param name="TableName">the table name</param>
        /// <param name="FileName">The file to export to</param>
        /// <param name="HeadersDict">the Columns to export</param>
        /// <param name="Fixed">true if field-length export</param>
        /// <param name="Delimiter">Delimiter, if not fixed length</param>
        /// <param name="Pad">The number of characters of padding to add to each column if fixed. Zero if no padding</param>
        /// <param name="Append">True to append to the output file. Otherwise re-create the output file</param>
        /// <param name="ShouldWriteHeader">True to write a header</param>
        /// <param name="MaxRows">Max rows (excl. header) to write</param>
        /// <param name="Quote">True to quote fields if fields contain a delimiter character</param>
        /// <returns>true if delimiters were found in the fields, and quoting was not specified</returns>

        public static bool DoExport(string ServerName, string DatabaseName, string TableName, string FileName,
                                    Dictionary <string, ColHeader> HeadersDict, bool Fixed, string Delimiter, int Pad, bool Append, bool ShouldWriteHeader, int MaxRows, bool Quote,
                                    out int RecordsWritten)
        {
            List <ColHeader> ColHeaders             = ColHeader.ToList(HeadersDict);
            string           Sql                    = BuildSelect(TableName, ColHeaders);
            bool             FoundDelimitersInField = false;
            string           Padding                = Pad != 0 ? new string(' ', Pad) : string.Empty;
            int RecordCount = 0;

            using (SqlConnection Cnct = GetSqlConnection(ServerName, DatabaseName))
                using (StreamWriter Writer = new StreamWriter(FileName, Append))
                {
                    SqlCommand command = new SqlCommand(Sql, Cnct)
                    {
                        CommandTimeout = GetSQLTimeout()
                    };
                    command.Connection.Open();
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            if (RecordCount == 0 && ShouldWriteHeader)
                            {
                                Writer.WriteLine(BuildHeader(ColHeaders, Fixed, Delimiter, Pad));
                            }
                            foreach (ColHeader Hdr in ColHeaders)
                            {
                                if (!Fixed && Hdr.OrdinalPosition > 0)
                                {
                                    Writer.Write(Delimiter);
                                }
                                string Fld = Hdr.ValueFrom(reader, Fixed);
                                if (!Fixed && (Fld.Contains(Delimiter) || Fld.Contains(ONE_DBL_QUOTE)))
                                {
                                    // if the field contains a delimiter, quote it. If it contains any quotes, also
                                    // quote it so the reader can strip the quotes and get the original contents back
                                    if (Quote)
                                    {
                                        Fld = ONE_DBL_QUOTE + Fld.Replace(ONE_DBL_QUOTE, TWO_DBL_QUOTES) + ONE_DBL_QUOTE;
                                    }
                                    FoundDelimitersInField = true;
                                }
                                Writer.Write(Fld);
                                if (Pad != 0)
                                {
                                    Writer.Write(Padding);
                                }
                            }
                            Writer.WriteLine();
                            if (++RecordCount >= MaxRows)
                            {
                                command.Cancel();
                                break;
                            }
                            if (RecordCount % 10000 == 0)
                            {
                                Log.InformationMessage("Records: {0}", RecordCount);
                            }
                        } // while (reader.Read())
                    }     // using SqlDataReader
                }// using SqlConnection & StreamWriter
            RecordsWritten = RecordCount;
            return(FoundDelimitersInField);
        }
Exemplo n.º 7
0
 private static bool TryGetHdr(string source, out Hdr result)
 {
     return(HdrFormats.TryGetValue(source, out result));
 }
Exemplo n.º 8
0
        private void HdrParser_onEvent(object sender, HdrEventParseArgs e)
        {
            switch (e.ParseType)
            {
                case HdrEventParseType.BeginHdr:
                    {
                        m_HdrCurrent = new Hdr(e.HdrType, e.GetExtraString(HdrEventParseArgs.EXTRA_FUNC_NAME_STRING));
                        break;
                    }
                case HdrEventParseType.EndHdr:
                case HdrEventParseType.ErrorHdr:
                    {
                        if (m_HdrCurrent == null)
                        {
                            LOG.Error("ErrorHdr/EndHdr: Unexpected code called");
                            return;
                        }
                        m_HdrCurrent.Error = (e.ParseType == HdrEventParseType.ErrorHdr);
                        m_Hdrs.Add(m_HdrCurrent);
                        m_HdrCurrent = null;
                        m_ItemCurrents.Clear();
                        break;
                    }
                case HdrEventParseType.BeginFnc:
                    {
                        if (m_HdrCurrent == null)
                        {
                            LOG.Error("BeginFnc: Unexpected code called");
                            return;
                        }
                        break;
                    }
                case HdrEventParseType.EndFunc:
                    {
                        if (m_HdrCurrent == null)
                        {
                            LOG.Error("EndFunc: Unexpected code called");
                            return;
                        }
                        break;
                    }
                case HdrEventParseType.SyntaxElt:
                    {
                        if (m_HdrCurrent == null)
                        {
                            LOG.Error("SyntaxElt: Unexpected code called");
                            return;
                        }
                        HdrItem item = new HdrItemSyntaxElt(
                            e.GetExtraString(HdrEventParseArgs.EXTRA_SYNTAX_NAME_STRING),
                            e.GetExtraString(HdrEventParseArgs.EXTRA_SYNTAX_DESCRIPTOR_STRING),
                            e.GetExtraInt32(HdrEventParseArgs.EXTRA_SYNTAX_VALUE_INT32));

                        if (m_ItemCurrents.Count != 0)
                        {
                            m_ItemCurrents[m_ItemCurrents.Count - 1].Items.Add(item);
                        }
                        else
                        {
                            m_HdrCurrent.Items.Add(item);
                        }
                        break;
                    }

                case HdrEventParseType.BeginCtrl:
                    {
                        if (m_HdrCurrent == null)
                        {
                            LOG.Error("BeginCtrl: Unexpected code called");
                            return;
                        }
                        m_ItemCurrents.Add(new HdrItemCtrl.HdrItemCtrlBegin(
                            e.GetExtraString(HdrEventParseArgs.EXTRA_CTRL_NAME_STRING),
                            e.GetExtraString(HdrEventParseArgs.EXTRA_CTRL_EXPRESSION_STRING),
                            e.GetExtraInt32(HdrEventParseArgs.EXTRA_CTRL_VALUE_INT32)
                            ));
                        break;
                    }

                case HdrEventParseType.EndCtrl:
                    {
                        if (m_HdrCurrent == null || m_ItemCurrents.Count == 0)
                        {
                            LOG.Error("EndCtrl: Unexpected code called");
                            return;
                        }

                        /* mItemCurrents[mItemCurrents.Count - 1].Items.Add(new HdrItemCtrl.HdrItemCtrlEnd(
                            e.GetExtraString(HdrEventParseArgs.EXTRA_CTRL_NAME_STRING)
                            ));
                         */
                        m_HdrCurrent.Items.Add(m_ItemCurrents[m_ItemCurrents.Count - 1]);
                        m_ItemCurrents.RemoveAt(m_ItemCurrents.Count - 1);
                        break;
                    }
            }
        }
Exemplo n.º 9
0
        private void HdrParser_onEvent(object sender, HdrEventParseArgs e)
        {
            switch (e.ParseType)
            {
            case HdrEventParseType.BeginHdr:
            {
                m_HdrCurrent = new Hdr(e.HdrType, e.GetExtraString(HdrEventParseArgs.EXTRA_FUNC_NAME_STRING));
                break;
            }

            case HdrEventParseType.EndHdr:
            case HdrEventParseType.ErrorHdr:
            {
                if (m_HdrCurrent == null)
                {
                    LOG.Error("ErrorHdr/EndHdr: Unexpected code called");
                    return;
                }
                m_HdrCurrent.Error = (e.ParseType == HdrEventParseType.ErrorHdr);
                m_Hdrs.Add(m_HdrCurrent);
                m_HdrCurrent = null;
                m_ItemCurrents.Clear();
                break;
            }

            case HdrEventParseType.BeginFnc:
            {
                if (m_HdrCurrent == null)
                {
                    LOG.Error("BeginFnc: Unexpected code called");
                    return;
                }
                break;
            }

            case HdrEventParseType.EndFunc:
            {
                if (m_HdrCurrent == null)
                {
                    LOG.Error("EndFunc: Unexpected code called");
                    return;
                }
                break;
            }

            case HdrEventParseType.SyntaxElt:
            {
                if (m_HdrCurrent == null)
                {
                    LOG.Error("SyntaxElt: Unexpected code called");
                    return;
                }
                HdrItem item = new HdrItemSyntaxElt(
                    e.GetExtraString(HdrEventParseArgs.EXTRA_SYNTAX_NAME_STRING),
                    e.GetExtraString(HdrEventParseArgs.EXTRA_SYNTAX_DESCRIPTOR_STRING),
                    e.GetExtraInt32(HdrEventParseArgs.EXTRA_SYNTAX_VALUE_INT32));

                if (m_ItemCurrents.Count != 0)
                {
                    m_ItemCurrents[m_ItemCurrents.Count - 1].Items.Add(item);
                }
                else
                {
                    m_HdrCurrent.Items.Add(item);
                }
                break;
            }

            case HdrEventParseType.BeginCtrl:
            {
                if (m_HdrCurrent == null)
                {
                    LOG.Error("BeginCtrl: Unexpected code called");
                    return;
                }
                m_ItemCurrents.Add(new HdrItemCtrl.HdrItemCtrlBegin(
                                       e.GetExtraString(HdrEventParseArgs.EXTRA_CTRL_NAME_STRING),
                                       e.GetExtraString(HdrEventParseArgs.EXTRA_CTRL_EXPRESSION_STRING),
                                       e.GetExtraInt32(HdrEventParseArgs.EXTRA_CTRL_VALUE_INT32)
                                       ));
                break;
            }

            case HdrEventParseType.EndCtrl:
            {
                if (m_HdrCurrent == null || m_ItemCurrents.Count == 0)
                {
                    LOG.Error("EndCtrl: Unexpected code called");
                    return;
                }

                /* mItemCurrents[mItemCurrents.Count - 1].Items.Add(new HdrItemCtrl.HdrItemCtrlEnd(
                 *  e.GetExtraString(HdrEventParseArgs.EXTRA_CTRL_NAME_STRING)
                 *  ));
                 */
                m_HdrCurrent.Items.Add(m_ItemCurrents[m_ItemCurrents.Count - 1]);
                m_ItemCurrents.RemoveAt(m_ItemCurrents.Count - 1);
                break;
            }
            }
        }
Exemplo n.º 10
0
 public HdrEventParseArgs(HdrEventParseType parseType, Hdr.HdrType hdrType)
     : base()
 {
     mParseType = parseType;
     mHdrType = hdrType;
 }