using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.IO; using System.Text; using Sog; namespace bill_statistics { public static partial class LogWrapper { public static bool bIOSOpen = false; public static bool bArenaOpen = false; public static void LogRetentionInfo() { FileStream fsFile = new FileStream("./bill_out_keep.txt", FileMode.Create); StreamWriter fileWriter = new StreamWriter(fsFile, Encoding.UTF8); string strMessage = "日期\t活跃用户\t活跃IOS用户\t活跃FB用户\tfacebook邀请人次\t新进用户\t新进IOS用户\t新进FB用户\t付费活跃用户\t最高在线\t平均在线\t新进次留\t2留\t3留\t5留\t7留\t15留\t30留\t活跃次留\t2留\t3留\t5留\t7留\t15留\t30留\t付费次留\t2留\t3留\t5留\t7留\t15留\t30留\t"; string matchMessage = "", iosMessage = ""; if(bArenaOpen == true) { matchMessage = "比赛新进次留\t2留\t3留\t5留\t7留\t15留\t30留\t比赛次留\t2留\t3留\t5留\t7留\t15留\t30留\t"; } if (bIOSOpen == true) { iosMessage = "IOS新进次留\t2留\t3留\t5留\t7留\t15留\t30留\tIOS活跃次留\t2留\t3留\t5留\t7留\t15留\t30留"; } strMessage += matchMessage; strMessage += iosMessage; fileWriter.WriteLine(strMessage); foreach (KeyValuePair pair in BillAlldays.Instance.m_billAllDays) { DateTime dateTime = pair.Key; BillInfoEveryDay info = pair.Value; int maxOnline = info.MaxOnline; int avgOnline = info.AvgOnlineADay; int fbUser = info.GetFaceBookUserCount(info.m_activeUser); int invitesuccessPlayerCount = info.m_activeUser.Count(o => o.Value.InviteSuccessInviteeRewardCount != 0); string strDay = string.Format("{0}/{1}/{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}" , dateTime.Year, dateTime.Month, dateTime.Day , info.ActiveUser, info.IOSActiveUser, fbUser, invitesuccessPlayerCount, info.NewUser, info.IOSNewUser, info.NewUserFB, info.ActivePayUser); string strNewUser = ""; string strActiveUser = ""; string strPayUser = ""; string strIOSNewUser = ""; string strIOSActiveUser = ""; if (info.NewUserMinus_CPE != 0) { strNewUser = string.Format("{0:0.0000}%\t{1:0.0000}%\t{2:0.0000}%\t{3:0.0000}%\t{4:0.0000}%\t{5:0.0000}%\t{6:0.0000}%", info.m_newUserRetentionInfo.Retention1 * 100.0f / info.NewUserMinus_CPE, info.m_newUserRetentionInfo.Retention2 * 100.0f / info.NewUserMinus_CPE, info.m_newUserRetentionInfo.Retention3 * 100.0f / info.NewUserMinus_CPE, info.m_newUserRetentionInfo.Retention5 * 100.0f / info.NewUserMinus_CPE, info.m_newUserRetentionInfo.Retention7 * 100.0f / info.NewUserMinus_CPE, info.m_newUserRetentionInfo.Retention15 * 100.0f / info.NewUserMinus_CPE, info.m_newUserRetentionInfo.Retention30 * 100.0f / info.NewUserMinus_CPE); } if (info.ActiveUserMinus_CPE != 0) { strActiveUser = string.Format("{0:0.0000}%\t{1:0.0000}%\t{2:0.0000}%\t{3:0.0000}%\t{4:0.0000}%\t{5:0.0000}%\t{6:0.0000}%", info.ActRetention1 * 100.0f / info.ActiveUserMinus_CPE, info.ActRetention2 * 100.0f / info.ActiveUserMinus_CPE, info.ActRetention3 * 100.0f / info.ActiveUserMinus_CPE, info.ActRetention5 * 100.0f / info.ActiveUserMinus_CPE, info.ActRetention7 * 100.0f / info.ActiveUserMinus_CPE, info.ActRetention15 * 100.0f / info.ActiveUserMinus_CPE, info.ActRetention30 * 100.0f / info.ActiveUserMinus_CPE); } int payUser = info.m_PayGoogleSuccessResUser.Count; if (payUser != 0) { strPayUser = string.Format("{0:0.0000}%\t{1:0.0000}%\t{2:0.0000}%\t{3:0.0000}%\t{4:0.0000}%\t{5:0.0000}%\t{6:0.0000}%", info.PayRetention1 * 100.0f / payUser, info.PayRetention2 * 100.0f / payUser, info.PayRetention3 * 100.0f / payUser, info.PayRetention5 * 100.0f / payUser, info.PayRetention7 * 100.0f / payUser, info.PayRetention15 * 100.0f / payUser, info.PayRetention30 * 100.0f / payUser); } else { strPayUser = "0.00%\t0.00%\t0.00%\t0.00%\t0.00%\t0.00%\t0.00%"; } // IOS if(bIOSOpen == true) { if (info.IOSNewUser != 0) { strIOSNewUser = string.Format("{0:0.0000}%\t{1:0.0000}%\t{2:0.0000}%\t{3:0.0000}%\t{4:0.0000}%\t{5:0.0000}%\t{6:0.0000}%", info.IOSNewRetention1 * 100.0f / info.IOSNewUser, info.IOSNewRetention2 * 100.0f / info.IOSNewUser, info.IOSNewRetention3 * 100.0f / info.IOSNewUser, info.IOSNewRetention5 * 100.0f / info.IOSNewUser, info.IOSNewRetention7 * 100.0f / info.IOSNewUser, info.IOSNewRetention15 * 100.0f / info.IOSNewUser, info.IOSNewRetention30 * 100.0f / info.IOSNewUser); } else { strIOSNewUser = "0.00%\t0.00%\t0.00%\t0.00%\t0.00%\t0.00%\t0.00%"; } if (info.IOSActiveUser != 0) { strIOSActiveUser = string.Format("{0:0.0000}%\t{1:0.0000}%\t{2:0.0000}%\t{3:0.0000}%\t{4:0.0000}%\t{5:0.0000}%\t{6:0.0000}%\t", info.IOSActiveRetention1 * 100.0f / info.IOSActiveUser, info.IOSActiveRetention2 * 100.0f / info.IOSActiveUser, info.IOSActiveRetention3 * 100.0f / info.IOSActiveUser, info.IOSActiveRetention5 * 100.0f / info.IOSActiveUser, info.IOSActiveRetention7 * 100.0f / info.IOSActiveUser, info.IOSActiveRetention15 * 100.0f / info.IOSActiveUser, info.IOSActiveRetention30 * 100.0f / info.IOSActiveUser); } else { strIOSActiveUser = "0.00%\t0.00%\t0.00%\t0.00%\t0.00%\t0.00%\t0.00%"; } } strMessage = string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}", strDay, maxOnline, avgOnline, strNewUser, strActiveUser, strPayUser, strIOSNewUser, strIOSActiveUser); fileWriter.WriteLine(strMessage); } fileWriter.Dispose(); fsFile.Dispose(); } public static void LogRetentionInfoChannel() { FileStream fsFile = new FileStream("./bill_out_channel_info.txt", FileMode.Create); StreamWriter fileWriter = new StreamWriter(fsFile, Encoding.UTF8); string strMessage = "日期"; foreach(var channel in BillAlldays.Instance.m_adjustAllChannel.Keys) { strMessage += "\t" + channel + "\t新进次留\t2留\t3留\t5留\t7留\t15留\t30留\t安装\t新进登录\t活跃付费"; } fileWriter.WriteLine(strMessage); foreach (KeyValuePair pair in BillAlldays.Instance.m_billAllDays) { DateTime dateTime = pair.Key; BillInfoEveryDay info = pair.Value; string strDay = string.Format("{0}/{1}/{2}", dateTime.Year, dateTime.Month, dateTime.Day); strMessage = strDay; foreach (var channel in BillAlldays.Instance.m_adjustAllChannel.Keys) { string strChannelKeep = "0.00%\t0.00%\t0.00%\t0.00%\t0.00%\t0.00%\t0.00%\t0\t0\t0"; int newUserCount = 0; UserChannelInfo channelinfo = null; if (info.m_userChannelInfo.ContainsKey(channel)) { channelinfo = info.m_userChannelInfo[channel]; newUserCount = channelinfo.NewUserCount; } if (newUserCount != 0 && channelinfo != null) { strChannelKeep = string.Format("{0:0.0000}%\t{1:0.0000}%\t{2:0.0000}%\t{3:0.0000}%\t{4:0.0000}%\t{5:0.0000}%\t{6:0.0000}%\t{7}\t{8}\t{9:0.0}", channelinfo.Retention1 * 100.0f / newUserCount, channelinfo.Retention2 * 100.0f / newUserCount, channelinfo.Retention3 * 100.0f / newUserCount, channelinfo.Retention5 * 100.0f / newUserCount, channelinfo.Retention7 * 100.0f / newUserCount, channelinfo.Retention15 * 100.0f / newUserCount, channelinfo.Retention30 * 100.0f / newUserCount, channelinfo.InstallCount, channelinfo.NewUserCount, channelinfo.PayMoneyUSD); } strMessage += "\t" + channel + "\t" + strChannelKeep; } fileWriter.WriteLine(strMessage); } fileWriter.Dispose(); fsFile.Dispose(); } } }