コード例 #1
0
        /// <summary>
        /// Handles the specified command.
        /// </summary>
        /// <param name="cmd">The command.</param>
        public void Handle(YodleeUserAddedAccountCommand cmd)
        {
            InfoAccumulator info = new InfoAccumulator();

            var userAccount = YodleeQueries.GetUserAccount(cmd.CustomerId);

            if (userAccount == null)
            {
                string err = "could not get useraccount from db for id: " + cmd.CustomerId;
                info.AddError(err);
                Log.Error(err);
                RegisterError(info, cmd);
                //go to retry
                throw new InvalidDataException(err);
            }

            YodleeGetUserAccountsCommand userAccountsCommand = new YodleeGetUserAccountsCommand {
                UserName        = userAccount.Username,
                UserPassword    = userAccount.Password,
                CobrandUserName = Config.CoBrandUserName,
                CobrandPassword = Config.CoBrandPassword,
                CustomerId      = cmd.CustomerId
            };

            SendCommand(ThirdPartyService.Address, userAccountsCommand, cmd);
        }
コード例 #2
0
        /// <summary>
        /// Handles the specified command.
        /// </summary>
        /// <param name="cmd">The command.</param>
        /// <exception cref="System.IO.InvalidDataException"></exception>
        public void Handle(YodleeAddUserAccountCommand cmd)
        {
            InfoAccumulator info = new InfoAccumulator();

            if (YodleeQueries.IsUserAlreadyHaveContentService(cmd.CustomerId, cmd.ContentServiceId))
            {
                string msg = "the customer already added this content service" + cmd.ContentServiceId;
                info.AddError(msg);
                Log.Info(msg);
                SendReply(info, cmd);
                return;
            }

            var siteId = YodleeQueries.GetSiteIdFromContentServiceId(cmd.ContentServiceId);

            if (!siteId.HasValue)
            {
                string err = "could not retrieve site id from DB";

                Log.Error(err);
                info.AddError(err);
                RegisterError(info, cmd);
                //go to retry
                throw new InvalidDataException(err);
            }

            var yodleeUserAccount = YodleeQueries.GetUserAccount(cmd.CustomerId);

            if (yodleeUserAccount == null)
            {
                var err = "could not get user account from DB for id: " + cmd.CustomerId;
                Log.Error(err);
                info.AddError(err);
                RegisterError(info, cmd);
                //go to retry
                throw new InvalidDataException(err);
            }

            YodleeGetFastLinkCommand fastLinkCommand = new YodleeGetFastLinkCommand {
                ContentServiceId = cmd.ContentServiceId,
                CobrandUserName  = Config.CoBrandUserName,
                CobrandPassword  = Config.CoBrandPassword,
                UserName         = yodleeUserAccount.Username,
                UserPassword     = yodleeUserAccount.Password,
                SiteId           = siteId.Value
            };

            SendCommand(ThirdPartyConfig.Address, fastLinkCommand, cmd);
        }