From 62d77d3bb8e7215d9da9ecf6f5aeda0b69f805f8 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期二, 08 十二月 2020 18:57:15 +0800
Subject: [PATCH] 20201208
---
HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/RoomEditPageBLL.cs | 160 ++++++++++++++++++++++++++++++++++------------------
1 files changed, 104 insertions(+), 56 deletions(-)
diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/RoomEditPageBLL.cs b/HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/RoomEditPageBLL.cs
index 4ede2cf..5c2cbb0 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/RoomEditPageBLL.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/RoomEditPageBLL.cs
@@ -2,6 +2,8 @@
using Shared;
using HDL_ON.Entity;
using System.Collections.Generic;
+using HDL_ON.DAL.Server;
+using System.Threading;
namespace HDL_ON.UI
{
@@ -233,22 +235,12 @@
btnTakePicture.MouseUpEventHandler = (sender, e) =>
{
btnTakePicture.IsSelected = false;
- //var pid = Guid.NewGuid();
- //CropImage.TakePicture((imagePath) =>
- //{
- // if (imagePath != null)
- // {
- // btnRoomBg.ImagePath = imagePath.ToString();
- // room.backgroundImage = btnRoomBg.ImagePath;
- // MainPage.Log("SelectPicture 瑁佸壀鍥剧墖杩斿洖璺緞: " + imagePath);
- // }
- //}, pid.ToString(), 16, 9);
-
- //var imageName = Guid.NewGuid().ToString();
- var imageName = room.uid;
+
+ var imageName = Guid.NewGuid().ToString();
+ //var imageName = room.sid;
CropImage.TakePicture((imagePath) =>
{
- CropImageCallBack(imagePath, imageName);
+ CropImageCallBack(imagePath);
}, imageName, 16, 9);
@@ -263,23 +255,13 @@
btnAlbum.MouseUpEventHandler = (sender, e) =>
{
btnAlbum.IsSelected = false;
- //var pid = Guid.NewGuid();
- //CropImage.SelectPicture((imagePath) =>
- //{
- // if (imagePath != null)
- // {
- // btnRoomBg.ImagePath = imagePath.ToString();
- // room.backgroundImage = btnRoomBg.ImagePath;
- // MainPage.Log("SelectPicture 瑁佸壀鍥剧墖杩斿洖璺緞: " + imagePath);
- // }
- //}, pid.ToString(), 16, 9);
//浠庣浉鍐岄�夋嫨鍥剧墖瑁佸壀
- //var imageName = Guid.NewGuid().ToString();
- var imageName = room.uid;
+ var imageName = Guid.NewGuid().ToString();
+ //var imageName = room.sid;
CropImage.SelectPicture((imagePath) =>
{
- CropImageCallBack(imagePath, imageName);
+ CropImageCallBack(imagePath);
}, imageName, 16, 9);
@@ -312,46 +294,112 @@
/// </summary>
/// <param name="imagePath">瑁佸壀鍚庣殑鐪熷疄璺緞</param>
/// <param name="imageName">鑷畾涔夌殑鍥剧墖鍚嶇О</param>
- void CropImageCallBack(string imagePath, string imageName)
+ void CropImageCallBack(string selectImagePath)
{
- if (string.IsNullOrEmpty(imagePath) == true)
+ if (string.IsNullOrEmpty(selectImagePath) == true)
{
return;
}
- try
+ //涓婁紶鎴愬姛鍒板洖璋�
+ Action<string> uploadSuccessAction = (imageUrl) =>
{
- var mPath = imagePath;
- MainPage.Log("SelectPicture 瑁佸壀鍥剧墖杩斿洖璺緞: " + imagePath);
-#if __IOS__
-
-
-#else
- //imageName = imageName + ".png";
-
- //1.浣跨敤鏂板悕瀛楋紝瑙e喅鐩稿悓璺緞涓嶅埛鏂板浘鐗囬棶棰�
- imageName = Guid.NewGuid().ToString() + ".png";
- //1.2濡傛灉鏄嚜瀹氫箟鍥剧墖鍒犻櫎涔嬪墠鐨�
- if (!btnRoomBg.ImagePath.Contains("Room")) {
- Utlis.WriteLine("鍒犻櫎: " + btnRoomBg.ImagePath);
- System.IO.File.Delete(btnRoomBg.ImagePath);
- }
- //1.3濡傛灉鏄畨鍗撻渶瑕佹嫹璐濆洖鏉PP鏍圭洰褰�
- FileUtils.FileCopyToRootPath(imagePath, imageName);
- System.IO.File.Delete(imagePath);
- mPath = imageName;
-#endif
- //娓呯┖鍘熸潵鍥剧墖
- btnRoomBg.ImagePath = "NULL";
- //鐢熸垚鍥剧墖
- room.backgroundImage = mPath;
- btnRoomBg.ImagePath = mPath;
-
+ //2020-12-03 闇�瑕佽鏈�鏂扮殑鍥剧墖璺緞鍚屾鍒颁簯绔�
+ room.backgroundImage = imageUrl;
if (pageTitleId == StringId.EditRoomInfo)
{
room.SaveRoomData();
+
+
}
+ };
+ //涓婁紶鍥剧墖鍒颁簯绔�
+ UploadImage(selectImagePath, btnRoomBg, room, uploadSuccessAction);
+ }
+
+ /// <summary>
+ /// 涓婁紶鍥剧墖鏂规硶
+ /// </summary>
+ /// <param name="selectImagePath">瑁佸壀鍚庣殑鍥剧墖璺緞</param>
+ /// <param name="imageView"></param>
+ /// <param name="uploadSuccessAction"></param>
+ void UploadImage(string selectImagePath, ImageView imageView, Room mRoom, Action<string> uploadSuccessAction)
+ {
+ try
+ {
+ //MainPage.Log("SelectPicture 瑁佸壀鍥剧墖杩斿洖璺緞: " + selectImagePath);
+ //1.璇诲彇瑁佸壀鍚庣殑鍥剧墖锛岀劧鍚庡垹闄�
+ var imageBytes = Shared.IO.FileUtils.ReadFile(selectImagePath);
+ System.IO.File.Delete(selectImagePath);
+
+ var waitPage = new Loading();
+ bodyView.AddChidren(waitPage);
+ waitPage.Start(Language.StringByID(StringId.PleaseWait));
+ //寮�濮嬩笂浼�
+ new Thread(() =>
+ {
+ try
+ {
+ var newImageName = mRoom.roomName.Trim() + ".png";
+ var uploadImageObj = new UploadImageObj()
+ {
+ prefix = "Room" + Utlis.GetTimestamp(),
+ fileName = newImageName,
+ uid = mRoom.uid,
+ content = imageBytes,
+ };
+
+ var imageUrl = ImageUtlis.Current.UploadImage(uploadImageObj);
+ if (!string.IsNullOrEmpty(imageUrl) && imageUrl.Contains(newImageName))
+ {
+ //涓婁紶鎴愬姛
+ Application.RunOnMainThread(() =>
+ {
+ //Utlis.WriteLine("涓婁紶鎴愬姛锛�" + imageUrl);
+ //1.2濡傛灉鏄嚜瀹氫箟鍥剧墖鍒犻櫎涔嬪墠鐨�
+ if (!string.IsNullOrEmpty(imageView.ImagePath) && !imageView.ImagePath.Contains("Classification/Room/Roombg"))
+ {
+ //Utlis.WriteLine("鍒犻櫎: " + imageView.ImagePath);
+ System.IO.File.Delete(imageView.ImagePath);
+ }
+ //閲嶅懡鍚嶄繚瀛�
+ FileUtils.WriteFileByBytes(imageUrl, imageBytes);
+ imageView.ImagePath = null;
+ imageView.ImageBytes = imageBytes;
+ //涓婁紶鎴愬姛
+ Utlis.ShowTip(Language.StringByID(StringId.UploadSuccessfully));
+ uploadSuccessAction?.Invoke(imageUrl);
+ });
+ }
+ else
+ {
+ //涓婁紶澶辫触
+ Application.RunOnMainThread(() =>
+ {
+ //涓婁紶澶辫触
+ Utlis.ShowTip(Language.StringByID(StringId.UploadFailed));
+ });
+ }
+
+ }
+ catch (Exception ex)
+ {
+ }
+ finally
+ {
+ Application.RunOnMainThread(() =>
+ {
+ if (waitPage != null)
+ {
+ waitPage.RemoveFromParent();
+ waitPage = null;
+ }
+ });
+ }
+ })
+ { IsBackground = true }.Start();
}
catch { }
}
+
}
}
\ No newline at end of file
--
Gitblit v1.8.0