コード例 #1
0
        private void InitialiseNewsRelease()
        {
            try
            {
                // load up news release object
                fxNews = new FxNews(DailyFxDownloadPath, IncludeMediumLevelNews, IncludeHighLevelNews);

                // if the news has loaded successfully
                if (fxNews.IsSuccess)
                {
                    news = fxNews.NewsDescriptions;

                    // Display to the log file the upcoming news items
                    foreach (string n in news)
                    {
                        Print(n);
                    }

                    Print(news.Count().ToString() + " IMPORTANT NEWS ITEMS THIS WEEK.");

                    if (news.Count() <= 0)
                    {
                        Print("No news items have been loaded, please check you have the recent news file from FXStreet.");
                        System.Media.SystemSounds.Exclamation.Play();
                    }
                }
                else
                {
                    Print(fxNews.ErrorMessage);
                }
            } catch (Exception e)
            {
                Print("** LOADING NEWS RELEASE FAILED: " + e.InnerException.ToString());
            }
        }
コード例 #2
0
ファイル: FxNewsJob.cs プロジェクト: radtek/ThomRe
        protected override void ExecuteInternal(JobExecutionContext context)
        {
            var startTime = DateTime.UtcNow;
            var logEntity = new SCHEDULERLOG {
                STARTTIME = startTime
            };

            var strInfo = new StringBuilder();

            try
            {
                var lastSyncTime = new DateTime(2016, 9, 28);

                using (var cneEntities = new CnEEntities())
                {
                    var date =
                        cneEntities.SCHEDULERLOGs.Where(x => x.STATUS == 0 && x.JOBTYPE == JobType).Select(
                            x => (DateTime?)x.STARTTIME).Max();
                    if (date != null)
                    {
                        //ToGMT8
                        lastSyncTime = date.Value.AddHours(8);
                    }
                }

                #region 执行数据同步程序
                var fn = new FxNews();
                fn.GetWebData(strInfo, lastSyncTime);
                #endregion

                var endTime = DateTime.UtcNow;
                logEntity.ENDTIME   = endTime;
                logEntity.JobStatus = JobStatus.Success;
                logEntity.RUNDETAIL = strInfo.ToString();
                WriteLogEntity(logEntity);
            }
            catch (Exception exception)
            {
                logEntity.ENDTIME   = DateTime.UtcNow.AddDays(-1);
                logEntity.JobStatus = JobStatus.Fail;
                logEntity.RUNDETAIL = strInfo + "\n" + exception;
                WriteLogEntity(logEntity);
            }
        }
コード例 #3
0
 protected override void OnStop()
 {
     botLink = null;
     fxNews  = null;
 }