[Tutorial] Request Gc "GC LOG"

Newbie Spellweaver
Joined
Jul 7, 2013
Messages
26
Reaction score
8
search

Code:
void FrontendWarZ::eventRequestGCTransactionData(r3dScaleformMovie* pMovie, const Scaleform::GFx::Value* args, unsigned argCount)

ADD ABOVE

Code:
void FrontendWarZ::eventRequestGCTransactionData(r3dScaleformMovie* pMovie, const Scaleform::GFx::Value* args, unsigned argCount)
{
    Scaleform::GFx::Value var[3];
    var[0].SetStringW(gLangMngr.getString("OneMomentPlease"));
    var[1].SetBoolean(false);
    var[2].SetString("");
    gfxMovie.Invoke("_root.api.showInfoMsg", var, 3);


    char* g_ServerApiKey = "bvx425698dg6GsnxwedszF";
    CWOBackendReq req("api_GetTransactions.aspx");
    req.AddSessionInfo(gUserProfile.CustomerID, gUserProfile.SessionID);
    req.AddParam("skey1",  g_ServerApiKey);
    req.AddParam("CustomerID", gUserProfile.CustomerID);


    if(!req.Issue())
    {
        r3dOutToLog("GetTransactions FAILED, code: %d\n", req.resultCode_);
        return;
    }


    pugi::xml_document xmlFile;
    req.ParseXML(xmlFile);
    pugi::xml_node Transactions = xmlFile.child("data");


    int Count = 0;
    bool HaveTransactions = false;
    while(!Transactions.empty())
    {
        char TransactionID[512];
        char DateTime[512];
        char name[512];
        char Amount2[512];
        HaveTransactions = true;
        strcpy(TransactionID,Transactions.attribute("TransactionID").value());
        uint32_t ItemID = Transactions.attribute("ItemID").as_uint();
        uint32_t Amount = Transactions.attribute("Amount").as_uint();
        strcpy(DateTime,Transactions.attribute("DateTime").value());
        Count++;


        Scaleform::GFx::Value var[5];
        var[0].SetInt(Count); // ID
        var[1].SetString(DateTime); // DATE 
        const BaseItemConfig* cfg = g_pWeaponArmory->getConfig(ItemID);


        // transactions descriptions
        if (strcmp(TransactionID, "INGAME")==0 && cfg) // buying in marketplace.
        {
            sprintf(name,"Marketplace: %s",cfg->m_StoreName);
        }
        else if (strcmp(TransactionID, "EarlyRevive")==0)
            strcpy(name,"$FR_EarlyRevival");
        else if (strcmp(TransactionID, "ConvertGCToGD")==0)
            strcpy(name,"$FR_CONVERT_GC_TO_GD");
        else if (strcmp(TransactionID, "ChangeName")==0)
            strcpy(name,"$FR_CONVERT_GC_TO_GD");
        var[2].SetStringW(gLangMngr.getString(name)); // name
        
        var[3].SetString("1"); // amount
        sprintf(Amount2,"%i GC",Amount);
        var[4].SetString(Amount2); // balance
        if (name[0])
            gfxMovie.Invoke("_root.api.Main.Marketplace.addTransactionData", var, 5);


        Transactions = Transactions.next_sibling();
    }
    gfxMovie.Invoke("_root.api.hideInfoMsg", "");
    if (!HaveTransactions)
    {
        Scaleform::GFx::Value var[3];
        var[0].SetStringW(gLangMngr.getString("$NotHaveTransactions"));
        var[1].SetBoolean(true);
        var[2].SetStringW(gLangMngr.getString("$FR_SystemNotice"));
        gfxMovie.Invoke("_root.api.showInfoMsg", var, 3);
        return;
    }
    gfxMovie.Invoke("_root.api.Main.Marketplace.showTransactionsPopup", "");
}

SQL

Code:
CREATE PROCEDURE [dbo].[WZ_GetTransactions]
    @in_CustomerID int
AS
BEGIN
select 0 as ResultCode


;WITH TransactionsData AS
    (
    SELECT TOP (1000000000000000) TransactionID,TransactionType,Amount,ItemID,DateTime AS DateTime,
    ROW_NUMBER() OVER
    (ORDER BY DateTime DESC) AS Pos
    FROM FinancialTransactions
    where CustomerID = @in_CustomerID and TransactionType = 3000 or CustomerID = @in_CustomerID and TransactionType = 2000 or CustomerID = @in_CustomerID and TransactionID = 'ConvertGCToGD' or CustomerID = @in_CustomerID and TransactionID = 'EarlyRevive'
    )
    SELECT TransactionID,TransactionType,Amount,DateTime,ItemID
    FROM TransactionsData
    WHERE Pos > 0 AND Pos <= 0 + 1000000000000000
END

API CREATE "api_GetTransactions.aspx"

api_GetTransactions.aspx - CLEAN ALL AND ADD

Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="api_GetTransactions.aspx.cs" Inherits="api_GetTransactions" %>

api_GetTransactions.aspx.CS CLEAN ALL AND ADD

Code:
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;


public partial class api_GetTransactions : WOApiWebPage
{
    protected override void Execute()
    {
        //if (!WoCheckLoginSession())
        //    return;


        string CustomerID = web.Param("CustomerID");


        SqlCommand sqcmd = new SqlCommand();
        sqcmd.CommandType = CommandType.StoredProcedure;
        sqcmd.CommandText = "WZ_GetTransactions";
        sqcmd.Parameters.AddWithValue("@in_CustomerID", CustomerID);


        if (!CallWOApi(sqcmd))
            return;


        //reader.Read();


        // report page of leaderboard
        StringBuilder xml = new StringBuilder();
        xml.Append("<?xml version=\"1.0\"?>\n");


        //reader.NextResult();
        while (reader.Read())
        {
            string DateTime = reader["DateTime"].ToString();
            string TransactionID = reader["TransactionID"].ToString();
            string ItemID = reader["ItemID"].ToString();
            string Amount = reader["Amount"].ToString();
            
            xml.Append("<data ");
            xml.Append(xml_attr("DateTime",DateTime));
            xml.Append(xml_attr("TransactionID",TransactionID));
            xml.Append(xml_attr("ItemID",ItemID));
            xml.Append(xml_attr("Amount",Amount));
            xml.Append(" />");
        }


        Response.Write(xml.ToString());
    }
}
 
Back