FreeMoney.FreeMoneyModule.TransferSuccess C# (CSharp) Method

TransferSuccess() private method

private TransferSuccess ( FreeMoneyTransaction transaction ) : void
transaction FreeMoneyTransaction
return void
        void TransferSuccess(FreeMoneyTransaction transaction)
        {
            if (transaction.InternalType == FreeMoneyTransaction.InternalTransactionType.Payment) {
                if (transaction.ObjectID == UUID.Zero) {
                    // User 2 User Transaction
                    m_log.Info ("[FreeMoney] Success: " + transaction.From + " did pay user " +
                                transaction.To + " " + m_gridCurrencySmallDenominationText + " " + transaction.Amount);

                    IUserAccountService userAccountService = m_scenes[0].UserAccountService;
                    UserAccount ua;

                    // Notify receiver
                    ua = userAccountService.GetUserAccount (transaction.From, "", "");
                    SendInstantMessage (transaction.To, ua.FirstName + " " + ua.LastName +
                                        " did pay you US$ cent " + transaction.Amount);

                    // Notify sender
                    ua = userAccountService.GetUserAccount (transaction.To, "", "");
                    SendInstantMessage (transaction.From, "You did pay " + ua.FirstName + " " +
                                        ua.LastName + " US$ cent " + transaction.Amount);
                } else {
                    if (OnObjectPaid != null) {
                        m_log.Info ("[FreeMoney] Success: " + transaction.From + " did pay object " +
                                    transaction.ObjectID + " owned by " + transaction.To +
                                    " " + m_gridCurrencySmallDenominationText + " " + transaction.Amount);

                        OnObjectPaid (transaction.ObjectID, transaction.From, transaction.Amount);
                    }
                }
            } else if (transaction.InternalType == FreeMoneyTransaction.InternalTransactionType.Purchase) {
                if (transaction.ObjectID == UUID.Zero) {
                    m_log.Error ("[FreeMoney] Unable to find Object bought! UUID Zero.");
                } else {
                    Scene s = LocateSceneClientIn (transaction.From);
                    SceneObjectPart part = s.GetSceneObjectPart (transaction.ObjectID);
                    if (part == null) {
                        m_log.Error ("[FreeMoney] Unable to find Object bought! UUID = " + transaction.ObjectID);
                        return;
                    }

                    m_log.Info ("[FreeMoney] Success: " + transaction.From + " did buy object " +
                                transaction.ObjectID + " from " + transaction.To + " paying " + m_gridCurrencySmallDenominationText + " " +
                                transaction.Amount);

                    IBuySellModule module = s.RequestModuleInterface<IBuySellModule> ();
                    if (module == null) {
                        m_log.Error ("[FreeMoney] Missing BuySellModule! Transaction failed.");
                    } else {
                        ScenePresence sp = s.GetScenePresence(transaction.From);
                        if (sp != null)
                            module.BuyObject (sp.ControllingClient,
                                          transaction.InternalPurchaseFolderID, part.LocalId,
                                          transaction.InternalPurchaseType, transaction.Amount);
                    }
                }
            } else if (transaction.InternalType == FreeMoneyTransaction.InternalTransactionType.Land) {
                // User 2 Land Transaction
                EventManager.LandBuyArgs e = transaction.E;

                lock (e) {
                    e.economyValidated = true;
                }

                Scene s = LocateSceneClientIn (transaction.From);
                ILandObject land = s.LandChannel.GetLandObject ((int)e.parcelLocalID);

                if (land == null) {
                    m_log.Error ("[FreeMoney] Unable to find Land bought! UUID = " + e.parcelLocalID);
                    return;
                }

                m_log.Info ("[FreeMoney] Success: " + e.agentId + " did buy land from " + e.parcelOwnerID +
                            " paying " + m_gridCurrencySmallDenominationText + " " + e.parcelPrice);

                land.UpdateLandSold (e.agentId, e.groupId, e.groupOwned, (uint)e.transactionID,
                                     e.parcelPrice, e.parcelArea);
            } else {
                m_log.Error ("[FreeMoney] Unknown Internal Transaction Type.");
                return;
            }
            // Cleanup.
            lock (m_transactionsInProgress)
                m_transactionsInProgress.Remove (transaction.TxID);
        }