/// <summary>
        /// Выаод информации
        /// </summary>
        /// <param name="text"></param>
        private void MPrint(string text, bool ptime, bool TelegramSend = true)
        {
            if (String.IsNullOrEmpty(text))
            {
                return;
            }

            if (TelegramSend)
            {
                TelegramBot.Send($"<{ProgName}> {text}");
            }

            string ptext = String.Format("{0}{1}{2}", ptime == false ? "" : DateTime.Now.ToString() + " - ", text, Environment.NewLine);

            if (textBoxLogsWindow.InvokeRequired)
            {
                textBoxLogsWindow.Invoke(new Action <string>((str) =>
                {
                    textBoxLogsWindow.AppendText(str);
                }), ptext);
            }
            else
            {
                textBoxLogsWindow.AppendText(ptext);
            }
        }
 private void ChangeSetting(FormSettings fSetting)
 {
     ProgName = fSetting.FormName;
     Text     = ProgName;
     TelegramBot.SetParam(FSetting.TelegramToken, FSetting.TelegramChatId);
     TelegramBot.Send($"Program <{ProgName}> is running.");
 }
示例#3
0
        private void PrintMethod(string Text, bool PrintTime = true, bool TelegramSend = true)
        {
            //await Task.Factory.StartNew(() => GPrint(String.Format("[{0}] - ", Param.Market) + text, PrintTime),
            //    TaskCreationOptions.PreferFairness);
            string RText = String.Format("[{0}] - {1}", Param.StrategyName, Text);

            if (TelegramSend)
            {
                TelegramBot.Send($"<{Form1.ProgName}> {RText}");
            }

            if (Param.WriteToFile)
            {
                string ptext = String.Format("{0}{1}", PrintTime == false ? "" : DateTime.Now.ToString() + " - ", RText);
                string fname = String.Format("{0}/Logs/{1}.txt", AppDomain.CurrentDomain.BaseDirectory, Param.StrategyName);
                lock (LockFile)
                {
                    using (var file = new System.IO.StreamWriter(fname, true))
                    {
                        file.WriteLine(ptext);
                    }
                }
                Form1.Print(RText, PrintTime, false);
            }
            else
            {
                Form1.Print(RText, PrintTime, false);
            }
        }
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     TelegramBot.DisposeResources();
 }