123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using SinochemCloudClient.Models;
- using SinochemPosClient.Models;
- namespace SinochemInternetPlusApp.EpsTrxCleanup
- {
- public class EpsTrxCleanupManager : StateManager
- {
- static NLog.Logger logger = NLog.LogManager.LoadConfiguration("nlog.config").GetLogger("SinochemEpsApp");
- private Eps eps;
- public EpsTrxCleanupManager(Eps eps) : base(0, "EpsTrxCleanup")
- {
- //debugLogger.Add("EpsTrxCleanupManager is constructed");
- logger.Info("EpsTrxCleanupManager is constructed");
- this.eps = eps;
- }
- public override string EntityType => "EpsTrxCleanup";
- public override string EntitySubType => "";
- protected override void ConfigStates()
- {
- States.CONFIGURATION.Config(stateMachine.StateTransitionLookup);
- }
- internal List<EpsTransaction> GetNeedRefundEpsTrxes()
- {
- DateTime dummyTime = DateTime.Now;
- return EpsTransactionQuery.GetEpsTrxesByTrxStatusAndCreatedTime
- (EpsTrxStatus.PaymentOkButNeedRefund, dummyTime, true);
- }
- internal List<EpsTransaction> GetNeedConfirmEpsTrxes()
- {
- DateTime expirationDatetime = DateTime.Now.AddMinutes(-1 * ConfigurationValues.NeedConfirmEpsTrxExpirationInMinutes);
- //debugLogger.Add("NeedConfirmEpsTrxes expiration datetime: " + expirationDatetime);
- logger.Info("NeedConfirmEpsTrxes expiration datetime: " + expirationDatetime);
- List<EpsTransaction> needConfirmEpsTrxes = EpsTransactionQuery.GetEpsTrxesByTrxStatusAndCreatedTime
- (EpsTrxStatus.PaymentNeedConfirm, expirationDatetime, false);
- debugLogger.Add(needConfirmEpsTrxes.Count() + " eps trxes need confirmation");
- return needConfirmEpsTrxes;
- }
- internal List<EpsTransaction> GetNeedResendPosNotifyEpsTrxes()
- {
- DateTime expirationDatetime = DateTime.Now.AddMinutes(-1 * ConfigurationValues.ResendPosNotifyExpirationInMinutes);
- //debugLogger.Add("NeedResendPosNotifyEpsTrxes expiration datetime: " + expirationDatetime);
- logger.Info("NeedResendPosNotifyEpsTrxes expiration datetime: " + expirationDatetime);
- List<EpsTransaction> needResendPosNotifyEpsTrxes = EpsTransactionQuery.GetEpsTrxesByNotifyPosFlagAndCreatedTime
- (NotifyPosFlag.NotifyFailed, expirationDatetime);
- //debugLogger.Add(needResendPosNotifyEpsTrxes.Count() + " eps trxes need resending pos notify");
- logger.Info(needResendPosNotifyEpsTrxes.Count() + " eps trxes need resending pos notify");
- return needResendPosNotifyEpsTrxes;
- }
- internal RefundResponse RefundEpsTrxInCloud(EpsTransactionModel trxModel)
- {
- return eps.SendRefundToCloud(trxModel, debugLogger);
- }
- internal TrxStatusInquiryResponse InquiryCloudTrxStatus(EpsTransactionModel trxModel)
- {
- return eps.SendTrxQueryToCloud(trxModel, debugLogger);
- }
- internal TrxNotificationResponse NotifySuccessfulTrxToPos(EpsTransactionModel trxModel)
- {
- return eps.NotifySuccessfulTrxToPos(trxModel, debugLogger);
- }
- internal void RemoveEpsTrxHistoryBeforeCertainDate()
- {
- DateTime oldEnoughDatetime = DateTime.Now.AddDays(-1 * ConfigurationValues.EpsTrxHistoryArchiveInDays);
- //debugLogger.Add("RemoveEpsTrxHistory before datetime: " + oldEnoughDatetime);
- logger.Info("RemoveEpsTrxHistory before datetime: " + oldEnoughDatetime);
- EpsTransactionQuery.DeleteEpsTrxesBefore(oldEnoughDatetime);
- }
- }
- }
|