예제 #1
0
            public SpSaveVatReturnData(AStrategy oStrategy, AConnection oDB, ASafeLog oLog) : base(oDB, oLog)
            {
                HistoryItems            = new List <HistoryItem>();
                this.m_oOldDeletedItems = new SortedSet <int>();

                this.m_oStrategy = oStrategy;
            }             // constructor
예제 #2
0
 public StrategyException(
     AStrategy oSource,
     string sMsg,
     Exception oInnerException = null
     ) : base(StrategyException.Msg(oSource, sMsg), oInnerException)
 {
 }                                                                          // constructor
예제 #3
0
        public UserSecurityData(AStrategy oStrategy)
        {
            this.strategy = oStrategy;

            Cfg = new UserManagementConfigs(this.strategy.DB, this.strategy.Log);

            this.strategy.Log.Debug("User management configuration: {0}.", Cfg);
        }         // constructor
예제 #4
0
 public BrokerLeadData(
     string sBrokerContactEmail,
     int origin,
     AStrategy oStrategy,
     int nLeadID,
     AConnection oDB
     ) : base(oStrategy, nLeadID, oDB)
 {
     m_sBrokerContactEmail = sBrokerContactEmail;
     this.origin           = origin;
 }         // constructor
예제 #5
0
파일: Job.cs 프로젝트: vijayamazon/ezbob
        }         // OnInit

        private void OnSuccess(AStrategy oInstance, ActionMetaData oMetaData)
        {
            DB.ExecuteNonQuery(
                "UpdateCronjobEnded",
                CommandSpecies.StoredProcedure,
                new QueryParameter("JobID", ID),
                new QueryParameter("ActionStatusID", (int)ActionStatus.Done),
                new QueryParameter("ActionID", oMetaData.ActionID),
                new QueryParameter("Now", DateTime.UtcNow)
                );
        }         // OnSuccess
예제 #6
0
        }         // Name

        public override void Execute()
        {
            Log.Debug("Resetting password for user {0}...", this.spLoad.TargetID);

            this.spLoad.ExecuteNonQuery();

            if (string.IsNullOrWhiteSpace(this.spLoad.Email))
            {
                Log.Warn("Resetting password for user {0} failed: no email found.", this.spLoad.TargetID);
                return;
            }             // if

            var pu = new PasswordUtility(CurrentValues.Instance.PasswordHashCycleCount);

            HashedPassword hashed = pu.Generate(this.spLoad.Email, ThePassword);

            var sp = new SavePassword(this.spLoad, DB, Log)
            {
                Password   = hashed.Password,
                Salt       = hashed.Salt,
                CycleCount = hashed.CycleCount,
            };

            sp.ExecuteNonQuery();

            Log.Debug("Resetting password for user {0} complete.", this.spLoad.TargetID);

            AStrategy oEmailSender = null;

            switch (this.targetType)
            {
            case PasswordResetTarget.Customer:
                oEmailSender = new PasswordChanged(this.spLoad.TargetID, ThePassword);
                break;

            case PasswordResetTarget.Broker:
                oEmailSender = new BrokerPasswordChanged(this.spLoad.TargetID, ThePassword);
                break;
            }             // switch

            FireToBackground(oEmailSender);
        }         // Execute
        }         // StressTestSync

        public StringListActionResult ListActiveActions()
        {
            try {
                ActionMetaData amd = NewSync("Admin.ListActiveActions");

                Log.Msg("ListActiveActions() method started...");

                var oResult = new List <string>();

                lock (lockActiveActions) {
                    oResult.AddRange(activeActions.Select(
                                         kv => {
                        AStrategy stra = kv.Value.Strategy;

                        return(string.Format(
                                   "{0} {2}- thread state: {1}",
                                   kv.Value,
                                   kv.Value.UnderlyingThread.ThreadState,
                                   stra == null ? string.Empty : "(" + stra.Context + ") "
                                   ));
                    }
                                         ));
                }                 // lock

                SaveActionStatus(amd, ActionStatus.Done);

                Log.Msg("ListActiveActions() method complete with result {0}.", amd);

                return(new StringListActionResult {
                    MetaData = amd, Records = oResult
                });
            }
            catch (Exception e) {
                if (!(e is AException))
                {
                    Log.Alert(e, "Exception during ListActiveActions() method.");
                }

                throw new FaultException(e.Message);
            }     // try
        }         // ListActiveActions
