예제 #1
0
        /// <summary>
        /// 取得投資風險評估切點時間範圍
        /// </summary>
        /// <returns>投資風險評估切點時間範圍</returns>
        public CuttimeRangeInfoEntity GetCurrentCuttimeRange()
        {
            CuttimeRangeInfoEntity cuttimeRange = null;

            if (_cuttimeRange != null)
            {
                return(_cuttimeRange);
            }

            string riskEvaCuttime = ConfigurationManager.AppSettings["risk.evaluation.cuttime"];

            string[] cuttimeArray = String.IsNullOrEmpty(riskEvaCuttime) ? null :
                                    riskEvaCuttime.Split(',');

            if (cuttimeArray != null)
            {
                List <DateTime> cuttimes = new List <DateTime>();

                foreach (string cuttime in cuttimeArray)
                {
                    if (!String.IsNullOrEmpty(cuttime) &&
                        (DateTime.TryParse(cuttime, out DateTime tempCuttime)))
                    {
                        cuttimes.Add(tempCuttime);
                    }
                }

                if (cuttimes.Count > 0)
                {
                    DateTime timeNow     = DateTime.Now;
                    DateTime cuttimesMax = cuttimes.Max();
                    DateTime cuttimesMin = cuttimes.Min();

                    cuttimes.Add(cuttimesMax.AddDays(-1));
                    cuttimes.Add(cuttimesMin.AddDays(1));

                    cuttimeRange = new CuttimeRangeInfoEntity
                    {
                        StartTime = cuttimes.Where(x => x < timeNow).Max(),
                        EndTime   = cuttimes.Where(x => x > timeNow).Min()
                    };
                }
            }

            return(cuttimeRange);
        }
예제 #2
0
        /// <summary>
        /// 檢查風險紀錄評估時間是否在目前作業週期內
        /// </summary>
        /// <param name="riskEvaluationDO">投資風險評估結果</param>
        /// <returns>檢查結果</returns>
        public bool CheckInCuttimeRange(RiskEvaluationDO riskEvaluationDO)
        {
            bool inCuttimeRange = false;

            CuttimeRangeInfoEntity cuttimeRange = GetCurrentCuttimeRange();

            if (cuttimeRange == null)
            {
                throw new InvalidOperationException("cuttimeRange not found");
            }

            if ((riskEvaluationDO.EvaluationDate < cuttimeRange.EndTime) &&
                (riskEvaluationDO.EvaluationDate >= cuttimeRange.StartTime))
            {
                inCuttimeRange = true;
            }

            return(inCuttimeRange);
        }
예제 #3
0
 /// <summary>
 /// 此建構函式會設定投資風險評估切點時間範圍的起訖時間。
 /// </summary>
 /// <param name="cuttimeRange">投資風險評估切點時間範圍</param>
 public RiskEvaluationService(CuttimeRangeInfoEntity cuttimeRange)
 {
     _cuttimeRange = cuttimeRange;
 }