using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using ServerCore; using ServerBase; using ServerCommon; using ServerCommon.BusinessLogDomain; using META_ID = System.UInt32; using META_TYPE = System.String; using USER_GUID = System.String; using System.Runtime.CompilerServices; using Microsoft.AspNetCore.Http; namespace GameServer { public static class LandAuctionBusinessLogHelper { public static void writeBusinessLogByLandAuctionResult( LandAuction landAuction, LandAuctionWinningResult? winningResult , QueryExecutorBase queryExecutorBase ) { var query_batch = queryExecutorBase.getQueryBatch(); NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!! - {landAuction.toBasicString()}"); query_batch.appendBusinessLog(new LandAuctionBusinessLog(query_batch.getLogAction(), landAuction.toLandAuctionLogInfo(winningResult))); } public static void writeBusinessLogByLandAuctionBid( LandAuction landAuction, LandAuctionBidResult bidResult , QueryExecutorBase queryExecutorBase) { var query_batch = queryExecutorBase.getQueryBatch(); NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!! - {landAuction.toBasicString()}"); query_batch.appendBusinessLog(new LandAuctionBusinessLog(query_batch.getLogAction(), landAuction.toLandAuctionLogInfo(null))); query_batch.appendBusinessLog(new LandAuctionBidBusinessLog(query_batch.getLogAction(), landAuction.toLandAuctionBidLogInfo(bidResult))); } public static void writeBusinessLogByLandAuctionBidPriceRefund( LandAuctionRefundBidPriceDoc refundBidPriceDoc, LandAuctionResult auctionResult , QueryExecutorBase queryExecutorBase ) { var query_batch = queryExecutorBase.getQueryBatch(); NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!! - {refundBidPriceDoc.toBasicString()}"); query_batch.appendBusinessLog(new LandAuctionBidPriceRefundBusinessLog(query_batch.getLogAction(), refundBidPriceDoc.toLandAuctionBidPriceRefundLogInfo(auctionResult))); } public static void writeBusinessLogByLandAuctionBidPriceRefund( LandAuctionRefundBidPrice refundBidPrice, LandAuctionResult auctionResult , QueryExecutorBase queryExecutorBase ) { var query_batch = queryExecutorBase.getQueryBatch(); NullReferenceCheckHelper.throwIfNull(query_batch, () => $"query_batch is null !!! - {refundBidPrice.toBasicString()}"); query_batch.appendBusinessLog(new LandAuctionBidPriceRefundBusinessLog(query_batch.getLogAction(), refundBidPrice.toLandAuctionBidPriceRefundLogInfo(auctionResult))); } public static void writeBusinessLogByLandAuctionActivity(LandAuctionActivityDoc activityDoc) { var activity_attrib = activityDoc.getAttrib(); NullReferenceCheckHelper.throwIfNull(activity_attrib, () => $"activity_attrib is null !!!"); var log_action = new LogActionEx(LogActionType.LandAuctionActivity); var log_info = new LandAuctionActivityLogInfo(); log_info.setLogProperty( activity_attrib.LandMetaId, activity_attrib.AuctionNumber , activityDoc.getPK(), activityDoc.getSK() , DateTimeHelper.Current); var error_code = BusinessLogger.collectLog( GameServerApp.getServerLogic() , new LandAuctionActivityBusinessLog(log_action, log_info) ); if(error_code.isFail()) { var err_msg = $"Failed to collectLog() !!! : {error_code.toBasicString()} - {log_info.getTypeName()}"; Log.getLogger().error(err_msg); } } public static LandAuctionBidPriceRefundLogInfo toLandAuctionBidPriceRefundLogInfo(this LandAuctionRefundBidPriceDoc refundBidPriceDoc, LandAuctionResult auctionResult) { var refund_bid_price_attrib = refundBidPriceDoc.getAttrib(); NullReferenceCheckHelper.throwIfNull(refund_bid_price_attrib, () => $"refund_bid_price_attrib is null !!! - {refundBidPriceDoc.toBasicString()}"); var log_info = new LandAuctionBidPriceRefundLogInfo(); log_info.setLogProperty( refund_bid_price_attrib.LandMetaId, refund_bid_price_attrib.AuctionNumber , refundBidPriceDoc.getPK(), refundBidPriceDoc.getSK() , refund_bid_price_attrib.BidUserGuid , refund_bid_price_attrib.LastBidType, refund_bid_price_attrib.BidCurrencyType, refund_bid_price_attrib.LastBidPrice , auctionResult , refund_bid_price_attrib.RefundableNormalBidPrice, refund_bid_price_attrib.RefundableBlindBidPrice); return log_info; } public static LandAuctionBidPriceRefundLogInfo toLandAuctionBidPriceRefundLogInfo(this LandAuctionRefundBidPrice refundBidPrice, LandAuctionResult auctionResult) { var refund_bid_price_attribute = refundBidPrice.getEntityAttribute(); NullReferenceCheckHelper.throwIfNull(refund_bid_price_attribute, () => $"refund_bid_price_attribute is null !!! - {refundBidPrice.toBasicString()}"); var origin_refund_bid_price_doc = refund_bid_price_attribute.getOriginDocBase() as LandAuctionRefundBidPriceDoc; NullReferenceCheckHelper.throwIfNull(origin_refund_bid_price_doc, () => $"origin_refund_bid_price_doc is null !!! - {refundBidPrice.toBasicString()}"); var log_info = new LandAuctionBidPriceRefundLogInfo(); log_info.setLogProperty( refund_bid_price_attribute.LandMetaId, refund_bid_price_attribute.AuctionNumber , origin_refund_bid_price_doc.getPK(), origin_refund_bid_price_doc.getSK() , refund_bid_price_attribute.BidUserGuid , refund_bid_price_attribute.LastBidType, refund_bid_price_attribute.BidCurrencyType, refund_bid_price_attribute.LastBidPrice , auctionResult , refund_bid_price_attribute.RefundableNormalBidPrice, refund_bid_price_attribute.RefundableBlindBidPrice ); return log_info; } public static LandAuctionBidLogInfo toLandAuctionBidLogInfo(this LandAuction landAuction, LandAuctionBidResult bidResult) { var highest_bid_user_attribute = landAuction.getEntityAttribute(); NullReferenceCheckHelper.throwIfNull(highest_bid_user_attribute, () => $"highest_bid_user_attribute is null !!! - {landAuction.toBasicString()}"); var origin_highest_bid_user_doc = highest_bid_user_attribute.getOriginDocBase() as LandAuctionHighestBidUserDoc; NullReferenceCheckHelper.throwIfNull(origin_highest_bid_user_doc, () => $"origin_highest_bid_user_doc is null !!! - {landAuction.toBasicString()}"); var log_info = new LandAuctionBidLogInfo(); log_info.setLogProperty( highest_bid_user_attribute.LandMetaId, highest_bid_user_attribute.AuctionNumber , origin_highest_bid_user_doc.getPK(), origin_highest_bid_user_doc.getSK() , bidResult.CurrentBidType , highest_bid_user_attribute.BidCurrencyType , highest_bid_user_attribute.HighestBidPrice, highest_bid_user_attribute.HighestBidUserGuid, highest_bid_user_attribute.HighestBidUserNickname , highest_bid_user_attribute.NormalHighestBidPrice, highest_bid_user_attribute.NormalHighestBidUserGuid, highest_bid_user_attribute.NormalHighestBidUserNickname , bidResult.BidTime ); return log_info; } public static LandAuctionLogInfo toLandAuctionLogInfo(this LandAuction landAuction, LandAuctionWinningResult? winningResult) { var registry_attribute = landAuction.getEntityAttribute(); NullReferenceCheckHelper.throwIfNull(registry_attribute, () => $"registry_attribute is null !!! - {landAuction.toBasicString()}"); var winning_user_guid = string.Empty; var winning_user_nickname = string.Empty; if(null != winningResult) { winning_user_guid = winningResult.WinningUserGuid; winning_user_guid = winningResult.WinningUserNickname; } var origin_registry_doc = registry_attribute.getOriginDocBase() as LandAuctionRegistryDoc; NullReferenceCheckHelper.throwIfNull(origin_registry_doc, () => $"origin_registry_doc is null !!! - {landAuction.toBasicString()}"); var log_info = new LandAuctionLogInfo(); log_info.setLogProperty( registry_attribute.LandMetaId, registry_attribute.AuctionNumber , origin_registry_doc.getPK(), origin_registry_doc.getSK() , registry_attribute.BidCurrencyType , registry_attribute.BidStartPrice , registry_attribute.AuctionReservationNoticeStartTime , registry_attribute.AuctionStartTime , registry_attribute.AuctionEndTime , registry_attribute.IsCancelAuction , registry_attribute.RegisteredVersionTime , registry_attribute.LandAuctionState , registry_attribute.LandAuctionResult , winning_user_guid, winning_user_nickname , registry_attribute.ProcessVersionTime ); return log_info; } } }