예제 #8
0
        }                                                                          // constructor

        public static string Msg(AStrategy oSource, string sMsg)
        {
            return
                ((string.IsNullOrEmpty(oSource.Name) ? string.Empty : oSource.Name + ": ") +
                 (string.IsNullOrWhiteSpace(sMsg) ? "Something exceptional happened" : sMsg));
        } // Msg
예제 #9
0
 public FailedToInitStrategyException(AStrategy oSource, Exception oInnerException) : base(oSource, "Failed to initialise.", oInnerException)
 {
 } // constructor
예제 #10
0
        }                                                    // FirmName

        public BrokerData(AStrategy oStrategy, int nBrokerID, AConnection oDB) : base(oStrategy, nBrokerID, oDB)
        {
        }         // constructor
예제 #11
0
        }         // Execute

        // async
        public ActionMetaData Execute(ExecuteArguments oArgs)
        {
            ActionMetaData amd = null;

            try {
                if (oArgs == null)
                {
                    throw new Alert(Log, "No ExecuteArguments specified.");
                }

                SetLogThreadProperties(oArgs);
                Log.Debug("Executing " + oArgs.StrategyType + " started...");

                amd = NewAsync(
                    oArgs.StrategyType.ToString(),
                    comment: oArgs.StrategyArgumentsStr,
                    nCustomerID: oArgs.CustomerID,
                    nUserID: oArgs.UserID
                    );

                ConstructorInfo oCreator = oArgs.StrategyType.GetConstructors().FirstOrDefault(
                    ci => ci.GetParameters().Length == oArgs.StrategyArguments.Count
                    );

                if (oCreator == null)
                {
                    string msg = string.Format(
                        "Failed to find a constructor for {0} with {1} arguments.",
                        oArgs.StrategyType,
                        oArgs.StrategyArguments.Count
                        );

                    throw new Alert(Log, msg);
                }                 // if

                Log.Debug(oArgs.StrategyType + " constructor found, invoking...");

                amd.UnderlyingThread = new Thread(() => {
                    try {
                        SetLogThreadProperties(oArgs);
                        AStrategy oInstance = (AStrategy)oCreator.Invoke(oArgs.StrategyArguments.ToArray());

                        if (oInstance == null)
                        {
                            throw new NullReferenceException("Failed to create an instance of " + oArgs.StrategyType);
                        }

                        amd.Strategy = oInstance;

                        oInstance.Context.UserID     = oArgs.UserID;
                        oInstance.Context.CustomerID = oArgs.CustomerID;

                        if (oArgs.OnInit != null)
                        {
                            Log.Debug(oInstance.Name + " instance created, invoking an initialization action...");

                            oArgs.OnInit(oInstance, amd);

                            Log.Debug(oInstance.Name + " initialization action complete.");
                        }                         // if

                        Log.Debug(oInstance.Name + " instance is initialized, executing...");

                        oInstance.Execute();

                        Log.Debug("Executing " + oArgs.StrategyType + " complete.");

                        SaveActionStatus(amd, ActionStatus.Done);

                        if (oArgs.OnSuccess != null)
                        {
                            Log.Debug(oInstance.Name + " instance running complete, invoking an OnSuccess action...");

                            oArgs.OnSuccess(oInstance, amd);

                            Log.Debug(oInstance.Name + " OnSuccess action complete.");
                        }                         // if
                    } catch (Exception e) {
                        Log.Alert(e, "Exception during executing " + oArgs.StrategyType + " strategy.");

                        amd.Comment = e.Message;
                        SaveActionStatus(amd, ActionStatus.Failed);

                        if (oArgs.OnFail != null)
                        {
                            Log.Debug(oArgs.StrategyType + " instance running failed, invoking an OnFail action...");

                            try {
                                oArgs.OnFail(amd);
                                Log.Debug(oArgs.StrategyType + " OnFail action complete.");
                            } catch (Exception ie) {
                                Log.Alert(
                                    ie,
                                    "Exception during executing of OnFail handler of " + oArgs.StrategyType + " strategy."
                                    );
                            }             // try
                        }                 // if
                    }                     // try
                });

                SaveActionStatus(amd, ActionStatus.Launched);

                if (oArgs.OnLaunch != null)
                {
                    Log.Debug(oArgs.StrategyType + " instance is to be launched, invoking an OnLaunch action...");

                    oArgs.OnLaunch(amd);

                    Log.Debug(oArgs.StrategyType + " OnLaunch action complete.");
                }                 // if

                amd.UnderlyingThread.Start();

                Log.Debug(
                    "Executing {0} started on another thread [{1}].",
                    oArgs.StrategyType,
                    amd.UnderlyingThread.ManagedThreadId
                    );

                return(amd);
            } catch (Exception e) {
                if (amd != null)
                {
                    amd.Comment += " Exception caught: " + e.Message;
                    SaveActionStatus(amd, ActionStatus.Failed);
                }                 // if

                if (!(e is AException))
                {
                    string sStrategyType = oArgs == null ? "UNKNOWN" : oArgs.StrategyType.ToString();
                    Log.Alert(e, "Exception during executing " + sStrategyType + " strategy.");
                }                 // if

                if ((oArgs != null) && (oArgs.OnException != null))
                {
                    try {
                        oArgs.OnException(amd);
                    } catch (Exception ie) {
                        Log.Alert(
                            ie,
                            "Exception during executing of OnException handler of " + oArgs.StrategyType + " strategy."
                            );
                    }             // try
                }                 // if

                throw new FaultException(e.Message);
            }     // try
        }         // Execute
