private void DiscardItemResponseTask(OperationResponse operationResponse) { try { if (operationResponse.ReturnCode == (short)ErrorType.Correct) { ItemID itemID = (ItemID)operationResponse.Parameters[(byte)DiscardItemResponseItem.ItemID]; int itemCount = (int)operationResponse.Parameters[(byte)DiscardItemResponseItem.ItemCount]; if(OnDiscardItemResponse != null) OnDiscardItemResponse(true, itemID, itemCount); } else { if (OnAlert != null) OnAlert(operationResponse.DebugMessage); if (OnDiscardItemResponse != null) OnDiscardItemResponse(false, 0, 0); } } catch (Exception ex) { DebugReturn(DebugLevel.ERROR, ex.Message); DebugReturn(DebugLevel.ERROR, ex.StackTrace); } }
protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters) { if (log.IsDebugEnabled) { log.DebugFormat("OnOperationRequest. Code={0}", operationRequest.OperationCode); } switch (operationRequest.OperationCode) { case (byte)MyOperationCodes.EchoOperation: { // The echo operation one is handled immediately because it does not require the client to join a game. var myEchoRequest = new MyEchoRequest(this.Protocol, operationRequest); if (this.ValidateOperation(myEchoRequest, sendParameters) == false) { return; } var myEchoResponse = new MyEchoResponse { Response = myEchoRequest.Text }; var operationResponse = new OperationResponse(operationRequest.OperationCode, myEchoResponse); this.SendOperationResponse(operationResponse, sendParameters); break; } default: { // for this example all other operations will handled by the base class base.OnOperationRequest(operationRequest, sendParameters); return; } } }
public override void OnOperationReturn(ClientConnection client, OperationResponse operationResponse) { Counters.ReceivedOperationResponse.Increment(); WindowsCounters.ReceivedOperationResponse.Increment(); switch (operationResponse.OperationCode) { case (byte)LoadBalancingEnums.OperationCode.Authenticate: if (operationResponse.ReturnCode == 0) { client.AuthenticationTicket = (string)operationResponse[(byte)LoadBalancingEnums.ParameterCode.Secret]; this.TransitState(client); } else { log.WarnFormat("OnOperationReturn: Authenticate on Master failed: ReturnCode: {0} ({1}). Disconnecting...", operationResponse.ReturnCode, operationResponse.DebugMessage); client.Peer.Disconnect(); } break; default: { log.WarnFormat("OnOperationReturn: unexpected return code {0} of operation {1}", operationResponse.ReturnCode, operationResponse.OperationCode); break; } } }
public override void OnHandlerMessage(Photon.SocketServer.OperationRequest request, OperationResponse response, ClientPeer peer, SendParameters sendParameters) { SubCode subCode = ParameterTool.GetParameter<SubCode>(request.Parameters,ParameterCode.SubCode,false); //给response参数添加subCode response.Parameters.Add((byte) ParameterCode.SubCode,subCode); switch (subCode) { case SubCode.AddTaskDB: TaskDB taskDB = ParameterTool.GetParameter<TaskDB>(request.Parameters, ParameterCode.TaskDB); taskDB.Role = peer.LoginRole; taskDBManager.AddTaskDB(taskDB); taskDB.Role = null; ParameterTool.AddParameter(response.Parameters,ParameterCode.TaskDB, taskDB); response.ReturnCode = (short) ReturnCode.Success; break; case SubCode.GetTaskDB: List<TaskDB> list = taskDBManager.GetTaskDBList(peer.LoginRole); foreach (var taskDb in list) { taskDb.Role = null; } ParameterTool.AddParameter(response.Parameters,ParameterCode.TaskDBList, list); response.ReturnCode = (short) ReturnCode.Success; break; case SubCode.UpdateTaskDB: TaskDB taskDB2 = ParameterTool.GetParameter<TaskDB>(request.Parameters, ParameterCode.TaskDB); taskDB2.Role = peer.LoginRole; taskDBManager.UpdataTaskDB(taskDB2); response.ReturnCode = (short) ReturnCode.Success; break; } }
public override OperationResponse OnHandlerMeesage(OperationRequest request, ClientPeer peer) { //1.获得客户端发送的帐号和明文密码 object json; request.Parameters.TryGetValue((byte) ParameterCode.UserCheckInfo, out json); var user = JsonMapper.ToObject<User>(json.ToString()); var userDb = _manager.GetUserByUsername(user.Username); var s = userDb != null ? string.Format("user.Username:{0},user.Password:{1} userDb.Username:{2},userDb.Password:{3}", user.Username, user.Password, userDb.Username, userDb.Password) : "未找到用户:" + user.Username; peer.WriteLog(s); //2.比较,然后创建响应 var response = new OperationResponse {OperationCode = request.OperationCode}; if (userDb != null && userDb.Password == MD5Tool.GetMD5(user.Password)) { response.ReturnCode = (short) ReturnCode.Success; peer.SetUser(userDb); } else { response.ReturnCode = (short) ReturnCode.Fail; response.DebugMessage = "用户名或密码错误!"; } return response; }
private void ExploreResponseTask(OperationResponse operationResponse) { try { if (operationResponse.ReturnCode == (short)ErrorType.Correct) { List<int> pathIDs = JsonConvert.DeserializeObject<List<int>>((string)operationResponse.Parameters[(byte)ExploreResponseItem.DiscoveredPathIDsDataString]); List<Pathway> paths = new List<Pathway>(); foreach (int pathID in pathIDs) { if (GameGlobal.GlobalMap.paths.ContainsKey(pathID)) { paths.Add(GameGlobal.GlobalMap.paths[pathID]); } } if (OnExploreResponse != null) OnExploreResponse(true, paths); } else { if (OnAlert != null) OnAlert(operationResponse.DebugMessage); if (OnExploreResponse != null) OnExploreResponse(false, null); } } catch (Exception ex) { DebugReturn(DebugLevel.ERROR, ex.Message); DebugReturn(DebugLevel.ERROR, ex.StackTrace); } }
protected override void OnOperationRequest(OperationRequest request, SendParameters sendParameters) { if (log.IsDebugEnabled) { log.DebugFormat("OnOperationRequest: pid={0}, op={1}", this.ConnectionId, request.OperationCode); } switch ((OperationCode)request.OperationCode) { default: var response = new OperationResponse(request.OperationCode) { ReturnCode = (short)ErrorCode.OperationInvalid, DebugMessage = "Unknown operation code" }; this.SendOperationResponse(response, sendParameters); break; case OperationCode.Authenticate: OperationResponse authenticateResponse = this.HandleAuthenticate(request); this.SendOperationResponse(authenticateResponse, sendParameters); break; case OperationCode.CreateGame: case OperationCode.JoinLobby: case OperationCode.LeaveLobby: case OperationCode.JoinRandomGame: case OperationCode.JoinGame: this.lobby.EnqueueOperation(this, request, sendParameters); break; } }
public override void OnOperationResponse (OperationResponse response) { SubCode subCode = ParameterTool.GetParameter<SubCode>(response.Parameters, ParameterCode.SubCode,false); switch(subCode) { case SubCode.GetTaskDB: List<TaskDB> list = ParameterTool.GetParameter< List<TaskDB> >(response.Parameters, ParameterCode.TaskDBList); if(OnGetTaskDBList != null) { OnGetTaskDBList(list); } break; case SubCode.AddTaskDB: TaskDB taskDB = ParameterTool.GetParameter<TaskDB>(response.Parameters, ParameterCode.TaskDB); if(OnAddTaskDB != null) { OnAddTaskDB(taskDB); } break; case SubCode.UpdateTaskDB: if(OnUpdateTaskDB != null) { OnUpdateTaskDB(); } break; } }
public override void OnOperationReturn(ClientConnection client, OperationResponse operationResponse) { Counters.ReceivedOperationResponse.Increment(); WindowsCounters.ReceivedOperationResponse.Increment(); switch (operationResponse.OperationCode) { case OperationCode.JoinGame: { if (operationResponse.ReturnCode == 0) { this.TransitState(client); } else { log.WarnFormat("OnOperationReturn: unexpected return code {0} of operation {1}", operationResponse.ReturnCode, operationResponse.OperationCode); client.Stop(); } break; } default: { log.WarnFormat("OnOperationReturn: unexpected return code {0} of operation {1}", operationResponse.ReturnCode, operationResponse.OperationCode); break; } } }
public override void OnOperationReturn(ClientConnection client, OperationResponse operationResponse) { Counters.ReceivedOperationResponse.Increment(); WindowsCounters.ReceivedOperationResponse.Increment(); switch (operationResponse.OperationCode) { case (byte)LoadBalancingEnums.OperationCode.JoinGame: case (byte)LoadBalancingEnums.OperationCode.CreateGame: if (operationResponse.ReturnCode == 0) { this.TransitState(client); } else { log.WarnFormat("OnOperationReturn: {0} failed: ReturnCode: {1} ({2}). Disconnecting...", Enum.GetName(typeof(LoadBalancingEnums.OperationCode), operationResponse.OperationCode), operationResponse.ReturnCode, operationResponse.DebugMessage); client.Peer.Disconnect(); } break; default: { log.WarnFormat("OnOperationReturn: unexpected return code {0} of operation {1}", operationResponse.ReturnCode, operationResponse.OperationCode); break; } } }
public override OperationResponse OnHandlerMeesage(OperationRequest request, ClientPeer peer) { object json; request.Parameters.TryGetValue((byte) ParameterCode.UserCheckInfo, out json); var user = JsonMapper.ToObject<User>(json.ToString()); var response = new OperationResponse {OperationCode = request.OperationCode}; //查询数据库 var userDb = _manager.GetUserByUsername(user.Username); if (userDb == null) { if (_manager.RegisterUser(user)) { response.ReturnCode = (short) ReturnCode.Success; peer.SetUser(user); } else { response.ReturnCode = (short) ReturnCode.Eception; response.DebugMessage = "异常"; } } else { response.ReturnCode = (short) ReturnCode.Fail; response.DebugMessage = "用户名已存在!"; } return response; }
public virtual OperationResponse GetResponse(ErrorCode errorCode, string debugMessage = "") { var response = new OperationResponse(OperationRequest.OperationCode); response.ReturnCode = (short) errorCode; response.DebugMessage = debugMessage; return response; }
public override void OnHandleResponse(OperationResponse response) { //NetworkManager view = _controller.ControlledView as NetworkManager; NetworkManager view = _controller.ControlledView as NetworkManager; view.LogDebug("GOT A RESPONSE for PROFILE"); if (response.ReturnCode == 0) { view.LogDebug(response.Parameters[(byte)ClientParameterCode.Spacebux].ToString()); view.LogDebug(response.Parameters[(byte)ClientParameterCode.Homestar].ToString()); view.LogDebug(response.Parameters[(byte)ClientParameterCode.LastLocX].ToString()); view.LogDebug(response.Parameters[(byte)ClientParameterCode.LastLocY].ToString()); // Update local player data according to server PlayerData.instance.UpdateLocalData( (int)response.Parameters[(byte)ClientParameterCode.Spacebux], (long)response.Parameters[(byte)ClientParameterCode.Homestar], (int)response.Parameters[(byte)ClientParameterCode.LastLocX], (int)response.Parameters[(byte)ClientParameterCode.LastLocY] ); } else { view.LogDebug("RESPONSE: " + response.DebugMessage); DisplayManager.Instance.DisplayMessage(response.DebugMessage); } }
/// <summary> /// 类型:方法 /// 名称:EnterWorldEventArgs /// 作者:taixihuase /// 作用:用自身角色进入场景所感兴趣的数据构造事件数据 /// 编写日期:2015/7/22 /// </summary> /// <param name="response"></param> public WorldEnterEventArgs(OperationResponse response) { Position position = (Position) Serialization.Deserialize(response.Parameters[(byte) ParameterCode.WorldEnter]); MyCharacterPosition = position; AnyCharacter = null; }
public override void OnHandleResponse(OperationResponse response) { NetworkManager view = _controller.ControlledView as NetworkManager; view.LogDebug("GOT A RESPONSE for SPACEBUX"); if (response.ReturnCode == 0) { view.LogDebug(response.Parameters[(byte)ClientParameterCode.Time].ToString()); DisplayManager.Instance.DisplayMessage("Spacebuck Collected"); // Deserialize XmlSerializer serializer = new XmlSerializer(typeof(DateTime)); DateTime collectionTime; using (StringReader textReader = new StringReader(response.Parameters[(byte)ClientParameterCode.Time].ToString())) { collectionTime = (DateTime)serializer.Deserialize(textReader); } // Update local data //PlayerData.instance.UpdateSpacebux((int)); // TODO: FIX THIS } else if (response.ReturnCode == 5) { view.LogDebug("Not enough spacebux to spend!"); DisplayManager.Instance.DisplayMessage("Not Enough Spacebux!"); } else { view.LogDebug("RESPONSE: " + response.DebugMessage); DisplayManager.Instance.DisplayMessage(response.DebugMessage); } }
public override void OnHandleResponse(OperationResponse response) { NetworkManager view = _controller.ControlledView as NetworkManager; view.LogDebug("GOT A RESPONSE for KNOWN Planets"); if (response.ReturnCode == 0) { // TODO FIX THIS FOR ONLY 1 PLANET?? view.LogDebug(response.Parameters[(byte)ClientParameterCode.Planets].ToString()); // Deserialize var xmlData = response.Parameters[(byte)ClientParameterCode.Planets].ToString(); XmlSerializer deserializer = new XmlSerializer(typeof(XmlPlanetList)); TextReader reader = new StringReader(xmlData); object obj = deserializer.Deserialize(reader); XmlPlanetList planetCollection = (XmlPlanetList)obj; reader.Close(); // Update local data foreach (SanPlanet p in planetCollection.Planets) { var planet = PlayerData.instance.ownedPlanets.Find(x => x.starID == p.StarId && x.planetID == p.PlanetNum); if (planet != null) { planet.planetpopulation = p.Population; } } } else { view.LogDebug("RESPONSE: " + response.DebugMessage); DisplayManager.Instance.DisplayMessage(response.DebugMessage); } }
public override void OnHandleResponse(OperationResponse response) { NetworkManager view = _controller.ControlledView as NetworkManager; view.LogDebug("GOT A RESPONSE for KNOWN STARS"); if (response.ReturnCode == 0) { view.LogDebug(response.Parameters[(byte)ClientParameterCode.KnownStars].ToString()); // Deserialize var xmlData = response.Parameters[(byte)ClientParameterCode.KnownStars].ToString(); XmlSerializer deserializer = new XmlSerializer(typeof(XmlStarPlayerList)); TextReader reader = new StringReader(xmlData); object obj = deserializer.Deserialize(reader); XmlStarPlayerList starCollection = (XmlStarPlayerList)obj; reader.Close(); List<KnownStar> stars = new List<KnownStar>(); foreach (SanStarPlayer s in starCollection.StarPlayers) stars.Add(new KnownStar(s)); // Update local data PlayerData.instance.UpdateKnownStars(stars); } else { view.LogDebug("RESPONSE: " + response.DebugMessage); DisplayManager.Instance.DisplayMessage(response.DebugMessage); } }
protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters) { switch (operationRequest.OperationCode) { default: { string message = string.Format("Unknown operation code {0}", operationRequest.OperationCode); this.SendOperationResponse(new OperationResponse { OperationCode = operationRequest.OperationCode, ReturnCode = -1, DebugMessage = message }, sendParameters); break; } case 1: { var pingOperation = new LatencyOperation(this.Protocol, operationRequest.Parameters); if (pingOperation.IsValid == false) { this.SendOperationResponse(new OperationResponse { OperationCode = operationRequest.OperationCode, ReturnCode = -1, DebugMessage = pingOperation.GetErrorMessage() }, sendParameters); return; } Thread.Sleep(5); var response = new OperationResponse(operationRequest.OperationCode, pingOperation); this.SendOperationResponse(response, sendParameters); break; } } }
public void OnOperationResponse(OperationResponse operationResponse) { // display operationCode this.DebugReturn(0, string.Format("OperationResult:" + operationResponse.OperationCode.ToString())); switch (operationResponse.OperationCode) { case (byte)OperationCode.Login: { if (operationResponse.ReturnCode == (short)ErrorCode.Ok) // if success { getRet = Convert.ToInt32(operationResponse.Parameters[(byte)LoginResponseCode.Ret]); getMemberID = Convert.ToString(operationResponse.Parameters[(byte)LoginResponseCode.MemberID]); getMemberPW = Convert.ToString(operationResponse.Parameters[(byte)LoginResponseCode.MemberPW]); getNickname = Convert.ToString(operationResponse.Parameters[(byte)LoginResponseCode.Nickname]); LoginStatus = true; } else { LoginResult = operationResponse.DebugMessage; LoginStatus = false; } break; } } //throw new System.NotImplementedException(); }
public override void OnHandleResponse(OperationResponse response) { NetworkManager view = _controller.ControlledView as NetworkManager; if (response.ReturnCode == 0) { // TODO FIX THIS FOR ONLY 1 PLANET?? view.LogDebug(response.Parameters[(byte)ClientParameterCode.Planets].ToString()); DisplayManager.Instance.DisplayMessage("Planet Colonized!"); // Deserialize var xmlData = response.Parameters[(byte)ClientParameterCode.Planets].ToString(); XmlSerializer deserializer = new XmlSerializer(typeof(XmlPlanetList)); TextReader reader = new StringReader(xmlData); object obj = deserializer.Deserialize(reader); XmlPlanetList planetCollection = (XmlPlanetList)obj; reader.Close(); // Update local data foreach (SanPlanet p in planetCollection.Planets) PlayerData.instance.AddOwnedPlanet(new OwnedPlanet(p)); } else { view.LogDebug("RESPONSE: " + response.DebugMessage); DisplayManager.Instance.DisplayMessage(response.DebugMessage); } }
public override void OnHandleResponse(OperationResponse response) { if (response.ReturnCode == 0) { Application.LoadLevel("CharacterLoading"); } }
public override void OnHandleResponse(OperationResponse response) { if (response.ReturnCode != 0) { return; } Debug.Log("asdf"); Application.LoadLevel("CharacterSelect"); }
public OperationResponse GetResponse() { OperationResponse resp = new OperationResponse((byte) DiscussionOpCode.Test, new Dictionary<byte, object> { {(byte) DiscussionParamKey.Message, Message} }); return resp; }
protected override void OnOperationResponse(OperationResponse operationResponse, SendParameters sendParameters) { IPhotonResponseHandler handler; if (ResponseHandlers.TryGetValue(operationResponse.OperationCode, out handler)) { handler.HandleResponse(operationResponse); } }
protected static void CheckDefaultOperationParams(OperationResponse response, OperationCodes operationCode) { CheckParamExists(response, ParameterKeys.ERR); CheckParamExists(response, ParameterKeys.DBG); int error = (int)response.Params[(short)Lite.Operations.ParameterKeys.ERR]; Assert.AreEqual(0, error, string.Format("Response has Error. ERR={0}, DBG={1}", error, response.Params[(short)ParameterKeys.DBG])); CheckParam(response, ParameterKeys.Code, (short)operationCode); }
public override void OnOperationResponse(OperationResponse response) { Dictionary<byte, object> parameters = response.Parameters; object jsonObject = null; parameters.TryGetValue((byte)ParameterCode.ServerList, out jsonObject); List<TaidouCommon.Model.ServerProperty> serverList = JsonMapper.ToObject<List<TaidouCommon.Model.ServerProperty>>(jsonObject.ToString()); StartmenuController._instance.InitServerListFromServer(serverList); }
public void OnOperationResponse(OperationResponse operationResponse) { Main.Dispatcher.Invoke(() => { Main.StatusTextBox.AppendText("OnOperationResponse called with: " + operationResponse.OperationCode + " - " + operationResponse.ReturnCode + " - " + operationResponse.DebugMessage + "\n") ; }); }
public void OnUnexpectedOperationError(OperationResponse operationResponse) { string message = string.Format( "{0}: unexpected operation error {1} from operation {2} in state {3}", "@avatarNameToDefine", operationResponse.DebugMessage, operationResponse.ReturnCode, stateStrategy.State); listener.LogError(this, message); }
/// <summary> /// The on operation return. /// </summary> /// <param name="client"> /// The client. /// </param> /// <param name="operationResponse"> /// The operation Response. /// </param> public override void OnOperationReturn(ClientConnection client, OperationResponse operationResponse) { Counters.ReceivedOperationResponse.Increment(); WindowsCounters.ReceivedOperationResponse.Increment(); switch (operationResponse.OperationCode) { case OperationCode.RaiseEvent: { if (operationResponse.ReturnCode != 0) { log.WarnFormat( "OnOperationReturn: unexpected return code {0} of operation {1}", operationResponse.ReturnCode, operationResponse.OperationCode); client.Stop(); } break; } case OperationCode.Leave: { if (operationResponse.ReturnCode == 0) { if (log.IsDebugEnabled) { log.Debug("Stopped Playing"); } client.State = Connected.Instance; client.StopTimers(); } else { log.WarnFormat( "OnOperationReturn: unexpected return code {0} of operation {1}", operationResponse.ReturnCode, operationResponse.OperationCode); client.Stop(); } break; } case OperationCode.JoinGame: { // ignore: ReturnIncoming app returns 10x response break; } default: { log.WarnFormat( "OnOperationReturn: unexpected return code {0} of operation {1}", operationResponse.ReturnCode, operationResponse.OperationCode); break; } } }
public override void OnHandlerMessage(OperationRequest request, OperationResponse response, ClientPeer peer, SendParameters sendParameters) { SubCode subcode = ParameterTool.GetParameter<SubCode>(request.Parameters, ParameterCode.SubCode, false); ParameterTool.AddParameter(response.Parameters,ParameterCode.SubCode,subcode, false); switch (subcode) { //查询 case SubCode.GetInventoryItemDB: List<InventoryItemDB> list = inventoryItemDbManager.GetInventoryDB(peer.LoginRole); foreach (var temp in list) { temp.Role = null; } ParameterTool.AddParameter(response.Parameters,ParameterCode.InventoryItemDBList,list); break; //添加 case SubCode.AddInventoryItemDB: InventoryItemDB itemDB = ParameterTool.GetParameter<InventoryItemDB>(request.Parameters,ParameterCode.InventoryItemDB); itemDB.Role = peer.LoginRole; inventoryItemDbManager.AddInventoryItemDB(itemDB); itemDB.Role = null; ParameterTool.AddParameter(response.Parameters,ParameterCode.InventoryItemDB, itemDB); response.ReturnCode = (short) ReturnCode.Success; break; //更新,一个的情况 case SubCode.UpdateInventoryItemDB: InventoryItemDB itemDB2 = ParameterTool.GetParameter<InventoryItemDB>(request.Parameters, ParameterCode.InventoryItemDB); itemDB2.Role = peer.LoginRole; inventoryItemDbManager.UpdateInventoryItemDB(itemDB2); break; //更新穿上和卸下的装备,两个的情况 case SubCode.UpdateInventoryItemDBList: List<InventoryItemDB> list2 = ParameterTool.GetParameter<List<InventoryItemDB>>(request.Parameters,ParameterCode.InventoryItemDBList); foreach (var itemDB3 in list2) { itemDB3.Role = peer.LoginRole; } inventoryItemDbManager.UpdateInventoryItemDBList(list2); break; //升级装备 case SubCode.UpgradeEquip: InventoryItemDB itemDB4 = ParameterTool.GetParameter<InventoryItemDB>(request.Parameters,ParameterCode.InventoryItemDB); Role role = ParameterTool.GetParameter<Role>(request.Parameters, ParameterCode.Role); peer.LoginRole = role; role.User = peer.LoginUser; itemDB4.Role = role; inventoryItemDbManager.UpgradeEquip(itemDB4, role); break; } }
public OperationResponse <SaleOpportunityGetByIdCommandOutputDTO> Execute(int id) { var result = new OperationResponse <SaleOpportunityGetByIdCommandOutputDTO>(); using (var dbContextScope = this.DbContextScopeFactory.Create()) { var getByIdResult = this.Repository.GetByIdWithProducts(id); var allOpportunityTargetPriceProducts = this.SaleOpportunityTargetPriceProductRepository.GetAll().Bag; result.AddResponse(getByIdResult); if (result.IsSucceed) { result.Bag = new SaleOpportunityGetByIdCommandOutputDTO { Id = getByIdResult.Bag.Id, Name = getByIdResult.Bag.Name, CustomerId = getByIdResult.Bag.CustomerId, CustomerName = getByIdResult.Bag.Customer.Name, TargetPrices = getByIdResult.Bag.SaleOpportunityTargetPrices.Select(targetPrice => new SaleOpportunityGetByIdCommandOutputTargetPriceItemDTO { Id = targetPrice.Id, Name = targetPrice.Name, SeasonName = targetPrice.SaleSeasonType.Name, TargetPrice = targetPrice.TargetPrice, SaleSeasonTypeId = targetPrice.SaleSeasonTypeId, AlternativesAmount = targetPrice.AlternativesAmount, SampleBoxes = targetPrice.SampleBoxes.Select(o => new SaleOpportunityGetByIdCommandOutputSampleBoxItemDTO { Id = o.Id, SaleOpportunityTargetPriceId = o.SaleOpportunityTargetPriceId, Name = o.Name, Order = o.Order, SampleBoxSaleOpportunityProductIds = o.SampleBoxProducts.Select(item => new SaleOpportunityGetByIdCommandOutputSampleBoxProductItemDTO { Id = o.Id, SaleOpportunityTargetPriceProductId = item.SaleOpportunityTargetPriceProductId, }).ToList() }).ToList(), SaleOpportunityTargetPriceProducts = targetPrice.SaleOpportunityTargetPriceProducts.Select(item => new SaleOpportunityGetByIdCommandOutputTargetPriceProductItemDTO { Id = item.Id, ProductId = item.ProductId, ProductAmount = item.ProductAmount, ProductName = item.Product.Name, ProductTypeId = item.Product.ProductTypeId, ProductTypeName = item.Product.ProductType.Name, ProductTypeDescription = item.Product.ProductType.Description, ProductPictureId = item.Product.ProductMedias.Select(media => media.FileRepositoryId).FirstOrDefault(), ProductColorTypeId = item.ProductColorTypeId, ProductColorTypeName = item.ProductColorType?.Name, OpportunityCount = allOpportunityTargetPriceProducts.Where(tpProduct => tpProduct.Product.Id == item.ProductId).Select(tpProduct => tpProduct.SaleOpportunityTargetPrice.SaleOpportunityId).Distinct().Count(), FirstOpportunityId = allOpportunityTargetPriceProducts.Where(tpProduct => tpProduct.Product.Id == item.ProductId).OrderBy(tpProduct => tpProduct.SaleOpportunityTargetPrice.SaleOpportunity.CreatedAt).Select(tpProduct => tpProduct.SaleOpportunityTargetPrice.SaleOpportunityId).FirstOrDefault(), FirstOpportunityName = allOpportunityTargetPriceProducts.Where(tpProduct => tpProduct.Product.Id == item.ProductId).OrderBy(tpProduct => tpProduct.SaleOpportunityTargetPrice.SaleOpportunity.CreatedAt).Select(tpProduct => tpProduct.SaleOpportunityTargetPrice.SaleOpportunity.Name).FirstOrDefault(), RelatedProducts = ((CompositionProduct)item.Product).Items.Select(o => new SaleOpportunityGetByIdCommandOutputRelatedProductItemDTO { Id = o.Id, ProductId = o.CompositionProductId, RelatedProductId = o.CompositionItemId, RelatedProductAmount = o.CompositionItemAmount, RelatedProductSizeId = o.ProductCategorySizeId, ColorTypeId = o.ColorTypeId, RelatedProductName = o.CompositionItem.Name, RelatedProductTypeName = o.CompositionItem.ProductType.Name, RelatedProductTypeDescription = o.CompositionItem.ProductType.Description, RelatedProductPictureId = o.CompositionItem.ProductMedias.Where(m => m.IsDeleted == null || m.IsDeleted == false).Select(media => media.FileRepositoryId).FirstOrDefault(), RelatedProductTypeId = o.CompositionItem.ProductTypeId, RelatedProductCategoryId = o.CompositionItem.ProductCategoryId }).ToList() }).ToList() }).ToList(), }; //if (getByIdResult.Bag.ProductAllowedColorType != null) //{ // result.Bag.ProductColorTypeId = getByIdResult.Bag.ProductAllowedColorType.ProductColorTypeId; //} foreach (var TargetPrice in getByIdResult.Bag.SaleOpportunityTargetPrices) { var resultTargetPrice = result.Bag.TargetPrices.FirstOrDefault(resultTargetPriceItem => resultTargetPriceItem.Settings != null); if (resultTargetPrice != null) { resultTargetPrice.Settings = new SaleOpportunityGetByIdCommandOutputSettingsDTO { Id = TargetPrice.SaleOpportunitySettings.Id, Delivered = TargetPrice.SaleOpportunitySettings.Delivered, }; } } } } return(result); }
public override void OnOperationResponse(OperationResponse response) { //DO Nothing }
private void HandleAuthResponse(OperationResponse operationResponse) { if (this.DebugOut >= DebugLevel.INFO) { this.listener.DebugReturn(DebugLevel.INFO, operationResponse.ToStringFull() + " on: " + this.chatPeer.NameServerAddress); } if (operationResponse.ReturnCode == 0) { if (this.State == ChatState.ConnectedToNameServer) { this.State = ChatState.Authenticated; this.listener.OnChatStateChange(this.State); if (operationResponse.Parameters.ContainsKey(ParameterCode.Secret)) { if (this.AuthValues == null) { this.AuthValues = new AuthenticationValues(); } this.AuthValues.Token = operationResponse[ParameterCode.Secret] as string; this.FrontendAddress = (string)operationResponse[ParameterCode.Address]; // we disconnect and status handler starts to connect to front end this.chatPeer.Disconnect(); } else { if (this.DebugOut >= DebugLevel.ERROR) { this.listener.DebugReturn(DebugLevel.ERROR, "No secret in authentication response."); } } } else if (this.State == ChatState.ConnectingToFrontEnd) { this.msDeltaForServiceCalls = this.msDeltaForServiceCalls * 4; // when we arrived on chat server: limit Service calls some more this.State = ChatState.ConnectedToFrontEnd; this.listener.OnChatStateChange(this.State); this.listener.OnConnected(); } } else { //this.listener.DebugReturn(DebugLevel.INFO, operationResponse.ToStringFull() + " NS: " + this.NameServerAddress + " FrontEnd: " + this.frontEndAddress); switch (operationResponse.ReturnCode) { case ErrorCode.InvalidAuthentication: this.DisconnectedCause = ChatDisconnectCause.InvalidAuthentication; break; case ErrorCode.CustomAuthenticationFailed: this.DisconnectedCause = ChatDisconnectCause.CustomAuthenticationFailed; break; case ErrorCode.InvalidRegion: this.DisconnectedCause = ChatDisconnectCause.InvalidRegion; break; case ErrorCode.MaxCcuReached: this.DisconnectedCause = ChatDisconnectCause.MaxCcuReached; break; case ErrorCode.OperationNotAllowedInCurrentState: this.DisconnectedCause = ChatDisconnectCause.OperationNotAllowedInCurrentState; break; } if (this.DebugOut >= DebugLevel.ERROR) { this.listener.DebugReturn(DebugLevel.ERROR, "Authentication request error: " + operationResponse.ReturnCode + ". Disconnecting."); } this.State = ChatState.Disconnecting; this.chatPeer.Disconnect(); } }
/// <summary> /// The Put Metric Settings operation creates or updates the metric /// settings for the resource. /// </summary> /// <param name='parameters'> /// Metric settings to be created or updated. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public async System.Threading.Tasks.Task <OperationResponse> CreateOrUpdateAsync(MetricSettingsPutParameters parameters, CancellationToken cancellationToken) { // Validate if (parameters == null) { throw new ArgumentNullException("parameters"); } if (parameters.MetricSetting == null) { throw new ArgumentNullException("parameters.MetricSetting"); } if (parameters.MetricSetting.ResourceId == null) { throw new ArgumentNullException("parameters.MetricSetting.ResourceId"); } if (parameters.MetricSetting.Value == null) { throw new ArgumentNullException("parameters.MetricSetting.Value"); } // Tracing bool shouldTrace = CloudContext.Configuration.Tracing.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = Tracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("parameters", parameters); Tracing.Enter(invocationId, this, "CreateOrUpdateAsync", tracingParameters); } // Construct URL string url = new Uri(this.Client.BaseUri, "/").ToString() + this.Client.Credentials.SubscriptionId + "/services/monitoring/metricsettings"; // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Put; httpRequest.RequestUri = new Uri(url); // Set Headers httpRequest.Headers.Add("Accept", "application/json"); httpRequest.Headers.Add("x-ms-version", "2013-10-01"); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Serialize Request string requestContent = null; JToken requestDoc = null; JObject metricSettingValue = new JObject(); requestDoc = metricSettingValue; metricSettingValue["ResourceId"] = parameters.MetricSetting.ResourceId; if (parameters.MetricSetting.Namespace != null) { metricSettingValue["Namespace"] = parameters.MetricSetting.Namespace; } JObject valueValue = new JObject(); metricSettingValue["Value"] = valueValue; valueValue["odata.type"] = parameters.MetricSetting.Value.GetType().FullName; if (parameters.MetricSetting.Value is AvailabilityMetricSettingValue) { AvailabilityMetricSettingValue derived = (AvailabilityMetricSettingValue)parameters.MetricSetting.Value; if (derived.AvailableLocations != null) { JArray availableLocationsArray = new JArray(); foreach (NameConfig availableLocationsItem in derived.AvailableLocations) { JObject nameConfigValue = new JObject(); availableLocationsArray.Add(nameConfigValue); if (availableLocationsItem.Name != null) { nameConfigValue["Name"] = availableLocationsItem.Name; } if (availableLocationsItem.DisplayName != null) { nameConfigValue["DisplayName"] = availableLocationsItem.DisplayName; } } valueValue["AvailableLocations"] = availableLocationsArray; } if (derived.Endpoints != null) { JArray endpointsArray = new JArray(); foreach (EndpointConfig endpointsItem in derived.Endpoints) { JObject endpointConfigValue = new JObject(); endpointsArray.Add(endpointConfigValue); if (endpointsItem.ConfigId != null) { endpointConfigValue["ConfigId"] = endpointsItem.ConfigId; } if (endpointsItem.Name != null) { endpointConfigValue["Name"] = endpointsItem.Name; } if (endpointsItem.Location != null) { endpointConfigValue["Location"] = endpointsItem.Location; } if (endpointsItem.Url != null) { endpointConfigValue["Url"] = endpointsItem.Url.ToString(); } } valueValue["Endpoints"] = endpointsArray; } } requestContent = requestDoc.ToString(Formatting.Indented); httpRequest.Content = new StringContent(requestContent, Encoding.UTF8); httpRequest.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { Tracing.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { Tracing.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; if (statusCode != HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, requestContent, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false), CloudExceptionType.Json); if (shouldTrace) { Tracing.Error(invocationId, ex); } throw ex; } // Create Result OperationResponse result = null; result = new OperationResponse(); result.StatusCode = statusCode; if (httpResponse.Headers.Contains("x-ms-request-id")) { result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (shouldTrace) { Tracing.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }
/// <summary> /// 根据Id加载审计日志数据 /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <OperationResponse <AuditLogOutputPageDto> > LoadAuditLogByIdAsync(ObjectId id) { var auditLog = await _auditLogRepository.FindByIdAsync(id); return(OperationResponse <AuditLogOutputPageDto> .Ok("操作成功", auditLog.MapTo <AuditLogOutputPageDto>())); }
private void OnGetMsg_SystemNotice(OperationResponse operationResponse) { if (operationResponse == null) { ClientLogger.Error("Model_Friend:OnGetMsg_SystemNotice:operationResponse=null"); return; } if (operationResponse.Parameters == null || !operationResponse.Parameters.ContainsKey(1)) { ClientLogger.Error("Model_Friend:OnGetMsg_SystemNotice:operationResponse.Parameters.ContainsKey((byte)MobaOpKey.ErrorCode)"); return; } base.LastError = (int)operationResponse.Parameters[1]; FriendModelData friendModelData = base.Data as FriendModelData; if (friendModelData == null) { ClientLogger.Error("Model_Friend:OnGetMsg_SystemNotice:data=null"); return; } MobaErrorCode lastError = (MobaErrorCode)base.LastError; if (lastError != MobaErrorCode.Ok) { base.DebugMessage = "====>GetArenaDefTeam" + operationResponse.OperationCode; } else if (!operationResponse.Parameters.ContainsKey(40)) { ClientLogger.Error("Model_Friend:OnGetMsg_SystemNotice:operationResponse[MobaOpKey.Notification]==null"); } else { byte[] buffer = operationResponse.Parameters[40] as byte[]; NotificationData notificationData = SerializeHelper.Deserialize <NotificationData>(buffer); if (notificationData == null) { ClientLogger.Error("Model_Friend:OnGetMsg_SystemNotice:deserialize failed"); } else { short type = notificationData.Type; if (type != 14) { if (type != 15) { if (type == 9) { string[] subItem = notificationData.Content.Split(new char[] { '|' }); FriendData friendData = friendModelData.friendDataList.Find((FriendData obj) => obj.TargetId == (long)int.Parse(subItem[0])); if (friendData != null) { if (friendData.Messages == null) { friendData.Messages = new List <Messages>(); } friendData.Messages.Add(new Messages { Time = subItem[subItem.Length - 1], Content = subItem[1] }); } } } else { string[] delsubItem = notificationData.Content.Split(new char[] { '|' }); FriendData item = friendModelData.friendDataList.Find((FriendData obj) => obj.TargetId == (long)int.Parse(delsubItem[delsubItem.Length - 1])); friendModelData.friendDataList.Remove(item); } } else { string[] blacksubItem = notificationData.Content.Split(new char[] { '|' }); friendModelData.friendDataList.RemoveAll((FriendData obj) => obj.TargetId == long.Parse(blacksubItem[1])); } base.DebugMessage = "====>OK " + operationResponse.OperationCode; } } base.Data = friendModelData; base.Valid = (base.LastError == 0); }
/// <summary> /// The Begin Deleting Virtual Machine Image operation deletes the /// specified virtual machine image. /// </summary> /// <param name='vmImageName'> /// Required. The name of the virtual machine image to delete. /// </param> /// <param name='deleteFromStorage'> /// Required. Specifies that the source blob for the image should also /// be deleted from storage. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public async System.Threading.Tasks.Task <OperationResponse> BeginDeletingAsync(string vmImageName, bool deleteFromStorage, CancellationToken cancellationToken) { // Validate if (vmImageName == null) { throw new ArgumentNullException("vmImageName"); } // Tracing bool shouldTrace = CloudContext.Configuration.Tracing.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = Tracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("vmImageName", vmImageName); tracingParameters.Add("deleteFromStorage", deleteFromStorage); Tracing.Enter(invocationId, this, "BeginDeletingAsync", tracingParameters); } // Construct URL string baseUrl = this.Client.BaseUri.AbsoluteUri; string url = "/" + (this.Client.Credentials.SubscriptionId != null ? this.Client.Credentials.SubscriptionId.Trim() : "") + "/services/vmimages/" + vmImageName.Trim() + "?"; if (deleteFromStorage == true) { url = url + "comp=media"; } // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.Length - 1] == '/') { baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); } if (url[0] == '/') { url = url.Substring(1); } url = baseUrl + "/" + url; // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Delete; httpRequest.RequestUri = new Uri(url); // Set Headers httpRequest.Headers.Add("x-ms-version", "2014-04-01"); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { Tracing.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { Tracing.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; if (statusCode != HttpStatusCode.Accepted) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false), CloudExceptionType.Xml); if (shouldTrace) { Tracing.Error(invocationId, ex); } throw ex; } // Create Result OperationResponse result = null; result = new OperationResponse(); result.StatusCode = statusCode; if (httpResponse.Headers.Contains("x-ms-request-id")) { result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (shouldTrace) { Tracing.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }
/// <summary> /// Updates an Azure SQL Database security policy object. /// </summary> /// <param name='resourceGroupName'> /// Required. The name of the Resource Group to which the Azure SQL /// Database Server belongs. /// </param> /// <param name='serverName'> /// Required. The name of the Azure SQL Database Server to which the /// Azure SQL Database belongs. /// </param> /// <param name='databaseName'> /// Required. The name of the Azure SQL Database to which the security /// policy is applied. /// </param> /// <param name='parameters'> /// Required. The required parameters for updating a security policy. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public async Task <OperationResponse> UpdateAsync(string resourceGroupName, string serverName, string databaseName, DatabaseSecurityPolicyUpdateParameters parameters, CancellationToken cancellationToken) { // Validate if (resourceGroupName == null) { throw new ArgumentNullException("resourceGroupName"); } if (serverName == null) { throw new ArgumentNullException("serverName"); } if (databaseName == null) { throw new ArgumentNullException("databaseName"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } if (parameters.Properties == null) { throw new ArgumentNullException("parameters.Properties"); } // Tracing bool shouldTrace = CloudContext.Configuration.Tracing.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = Tracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("serverName", serverName); tracingParameters.Add("databaseName", databaseName); tracingParameters.Add("parameters", parameters); Tracing.Enter(invocationId, this, "UpdateAsync", tracingParameters); } // Construct URL string url = "/subscriptions/" + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId) + "/resourceGroups/" + Uri.EscapeDataString(resourceGroupName) + "/providers/Microsoft.Sql/servers/" + Uri.EscapeDataString(serverName) + "/databaseSecurityPolicies/" + Uri.EscapeDataString(databaseName) + "?"; url = url + "api-version=2014-04-01"; string baseUrl = this.Client.BaseUri.AbsoluteUri; // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.Length - 1] == '/') { baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); } if (url[0] == '/') { url = url.Substring(1); } url = baseUrl + "/" + url; url = url.Replace(" ", "%20"); // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Put; httpRequest.RequestUri = new Uri(url); // Set Headers // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Serialize Request string requestContent = null; JToken requestDoc = null; JObject databaseSecurityPolicyUpdateParametersValue = new JObject(); requestDoc = databaseSecurityPolicyUpdateParametersValue; JObject propertiesValue = new JObject(); databaseSecurityPolicyUpdateParametersValue["properties"] = propertiesValue; propertiesValue["isAuditingEnabled"] = parameters.Properties.IsAuditingEnabled; propertiesValue["retentionDays"] = parameters.Properties.RetentionDays; propertiesValue["isEventTypeDataAccessEnabled"] = parameters.Properties.IsEventTypeDataAccessEnabled; propertiesValue["isEventTypeSchemaChangeEnabled"] = parameters.Properties.IsEventTypeSchemaChangeEnabled; propertiesValue["isEventTypeDataChangesEnabled"] = parameters.Properties.IsEventTypeDataChangesEnabled; propertiesValue["isEventTypeSecurityExceptionsEnabled"] = parameters.Properties.IsEventTypeSecurityExceptionsEnabled; propertiesValue["isEventTypeGrantRevokePermissionsEnabled"] = parameters.Properties.IsEventTypeGrantRevokePermissionsEnabled; if (parameters.Properties.StorageAccountName != null) { propertiesValue["storageAccountName"] = parameters.Properties.StorageAccountName; } if (parameters.Properties.StorageAccountKey != null) { propertiesValue["storageAccountKey"] = parameters.Properties.StorageAccountKey; } if (parameters.Properties.SecondaryStorageAccountKey != null) { propertiesValue["secondaryStorageAccountKey"] = parameters.Properties.SecondaryStorageAccountKey; } if (parameters.Properties.StorageTableEndpoint != null) { propertiesValue["storageTableEndpoint"] = parameters.Properties.StorageTableEndpoint; } if (parameters.Properties.StorageAccountResourceGroupName != null) { propertiesValue["storageAccountResourceGroupName"] = parameters.Properties.StorageAccountResourceGroupName; } if (parameters.Properties.StorageAccountSubscriptionId != null) { propertiesValue["storageAccountSubscriptionId"] = parameters.Properties.StorageAccountSubscriptionId; } if (parameters.Properties.ProxyDnsName != null) { propertiesValue["proxyDnsName"] = parameters.Properties.ProxyDnsName; } if (parameters.Properties.ProxyPort != null) { propertiesValue["proxyPort"] = parameters.Properties.ProxyPort; } propertiesValue["useServerDefault"] = parameters.Properties.UseServerDefault; propertiesValue["isBlockDirectAccessEnabled"] = parameters.Properties.IsBlockDirectAccessEnabled; requestContent = requestDoc.ToString(Formatting.Indented); httpRequest.Content = new StringContent(requestContent, Encoding.UTF8); httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { Tracing.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { Tracing.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; if (statusCode != HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, requestContent, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); if (shouldTrace) { Tracing.Error(invocationId, ex); } throw ex; } // Create Result OperationResponse result = null; result = new OperationResponse(); result.StatusCode = statusCode; if (httpResponse.Headers.Contains("x-ms-request-id")) { result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (shouldTrace) { Tracing.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }
/// <summary> /// 处理是否添加好友的结果 /// </summary> /// <param name="response"></param> public override void OnOperationResponse(OperationResponse response) { m_MainPanel.OnAddResult(response); }
void IOutgoingServerPeer.OnOperationResponse(IRpcProtocol protocol, OperationResponse operationResponse, SendParameters sendParameters) { #if MMO_DEBUG _logger.DebugFormat("[OnServerOperationResponse]: OperationResponse (OpCode={0}) is not handled", operationResponse.OperationCode); #endif }
private static bool HandleInsert <T>(T dataEntity, Param[] parameters, PropertyInfo identityProperty, IDictionary <PropertyInfo, ReflectedProperty> propertyMap, OperationResponse response) where T : class { var success = response != null && response.RecordsAffected > 0; if (!success) { return(false); } if (identityProperty != null) { var identityValue = parameters.Single(p => p.Name == identityProperty.Name).Value; if (identityValue != null && !Convert.IsDBNull(identityValue)) { Reflector.Property.Set(dataEntity, identityProperty.Name, identityValue); } } Identity.Get <T>().Set(dataEntity); var outputProperties = propertyMap .Where(p => p.Key.CanWrite && p.Value != null && (p.Value.Direction == ParameterDirection.InputOutput || p.Value.Direction == ParameterDirection.Output)) .Select(p => p.Key); SetOutputParameterValues(dataEntity, outputProperties, propertyMap, parameters); ObjectFactory.TrySetObjectState(dataEntity); if (!(dataEntity is IAuditableDataEntity)) { return(true); } var logProvider = ConfigurationFactory.Get <T>().AuditLogProvider; if (logProvider != null) { logProvider.Write(new AuditLog <T>(ObjectFactory.OperationInsert, default(T), dataEntity)); } return(true); }
public abstract void OnOperationResponse(OperationResponse opResponse);
public override void OnOperationResponse(OperationResponse response) { m_RegisterPanel.OnRegisterResponse(response); }
public void OnOperationResponse(OperationResponse operationResponse) { }
public WebRpcResponse(OperationResponse response) { }
public void OnWebRpcResponse(OperationResponse response) { }
/// <summary> /// The Delete Virtual Machine Image operation deletes the specified /// virtual machine image. /// </summary> /// <param name='vmImageName'> /// Required. The name of the virtual machine image to delete. /// </param> /// <param name='deleteFromStorage'> /// Required. Specifies that the source blob for the image should also /// be deleted from storage. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// The response body contains the status of the specified asynchronous /// operation, indicating whether it has succeeded, is inprogress, or /// has failed. Note that this status is distinct from the HTTP status /// code returned for the Get Operation Status operation itself. If /// the asynchronous operation succeeded, the response body includes /// the HTTP status code for the successful request. If the /// asynchronous operation failed, the response body includes the HTTP /// status code for the failed request and error information regarding /// the failure. /// </returns> public async System.Threading.Tasks.Task <OperationStatusResponse> DeleteAsync(string vmImageName, bool deleteFromStorage, CancellationToken cancellationToken) { ComputeManagementClient client = this.Client; bool shouldTrace = CloudContext.Configuration.Tracing.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = Tracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("vmImageName", vmImageName); tracingParameters.Add("deleteFromStorage", deleteFromStorage); Tracing.Enter(invocationId, this, "DeleteAsync", tracingParameters); } try { if (shouldTrace) { client = this.Client.WithHandler(new ClientRequestTrackingHandler(invocationId)); } cancellationToken.ThrowIfCancellationRequested(); OperationResponse response = await client.VirtualMachineVMImages.BeginDeletingAsync(vmImageName, deleteFromStorage, cancellationToken).ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); OperationStatusResponse result = await client.GetOperationStatusAsync(response.RequestId, cancellationToken).ConfigureAwait(false); int delayInSeconds = 30; while ((result.Status != OperationStatus.InProgress) == false) { cancellationToken.ThrowIfCancellationRequested(); await TaskEx.Delay(delayInSeconds * 1000, cancellationToken).ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); result = await client.GetOperationStatusAsync(response.RequestId, cancellationToken).ConfigureAwait(false); delayInSeconds = 30; } if (shouldTrace) { Tracing.Exit(invocationId, result); } if (result.Status != OperationStatus.Succeeded) { if (result.Error != null) { CloudException ex = new CloudException(result.Error.Code + " : " + result.Error.Message); ex.ErrorCode = result.Error.Code; ex.ErrorMessage = result.Error.Message; if (shouldTrace) { Tracing.Error(invocationId, ex); } throw ex; } else { CloudException ex = new CloudException(""); if (shouldTrace) { Tracing.Error(invocationId, ex); } throw ex; } } return(result); } finally { if (client != null && shouldTrace) { client.Dispose(); } } }
/// <summary> /// EntitleResource is used only for 3rd party Store providers. Each /// subscription must be entitled for the resource before creating /// that particular type of resource. /// </summary> /// <param name='parameters'> /// Required. Parameters provided to the EntitleResource method. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public async System.Threading.Tasks.Task <OperationResponse> EntitleResourceAsync(EntitleResourceParameters parameters, CancellationToken cancellationToken) { // Validate if (parameters == null) { throw new ArgumentNullException("parameters"); } if (parameters.ResourceNamespace == null) { throw new ArgumentNullException("parameters.ResourceNamespace"); } if (parameters.ResourceType == null) { throw new ArgumentNullException("parameters.ResourceType"); } // Tracing bool shouldTrace = CloudContext.Configuration.Tracing.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = Tracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("parameters", parameters); Tracing.Enter(invocationId, this, "EntitleResourceAsync", tracingParameters); } // Construct URL string url = (this.Credentials.SubscriptionId != null ? this.Credentials.SubscriptionId.Trim() : "") + "/EntitleResource"; string baseUrl = this.BaseUri.AbsoluteUri; // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.Length - 1] == '/') { baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); } if (url[0] == '/') { url = url.Substring(1); } url = baseUrl + "/" + url; url = url.Replace(" ", "%20"); // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Post; httpRequest.RequestUri = new Uri(url); // Set Headers httpRequest.Headers.Add("x-ms-version", "2013-03-01"); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Serialize Request string requestContent = null; XDocument requestDoc = new XDocument(); XElement entitleResourceElement = new XElement(XName.Get("EntitleResource", "http://schemas.microsoft.com/windowsazure")); requestDoc.Add(entitleResourceElement); XElement resourceProviderNameSpaceElement = new XElement(XName.Get("ResourceProviderNameSpace", "http://schemas.microsoft.com/windowsazure")); resourceProviderNameSpaceElement.Value = parameters.ResourceNamespace; entitleResourceElement.Add(resourceProviderNameSpaceElement); XElement typeElement = new XElement(XName.Get("Type", "http://schemas.microsoft.com/windowsazure")); typeElement.Value = parameters.ResourceType; entitleResourceElement.Add(typeElement); XElement registrationDateElement = new XElement(XName.Get("RegistrationDate", "http://schemas.microsoft.com/windowsazure")); registrationDateElement.Value = parameters.RegistrationDate.ToString(); entitleResourceElement.Add(registrationDateElement); requestContent = requestDoc.ToString(); httpRequest.Content = new StringContent(requestContent, Encoding.UTF8); httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/xml"); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { Tracing.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { Tracing.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; if (statusCode != HttpStatusCode.Accepted) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, requestContent, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); if (shouldTrace) { Tracing.Error(invocationId, ex); } throw ex; } // Create Result OperationResponse result = null; result = new OperationResponse(); result.StatusCode = statusCode; if (httpResponse.Headers.Contains("x-ms-request-id")) { result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (shouldTrace) { Tracing.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }
public override void OnOperationResponse(OperationResponse operationResponse) { throw new NotImplementedException(); }
/// <summary> /// Requests the given item is updated by applying the given delta. /// </summary> /// <param name="item">The original item to be updated.</param> /// <param name="delta">A dictionary with new property values.</param> /// <param name="cancellationToken">A cancellation token for the async operation.</param> /// <returns>A new OperationResponse instance that contains the results of the operation.</returns> public async Task <OperationResponse> UpdateAsync(FileExplorerItem item, IDictionary <string, object> delta, CancellationToken cancellationToken) { var result = new OperationResponse(); await Task.Run(() => { if (!delta.ContainsKey("Path")) { result.ErrorMessage = "Only Path property update supported"; return; } var tempItem = new FileExplorerItem { Path = delta["Path"]?.ToString() }; var targetNode = _root.Where(x => x.Path() == tempItem.Path).FirstOrDefault(); var targetParentNode = targetNode is null ? _root.Where(x => x.Path() == tempItem.ParentPath).FirstOrDefault() : targetNode.Parent; if (targetParentNode is null) { result.ErrorMessage = "Invalid Path: Parent item not found"; return; } var itemNode = _root.Where(x => x.Path() == item.Path).FirstOrDefault(); if (itemNode is null) { result.ErrorMessage = "Item not found"; return; } // if copy then create a deep clone of the copied item var isCopy = delta.ContainsKey("Copy") && string.Equals(delta["Copy"].ToString(), "true", StringComparison.OrdinalIgnoreCase); if (isCopy) { itemNode = itemNode.Clone(); itemNode.DateModified = DateTimeOffset.UtcNow; } // target path does not exist - move or rename if (targetNode == null) { if (itemNode.Parent != null) { itemNode.Parent.Items.Remove(itemNode); } targetParentNode.Items.Add(itemNode); itemNode.Parent = targetParentNode; itemNode.Name = tempItem.Name; } else { // target path exists if (targetNode.Type == FileExplorerItemType.File) { // conflict - file already exists result.ErrorMessage = "Item already exists"; return; } // target is folder - so move item into if (itemNode.Parent != null) { itemNode.Parent.Items.Remove(itemNode); } targetNode.Items.Add(itemNode); itemNode.Parent = targetNode; } result.Success = true; }).ConfigureAwait(false); return(result); }
/// <summary> /// 创建副本怪物信息 /// </summary> /// <param name="request"></param> /// <param name="response"></param> /// <param name="peer"></param> /// <param name="sendParameters"></param> void OnCreateMonster(OperationRequest request, OperationResponse response, ClientPeer peer, SendParameters sendParameters) { if (m_pInitMonsterPeer.Contains(peer)) { Helper.Log("已经为:" + peer.m_curRole.Name + "--创建了怪物列表"); return; } Dictionary <byte, object> dic = request.Parameters; object value; if (dic.TryGetValue((byte)ParameterCode.monsterInfo, out value)) { // 为当前peer创建RoomTeam List <ClientPeer> pPeerList = new List <ClientPeer>(); if (null == peer.m_myTeam || peer.m_myTeam.m_pTeam.Count == 0) { pPeerList.Add(peer); m_pInitMonsterPeer.Add(peer); } else { pPeerList = peer.m_myTeam.m_pTeam; m_pInitMonsterPeer.AddRange(pPeerList); } MyRoomTeam myRoomTeam = new MyRoomTeam(pPeerList); string strRoomId = value.ToString(); Helper.Log("接受到副本创建怪物申请:" + strRoomId); RoomInfo targetRoom = null; for (int i = 0; i < m_roomInfo.m_pRoom.Count; ++i) { RoomInfo curRoom = m_roomInfo.m_pRoom[i]; if (curRoom.m_nID.ToString().Equals(strRoomId)) { targetRoom = curRoom; break; } } if (targetRoom != null) { // 保存角色出生点位置 if (null == peer.m_pRoleSpawn) { peer.m_pRoleSpawn = targetRoom.m_pSpawn; } for (int j = 0; j < targetRoom.m_pTrigger.Count; ++j) { TriggerInfo curTrigger = targetRoom.m_pTrigger[j]; if (curTrigger != null) { m_pTriggerPos.Clear(); List <Vector3> pCruisePos = new List <Vector3>(); // MonsterModel ID string strModelID = curTrigger.m_strModelID; int nNum = curTrigger.m_nNum; if (nNum > curTrigger.m_pPosList.Count) { nNum = curTrigger.m_pPosList.Count; } string strRes; strRes = ""; // 怪物数据:GUID,ModelID,x,y,z,cruiseID| for (int k = 0; k < nNum; ++k) { TriggerPosInfo curTiggerPos = curTrigger.m_pPosList[k]; string strGUIID = Guid.NewGuid().ToString(); strRes += strGUIID + "," + strModelID + "," + curTiggerPos.m_fX.ToString() + "," + curTiggerPos.m_fY.ToString() + "," + curTiggerPos.m_fZ.ToString() + "," + curTrigger.m_nID.ToString() + "|"; dic.Clear(); dic.Add((byte)ParameterCode.monsterInfo, strRes); Vector3 vPos = new Vector3(curTiggerPos.m_fX, curTiggerPos.m_fY, curTiggerPos.m_fZ); m_pTriggerPos.Add(vPos); pCruisePos.Add(vPos); // GetMonsterInfo Monster curMonster = GetMonster(strModelID); if (curMonster != null) { curMonster.m_strGuid = strGUIID; curMonster.m_curPos = vPos; curMonster.m_targetPos = vPos; curMonster.m_ActionType = 1; } // 保存Monster myRoomTeam.AddMonster(curMonster); // 保存Monster初始位置 myRoomTeam.InitMonsterPos(strGUIID, vPos); } // 保存巡航点 myRoomTeam.SetMonsterCruise(strModelID, pCruisePos); // 通知队伍中客户端创建该怪物出生点的怪物 myRoomTeam.SendCreateMonsterEvent(dic); } } // 开启定时器 // myRoomTeam.StartTimer(); } } }
/// <summary> /// Unregister your subscription to use Windows Azure Web Sites. /// </summary> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public async System.Threading.Tasks.Task <OperationResponse> UnregisterSubscriptionAsync(CancellationToken cancellationToken) { // Validate // Tracing bool shouldTrace = CloudContext.Configuration.Tracing.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = Tracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); Tracing.Enter(invocationId, this, "UnregisterSubscriptionAsync", tracingParameters); } // Construct URL string url = new Uri(this.BaseUri, "/").AbsoluteUri + this.Credentials.SubscriptionId + "/services?"; url = url + "service=website"; url = url + "&action=unregister"; // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Put; httpRequest.RequestUri = new Uri(url); // Set Headers httpRequest.Headers.Add("x-ms-version", "2013-08-01"); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { Tracing.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { Tracing.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; if (statusCode != HttpStatusCode.Accepted) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false), CloudExceptionType.Xml); if (shouldTrace) { Tracing.Error(invocationId, ex); } throw ex; } // Create Result OperationResponse result = null; result = new OperationResponse(); result.StatusCode = statusCode; if (httpResponse.Headers.Contains("x-ms-request-id")) { result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (shouldTrace) { Tracing.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }
public void OnOperationResponse(OperationResponse operationResponse) { Listener?.OnOperationResponse(operationResponse); }
/// <summary> /// Deletes an Azure SQL Database Server Firewall rule. /// </summary> /// <param name='resourceGroupName'> /// Required. The name of the Resource Group to which the server /// belongs. /// </param> /// <param name='serverName'> /// Required. The name of the Azure SQL Database Server on which the /// database is hosted. /// </param> /// <param name='firewallRule'> /// Required. The name of the Azure SQL Database Server Firewall Rule. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// A standard service response including an HTTP status code and /// request ID. /// </returns> public async Task <OperationResponse> DeleteAsync(string resourceGroupName, string serverName, string firewallRule, CancellationToken cancellationToken) { // Validate if (resourceGroupName == null) { throw new ArgumentNullException("resourceGroupName"); } if (serverName == null) { throw new ArgumentNullException("serverName"); } if (firewallRule == null) { throw new ArgumentNullException("firewallRule"); } // Tracing bool shouldTrace = CloudContext.Configuration.Tracing.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = Tracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("serverName", serverName); tracingParameters.Add("firewallRule", firewallRule); Tracing.Enter(invocationId, this, "DeleteAsync", tracingParameters); } // Construct URL string url = "/subscriptions/" + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId) + "/resourceGroups/" + Uri.EscapeDataString(resourceGroupName) + "/providers/Microsoft.Sql/servers/" + Uri.EscapeDataString(serverName) + "/firewallRules/" + Uri.EscapeDataString(firewallRule) + "?"; url = url + "api-version=2014-04-01"; string baseUrl = this.Client.BaseUri.AbsoluteUri; // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.Length - 1] == '/') { baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); } if (url[0] == '/') { url = url.Substring(1); } url = baseUrl + "/" + url; url = url.Replace(" ", "%20"); // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Delete; httpRequest.RequestUri = new Uri(url); // Set Headers // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { Tracing.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { Tracing.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; if (statusCode != HttpStatusCode.NoContent) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); if (shouldTrace) { Tracing.Error(invocationId, ex); } throw ex; } // Create Result OperationResponse result = null; result = new OperationResponse(); result.StatusCode = statusCode; if (httpResponse.Headers.Contains("x-ms-request-id")) { result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (shouldTrace) { Tracing.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }
void IPhotonPeerListener.OnOperationResponse(OperationResponse operationResponse) { Debug.Log("ruizi!"); Application.Quit(); //throw new System.NotImplementedException (); }
public override void OnResponse(OperationResponse response) { base.OnResponse(response); _waitServer = false; OperationCode opCode = (OperationCode)response.OperationCode; ErrorCode errCode = (ErrorCode)response.ReturnCode; if (errCode != ErrorCode.Success) { Debug.Log(string.Format("ResponseReceived, OperationCode = {0}, ReturnCode = {1}, DebugMsg = {2}", opCode, errCode, response.DebugMessage)); this.HandleErrorCode(errCode); return; } switch (opCode) { case OperationCode.ShopBuy: if (errCode == ErrorCode.Success) { byte[] userData = (byte[])response[(byte)ParameterCode.UserBase]; int itemKind = (int)response[(byte)ParameterCode.ItemKind]; byte[] objData = (byte[])response[(byte)ParameterCode.ShopItem]; GameUser.UserBase miniUser = Serialization.LoadStruct <GameUser.UserBase>(userData); GameManager.GameUser.Base.Gold = miniUser.Gold; GameManager.GameUser.Base.Silver = miniUser.Silver; if (itemKind == (int)ItemKind.Hero) { UserRole userRole = Serialization.Load <UserRole>(objData); userRole.GameRole = (GameRole)GameManager.GameHeroes[userRole.Base.RoleId]; GameManager.GameUser.UserRoles.Add(userRole); } _manager.OnResponseBuyHero(); } break; case OperationCode.UserUpdate: { SubCode subCode = (SubCode)response.Parameters[(byte)ParameterCode.SubCode]; if (errCode == ErrorCode.Success) { switch (subCode) { case SubCode.CheckCash: { byte[] userData = (byte[])response[(byte)ParameterCode.UserBase]; GameUser.UserBase miniUser = Serialization.LoadStruct <GameUser.UserBase>(userData); GameManager.GameUser.Base = miniUser; _manager.OnRefreshGold(); } break; } } } break; default: break; } }
/// <summary> /// The try parse operation response. /// </summary> /// <param name = "data"> /// The data. /// </param> /// <param name = "reliability"> /// The reliability. /// </param> /// <param name = "channelId"> /// The channel id. /// </param> /// <param name = "operationResponse"> /// The operation response. /// </param> /// <returns> /// An exception. /// </returns> /// <exception cref = "NotSupportedException"> /// This method is not supported. /// </exception> public bool TryParseOperationResponse(byte[] data, Reliability reliability, byte channelId, out OperationResponse operationResponse) { throw new NotSupportedException(); }
/// <summary>WebRpcのレスポンスがあった時</summary> public override void OnWebRpcResponse(OperationResponse response) { Debug.Log("OnWebRpcResponse"); }
private static bool HandleUpdate <T>(T dataEntity, IEnumerable <PropertyInfo> outputProperties, IDictionary <PropertyInfo, ReflectedProperty> propertyMap, Param[] parameters, bool supportsChangeTracking, OperationResponse response) where T : class { var success = response != null && response.RecordsAffected > 0; if (!success) { return(false); } Identity.Get <T>().Set(dataEntity); SetOutputParameterValues(dataEntity, outputProperties, propertyMap, parameters); if (supportsChangeTracking) { ((ITrackableDataEntity)dataEntity).ObjectState = ObjectState.Clean; } if (!(dataEntity is IAuditableDataEntity)) { return(true); } var logProvider = ConfigurationFactory.Get <T>().AuditLogProvider; if (logProvider != null) { logProvider.Write(new AuditLog <T>(ObjectFactory.OperationUpdate, (dataEntity.Old() ?? dataEntity), dataEntity)); } return(true); }
protected override void OnOperationResponse(OperationResponse operationResponse, SendParameters sendParameters) { _serverPeer.OnOperationResponse(operationResponse, sendParameters); }