Example #1
0
        /**
         * Refreshes the specified item (not MFA)
         */
        public void RefreshItem(UserContext userContext, long?itemId, bool forceRefresh = false)
        {
            var refreshParameters = new RefreshParameters
            {
                refreshMode              = RefreshMode.NORMAL_REFRESH_MODE,
                refreshModeSpecified     = true,
                refreshPriority          = REFRESH_PRIORITY_HIGH,
                refreshPrioritySpecified = true,
                forceRefresh             = forceRefresh
            };

            bool          startRefresh7ReturnSpecified;
            RefreshStatus?status;

            refresh.startRefresh7(userContext, itemId, itemIdSpecified: true, refreshParameters: refreshParameters, startRefresh7Return: out status, startRefresh7ReturnSpecified: out startRefresh7ReturnSpecified);
            if (status.ToString().Equals(RefreshStatus.SUCCESS_START_REFRESH.ToString()))
            {
                Log.Debug("\tStarted refresh");
            }
            else
            {
                throw new RefreshYodleeException(status.HasValue ? status.Value : RefreshStatus.STATUS_UNKNOWN);
            }
        }
Example #2
0
        /**
         * Refreshes the specified item
         *
         */
        public void refreshItem(UserContext userContext, long?itemId, bool isMFA)
        {
            System.Console.WriteLine("Attempting to start refresh");
            //   bool startRefresh4ReturnSpecified = true;
            try
            {
                int REFRESH_PRIORITY_HIGH           = 1;
                RefreshParameters refreshParameters = new RefreshParameters();
                RefreshMode       refreshMode;
                if (isMFA)
                {
                    refreshMode = RefreshMode.MFA_REFRESH_MODE;
                }
                else
                {
                    refreshMode = RefreshMode.NORMAL_REFRESH_MODE;
                }

                refreshParameters.refreshMode              = refreshMode;
                refreshParameters.refreshModeSpecified     = true;
                refreshParameters.refreshPriority          = REFRESH_PRIORITY_HIGH;
                refreshParameters.refreshPrioritySpecified = true;
                refreshParameters.forceRefresh             = false;

                bool          itemIdspecified = true;
                bool          startRefresh7ReturnSpecified;
                RefreshStatus?status;
                refresh.startRefresh7(userContext, itemId, itemIdspecified, refreshParameters, out status, out startRefresh7ReturnSpecified);
                if (status.ToString().Equals(RefreshStatus.SUCCESS_START_REFRESH.ToString()))
                {
                    System.Console.WriteLine("\tStarted refresh");
                }
                else if (status.ToString().Equals(RefreshStatus.REFRESH_ALREADY_IN_PROGRESS.ToString()))
                {
                    System.Console.WriteLine("\tThe refresh is already in progress");
                }
                else if (status.ToString().Equals(RefreshStatus.ALREADY_REFRESHED_RECENTLY.ToString()))
                {
                    throw new Exception("The item has been refreshed very recently. Please try again later.");
                }
                else if (status.ToString().Equals(RefreshStatus.ITEM_CANNOT_BE_REFRESHED.ToString()))
                {
                    throw new Exception("The refresh on this item is not permitted.");
                }
                else
                {
                    throw new Exception("Unbale to refresh the item\nRefreshStatus:" + status);
                }
                if (isMFA)
                {
                    //We might need delay here to give few seconds for the message to be posted since this is a console based.
                    //In an application, it might not be required.
                    Thread.Sleep(MFA_QUEUE_WAIT_TIME_MILLIS);
                    MFARefreshInfo mfaInfo   = refresh.getMFAResponse(userContext, itemId, true);
                    MFA            mfa       = new MFA();
                    long           errorCode = mfa.processMFA(userContext, mfaInfo, itemId);
                    if (errorCode == 0)
                    {
                        System.Console.WriteLine("MFA Account has been added successfully");
                    }
                    else if (errorCode > 0)
                    {
                        System.Console.WriteLine("Error while adding this account with an error code " + errorCode);
                    }
                    else
                    {
                        System.Console.WriteLine("Error while adding this account");
                    }
                }
            }
            catch (SoapException se)
            {
                System.Console.WriteLine("The given item is invalid\nException:\n" + se.ToString());
            }
        }