Daily Stats To Peerstream

Status

Derecated. Removed from production.

Purpose

Gether the active users, total trial users & total paid users and write to the Peerstream BI database

Technology

.NET Framework 4.6.1 - Console application

Source code

Application source code is stored SVN

Project: DailyStatsToPeerstream

Repo: http://svn.paltalk.com/svn/ppnsystem/Console/DailyStatsToPeerstream

Deployment Method

Build locally and copy and paste to server

Description

Calls a SP on PPNSystem_main

SubSonic.StoredProcedure sp = PPNumber.Web.DAL.SPs.DashboardGetDailyStats();
rdr = sp.GetReader();

Gets vaules for active users, total trial users & total paid users 

rdr.Read();

string TotalActiveUsers = rdr.GetValue(0).ToString();
string TotalTrialUsers = rdr.GetValue(1).ToString();
string TotalPaidUsers = rdr.GetValue(2).ToString();

Inserts values into remote MySQL DB

InsertStats(TotalActiveUsers, TotalTrialUsers, TotalPaidUsers);

public static bool InsertStats(string inTotalActiveUsers, string inTotalTrialUsers, string inTotalPaidUsers)
    {
        bool aRet = false;
        string currentDateTime = DateTime.UtcNow.ToShortDateString();


        try
        {
            string connectionString = ConfigurationManager.ConnectionStrings["PeerstreamMySqlServer"].ConnectionString;

            lock (LockDB)
            {
                using (OdbcConnection ODBCConnection = new OdbcConnection(connectionString))
                {
                    if (ODBCConnection.State == ConnectionState.Closed) { ODBCConnection.Open(); }
                    if (ODBCConnection.State == ConnectionState.Open)
                    {
                        using (OdbcCommand SQLCommand = new OdbcCommand(string.Format("INSERT INTO vumber.daily_stats_vumber (stat_date, stat_id, version_id, value) VALUES ('{0}', '{1}', '{2}', '{3}')", currentDateTime, "totalActiveUsers", "1", inTotalActiveUsers ), ODBCConnection))
                        {
                            aRet = (SQLCommand.ExecuteNonQuery() > 0);
                        }
                        using (OdbcCommand SQLCommand = new OdbcCommand(string.Format("INSERT INTO vumber.daily_stats_vumber (stat_date, stat_id, version_id, value) VALUES ('{0}', '{1}', '{2}', '{3}')", currentDateTime, "totalTrialUsers", "1", inTotalTrialUsers), ODBCConnection))
                        {
                            aRet = (SQLCommand.ExecuteNonQuery() > 0);
                        }
                        using (OdbcCommand SQLCommand = new OdbcCommand(string.Format("INSERT INTO vumber.daily_stats_vumber (stat_date, stat_id, version_id, value) VALUES ('{0}', '{1}', '{2}', '{3}')", currentDateTime, "totalPaidUsers", "1", inTotalPaidUsers), ODBCConnection))
                        {
                            aRet = (SQLCommand.ExecuteNonQuery() > 0);
                        }
                    }
                }
            }
        }
        catch
        {
            aRet = false;
            throw;
        }

        return aRet;
    }

Hosted

Not hosted - not in production

Logging

Local