public void query(string guid, out SQLiteLogData data) { string condition = ""; appendConditionString(ref condition, SQLiteLogData.COL_GUID, guid, ""); parseReader(doQuery(condition), out data); }
public void insert(SQLiteLogData data) { string valueString = ""; appendValueString(ref valueString, data.mUserID); appendValueString(ref valueString, data.mLogType); appendValueString(ref valueString, data.mTime); appendValueString(ref valueString, data.mLogInfo); appendValueString(ref valueString, data.mGUID); appendValueInt(ref valueString, data.mUploaded, true); doInsert(valueString); }
protected void sendLog(ref bool run) { // 将日志缓存同步到发送列表中 mSendLock.waitForUnlock(); mBufferLock.waitForUnlock(); if (mLogBufferList.Count > 0) { for (int i = 0; i < mLogBufferList.Count; ++i) { LogData data = mLogBufferList[i]; mLogSendList.Add(data.mGuid.ToString(), data); } mLogBufferList.Clear(); } mBufferLock.unlock(); // 复制一份列表,然后解锁列表,避免其他线程阻塞 Dictionary <string, LogData> tempList = new Dictionary <string, LogData>(mLogSendList); mSendLock.unlock(); foreach (var item in tempList) { // 找到未上传的数据 if (item.Value.mState == LOG_STATE.LS_UNUPLOAD) { LogData data = item.Value; // 设置为正在上传状态 data.mState = LOG_STATE.LS_UPLOADING; if (data.mType.ToString().Length >= 64 || data.mTime.ToString("G").Length >= 32 || data.mInfo.Length >= 256 || data.mGuid.ToString().Length >= 64) { continue; } mSqlLiteLock.waitForUnlock(); SQLiteLogData logData = new SQLiteLogData(); logData.mUserID = mUserID; logData.mLogType = data.mType.ToString(); logData.mTime = data.mTime.ToString("G"); logData.mLogInfo = data.mInfo; logData.mGUID = data.mGuid.ToString(); logData.mUploaded = 0; mSQLiteLog.insert(logData); mSqlLiteLock.unlock(); // 将日志上传服务器,并且记录到本地数据库 string uploadData = ""; prepareData(data, ref uploadData); //HttpUtility.httpWebRequestPost(GameDefine.GAME_LOG_URL, GameDefine.HTTP_URL_GAMEDATA + uploadData, onDataUploadResult, data.mGuid.ToString(), false); } } }