コード例 #1
0
    public void SaveMonsterOrderToFile()
    {
        DateTime dateTime = DateTime.Now;
        var      dic      = canvas.GetComponent <UiController>().order;
        string   path     = Application.dataPath + "/Resources/" + "order_" + dateTime.Hour + "_" + dateTime.Minute + "_" + dateTime.Second + "_" + dateTime.Day + "_" + dateTime.Month + "_" + dateTime.Year + ".json";

        Debug.Log(path);
        FileStream stream = new FileStream(path, FileMode.Create);

        using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8))
        {
            writer.WriteLine(SimpleEmailSender.GetEmail());
            foreach (var item in dic)
            {
                foreach (var item1 in item.Value)
                {
                    writer.WriteLine(JsonUtility.ToJson(item1.Value));
                }
            }
        }
        string        secondPath = SaveLogs();
        List <string> paths      = new List <string>();

        paths.Add(path);
        paths.Add(secondPath);
        SimpleEmailSender.Send(paths, SendCompletedCallback);
        popUp.gameObject.SetActive(true);
        StartCoroutine(DisablePopUp());
    }
コード例 #2
0
    string SaveLogs()
    {
        DateTime   dateTime = DateTime.Now;
        var        logs     = canvas.GetComponent <UiController>().logs;
        string     path     = Application.dataPath + "/Resources/" + "log_" + dateTime.Hour + "_" + dateTime.Minute + "_" + dateTime.Second + "_" + dateTime.Day + "_" + dateTime.Month + "_" + dateTime.Year + ".json";
        FileStream stream   = new FileStream(path, FileMode.Create);

        using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8))
        {
            writer.WriteLine(SimpleEmailSender.GetEmail());
            foreach (var item in logs)
            {
                foreach (var item1 in item.Value.logs)
                {
                    writer.WriteLine(item1);
                }
                writer.WriteLine("Total time: " + item.Value.totalSeconds);
            }
        }
        return(path);
    }