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 class NameMgr:Singleton { public Dictionary ownUidName = new Dictionary(); public void RegisterNameToUid(int uid, string name) { if(!ownUidName.ContainsKey(uid)) { ownUidName.Add(uid, name); } } public void RegisterAllUidName() { RegisterNameToUid(277578, "张卓"); RegisterNameToUid(130307, "邹伟"); RegisterNameToUid(10002, "邹伟"); RegisterNameToUid(10044, "邹伟"); RegisterNameToUid(10068, "阎哲"); RegisterNameToUid(38532, "赖灿渭"); RegisterNameToUid(99362, "陈超"); RegisterNameToUid(77687, "陈维"); RegisterNameToUid(10028, "袁靖"); RegisterNameToUid(10062, "龚正凯"); RegisterNameToUid(10014, "齐建新"); RegisterNameToUid(10012, "吕亮亮"); RegisterNameToUid(10032, "吕亮亮"); RegisterNameToUid(92098, "周少青"); RegisterNameToUid(10034, "周少青"); RegisterNameToUid(10054, "吴文杰"); RegisterNameToUid(10004, "吴文杰"); RegisterNameToUid(154488, "吴文杰"); RegisterNameToUid(10064, "邓师阁"); RegisterNameToUid(280330, "范校伟"); RegisterNameToUid(205520, "祁玉丽"); RegisterNameToUid(10026, "李文强"); RegisterNameToUid(10018, "尹甫"); RegisterNameToUid(10048, "尹甫"); RegisterOurOwn(); } public void RegisterOurOwn() { var ownUidName = NameMgr.Instance.ownUidName; var m_ownNameCount = BillAlldays.Instance.m_ownNameCount; foreach (var dev in ownUidName) { if (!m_ownNameCount.ContainsKey(dev.Value)) { m_ownNameCount.Add(dev.Value, 0); } } } } public static partial class LogWrapper { public static int allUserGameCount(int uid) { return compareUid(uid); } public static int compareUid(int uid) { var ownUidName = NameMgr.Instance.ownUidName; var m_ownNameCount = BillAlldays.Instance.m_ownNameCount; if (ownUidName.ContainsKey(uid)) { return m_ownNameCount[ownUidName[uid]]++; } else { return 0; } } //public static void OurOwnGameCount() //{ // FileStream fsFile = new FileStream("./bill_out_ourOwnGameCount.txt", FileMode.Create); // StreamWriter fileWriter = new StreamWriter(fsFile, Encoding.UTF8); // string strMessage = "Data\tuid\t玩牌局数"; // fileWriter.WriteLine(strMessage); // int[] ourOwnUid = { 277578, 130307, 10002, 10044, 10068, 38532, 99362, 77687, 10028, 10062, 10014, 10012, 10032, 92098, 10034, 10054, 10004, 154488, 10064, 280330, 205520, 10026, 10018, 10048 }; // int ourOwnUidLength = ourOwnUid.Length; // foreach (KeyValuePair pair in BillAlldays.Instance.m_billAllDays) // { // DateTime dateTime = pair.Key; // BillInfoEveryDay info = pair.Value; // strMessage = string.Format("{0}/{1}/{2}" // , dateTime.Year, dateTime.Month, dateTime.Day); // for (int i = 0; i <= ourOwnUidLength - 1; i++) // { // strMessage += "\t" + ourOwnUid[i].ToString() + "\t" + info.OwnCount(ourOwnUid[i]).ToString() + "\r\n"; // } // fileWriter.WriteLine(strMessage); // } // fileWriter.Dispose(); // fsFile.Dispose(); //} public static void OurOwnAllGameCount() { FileStream fsFile = new FileStream("./bill_out_ourOwnAllGameCount.txt", FileMode.Create); StreamWriter fileWriter = new StreamWriter(fsFile, Encoding.UTF8); string strMessage = "Data\t姓名\t当月总玩牌局数"; fileWriter.WriteLine(strMessage); var m_ownNameCount = BillAlldays.Instance.m_ownNameCount; foreach (var devv in m_ownNameCount) { //j++; string name = devv.Key; int count = devv.Value; strMessage = DateTime.Now.ToString("y") + "\t" + name + "\t" + count + "\n"; fileWriter.WriteLine(strMessage); } fileWriter.Dispose(); fsFile.Dispose(); } } }