public async Task <DatabaseResponse> UpdateCommunityApprovalCount(UpdateCount updateCount) { try { SqlParameter[] parameters = { new SqlParameter("@ApproveCount", SqlDbType.Int), new SqlParameter("@RejectCount", SqlDbType.Int), new SqlParameter("@UserId", SqlDbType.Int) }; parameters[0].Value = updateCount.ApproveCount; parameters[1].Value = updateCount.RejectCount; parameters[2].Value = updateCount.UserId; _DataHelper = new DataAccessHelper("spu_CommunityApproveRejectCount", parameters, _configuration); DataTable dt = new DataTable(); int result = await _DataHelper.RunAsync(dt); return(new DatabaseResponse { ResponseCode = result, Results = null }); } catch (Exception ex) { Log.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); throw; } finally { _DataHelper.Dispose(); } }
protected override void AfterInit() { AverageTimer.Reset(); CreateCount.Reset(); ReadCount.Reset(); DeleteCount.Reset(); UpdateCount.Reset(); IncomePerSec.Reset(); AllProcessPerSec.Reset(); AsyncProcessPerSec.Reset(); SyncProcessPerSec.Reset(); CustomOperationCount.Reset(); }
public async Task <IActionResult> UpdateCommunityApprovalCount([FromBody] UpdateCount updateCount) { try { AppDataDataAccess _appDataAccess = new AppDataDataAccess(_iconfiguration); DatabaseResponse response = await _appDataAccess.UpdateCommunityApprovalCount(updateCount); if (response.ResponseCode == (int)DbReturnValue.UpdateSuccess) { return(Ok(new OperationResponse { HasSucceeded = true, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.UpdateSuccess), ReturnedObject = response.Results })); } else { Log.Error(EnumExtensions.GetDescription(DbReturnValue.UpdationFailed)); return(Ok(new OperationResponse { HasSucceeded = false, IsDomainValidationErrors = false, Message = EnumExtensions.GetDescription(DbReturnValue.NotExists), ReturnedObject = response.Results })); } } catch (Exception ex) { Log.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); return(Ok(new OperationResponse { HasSucceeded = false, Message = StatusMessages.ServerError, StatusCode = ((int)ResponseStatus.ServerError).ToString(), IsDomainValidationErrors = false })); } }
public override int GetHashCode() { int hash = 1; if (UpdateCount != 0L) { hash ^= UpdateCount.GetHashCode(); } if (stateCase_ == StateOneofCase.Ikea) { hash ^= Ikea.GetHashCode(); } if (stateCase_ == StateOneofCase.Sandwich) { hash ^= Sandwich.GetHashCode(); } hash ^= (int)stateCase_; return(hash); }
public override int GetHashCode() { int hash = 1; if (Instrument.Length != 0) { hash ^= Instrument.GetHashCode(); } if (Spread != 0D) { hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Spread); } if (SourceTimeStamp != 0L) { hash ^= SourceTimeStamp.GetHashCode(); } if (SourceMessageCount != 0L) { hash ^= SourceMessageCount.GetHashCode(); } if (UpdateCount != 0L) { hash ^= UpdateCount.GetHashCode(); } hash ^= bid_.GetHashCode(); hash ^= ask_.GetHashCode(); if (Source.Length != 0) { hash ^= Source.GetHashCode(); } if (UniqueName.Length != 0) { hash ^= UniqueName.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public void SetUpdatePerSecond(UpdateCount ucount) { updatePerSeccond = ucount; }
public bool IsInteresting(EntitiesConfiguration configuration = null) { if (configuration == null) { return(true); } if (!configuration.Enabled) { return(false); } if (!configuration.IgnoreNulls) { return(true); } var monitoredStatistics = configuration.MonitoredStatistics; var filterStats = (monitoredStatistics?.Count).GetValueOrDefault(0) > 0; if ((filterStats && !monitoredStatistics.Contains("LoadCount")) || (configuration.IgnoreNulls && LoadCount.GetValueOrDefault(0) == 0)) { LoadCount = null; } if ((filterStats && !monitoredStatistics.Contains("UpdateCount")) || (configuration.IgnoreNulls && UpdateCount.GetValueOrDefault(0) == 0)) { UpdateCount = null; } if ((filterStats && !monitoredStatistics.Contains("DeleteCount")) || (configuration.IgnoreNulls && DeleteCount.GetValueOrDefault(0) == 0)) { DeleteCount = null; } if ((filterStats && !monitoredStatistics.Contains("FetchCount")) || (configuration.IgnoreNulls && FetchCount.GetValueOrDefault(0) == 0)) { FetchCount = null; } if ((EntityType != "Entity") || (filterStats && !monitoredStatistics.Contains("InsertCount")) || (configuration.IgnoreNulls && InsertCount.GetValueOrDefault(0) == 0)) { InsertCount = null; } if ((EntityType != "Entity") || (filterStats && !monitoredStatistics.Contains("OptimisticFailureCount")) || (configuration.IgnoreNulls && OptimisticFailureCount.GetValueOrDefault(0) == 0)) { OptimisticFailureCount = null; } if ((EntityType != "Collection") || (filterStats && !monitoredStatistics.Contains("RecreateCount")) || (configuration.IgnoreNulls && RecreateCount.GetValueOrDefault(0) == 0)) { RecreateCount = null; } var isInteresting = ( ( LoadCount.HasValue || UpdateCount.HasValue || InsertCount.HasValue || DeleteCount.HasValue || FetchCount.HasValue || OptimisticFailureCount.HasValue || RecreateCount.HasValue ) ); if (!isInteresting) { EntityName = null; EntityType = null; } return(isInteresting); }//end IsInteresting()
/// <summary> /// 更新统计表的抽象共用函数 /// </summary> /// <typeparam name="TRecordType">单条记录类型</typeparam> /// <typeparam name="TCountType">统计数据类型</typeparam> /// <param name="timeRanges">时间列表</param> /// <param name="timeID">时间id</param> /// <param name="groupBy">统计的公式的group by参数</param> /// <param name="idName">要统计的id的名称</param> /// <param name="idName2">要统计的id的别名</param> /// <param name="makeFormulaCmd">创建该公式的临时表的where语句参数</param> /// <param name="updateCount">更新统计信息</param> /// <param name="makeFindSameCmd">查找是否已有相同条件的统计信息的where语句参数</param> private void UpdateTable <TRecordType, TCountType> (IEnumerable <TimeRange> timeRanges, int timeID, string groupBy, string idName, MakeFormulaCmd <TCountType> makeFormulaCmd, UpdateCount <TCountType> updateCount, MakeFormulaCmd <TCountType> makeFindSameCmd, string idName2 = null) where TRecordType : RecordBase, new() where TCountType : RecordBase, new() { Log?.Information("Start Update {0} with time ID = {1} in thread pid = {2}.", typeof(TCountType).Name, timeID, Thread.CurrentThread.ManagedThreadId); var watch = new Stopwatch(); watch.Start(); try { var recordTable = _db.GetMapping <TRecordType>(); var countTable = _db.GetMapping <TCountType>(); string cmd; string tmpTableName; string formulaTmpTable; lock (_updateCallCountLock) { ++_updateCallCount; tmpTableName = "Temp" + typeof(TRecordType).Name + "_" + _updateCallCount; formulaTmpTable = "Temp" + typeof(TRecordType).Name + "Formula" + "_" + _updateCallCount; } cmd = $"DROP TABLE IF EXISTS '{tmpTableName}';"; _db.Execute(cmd); cmd = $"CREATE TEMP TABLE '{tmpTableName}' " + $"AS SELECT * FROM {recordTable.TableName} " + $"WHERE {TimeRange.TimeRangeList2SQL(timeRanges, TimeStr)} " + $"AND ({groupBy}) in (select {groupBy} FROM " + $"{recordTable.TableName} GROUP BY {groupBy} " + $"HAVING count(*) >= {FilterCount});"; _db.Execute(cmd); // 创建时间段临时表,同时过滤数量 // 获取不重复的公式 cmd = $"SELECT *,count(*) AS total FROM '{tmpTableName}' " + $"GROUP BY {groupBy}"; var formulaList = _db.Query <TCountType>(cmd); // 创建临时表 _db.Execute($"CREATE TEMP TABLE '{formulaTmpTable}' " + $"AS SELECT * FROM {tmpTableName} LIMIT 1;"); _db.Execute($"DELETE FROM '{formulaTmpTable}';"); var updateList = new List <TCountType>(); var insertList = new List <TCountType>(); var timestamp = GetUTC(); foreach (var it in formulaList) { //创建该公式的临时表 cmd = $"INSERT INTO '{formulaTmpTable}' " + $"SELECT * FROM '{tmpTableName}' WHERE " + makeFormulaCmd(it) + ";"; _db.Execute(cmd); it.timestamp = timestamp; // 选取要查找的id(gun/equip等) cmd = $"SELECT DISTINCT {idName} FROM '{formulaTmpTable}'"; var idList = _db.QueryScalars <int>(cmd); foreach (var id in idList) { cmd = $"SELECT count(*) FROM {formulaTmpTable} " + $"WHERE {idName} == {id}"; if (idName2 != null) { cmd += $" AND {idName2} == {id};"; } else { cmd += ";"; } var total = _db.QueryScalars <int>(cmd); updateCount(it, total[0], id, timeID); // 查询之前是否已经有相同公式的记录 cmd = $"SELECT * FROM '{countTable.TableName}' WHERE " + makeFindSameCmd(it) + ";"; var list = _db.Query <TCountType>(cmd); it.id = list.Count > 0 ? list[0].id : 0; updateList.Add(Clone(it)); if (list.Count > 0) { it.id = list[0].id; updateList.Add(Clone(it)); } else { it.id = 0; insertList.Add(Clone(it)); } } _db.Execute($"DELETE FROM '{formulaTmpTable}';"); } //统一更新 using (_db.Lock()) { _db.BeginTransaction(); foreach (var obj in updateList) { _db.InsertOrReplace(obj); } foreach (var obj in insertList) { _db.Insert(obj); } _db.Execute($"DROP TABLE '{formulaTmpTable}';"); _db.Execute($"DROP TABLE '{tmpTableName}';"); _db.Commit(); } } catch (SQLiteException e) { Log?.Warning(e, "Error during Update {0} with time ID = {1} in thread pid = {2}, result = {3}.", typeof(TCountType).Name, timeID, Thread.CurrentThread.ManagedThreadId, ((SQLiteException)e).Result); } catch (Exception e) { Log?.Warning(e, "Error during Update {0} with time ID = {1} in thread pid = {2}.", typeof(TCountType).Name, timeID, Thread.CurrentThread.ManagedThreadId); } watch.Stop(); Log?.Information("Finish Update {0} with time ID = {1} in thread pid = {2} in {3}s .", typeof(TCountType).Name, timeID, Thread.CurrentThread.ManagedThreadId, watch.Elapsed.TotalSeconds); }