Ejemplo n.º 1
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (ReceiveTime.Length != 0)
            {
                hash ^= ReceiveTime.GetHashCode();
            }
            if (Info.Length != 0)
            {
                hash ^= Info.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 2
0
            public ExchangeOrderResult ToExchangeOrderResult(Dictionary <string, long> symbolToIdMapping)
            {
                ExchangeAPIOrderResult orderResult;

                switch (OrderState.ToLowerInvariant())
                {
                case "unknown":
                    orderResult = ExchangeAPIOrderResult.Unknown;
                    break;

                case "working":
                    orderResult = ExchangeAPIOrderResult.Open;
                    break;

                case "rejected":
                    orderResult = ExchangeAPIOrderResult.Rejected;
                    break;

                case "canceled":
                    orderResult = ExchangeAPIOrderResult.Canceled;
                    break;

                case "expired":
                    orderResult = ExchangeAPIOrderResult.Canceled;
                    break;

                case "fullyexecuted":
                    orderResult = ExchangeAPIOrderResult.Filled;
                    break;

                default:
                    throw new NotImplementedException($"Unexpected status type: {OrderState.ToLowerInvariant()}");
                }
                ;
                var symbol = symbolToIdMapping.Where(pair => pair.Value.Equals(Instrument));

                return(new ExchangeOrderResult()
                {
                    Amount = Quantity,
                    IsBuy = Side.Equals("buy", StringComparison.InvariantCultureIgnoreCase),
                    MarketSymbol = symbol.Any() ? symbol.First().Key : null,
                    Price = Price,
                    Result = orderResult,
                    OrderDate = ReceiveTime.UnixTimeStampToDateTimeMilliseconds(),

                    OrderId = OrderId.ToStringInvariant(),
                });
            }
Ejemplo n.º 3
0
        public override int GetHashCode()
        {
            unchecked
            {
                int hashCode = Key != null?Key.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (AlarmStation != null ? AlarmStation.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (ReceiveTime != null ? ReceiveTime.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Id != null ? Id.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ AlarmLevel;
                hashCode = (hashCode * 397) ^ (CallerName != null ? CallerName.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (CallerTelephoneNumber != null ? CallerTelephoneNumber.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Subject != null ? Subject.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Location != null ? Location.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (AdditionalInformation != null ? AdditionalInformation.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (StatusText != null ? StatusText.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (WatchOutTime != null ? WatchOutTime.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (SirenProgram != null ? SirenProgram.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (FinishedTime != null ? FinishedTime.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (FireBrigades != null ? FireBrigades.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ Index;
                return(hashCode);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 查找报文
        /// </summary>
        /// <param name="_startTime">起始时间</param>
        /// <param name="_endTime">终止时间</param>
        /// <param name="SourceIP">源IP</param>
        /// <param name="DestIP">目的IP</param>
        /// <returns>报文列表</returns>
        static private List <string> GetFiles(DateTime _startTime, DateTime _endTime, string SourceIP, string DestIP)
        {
            string        path      = string.Empty;
            List <string> filesList = new List <string>();

            #region 跨天查询
            if (_startTime.Year != DateTime.Now.Year || _startTime.Month != DateTime.Now.Month || DateTime.Now.Day - _startTime.Day > 7)
            {
                MessageBox.Show("只能查询7日内的数据,请重新输入!");
                return(null);
            }
            if (_endTime.Year != DateTime.Now.Year || _endTime.Month != DateTime.Now.Month || DateTime.Now.Day - _endTime.Day > 7)
            {
                MessageBox.Show("只能查询7日内的数据,请重新输入!");
                return(null);
            }

            if (_startTime > _endTime)//开始时间不能大于终止时间。
            {
                MessageBox.Show("开始时间大于终止时间!");
                return(null);
            }
            else
            {
                try
                {
                    #region 将符合的txt文件存入数组中

                    #region 起止时间不是同一天

                    if (_startTime.Day != _endTime.Day)
                    {
                        int _day = _startTime.Day;
                        for (; _day <= _endTime.Day; _day++)
                        {
                            #region 起始那天
                            if (_day == _startTime.Day)
                            {
                                for (int h = _startTime.Hour; h < 24; h++)
                                {
                                    if (h == _startTime.Hour)
                                    {
                                        for (int m = _startTime.Minute; m < 60; m++)
                                        {
                                            path = "BytesFilesLog" + "\\" + SourceIP + "--" + DestIP + "\\" + _startTime.ToString("yyyy") + "\\" + _startTime.ToString("MM") + "-" + _day.ToString().PadLeft(2, '0')
                                                   + "\\" + h.ToString().PadLeft(2, '0') + "-" + m.ToString().PadLeft(2, '0') + ".txt";
                                            try
                                            {
                                                StreamReader sr = new StreamReader(path, Encoding.Default);
                                                String       line;
                                                while ((line = sr.ReadLine()) != null)
                                                {
                                                    ReceiveTime recvTime = new ReceiveTime(line, path);
                                                    if (recvTime.Second >= _startTime.Second)
                                                    {
                                                        filesList.Add(line.ToString());
                                                    }
                                                }
                                                sr.Close();
                                            }
                                            catch (Exception e)
                                            {
                                            }
                                        }
                                    }
                                    else
                                    {
                                        for (int m = 0; m < 60; m++)
                                        {
                                            path = "BytesFilesLog" + "\\" + SourceIP + "--" + DestIP + "\\" + _startTime.ToString("yyyy") + "\\" + _startTime.ToString("MM") + "-" + _day.ToString().PadLeft(2, '0')
                                                   + "\\" + h.ToString().PadLeft(2, '0') + "-" + m.ToString().PadLeft(2, '0') + ".txt";
                                            try
                                            {
                                                StreamReader sr = new StreamReader(path, Encoding.Default);
                                                String       line;
                                                while ((line = sr.ReadLine()) != null)
                                                {
                                                    filesList.Add(line.ToString());
                                                }
                                                sr.Close();
                                            }
                                            catch (Exception e)
                                            {
                                            }
                                        }
                                    }
                                }
                            }
                            #endregion

                            #region 终止那天
                            else if (_day == _endTime.Day)
                            {
                                for (int h = 0; h < _endTime.Hour; h++)
                                {
                                    if (h == _endTime.Hour)
                                    {
                                        for (int m = 0; m < _endTime.Minute; m++)
                                        {
                                            path = "BytesFilesLog" + "\\" + SourceIP + "--" + DestIP + "\\" + _endTime.ToString("yyyy-MM") + "-"
                                                   + _day.ToString().PadLeft(2, '0') + "\\" + h.ToString().PadLeft(2, '0') + "-"
                                                   + m.ToString().PadLeft(2, '0') + ".txt";
                                            try
                                            {
                                                StreamReader sr = new StreamReader(path, Encoding.Default);
                                                String       line;
                                                while ((line = sr.ReadLine()) != null)
                                                {
                                                    ReceiveTime recvTime = new ReceiveTime(line, path);
                                                    if (recvTime.Second <= _endTime.Second)
                                                    {
                                                        filesList.Add(line.ToString());
                                                    }
                                                }
                                                sr.Close();
                                            }
                                            catch (Exception e)
                                            {
                                            }
                                        }
                                    }
                                    else
                                    {
                                        for (int m = 0; m < 60; m++)
                                        {
                                            path = "BytesFilesLog" + "\\" + SourceIP + "--" + DestIP + "\\" + _startTime.ToString("yyyy-MM") + "-"
                                                   + _day.ToString().PadLeft(2, '0') + "\\" + h.ToString().PadLeft(2, '0') + "-"
                                                   + m.ToString().PadLeft(2, '0') + ".txt";
                                            try
                                            {
                                                StreamReader sr = new StreamReader(path, Encoding.Default);
                                                String       line;
                                                while ((line = sr.ReadLine()) != null)
                                                {
                                                    filesList.Add(line.ToString());
                                                }
                                                sr.Close();
                                            }
                                            catch (Exception e)
                                            {
                                            }
                                        }
                                    }
                                }
                            }
                            #endregion

                            #region 中间天
                            else //中间天
                            {
                                for (int h = 0; h < 24; h++)
                                {
                                    for (int m = 0; m < 60; m++)
                                    {
                                        path = "BytesFilesLog" + "\\" + SourceIP + "--" + DestIP + "\\" + _startTime.ToString("yyyy") + "\\" + _startTime.ToString("MM") + "-"
                                               + _day.ToString().PadLeft(2, '0') + "\\" + h.ToString().PadLeft(2, '0') + "-"
                                               + m.ToString().PadLeft(2, '0') + ".txt";

                                        try
                                        {
                                            StreamReader sr = new StreamReader(path, Encoding.Default);
                                            String       line;
                                            while ((line = sr.ReadLine()) != null)
                                            {
                                                filesList.Add(line.ToString());
                                            }
                                            sr.Close();
                                        }
                                        catch (Exception e)
                                        {
                                        }
                                    }
                                }
                            }
                            #endregion
                            //fileArrayList.AddRange(Directory.GetFiles(Application.StartupPath + @"\Log" + @"\" + path + @"\" + _startTime.Year + @"\" + _month));  //将文件名存入数组
                        }
                    }
                    #endregion

                    #region 开始和结束是同一天
                    else //开始和结束是同一天,在一个文件夹里面找
                    {
                        string strCatDate = _startTime.ToString("yyyy-MM-dd");
                        #region  一个小时
                        if (_startTime.Hour == _endTime.Hour)
                        {
                            if (_startTime.Minute == _endTime.Minute)//同分钟,在一个文件里面查找
                            {
                                string strCatTime = _startTime.ToString("HH-mm");
                                path = "BytesFilesLog" + "\\" + SourceIP + "--" + DestIP + "\\" + _startTime.ToString("yyyy") + "\\" + _startTime.ToString("MM-dd") + "\\" + strCatTime + ".txt";
                                try
                                {
                                    StreamReader sr = new StreamReader(path, Encoding.Default);
                                    String       line;
                                    while ((line = sr.ReadLine()) != null)
                                    {
                                        ReceiveTime recvTime = new ReceiveTime(line, path);
                                        if (recvTime.Second >= _startTime.Second && recvTime.Second <= _endTime.Second)
                                        {
                                            filesList.Add(line.ToString());
                                        }
                                    }
                                    sr.Close();
                                }
                                catch (Exception e)
                                { }
                            }
                            else //同小时不同分钟
                            {
                                for (int min = _startTime.Minute; min <= _endTime.Minute; min++)
                                {
                                    path = "BytesFilesLog" + "\\" + SourceIP + "--" + DestIP + "\\" + _startTime.ToString("yyyy") + "\\" + _startTime.ToString("MM-dd") + "\\" + _startTime.Hour + "-" + min + ".txt";
                                    try
                                    {
                                        StreamReader sr = new StreamReader(path, Encoding.Default);
                                        String       line;
                                        while ((line = sr.ReadLine()) != null)
                                        {
                                            ReceiveTime recvTime = new ReceiveTime(line, path);
                                            if (min == _startTime.Minute)
                                            {
                                                if (recvTime.Second >= _startTime.Second)
                                                {
                                                    filesList.Add(line.ToString());
                                                }
                                            }
                                            else if (min == _endTime.Minute)
                                            {
                                                if (recvTime.Second <= _endTime.Second)
                                                {
                                                    filesList.Add(line.ToString());
                                                }
                                            }
                                            else
                                            {
                                                filesList.Add(line.ToString());
                                            }
                                        }
                                        sr.Close();
                                    }
                                    catch (Exception e)
                                    { }
                                }
                            }
                        }
                        #endregion

                        #region   小时
                        else
                        {
                            for (int hour = _startTime.Hour; hour <= _endTime.Hour; hour++)
                            {
                                if (hour == _startTime.Hour)
                                {
                                    for (int m = _startTime.Minute; m < 60; m++)
                                    {
                                        path = "BytesFilesLog" + "\\" + SourceIP + "--" + DestIP + "\\" + _startTime.ToString("yyyy") + "\\" + _startTime.ToString("MM-dd") + "\\" + hour.ToString().PadLeft(2, '0') + "-" + m.ToString().PadLeft(2, '0') + ".txt";
                                        if (m == _startTime.Minute)
                                        {
                                            try
                                            {
                                                StreamReader sr = new StreamReader(path, Encoding.Default);
                                                String       line;
                                                while ((line = sr.ReadLine()) != null)
                                                {
                                                    ReceiveTime recvTime = new ReceiveTime(line, path);
                                                    if (recvTime.Second >= _startTime.Second)
                                                    {
                                                        filesList.Add(line.ToString());
                                                    }
                                                }
                                                sr.Close();
                                            }
                                            catch (Exception e)
                                            { }
                                        }
                                        else
                                        {
                                            try
                                            {
                                                StreamReader sr = new StreamReader(path, Encoding.Default);
                                                String       line;
                                                while ((line = sr.ReadLine()) != null)
                                                {
                                                    ReceiveTime recvTime = new ReceiveTime(line, path);
                                                    filesList.Add(line.ToString());
                                                }
                                                sr.Close();
                                            }
                                            catch (Exception e)
                                            { }
                                        }
                                    }
                                }
                                else if (hour == _endTime.Hour)
                                {
                                    for (int m = 0; m <= _endTime.Minute; m++)
                                    {
                                        path = "BytesFilesLog" + "\\" + SourceIP + "--" + DestIP + "\\" + _endTime.ToString("yyyy") + "\\" + _endTime.ToString("MM-dd") + "\\"
                                               + hour.ToString().PadLeft(2, '0') + "-" + m.ToString().PadLeft(2, '0') + ".txt";
                                        if (m == _endTime.Minute)
                                        {
                                            try
                                            {
                                                StreamReader sr = new StreamReader(path, Encoding.Default);
                                                String       line;
                                                while ((line = sr.ReadLine()) != null)
                                                {
                                                    ReceiveTime recvTime = new ReceiveTime(line, path);
                                                    if (recvTime.Second <= _endTime.Second)
                                                    {
                                                        filesList.Add(line.ToString());
                                                    }
                                                    sr.Close();
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                            }
                                        }
                                        else
                                        {
                                            try
                                            {
                                                StreamReader sr = new StreamReader(path, Encoding.Default);
                                                String       line;
                                                while ((line = sr.ReadLine()) != null)
                                                {
                                                    ReceiveTime recvTime = new ReceiveTime(line, path);
                                                    filesList.Add(line.ToString());
                                                }
                                                sr.Close();
                                            }
                                            catch (Exception ex)
                                            {
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    for (int m = 0; m < 60; m++)
                                    {
                                        path = "BytesFilesLog" + "\\" + SourceIP + "--" + DestIP + "\\" + _startTime.ToString("yyyy") + "\\" + _startTime.ToString("MM-dd") + "\\" + hour.ToString().PadLeft(2, '0') + "-" + m.ToString().PadLeft(2, '0') + ".txt";
                                        try
                                        {
                                            StreamReader sr = new StreamReader(path, Encoding.Default);
                                            String       line;
                                            while ((line = sr.ReadLine()) != null)
                                            {
                                                filesList.Add(line.ToString());
                                            }
                                            sr.Close();
                                        }
                                        catch (Exception ex)
                                        {
                                        }
                                    }
                                }
                            }
                        }
                        #endregion
                    }
                    #endregion

                    #endregion
                }
                catch (Exception ex)
                {
                    //return null;
                }
            }
            #endregion


            return(filesList);
        }
Ejemplo n.º 5
0
 public override string ToString()
 {
     return($"{ReceiveTime.ToDateTime():MM:dd HH:mm:ss fff} | Id:[{Id}] Desc:[{Desc()}] ");
 }