public void SaveData(MsgUnit m) { string log = JsonUtility.ToJson(m); //Debug.LogError("savedata:"+log); WriteFile(log); }
public void SetData(Farm_Game_PaySucc_Anw p) { MsgUnit msg = new MsgUnit(); msg.type = 4; msg.id = Convert.ToInt32(p.Ordernum); System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 当地时区 DateTime dt = startTime.AddSeconds(Convert.ToInt32(p.Time)); msg.sendTime = dt.ToString("HH:mm"); string c = ""; if (p.Type == 1) { c += "登录支付成功\n"; } else if (p.Type == 2) { c += "兑换成功\n"; } c += ("订单号:" + p.Ordernum + "\n"); c += ("支付的邮费:" + p.Money + "\n"); c += ("时间:" + msg.sendTime + "\n"); c += ("物品信息:"); for (int i = 0; i < p.ObjsCount; i++) { BaseAtrribute ba = LoadObjctDateConfig.Instance.GetAtrribute(p.ObjsList[i].Id); c += (ba.Name + "x" + p.ObjsList[i].Count + "\n"); } msg.content = c; orders.Add(msg); //SaveData(msg); }
public void DeleteData(MsgUnit msg) { if (File.Exists(folderName + "/Order")) { File.Delete(folderName + "/Order"); } for (int i = 0; i < orders.Count; i++) { if (orders[i].id == msg.id) { orders.Remove(orders[i]); continue; } SaveData(orders[i]); } }
public void GetData() { //Debug.LogError("getdata"); List <string> LogList = ReadFile(); List <MsgUnit> _orders = new List <MsgUnit>(); for (int i = 0; i < LogList.Count; i++) { //Debug.LogError(LogList[i]); MsgUnit c = new MsgUnit(); c = JsonUtility.FromJson <MsgUnit>(LogList[i]); _orders.Add(c); } orders = _orders; if (orders.Count == 0) { SystemMsgView.SystemFunction(Function.Tip, "当前没有订单"); return; } CommitController.Instance.GetDispatcher().Dispatch(CommitController.CommitControllerEvent.OnOrderCallback); }
public void SetData(Farm_Game_LogisticsOrder p) { MsgUnit msg = new MsgUnit(); msg.type = 4; msg.id = Convert.ToInt32(p.Ordernum); // System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 当地时区 // DateTime dt = startTime.AddSeconds((double)Convert.ToInt32(p.Sendtime)); // msg.sendTime = dt.ToString("HH:mm"); msg.sendTime = p.Sendtime; string c = ""; // if (p.Type== 1) // { // c += "登录支付成功\n"; // // // } // else if (p.Type == 2) { c += ("快递单号:" + (p.LogisticsOrder == ""?"请等待发货": p.LogisticsOrder) + "\n"); } c += ("快递公司:" + p.Company + "\n"); c += ("订单号:" + p.Ordernum + "\n"); c += ("支付的邮费:" + p.Money + "\n"); c += ("时间:" + msg.sendTime + "\n"); c += ("物品信息:\n"); for (int i = 0; i < p.ObjsCount; i++) { BaseAtrribute ba = LoadObjctDateConfig.Instance.GetAtrribute(p.ObjsList[i].Id); c += ("[" + ba.Name + "x" + p.ObjsList[i].Count + "]" + "\n"); } msg.content = c; orders.Add(msg); //SaveData(msg); }
//消息消息输入 public static Dictionary <int, MsgUnit> SetAnwData(IList <PMsg_MessageUnit> list) { Dictionary <int, MsgUnit> MsgList = MessageModel.Instance.MsgList; bool isChange = false; //Debug.LogError(list.Count); for (int i = 0; i < list.Count; i++) { if (MsgList.ContainsKey(list[i].MsgID)) { continue; } if (list[i].FromUid == LoginModel.Instance.Uid) { MessageController.Instance.DelMsg(list[i].MsgID); continue; } isChange = true; MsgUnit unit = new MsgUnit(); unit.id = list[i].MsgID; unit.type = list[i].MsgType; unit.content = list[i].Content; unit.SendTime = list[i].SendTime; System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 当地时区 DateTime dt = startTime.AddSeconds(list[i].SendTime); //System.Debug.Log(dt.ToString("yyyy/MM/dd HH:mm:ss:ffff")); unit.sendTime = dt.ToString("HH:mm"); unit.PlayerUid = list[i].FromUid; unit.PlayerHead = list[i].FromHead; unit.PlayerName = list[i].FromName; int _id = -1; foreach (var msg in MsgList.Values) { if (msg.type == 2 && msg.PlayerUid == list[i].FromUid && msg.content != list[i].Content) { _id = msg.id; break; } } if (_id != -1) { ChatLog c = new ChatLog(); c.SendPlayer = 2; c.Content = MsgList[_id].content; c.sendTime = dt.ToString("yyyy/MM/dd HH:mm"); ChatLogManager.Instance.SaveData(MsgList[_id].PlayerUid, c); MessageController.Instance.DelMsg(MsgList[_id].id); MsgList.Remove(_id); } MsgList.Add(unit.id, unit); //bool isHas = false; //if (PlayerSave.HasKey(list[i].FromUid.ToString())) //{ // string s=PlayerSave.GetString(list[i].FromUid.ToString()); // string[] contents= s.Split(','); // for (int j = 0; j < contents.Length; j++) // { // //如果内容ID已经存在则跳出循环 // if (contents[j]== list[i].MsgID.ToString()) // { // isHas = true; // break; // } // } // //如果没有出现过则添加进去 // if (!isHas) // { // StringBuilder sb=new StringBuilder(s); // sb.Append("," + list[i].MsgID.ToString()); // PlayerSave.SetString(list[i].FromUid.ToString(),sb.ToString()); // // MsgList.Add(unit.id, unit); // } // //} //else //{ // PlayerSave.SetString(list[i].FromUid.ToString(), list[i].MsgID.ToString()); // // MsgList.Add(unit.id, unit); // //} } if (isChange) { MessageController.Instance.MsgCount = MsgList.Count; GlobalDispatcher.Instance.Dispatch(GlobalEvent.OnMsgChange, MsgList.Count); } //Debug.LogError(MsgList.Count); return(MsgList); }