Example #1
0
        public static void Save()
        {
            if (!TxtRecord)
                return;
            //DateTime dt = DateTime.Now;
            int interval = SaveRecordSecond;
            //dt = dt.AddMinutes(5);
            dt = dt.AddSeconds(interval);

            //int totalM = 0  ; //注册人数(男)
            //int totalF = 0; //注册人数(女)
            //int onlineM = 0; //在线人数(男)
            //int onlineF = 0; //在线人数(女)
            //int paymenM = 0; //付费用户(男)
            //int paymenF = 0; //付费用户(女)
            //int activePaymenM = 0; //活跃付费用户(男)
            //int activePaymenF = 0; //活跃付费用户(女)
            //int activeCustomerM = 0; //活跃消费用户(男)
            //int activeCustomerF = 0; //活跃消费用户(女)

            //            新的User日志格式

            //#格式:【用户记录】游戏类型,分区,服务器ID,[时间],注册人数(男),注册人数(女),在线人数(男),在线人数(女),登陆用户数(男), 登陆用户数(女),活跃充值用户(男),活跃充值用户(女),活跃消费用户(男),活跃消费用户(女),活跃在线用户(男)、活跃在线用户(女)

            using (ServiceBussiness db = new ServiceBussiness())
            {
                try
                {
                    RecordInfo info = db.GetRecordInfo(dt, SaveRecordSecond);
                    int online = LoginMgr.GetOnlineCount();

                    //writer.WriteLine(string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}", dt, totalM, totalF, onlineM, onlineF, paymenM, paymenF, activePaymenM, activePaymenF, activeCustomerM, activeCustomerF));
                    if (info == null)
                    {
                        info = new RecordInfo();
                    }
                    _saveLogCache.Add(string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13}", _headStr, dt, info.TotalBoy, info.TotalGirl, online, 0,
                        info.ExpendBoy, info.ExpendGirl, info.ActviePayBoy, info.ActviePayGirl, info.ActiveExpendBoy, info.ActiveExpendGirl, info.ActiveOnlineBoy, info.ActiveOnlineGirl));

                    string file = string.Format("{0}\\user-{1:D2}{2:D2}{3:D2}-{4:yyyyMMdd}.log", _logPath, _gameType, _areaId, _serverId, dt);
                    using (FileStream fs = File.Open(file, FileMode.Append))
                    {
                        using (StreamWriter writer = new StreamWriter(fs))
                        {
                            while (_saveLogCache.Count != 0)
                            {
                                writer.WriteLine(_saveLogCache[0]);
                                _saveLogCache.RemoveAt(0);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (log.IsErrorEnabled)
                        log.Error("Save log error", ex);
                }

                try
                {
                    //1,1,2,2009-1-10 0:02:06,0,
                    //游戏类型、代理商、频道、日期、在线用户、注册用户
                    Dictionary<int, int> lines = LoginMgr.GetOnlineForLine();

                    int online = LoginMgr.GetOnlineCount();
                    _onlineLogCache.Add(string.Format("{0},{1},{2},{3},{4},{5}", _gameType, _areaId, 0, dt, online, RegCount));
                    RegCount = 0;

                    string file = string.Format("{0}\\online-{1:D2}{2:D2}{3:D2}-{4:yyyyMMdd}.log", _logPath, _gameType, _areaId, _serverId, dt);
                    using (FileStream fs = File.Open(file, FileMode.Append))
                    {
                        using (StreamWriter writer = new StreamWriter(fs))
                        {
                            while (_onlineLogCache.Count != 0)
                            {
                                writer.WriteLine(_onlineLogCache[0]);
                                _onlineLogCache.RemoveAt(0);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (log.IsErrorEnabled)
                        log.Error("OnlineForLine log error", ex);
                }

            }
            //#格式:【用户记录】游戏类型,分区,时间,付费方式(ebank、SMS、Post),男人数,女人数,男付费金额,女付费金额
            //using (PlayerBussiness db = new PlayerBussiness())
            //{
            //    ChargeRecordInfo[] infos = db.GetChargeRecordInfo(dt, SaveRecordSecond);
            //    string file = string.Format("{0}\\pay-{1:D2}{2:D2}{3:D2}-{4:yyyyMMdd}.log", _logPath, _gameType, _areaId, _serverId, dt);
            //    using (FileStream fs = File.Open(file, FileMode.Append))
            //    {
            //        using (StreamWriter writer = new StreamWriter(fs))
            //        {
            //            foreach (ChargeRecordInfo info in infos)
            //            {
            //                writer.WriteLine(string.Format("{0},{1},{2},{3},{4},{5},{6}",
            //                    _headStr, dt, info.PayWay, info.TotalBoy, info.TotalGirl, info.BoyTotalPay, info.GirlTotalPay));
            //            }
            //        }
            //    }
            //}
        }
Example #2
0
        public RecordInfo GetRecordInfo(DateTime date, int SaveRecordSecond)
        {
            SqlDataReader reader = null;
            try
            {
                SqlParameter[] para = new SqlParameter[2];
                para[0] = new SqlParameter("@Date", date.ToString("yyyy-MM-dd HH:mm:ss"));
                para[1] = new SqlParameter("@Second", SaveRecordSecond);

                db.GetReader(ref reader, "SP_Server_Record",para);
                while (reader.Read())
                {
                    RecordInfo info = new RecordInfo();
                    info.ActiveExpendBoy = (int)reader["ActiveExpendBoy"];
                    info.ActiveExpendGirl = (int)reader["ActiveExpendGirl"];
                    info.ActviePayBoy = (int)reader["ActviePayBoy"];
                    info.ActviePayGirl = (int)reader["ActviePayGirl"];
                    info.ExpendBoy = (int)reader["ExpendBoy"];
                    info.ExpendGirl = (int)reader["ExpendGirl"];
                    info.OnlineBoy = (int)reader["OnlineBoy"];
                    info.OnlineGirl = (int)reader["OnlineGirl"];
                    info.TotalBoy = (int)reader["TotalBoy"];
                    info.TotalGirl = (int)reader["TotalGirl"];
                    info.ActiveOnlineBoy = (int)reader["ActiveOnlineBoy"];
                    info.ActiveOnlineGirl = (int)reader["ActiveOnlineGirl"];
                    return info;
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                    log.Error("Init", e);
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();
            }
            return null;
        }