lcy
2 天以前 2dd1841d03a730d3d369092c2a3ad656cee4bf64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using LitJson;
 
 
public class OperationLogCollect : Singleton<OperationLogCollect>
{
 
    const string url = "http://xssgcenter.secondworld.net.cn:11000/center/eventreport.php?";
 
    //6001 启动游戏
    //6002 请求版本信息
    //6003 准备下载
    //6004 开始下载
    //6005 加载代码
    //6006 启动代码
    //6007 进入游戏
    //6008 拷贝表格
    //6009 请求权限
    //6010 初始化设置
    //6011 sdk初始化
    //6012 游戏版本信息
    //6013 检测资源
    //6014 下载资源
    //6015 加载资源
    //6016 加载表格
    //6017 加载shader
    //6018 显示登录界面
 
    //6101 SDK初始化成功
    //6102 SDK初始化失败
    //6103 SDK账号登录成功
    //6104 SDK账号登录失败
    public void RecordLauchEvent(int _step)
    {
#if !UNITY_EDITOR
        //默认发送即使表没有初始化
        if (SDKUtils.Instance.AssetCopyFinished)
        {
            var config = InitialFunctionConfig.Get("Event");
            if (config != null && config.Numerical1 != "1")
            {
                return;
            }
        }
        var tables = new Dictionary<string, string>();
        tables["OperatorID"] = VersionConfig.Get().appId;
        tables["RegionName"] = "data";
        tables["EventID"] = (6000 + _step).ToString();
        tables["ProductID"] = VersionConfig.Get().gameId;
        tables["Device"] = DeviceUtility.GetDeviceModel();
        tables["os_version"] = DeviceUtility.GetDeviceOSLevel();
        tables["game_version"] = StringUtility.Concat(VersionConfig.Get().version, "_", VersionConfig.Get().buildIndex.ToString());
        tables["IMEI"] = DeviceUtility.GetDeviceUniquenessIdentify();
        tables["Time"] = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
 
        HttpRequest.Instance.RequestHttpGet(StringUtility.Concat(url, HttpRequest.HashtablaToString(tables)), HttpRequest.defaultHttpContentType);
#endif
    }
 
 
 
    const string bugReportUrl = "http://xssgcenter.secondworld.net.cn:11000/center/eventreport.php?";
 
