public IEnumerator TestDownloadRemoteAssetBundle(System.Action <string, AssetBundle> callback) { Debug.Log("Testing RemoteAssetBundleUtils.DownloadAssetBundle"); AssetBundleInfo info = new AssetBundleInfo(TestConstants.TEST_BUNDLE_NAME, TestConstants.TEST_BUNDLE_PATH); FCMMessage message = new FCMMessage("Test Upload", "This is a test", null); Task <RemoteAssetBundle> task = RemoteAssetBundleUtils.UploadAssetBundle(TestConstants.TEST_SERVER_URL, info, message, null, TestConstants.JWT_TOKEN_NAME); while (!task.IsCompleted) { yield return(new WaitForFixedUpdate()); } RemoteAssetBundle bundle = task.Result; Assert.AreEqual(bundle.toHash128().isValid, true); yield return(StartCoroutine(RemoteAssetBundleUtils.DownloadAssetBundleAsync(TestConstants.TEST_SERVER_URL, bundle, callback))); // Try to download again and check the cache yield return(StartCoroutine(RemoteAssetBundleUtils.DownloadAssetBundleAsync(TestConstants.TEST_SERVER_URL, bundle, TestDownloadCachedAsset))); // Now try to delete it Task <HttpStatusCode> t = RemoteAssetBundleUtils.DeleteAssetBundle(TestConstants.TEST_SERVER_URL, bundle); while (!t.IsCompleted) { yield return(new WaitForFixedUpdate()); } HttpStatusCode status = t.Result; Assert.AreEqual(status, HttpStatusCode.OK); Debug.Log("Passed"); finished = true; }
public IEnumerator VerifyUploadAssetBundle() { Debug.Log("Testing RemoteAssetBundleUtils.UploadAssetBundle"); AssetBundleInfo info = new AssetBundleInfo(TestConstants.TEST_BUNDLE_NAME, TestConstants.TEST_BUNDLE_PATH); FCMMessage message = new FCMMessage("Test Upload", "This is a test", null); Task <RemoteAssetBundle> task = RemoteAssetBundleUtils.UploadAssetBundle(TestConstants.TEST_SERVER_URL, info, message, null, TestConstants.JWT_TOKEN_NAME); while (!task.IsCompleted) { yield return(null); } bundle = task.Result; Assert.IsTrue(bundle.toHash128().isValid); Assert.AreEqual(Application.productName, bundle.appName); }
public async Task <FCMResponse> PostMessage(FCMMessage message) { var request = new RestRequest("fcm/send", Method.POST) { JsonSerializer = _jsonSerializer }; request.AddJsonBody(message); var response = await _restClient.ExecuteTaskAsync <FCMResponse>(request); var statusCode = response.StatusCode; var responseData = response.Data; if (statusCode == HttpStatusCode.OK) { return(responseData); } else { throw new FCMException(responseData); } }
public async Task <ShoppingCartDetailDTO> PutShopingCartAction(ShoppingCartDetailDTO model) { var output = new ShoppingCartDetailDTO(); var result = await _repoWrapper.ShoppingCart.PostShopingCartAction(model); if (result) { output.ErrorCode = "00"; output.Message = "Xử lý thành công"; var shopingCartDetail = await _repoWrapper.ShoppingCart.FirstOrDefaultAsync(x => x.Id == model.Id); var product = await _repoWrapper.Product.FirstOrDefaultAsync(x => x.Product_ID == shopingCartDetail.ProductId); string message = ""; string title = ""; FCMMessageOutputDTO notiModel = new FCMMessageOutputDTO(); if (model.StatusCart == 2) // Chờ xác nhận { title = "Xác nhận đơn hàng"; message = $"Đơn hàng {shopingCartDetail.ShopingCartCode}, đã được cửa hàng xác nhận"; notiModel.Data.formId = "CART_SELL"; notiModel.Topic = shopingCartDetail.CreateBy.ToString(); // Noti cho người mua notiModel.Data.id = shopingCartDetail.Id; notiModel.Data.notiSpecType = 0; } else if (model.StatusCart == 3) //Hoàn thành { title = "Xác nhận đơn hàng hoàn tất"; message = $"Đơn hàng {shopingCartDetail.ShopingCartCode}, đã được hoàn tất"; notiModel.Data.formId = "CART_SELL"; notiModel.Topic = shopingCartDetail.CreateBy.ToString(); // Noti cho người mua notiModel.Data.id = shopingCartDetail.Id; notiModel.Data.notiSpecType = 0; } else if (model.StatusCart == 4) // Đã hủy { if (model.IsCancelByBuyer == 1) { title = "Đơn hàng bị hủy"; message = $"Đơn hàng {shopingCartDetail.ShopingCartCode}, đã hủy bởi người mua - lý do: {model.ReasonCancel}"; notiModel.Data.formId = "CART_BUY"; notiModel.Topic = product?.CreateBy.ToString(); // Thông báo tới gian hàng notiModel.Data.id = shopingCartDetail.Id; notiModel.Data.notiSpecType = 0; } else if (model.IsCancelByBuyer == 0) { title = "Đơn hàng bị hủy"; message = $"Đơn hàng {shopingCartDetail.ShopingCartCode}, đã hủy bởi người bán - lý do: {model.ReasonCancel}"; notiModel.Data.formId = "CART_SELL"; notiModel.Topic = shopingCartDetail.CreateBy.ToString(); // Noti cho người mua notiModel.Data.id = shopingCartDetail.Id; notiModel.Data.notiSpecType = 0; } } notiModel.Notification.Title = title; notiModel.Notification.Body = message; //notiModel.Topic = product?.CreateBy.ToString(); // Thông báo tới gian hàng var pushNoti = Utils.Util.SendMessageFirebase(notiModel); FCMMessage fCMMessage = new FCMMessage(); fCMMessage.Title = notiModel.Notification.Title; fCMMessage.Body = notiModel.Notification.Body; fCMMessage.CreateBy = product?.CreateBy; fCMMessage.CreateDate = DateTime.Now; fCMMessage.LastEditBy = product?.CreateBy; fCMMessage.LastEditDate = DateTime.Now; fCMMessage.UserID = product?.CreateBy; fCMMessage.Topic = notiModel.Topic; fCMMessage.NotificationType = notiModel.Data.notifyType; fCMMessage.Form_ID = notiModel.Data.formId; fCMMessage.ParameterId = notiModel.Data.id; fCMMessage.FullUrl = notiModel.Data.fullUrl; fCMMessage.FullUrlImage = notiModel.Data.fullUrlImage; fCMMessage.NotiSpecType = 1; fCMMessage.IsPinTop = notiModel.Data.isPinTop; fCMMessage.FormNameApp = notiModel.Data.formAppName; fCMMessage.ProductTypeId = notiModel.Data.typeId; fCMMessage.CategoryId = notiModel.Data.categoryId; fCMMessage.FullUrlImage = $"https://hanoma-cdn.s3.cloud.cmctelecom.vn/DataMobile/Notify/notifyDefault.png"; fCMMessage.Content = message; fCMMessage.FullUrl = ""; fCMMessage.HasRead = 0; await _repoWrapper.FCMMessage.AddNewFCMMessage(fCMMessage); } else { output.ErrorCode = "01"; output.Message = "Có lỗi trong quá trình xử lý đơn hàng"; } return(output); }
//[Authorize] public async Task <ModelBaseStatus> PostShoppingCart(List <PostShoppingCart> model) { var output = new ModelBaseStatus(); var result = await _repoWrapper.ShoppingCart.PostShopingCart(model); if (result.Count != 0) { output.ErrorCode = "00"; output.Message = "Đặt hàng thành công"; foreach (var p in result) { var product = await _repoWrapper.Product.FirstOrDefaultAsync(x => x.Product_ID == p.ProductId); FCMMessageOutputDTO notiModel = new FCMMessageOutputDTO(); notiModel.Notification.Title = $"Đơn hàng được tạo mới"; notiModel.Notification.Body = $"{DateTime.Now.ToString("dd/MM/yyyy")} Đơn hàng {p.ShopingCartCode} vừa được tạo mới"; notiModel.Topic = product?.CreateBy.ToString(); // Thông báo tới gian hàng notiModel.Data.formId = "CART_BUY"; notiModel.Data.id = p.Id; // ShoppingCartDetail ID notiModel.Data.notiSpecType = 0; var pushNoti = Utils.Util.SendMessageFirebase(notiModel); FCMMessage fCMMessage = new FCMMessage(); fCMMessage.Title = notiModel.Notification.Title; fCMMessage.Body = notiModel.Notification.Body; fCMMessage.CreateBy = product?.CreateBy; fCMMessage.CreateDate = DateTime.Now; fCMMessage.LastEditBy = product?.CreateBy; fCMMessage.LastEditDate = DateTime.Now; fCMMessage.UserID = product?.CreateBy; fCMMessage.Topic = product?.CreateBy.ToString(); // Thông báo tới gian hàng fCMMessage.NotificationType = notiModel.Data.notifyType; fCMMessage.Form_ID = notiModel.Data.formId; fCMMessage.ParameterId = notiModel.Data.id; fCMMessage.FullUrl = notiModel.Data.fullUrl; fCMMessage.FullUrlImage = notiModel.Data.fullUrlImage; fCMMessage.NotiSpecType = 1; fCMMessage.IsPinTop = notiModel.Data.isPinTop; fCMMessage.FormNameApp = notiModel.Data.formAppName; fCMMessage.ProductTypeId = notiModel.Data.typeId; fCMMessage.CategoryId = notiModel.Data.categoryId; fCMMessage.FullUrlImage = $"https://hanoma-cdn.s3.cloud.cmctelecom.vn/DataMobile/Notify/notifyDefault.png"; fCMMessage.Content = $"{DateTime.Now.ToString("dd/MM/yyyy")} Đơn hàng {p.ShopingCartCode} vừa được tạo mới"; fCMMessage.FullUrl = ""; fCMMessage.HasRead = 0; await _repoWrapper.FCMMessage.AddNewFCMMessage(fCMMessage); } } else { output.ErrorCode = "01"; output.Message = "Có lỗi trong quá trình đặt hàng"; FCMMessageOutputDTO notiModel = new FCMMessageOutputDTO(); notiModel.Notification.Title = "Có lỗi trong quá trình đặt hàng"; notiModel.Notification.Body = "Có lỗi trong quá trình đặt hàng"; notiModel.Topic = model[0].UserId; // Thông báo tới chính người dùng notiModel.Data.formId = "SHOPPINGCARTNSS"; notiModel.Data.notiSpecType = 0; var pushNoti = Utils.Util.SendMessageFirebase(notiModel); FCMMessage fCMMessage = new FCMMessage(); fCMMessage.Title = notiModel.Notification.Title; fCMMessage.Body = notiModel.Notification.Body; fCMMessage.CreateBy = Guid.Parse(model[0].UserId); fCMMessage.CreateDate = DateTime.Now; fCMMessage.LastEditBy = Guid.Parse(model[0].UserId); fCMMessage.LastEditDate = DateTime.Now; fCMMessage.UserID = Guid.Parse(model[0].UserId); fCMMessage.Topic = model[0].UserId; // Thông báo tới chính người dùng fCMMessage.NotificationType = notiModel.Data.notifyType; fCMMessage.Form_ID = notiModel.Data.formId; fCMMessage.ParameterId = notiModel.Data.id; fCMMessage.FullUrl = notiModel.Data.fullUrl; fCMMessage.FullUrlImage = notiModel.Data.fullUrlImage; fCMMessage.NotiSpecType = 1; fCMMessage.IsPinTop = notiModel.Data.isPinTop; fCMMessage.FormNameApp = notiModel.Data.formAppName; fCMMessage.ProductTypeId = notiModel.Data.typeId; fCMMessage.CategoryId = notiModel.Data.categoryId; fCMMessage.FullUrlImage = $"https://hanoma-cdn.s3.cloud.cmctelecom.vn/DataMobile/Notify/notifyDefault.png"; fCMMessage.Content = "Có lỗi trong quá trình đặt hàng"; fCMMessage.FullUrl = ""; fCMMessage.HasRead = 0; await _repoWrapper.FCMMessage.AddNewFCMMessage(fCMMessage); } return(output); }
// Async Server Methods public async void UploadAssetBundle(AssetBundleInfo assetBundleInfo, string appName, FCMMessage message) { Object jwt = GUIConfigureTab.jwtFile; string endpoint = FormatEndpoint(uploadEndpoint); if (!string.IsNullOrEmpty(endpoint)) { string jwtName = jwt ? jwt.name : null; try { EditorUtility.DisplayProgressBar("Remote Asset Bundles", string.Format("Uploading Asset Bundle {0} from {1}", assetBundleInfo.name, appName), 1.0f); RemoteAssetBundle ab = await RemoteAssetBundleUtils.UploadAssetBundle(endpoint, assetBundleInfo, message, appName, jwtName); GUIAddTab.AddMessage(string.Format("Successfully Uploaded Asset Bundle {0}", assetBundleInfo.name), MessageStatus.Success); EditorUtility.ClearProgressBar(); } catch (System.Exception ex) { EditorUtility.ClearProgressBar(); GUIAddTab.AddMessage(string.Format("Unable to upload Asset Bundle {0}. \n Reason: {1}", assetBundleInfo.name, ex.Message), MessageStatus.Error); throw; } } }
public RemoteAssetBundleGUIAddTab(string label) : base(label) { UploadMessage = new FCMMessage(null, null, null); }
public async Task <FCMMessageDTO> PushNoti([FromBody] FCMMessageDTO model) { try { //Sent Noti to FireBase var output = Utils.Util.SendMessageFirebase(model.FCMMsg); //Save Message //int FCMMessageID = _repoWrapper.FCMMessage.AddNewData(UserID); //Update Data FCMMessage fCMMessage = new FCMMessage(); fCMMessage.Title = model.FCMMsg.Notification.Title; fCMMessage.Body = model.FCMMsg.Notification.Body; fCMMessage.CreateBy = model.UserId; fCMMessage.CreateDate = DateTime.Now; fCMMessage.LastEditBy = model.UserId; fCMMessage.LastEditDate = DateTime.Now; fCMMessage.UserID = model.UserId; fCMMessage.Topic = model.FCMMsg.Topic; fCMMessage.NotificationType = model.FCMMsg.Data.notifyType; fCMMessage.Form_ID = model.FCMMsg.Data.formId; fCMMessage.ParameterId = model.FCMMsg.Data.id; fCMMessage.FullUrl = model.FCMMsg.Data.fullUrl; fCMMessage.FullUrlImage = model.FCMMsg.Data.fullUrlImage; fCMMessage.NotiSpecType = model.FCMMsg.Data.notiSpecType; fCMMessage.IsPinTop = model.FCMMsg.Data.isPinTop; fCMMessage.FormNameApp = model.FCMMsg.Data.formAppName; fCMMessage.ProductTypeId = model.FCMMsg.Data.typeId; fCMMessage.CategoryId = model.FCMMsg.Data.categoryId; fCMMessage.HasRead = 0; await _repoWrapper.FCMMessage.AddNewFCMMessage(fCMMessage); if (model.FCMMsg.Topic == "Global") { var lstMsg = _repoWrapper.FCMClient.FindAll().ToList(); foreach (var p in lstMsg) { if (!String.IsNullOrEmpty(p.UserID.ToString())) { FCMMessage fCMMessage1 = new FCMMessage(); fCMMessage1.Title = model.FCMMsg.Notification.Title; fCMMessage1.Body = model.FCMMsg.Notification.Body; fCMMessage1.CreateBy = model.UserId; fCMMessage1.CreateDate = DateTime.Now; fCMMessage1.LastEditBy = model.UserId; fCMMessage1.LastEditDate = DateTime.Now; fCMMessage1.UserID = model.UserId; fCMMessage1.Topic = p.UserID.ToString(); fCMMessage1.NotificationType = model.FCMMsg.Data.notifyType; fCMMessage1.Form_ID = model.FCMMsg.Data.formId; fCMMessage1.CategoryId = model.FCMMsg.Data.categoryId; fCMMessage1.ParameterId = model.FCMMsg.Data.id; fCMMessage1.FullUrl = model.FCMMsg.Data.fullUrl; fCMMessage1.FullUrlImage = model.FCMMsg.Data.fullUrlImage; fCMMessage1.NotiSpecType = model.FCMMsg.Data.notiSpecType; fCMMessage1.IsPinTop = model.FCMMsg.Data.isPinTop; fCMMessage1.FormNameApp = model.FCMMsg.Data.formAppName; fCMMessage1.ProductTypeId = model.FCMMsg.Data.typeId; fCMMessage1.HasRead = 0; await _repoWrapper.FCMMessage.AddNewFCMMessage(fCMMessage1); } } } } catch (Exception ex) { _logger.LogError($"FCMMessageDTO: {ex.ToString()}"); model.ErrorCode = "005"; model.Message = Utils.ConstMessage.GetMsgConst("005"); } return(model); }