예제 #12
0
        }         // GetBusinessData

        public override void Execute()
        {
            Log.Info(
                "Starting company check with parameters: IsLimited={0} ExperianRefNum={1}",
                this.isLimited ? "yes" : "no",
                this.experianRefNum
                );

            if (!this.foundCompany || (this.experianRefNum == "NotFound"))
            {
                Log.Info("Can't execute Experian company check for customer with no company");
                return;
            }             // if

            string             experianError = null;
            BusinessReturnData oExperianData = null;

            if (string.IsNullOrEmpty(this.experianRefNum))
            {
                experianError = "RefNumber is empty";
            }
            else
            {
                Log.Info("ExperianCompanyCheck strategy will make sure we have experian data");

                oExperianData = GetBusinessData(
                    this.isLimited,
                    this.experianRefNum,
                    this.customerId,
                    false,
                    this.forceCheck
                    );

                if (oExperianData != null)
                {
                    Log.Info(
                        "Fetched BureauScore {0} & MaxBureauScore {1} for customer {2}.",
                        oExperianData.BureauScore,
                        oExperianData.MaxBureauScore, this.customerId
                        );

                    if (!oExperianData.IsError)
                    {
                        MaxScore = oExperianData.MaxBureauScore;
                        Score    = oExperianData.BureauScore;
                        Log.Info("Filled Score & MaxScore of the strategy");
                    }
                    else
                    {
                        experianError = oExperianData.Error;
                    }

                    if (!oExperianData.CacheHit && CurrentValues.Instance.CreditSafeEnabled)
                    {
                        try {
                            AStrategy stra = this.isLimited
                                                                ? (AStrategy) new ServiceLogCreditSafeLtd(this.experianRefNum, this.customerId)
                                                                : (AStrategy) new ServiceLogCreditSafeNonLtd(this.customerId);

                            stra.Execute();
                        } catch (Exception e) {
                            Log.Error(e, "CreditSafeLtd/NonLtd NonCachHit failed for unexpected reason");
                        } // try
                    }     // if
                }         // if
            }             // if

            if (!string.IsNullOrEmpty(experianError))
            {
                Log.Warn(
                    "Error in experian company check. Customer:{0} RefNumber:{1} Errors: {2}",
                    this.customerId,
                    this.experianRefNum,
                    experianError
                    );
            }             // if

            Log.Info("Filling Analytics with Score: {0} & max score: {1}", Score, MaxScore);

            if (oExperianData == null)
            {
                Log.Debug("Premature completion: no data received from Experian.");
                return;
            }             // if

            if (oExperianData.IsError)
            {
                Log.Debug("Premature completion because of error: {0}.", oExperianData.Error);
                return;
            }             // if

            if (oExperianData.IsLimited)
            {
                new UpdateLimitedExperianDirectors(this.customerId, oExperianData.ServiceLogID).Execute();
            }

            if (this.doSilentAutomation)
            {
                new SilentAutomation(this.customerId).SetTag(SilentAutomation.Callers.Company).Execute();
            }
        }         // Execute
예제 #13
0
 public CustomerData(AStrategy oStrategy, int nCustomerID, AConnection oDB)
 {
     Strategy    = oStrategy;
     RequestedID = nCustomerID;
     DB          = oDB;
 }         // constructor