    public void BugReport(string _title, string _content)
    {
        var tables = new Dictionary<string, string>();
        tables["OperatorID"] = VersionConfig.Get().appId;
        tables["RegionName"] = "data";
        tables["RegionID"] = ServerListCenter.Instance.currentServer.region_flag.ToString();
        tables["EventID"] = 9002.ToString();
        tables["ProductID"] = VersionConfig.Get().gameId;
        tables["Time"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        tables["IP"] = DeviceUtility.GetIp();
        tables["AccountID"] = LoginManager.Instance.sdkLoginResult.account;
        tables["Level"] = PlayerDatas.Instance.baseData.LV.ToString();
        tables["RoleID"] = PlayerDatas.Instance.baseData.PlayerName;
        tables["VIPLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString();
        tables["DeviceFlag"] = SDKUtils.Instance.Device.uniqueID;
 
        var contentPrefix = StringUtility.Concat("IMEI:", DeviceUtility.GetDeviceUniquenessIdentify(), ";");
        contentPrefix = StringUtility.Concat(contentPrefix, "Version:", StringUtility.Concat(VersionConfig.Get().version, "_", 
            VersionConfig.Get().buildIndex.ToString(), "-", LoginManager.Instance.hotVersion), Language.Id, ";");
        contentPrefix = StringUtility.Concat(contentPrefix, "Brand:", DeviceUtility.GetDeviceName(), ";");
        contentPrefix = StringUtility.Concat(contentPrefix, "MI5:", DeviceUtility.GetDeviceModel(), ";");
        contentPrefix = StringUtility.Concat(contentPrefix, "os_version:", DeviceUtility.GetDeviceOSLevel(), ";");
 
        tables["Title"] = _title;
        tables["Content"] = _content;
        tables["ClientInfo"] = contentPrefix;
 
        HttpRequest.Instance.RequestHttpGet(StringUtility.Concat(bugReportUrl, HttpRequest.HashtablaToString(tables)), HttpRequest.defaultHttpContentType);
 
    }
 
    //10000 战场报错, 10001 封包错误, 10002 界面操作
    public void BugReportSys(string _content, string sid = "10000")
    {
#if !UNITY_EDITOR
        try
        {
            var tables = new Dictionary<string, string>();
            tables["OperatorID"] = VersionConfig.Get().appId;
            tables["RegionName"] = "data";
            tables["RegionID"] = sid;
            tables["EventID"] = 9002.ToString();
            tables["ProductID"] = VersionConfig.Get().gameId;
            tables["Time"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            tables["IP"] = DeviceUtility.GetIp();
            tables["AccountID"] = "system";
            tables["Level"] = "1";
            tables["RoleID"] = "system";
            tables["VIPLevel"] = "1";
            tables["DeviceFlag"] = SDKUtils.Instance.Device.uniqueID;
 
            var contentPrefix = StringUtility.Concat("IMEI:", DeviceUtility.GetDeviceUniquenessIdentify(), ";");
            contentPrefix = StringUtility.Concat(contentPrefix, "Version:", StringUtility.Concat(VersionConfig.Get().version, "_",
                VersionConfig.Get().buildIndex.ToString(), "-", LoginManager.Instance.hotVersion), Language.Id, ";");
            contentPrefix = StringUtility.Concat(contentPrefix, "Brand:", DeviceUtility.GetDeviceName(), ";");
            contentPrefix = StringUtility.Concat(contentPrefix, "MI5:", DeviceUtility.GetDeviceModel(), ";");
            contentPrefix = StringUtility.Concat(contentPrefix, "os_version:", DeviceUtility.GetDeviceOSLevel(), ";");
 
            tables["Title"] = "system";
            _content = _content.Replace("0000", "");
            if (ConfigManager.Instance.isLoadFinished && DTC0102_tagCDBPlayer.playerIdBuf != 0 && LoginManager.Instance.sdkLoginResult != null && !string.IsNullOrEmpty(LoginManager.Instance.sdkLoginResult.account))
            {
                _content = StringUtility.Concat(LoginManager.Instance.sdkLoginResult.account, "@", ServerListCenter.Instance.currentServer.region_flag.ToString(), " ", _content);
            }
            
            tables["Content"] = _content.Substring(0, Math.Min(800, _content.Length));
            tables["ClientInfo"] = contentPrefix;
 
            HttpRequest.Instance.RequestHttpGet(StringUtility.Concat(bugReportUrl, HttpRequest.HashtablaToString(tables)), HttpRequest.defaultHttpContentType);
        }
        catch (System.Exception ex)
        {
            Debug.LogError("BugReportSys error" + ex);
        }
#endif
    }
 
 
    const string chatReportUrl = "http://xssgcenter.secondworld.net.cn:11000/center/eventreport.php?";
    public void ChatReport(string content, string channelName, string toPlayer, int chatType)
    {
#if !UNITY_EDITOR
        bool isFairy = chatType == 3;
        var tables = new Dictionary<string, string>();
        tables["ProductID"] = VersionConfig.Get().gameId;
        tables["OperatorID"] = VersionConfig.Get().appId;
        tables["OperatorName"] = string.Empty;
        tables["ChannelType"] = chatType.ToString();
        tables["RegionName"] = StringUtility.Concat("s", ServerListCenter.Instance.currentServer.region_flag.ToString());
        tables["RegionID"] = ServerListCenter.Instance.currentServer.region_flag.ToString();
        tables["EventID"] = 9003.ToString();
        tables["Time"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        tables["IP"] = DeviceUtility.GetIp();
        tables["ChatChannel"] = channelName;
        var sdkLoginResult = LoginManager.Instance.sdkLoginResult;
        tables["AccountID"] = sdkLoginResult == null ? LoginManager.Instance.accountBuf : sdkLoginResult.account;
        tables["RoleID"] = StringUtility.Concat(isFairy ? UIHelper.ServerStringTrim(PlayerDatas.Instance.baseData.FamilyName) : string.Empty,
           isFairy ? "-" : string.Empty, UIHelper.ServerStringTrim(PlayerDatas.Instance.baseData.PlayerName));
        tables["ToRoleID"] = UIHelper.ServerStringTrim(toPlayer);
        tables["PlayerID"] = PlayerDatas.Instance.baseData.PlayerID.ToString();
        tables["Level"] = PlayerDatas.Instance.baseData.LV.ToString();
        tables["VIPLevel"] = PlayerDatas.Instance.baseData.VIPLv.ToString();
        tables["Content"] = UrlEncode(UIHelper.TrimContentToServer(content));
        tables["DeviceFlag"] = SDKUtils.Instance.Device == null ? string.Empty : SDKUtils.Instance.Device.uniqueID;
        var chatStr = StringUtility.Concat(chatReportUrl, HttpRequest.HashtablaToString(tables));
        HttpRequest.Instance.RequestHttpGet(chatStr, HttpRequest.defaultHttpContentType);
#endif
    }
 
 
    /// <summary>
    /// 自定义 URL 编码函数(防止 AOT 裁剪)
    /// </summary>
    public string UrlEncode(string value)
    {
        if (string.IsNullOrEmpty(value))
            return string.Empty;
        
        System.Text.StringBuilder result = new System.Text.StringBuilder();
        
        foreach (char c in value)
        {
            // 不需要编码的字符
            if ((c >= 'a' && c <= 'z') || 
                (c >= 'A' && c <= 'Z') || 
                (c >= '0' && c <= '9') ||
                c == '-' || c == '_' || c == '.' || c == '~')
            {
                result.Append(c);
            }
            else if (c == ' ')
            {
                // 空格替换为 +
                result.Append('+');
            }
            else
            {
                // 其他字符编码为 %XX 格式
                byte[] bytes = System.Text.Encoding.UTF8.GetBytes(c.ToString());
                foreach (byte b in bytes)
                {
                    result.Append('%');
                    result.Append(b.ToString("X2"));
                }
            }
        }
        
        return result.ToString();
    }
 
}