Exemple #1
0
        public void SendMessage(IMessage message)
        {
            var multipart = new MultipartMessage((Message)message);
            var frames    = (IList <byte[]>)multipart.Frames;
            var msg       = new Msg();

            try
            {
                var framesCount = frames.Count;
                for (var i = 0; i < framesCount;)
                {
                    var buffer = frames[i];
                    msg.InitGC(buffer, buffer.Length);
                    var sendingTimeout1 = config.SendTimeout;
                    if (!socket.TrySend(ref msg, sendingTimeout1, ++i < framesCount))
                    {
                        throw new TimeoutException($"Sending timed out after {sendingTimeout1.TotalMilliseconds} ms!");
                    }
                }
                SendRate?.Increment();
            }
            finally
            {
                msg.Close();
            }
        }
Exemple #2
0
        private void StartProgress()
        {
            using Progress pro = new Progress();
            IScalar sc = new ScalarKospi200();

            new Task(() => StartBackTesting(sc, pro, string.Concat(Path.Combine(Environment.CurrentDirectory, @"..\"), @"\Statistics\", DateTime.Now.Hour > 23 || DateTime.Now.Hour < 9 ? DateTime.Now.AddDays(-1).ToString("yyMMdd") : DateTime.Now.ToString("yyMMdd"), ".csv"), string.Concat(Path.Combine(Environment.CurrentDirectory, @"..\"), @"\Log\", DateTime.Now.Hour > 23 || DateTime.Now.Hour < 9 ? DateTime.Now.AddDays(-1).ToString("yyMMdd") : DateTime.Now.ToString("yyMMdd"), @"\"))).Start();
            Size          = new Size(5, 5);
            StartPosition = FormStartPosition.Manual;
            Location      = new Point(1, 1010);
            DoubleBufferedTableLayoutPanel db = new DoubleBufferedTableLayoutPanel
            {
                ColumnCount = 1,
                RowCount    = 1,
                AutoSize    = true,
                Margin      = new Padding(0),
                Dock        = DockStyle.Fill,
            };

            pro.Dock = DockStyle.Fill;
            db.Controls.Add(pro);
            Controls.Add(db);
            SendRate += pro.Rate;
            SendRate?.Invoke(this, new Rate(Enum.GetValues(typeof(IStopLossAndRevenue.StopLossAndRevenue)).Length *sc.StopLoss.Length *sc.Revenue.Length *sc.Reaction.Length *sc.ShortMinutePeriod.Length *sc.ShortDayPeriod.Length *sc.LongMinutePeriod.Length *sc.LongDayPeriod.Length));
            ShowDialog();
        }
Exemple #3
0
        private string[] ChooseResult(DialogResult result)
        {
            if (result.Equals(DialogResult.Yes))
            {
                using ChooseAnalysis ca = new ChooseAnalysis();
                Size = new Size(5, 5);
                panel.Controls.Add(ca);
                ca.Dock       = DockStyle.Fill;
                StartPosition = FormStartPosition.CenterScreen;
                ca.SendQuit  += OnReceiveDialogClose;
                ShowDialog();

                return(ca.TempText.Split('.'));
            }
            else if (result.Equals(DialogResult.No))
            {
                using Progress pro = new Progress();
                Size          = new Size(5, 5);
                StartPosition = FormStartPosition.Manual;
                Location      = new Point(1, 1010);
                panel.Controls.Add(pro);
                pro.Dock  = DockStyle.Fill;
                SendRate += pro.Rate;
                new Task(() => BackTesting(pro, string.Concat(Environment.CurrentDirectory, @"\Statistics\", DateTime.Now.Hour > 23 || DateTime.Now.Hour < 9 ? DateTime.Now.AddDays(-1).ToString("yyMMdd") : DateTime.Now.ToString("yyMMdd"), ".csv"), string.Concat(Environment.CurrentDirectory, @"\Log\", DateTime.Now.Hour > 23 || DateTime.Now.Hour < 9 ? DateTime.Now.AddDays(-1).ToString("yyMMdd") : DateTime.Now.ToString("yyMMdd"), @"\"))).Start();
                SendRate?.Invoke(this, new ProgressRate(Reaction * smp.Length * sdp.Length * lmp.Length * ldp.Length));
                ShowDialog();
            }
            Dispose();
            Environment.Exit(0);

            return(null);
        }
        public IHttpActionResult GetItem(SendRate sendRate)
        {
            sendRate.IsDefault = false;
            var reuslt = sendRateService.GetItem(sendRate, WorkUser);

            return(Ok(reuslt));
        }
        public IHttpActionResult GeDefaultItem()
        {
            var sendRate = new SendRate();

            sendRate.IsDefault = true;
            var reuslt = sendRateService.GetItem(sendRate, WorkUser);

            return(Ok(reuslt));
        }
Exemple #6
0
        private string[] ChooseResult(DialogResult result)
        {
            if (result.Equals(DialogResult.Yes))
            {
                using ChooseAnalysis ca = new ChooseAnalysis();
                Size = new Size(5, 5);
                tableLayoutPanel.RowStyles.Clear();
                tableLayoutPanel.Controls.Add(webBrowser, 0, tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 0)));
                tableLayoutPanel.Controls.Add(panel, 0, tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100)));
                panel.Controls.Add(ca);
                ca.Dock      = DockStyle.Fill;
                ca.SendQuit += OnReceiveDialogClose;
                ShowDialog();

                return(ca.TempText.Split('.'));
            }
            else if (result.Equals(DialogResult.No))
            {
                using Progress pro = new Progress();
                tableLayoutPanel.RowStyles.Clear();
                tableLayoutPanel.Controls.Add(webBrowser, 0, tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 70)));
                tableLayoutPanel.Controls.Add(panel, 0, tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 31)));
                panel.Controls.Add(pro);
                pro.Dock          = DockStyle.Fill;
                panel.BorderStyle = BorderStyle.None;
                WindowState       = FormWindowState.Maximized;
                webBrowser.Show();
                SendRate += pro.Rate;
                new Task(() => BackTesting(pro, string.Concat(Environment.CurrentDirectory, @"\Statistics\", DateTime.Now.Hour > 23 || DateTime.Now.Hour < 9 ? DateTime.Now.AddDays(-1).ToString("yyMMdd") : DateTime.Now.ToString("yyMMdd"), ".csv"), string.Concat(Environment.CurrentDirectory, @"\Log\", DateTime.Now.Hour > 23 || DateTime.Now.Hour < 9 ? DateTime.Now.AddDays(-1).ToString("yyMMdd") : DateTime.Now.ToString("yyMMdd"), @"\"))).Start();
                SendRate?.Invoke(this, new ProgressRate(Reaction * smp.Length * sdp.Length * lmp.Length * ldp.Length));
                ShowDialog();
            }
            Dispose();
            Environment.Exit(0);

            return(null);
        }
Exemple #7
0
 public void Close()
 {
     if (ConsumerThreadCount != null)
     {
         ConsumerThreadCount.Dispose();
         ConsumerThreadCount = null;
     }
     if (ReceiveThreadCount != null)
     {
         ReceiveThreadCount.Dispose();
         ReceiveThreadCount = null;
     }
     if (ReceiveRate != null)
     {
         ReceiveRate.Dispose();
         ReceiveRate = null;
     }
     if (PublishRate != null)
     {
         PublishRate.Dispose();
         PublishRate = null;
     }
     if (SendRate != null)
     {
         SendRate.Dispose();
         SendRate = null;
     }
     if (ReceiveCount != null)
     {
         ReceiveCount.Dispose();
         ReceiveCount = null;
     }
     if (PublishCount != null)
     {
         PublishCount.Dispose();
         PublishCount = null;
     }
     if (SentCount != null)
     {
         SentCount.Dispose();
         SentCount = null;
     }
     if (ConsumerDuration != null)
     {
         ConsumerDuration.Dispose();
         ConsumerDuration = null;
     }
     if (ConsumerDurationBase != null)
     {
         ConsumerDurationBase.Dispose();
         ConsumerDurationBase = null;
     }
     if (ReceiveDuration != null)
     {
         ReceiveDuration.Dispose();
         ReceiveDuration = null;
     }
     if (ReceiveDurationBase != null)
     {
         ReceiveDurationBase.Dispose();
         ReceiveDurationBase = null;
     }
     if (PublishDuration != null)
     {
         PublishDuration.Dispose();
         PublishDuration = null;
     }
     if (PublishDurationBase != null)
     {
         PublishDurationBase.Dispose();
         PublishDurationBase = null;
     }
 }
Exemple #8
0
 public void Send(T message)
 {
     messageQueue.Add(message);
     dataAvailable.Set();
     SendRate?.Increment();
 }
        public IHttpActionResult SetSendRate(SendRate sendRate)
        {
            var reuslt = sendRateService.AddOrUpdateItem(sendRate, WorkUser);

            return(Ok(reuslt));
        }