public void Update(ActivityServerControl _this) { if (InAppPurchase.ChargingState != ChargingState.Waiting) { return; } CoroutineFactory.NewCoroutine(RechageOnce, _this).MoveNext(); }
public new void Init(string[] args) { Logger.Info(@"Activity server initlizing..."); CoroutineFactory.ExceptionHandler = exception => { Logger.Error("ex " + exception.ToString()); return(true); }; UpdateManager = new UpdateManager(); UpdateManager.Init("Activity"); ServerControl = new ActivityServerControl(); if (!int.TryParse(args[1], out mPort)) { Logger.Warn(@"Activity server initlizing Faild! args[1]={0}", args[1]); return; } base.Init(args); int nId; if (!int.TryParse(args[0], out nId)) { Logger.Warn(@"Activity server initlizing Faild! args[0]={0}", args[0]); return; } Id = (uint)nId; mAuth = args[2]; var strDbConfig = args[4]; DB = new DataManager(strDbConfig, ServerControl, DataCategory.Activity, nId); dynamic ServersConfig = JsonConfig.Config.ApplyJson(args[5]); string PayServer = ServersConfig.PayServer; if (!PayServer.StartsWith("http")) { PayServer = string.Format("http://{0}", PayServer); } ServerControl.PayServerNotifyAddress = string.Format("{0}/notify/", PayServer); ServerControl.PayServerVerifyAddress = string.Format("{0}/verify/", PayServer); }
public static void Update(ActivityServerControl _this) { mImpl.Update(_this); }
private IEnumerator RechageOnce(Coroutine co, ActivityServerControl _this) { InAppPurchase.ChargingState = ChargingState.GettingPayOrder; var data = new ConnectData { mType = ConnectDataType.GetData, connect = InAppPurchase.PayDbConnection }; //var order = InAppPurchase.PayDbConnection.GetWaittingResultOrder(); yield return(_this.payDbManagerManager.DoOrder(co, data)); ResultOrder order = null; string platform; try { order = data.resultOrder; if (order == null) { InAppPurchase.ChargingState = ChargingState.Waiting; yield break; } RechargeLogger.Info("GetWaittingResultOrder orderid : {0},playerid : {1},uid: {2} , channel:{3}", order.OrderId, order.PlayerId, order.Uid, order.Channel); RechargeLogger.Info("RechageOnce get order channel:{0} step 1", order.Channel); var strs = order.Channel.Split('.'); platform = strs[0]; RechargeLogger.Info("RechageOnce split channel, platfrom :{0} step 2", platform); InAppPurchase.ChargingState = ChargingState.AddingItem; RechargeLogger.Info( "RechageOnce ss to logic RechargeSuccess, playerid:{0}, platfrom:{1}, orderType:{2}, amount:{3},orderid:{4} step 3", order.PlayerId, platform, order.PayType, order.Amount, order.OrderId); } catch (Exception) { InAppPurchase.ChargingState = ChargingState.Waiting; yield break; } var reslut = ActivityServer.Instance.LogicAgent.RechargeSuccess(order.PlayerId, platform, order.PayType, order.Amount, order.OrderId, order.Channel); yield return(reslut.SendAndWaitUntilDone(co)); if (reslut.State == MessageState.Reply) { if (reslut.ErrorCode == (int)ErrorCodes.OK) { RechargeLogger.Info("RechargeSuccess return ok ,orderid:{0} step 4", order.OrderId); InAppPurchase.ChargingState = ChargingState.WriteOrderBack; order.State = (short)eOrderState.Success; var connectData = new ConnectData { resultOrder = order, mType = ConnectDataType.ModifyData, connect = InAppPurchase.PayDbConnection }; yield return(_this.payDbManagerManager.DoOrder(co, connectData)); //InAppPurchase.PayDbConnection.UpdateResultOrderById(order.OrderId, eOrderState.Success); } else { RechargeLogger.Error( "ActivityServer.Instance.LogicAgent.RechargeSuccess return error ErrorCode = {0}!"); Logger.Error("ActivityServer.Instance.LogicAgent.RechargeSuccess return error ErrorCode = {0}!", reslut.ErrorCode); order.State = (short)eOrderState.Error; yield return(_this.payDbManagerManager.DoOrder(co, new ConnectData { resultOrder = order, mType = ConnectDataType.ModifyData, connect = InAppPurchase.PayDbConnection })); //InAppPurchase.PayDbConnection.UpdateResultOrderById(order.OrderId, eOrderState.Error); } } else { RechargeLogger.Error("ActivityServer.Instance.LogicAgent.RechargeSuccess did not reply!"); Logger.Error("ActivityServer.Instance.LogicAgent.RechargeSuccess did not reply!"); } InAppPurchase.ChargingState = ChargingState.Waiting; RechargeLogger.Info("RechageOnce finished oid:{1} step 5", order.OrderId); }