private void InnerSendTestMail(string recepientEmail, string subject, string content)
        {
            var result = EmailSender.SendEmail(recepientEmail, subject, content);

            OnUpdateStockScannerComplete(result);
        }
Ejemplo n.º 2
0
        void CSIFeed_GetHistoryComplete(object sender, CSIData.BarInfo value)
        {
            if (started && value != null)
            {
                BarInfo binfo = new BarInfo
                {
                    Token = new HistoryRequest
                    {
                        ID          = value.Token.ID,
                        MaxAmount   = value.Token.MaxAmount,
                        period      = value.Token.period,
                        periodicity = Periodicity.Day,
                        Symbol      = value.Token.Symbol
                    },
                };
                foreach (var itm in value)
                {
                    binfo.Add(new Bar
                    {
                        Close     = itm.Close,
                        High      = itm.High,
                        Low       = itm.Low,
                        Open      = itm.Open,
                        TimeStamp = itm.TimeStamp,
                        Volume    = itm.Volume
                    });
                }

                binfo = DataFeed.BarConverter.ConvertToWeekly(binfo);

                var data = TechnicalCalculations.AroonOscillator(binfo, 16);

                if (data.Count >= 2)
                {
                    if (data[data.Count - 1].Value != data[data.Count - 2].Value)
                    {
                        var    user    = Users[binfo.Token.ID];
                        string content = GetMailContent(user.FirstName + " " + user.LastName, user.DefaultTiker, data[data.Count - 1].Value);
                        var    ret     = EmailSender.SendEmail(user.Email, Config.MailSubject, content, Config);
                        if (ret.InternalError)
                        {
                            LogFile.WriteToLog("Send mail error: " + ret.InternalErrorMessage);
                        }
                        else
                        {
                            LogFile.WriteToLog("Send mail: to " + user.Email + "| subject: " + Config.MailSubject + "| content: " + content);
                        }
                    }
                }
                if (started)
                {
                    string nID       = null;
                    bool   cangetkey = false;
                    foreach (var key in Users.Keys)
                    {
                        if (cangetkey)
                        {
                            nID = key;
                            break;
                        }
                        if (key.Equals(binfo.Token.ID))
                        {
                            cangetkey = true;
                        }
                    }
                    if (nID != null)
                    {
                        ProcessCalcualtions(nID);
                    }
                    else
                    {
                        inprogress = false;
                    }
                }
                else
                {
                    inprogress = false;
                    DisableUI(started);
                }
            }
            else
            {
                inprogress = false;
                DisableUI(started);
            }
        }