Browse Source

XunJianUIItem_Texture分类,LangChaoMinIo安卓平台

蓝色星空 1 year ago
parent
commit
51dbff9f9d

+ 9 - 22
Assets/Game/Blue/Controller/Item/ShowXunJian_UIItem.cs

@@ -6,9 +6,6 @@ using SC.XR.Unity;
 using UnityEngine;
 using UnityEngine;
 using UnityEngine.UI;
 using UnityEngine.UI;
 using System.Collections.Generic;
 using System.Collections.Generic;
-using Google.Protobuf;
-using Newtonsoft.Json;
-using System.IO;
 
 
 public class ShowXunJian_UIItem : MonoBehaviour, IController
 public class ShowXunJian_UIItem : MonoBehaviour, IController
 {
 {
@@ -26,7 +23,7 @@ public class ShowXunJian_UIItem : MonoBehaviour, IController
 
 
     [SerializeField] private GameObject mErrorBtn_go;
     [SerializeField] private GameObject mErrorBtn_go;
 
 
-    public List<Image> ScreenshotList;
+    [SerializeField] private List<XunJianUIItem_Texture> XunJianUIItemTexture_List;
 
 
     private void Start()
     private void Start()
     {
     {
@@ -72,12 +69,8 @@ public class ShowXunJian_UIItem : MonoBehaviour, IController
             }
             }
         }
         }
     }
     }
-    class ByteClass
-    {
-        public bool upload;
-        public byte[] bytes;
-    }
-    Dictionary<int, ByteClass> byteDic = new Dictionary<int, ByteClass>();
+    
+    private Dictionary<int, ByteClass> byteDic = new Dictionary<int, ByteClass>();
     public void ChangeSprite(int id, Texture2D Texture2D)
     public void ChangeSprite(int id, Texture2D Texture2D)
     {
     {
         if (byteDic.ContainsKey(id))
         if (byteDic.ContainsKey(id))
@@ -102,20 +95,9 @@ public class ShowXunJian_UIItem : MonoBehaviour, IController
                 mOutliers = InspectionStep.outliers;
                 mOutliers = InspectionStep.outliers;
             }
             }
 
 
-            int current = 0;
             for (int i = 0; i < 3; i++)
             for (int i = 0; i < 3; i++)
             {
             {
-                LangChaoMinIo.Instance.getFile(this.GetService<IInspectionService>().InspectionInfo.id, mItemID.ToString(), i, Texture2D =>
-                {
-                    if (Texture2D != null)
-                    {
-                        byteDic.Add(current, new ByteClass() { upload = false, bytes = Texture2D.EncodeToPNG() });
-                        Sprite sprite = Sprite.Create(Texture2D, new Rect(0, 0, Texture2D.width, Texture2D.height), Vector2.zero);
-                        sprite.name = current.ToString();
-                        ScreenshotList[current].sprite = sprite; current++;
-                        //Destroy(Texture2D);
-                    }
-                });
+                XunJianUIItemTexture_List[i].GetSprite(byteDic, mItemID, i);
             }
             }
         }
         }
     }
     }
@@ -171,4 +153,9 @@ public class ShowXunJian_UIItem : MonoBehaviour, IController
 public static class CurrentStep
 public static class CurrentStep
 {
 {
     public static int step;
     public static int step;
+}
+public class ByteClass
+{
+    public bool upload;
+    public byte[] bytes;
 }
 }

+ 22 - 0
Assets/Game/Blue/Controller/Item/XunJianUIItem_Texture.cs

@@ -0,0 +1,22 @@
+using Blue;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+
+public class XunJianUIItem_Texture : MonoBehaviour,IController
+{
+    public void GetSprite(Dictionary<int, ByteClass> byteDic, int mItemID, int Index)
+    {
+        //Debug.LogError($"mItemID:{mItemID}, Index:{Index}");
+        LangChaoMinIo.Instance.getFile(this.GetService<IInspectionService>().InspectionInfo.id, mItemID.ToString(), Index, Texture2D =>
+        {
+            if (Texture2D != null)
+            {
+                byteDic.Add(Index, new ByteClass() { upload = false, bytes = Texture2D.EncodeToPNG() });
+                Sprite sprite = Sprite.Create(Texture2D, new Rect(0, 0, Texture2D.width, Texture2D.height), Vector2.zero);
+                sprite.name = Index.ToString();
+                GetComponent<Image>().sprite = sprite;
+            }
+        });
+    }
+}

+ 11 - 0
Assets/Game/Blue/Controller/Item/XunJianUIItem_Texture.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d8c7c4bbd06faa94e97b0cba16e43648
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 9 - 0
Assets/Game/Blue/Controller/LangChaoMinIo.cs

@@ -228,6 +228,14 @@ public class LangChaoMinIo : MonoSingleton<LangChaoMinIo>
     /// <returns></returns>
     /// <returns></returns>
     IEnumerator _GetTexture(string url, Action<Texture2D> actionResult)
     IEnumerator _GetTexture(string url, Action<Texture2D> actionResult)
     {
     {
+#if UNITY_ANDROID
+        //Debug.LogError("ÇëÇóͼƬ£º"+url);
+        WWW w = new WWW("file://" + url);
+        yield return w;
+        if (w.isDone)
+            actionResult?.Invoke(w.texture);
+#else
+
         UnityWebRequest uwr = new UnityWebRequest(url);
         UnityWebRequest uwr = new UnityWebRequest(url);
         DownloadHandlerTexture downloadTexture = new DownloadHandlerTexture(true);
         DownloadHandlerTexture downloadTexture = new DownloadHandlerTexture(true);
         uwr.downloadHandler = downloadTexture;
         uwr.downloadHandler = downloadTexture;
@@ -246,6 +254,7 @@ public class LangChaoMinIo : MonoSingleton<LangChaoMinIo>
         {
         {
             actionResult(t);
             actionResult(t);
         }
         }
+#endif
     }
     }
     // File uploader task.
     // File uploader task.
     private async Task Run()
     private async Task Run()

+ 1 - 0
Assets/Game/Blue/RTC/Service/InspectionService.cs

@@ -23,6 +23,7 @@ public class InspectionService : IInspectionService
                 {
                 {
                     Debug.LogError("data:" + jobject["data"].ToString());
                     Debug.LogError("data:" + jobject["data"].ToString());
                     InspectionInfo = JsonConvert.DeserializeObject<InspectionInfo>(jobject["data"].ToString());
                     InspectionInfo = JsonConvert.DeserializeObject<InspectionInfo>(jobject["data"].ToString());
+                    PlayerPrefs.SetInt("XunJianInspectionInfoID", InspectionInfo.id);
                     /*
                     /*
                     Debug.LogError($"ID:{InspectionInfo.id}");
                     Debug.LogError($"ID:{InspectionInfo.id}");
                     foreach (var item in InspectionInfo.items)
                     foreach (var item in InspectionInfo.items)

+ 323 - 114
Assets/Game/Blue/Test/TestMinIO.cs

@@ -1,167 +1,376 @@
 using LitJson;
 using LitJson;
 using Minio;
 using Minio;
 using Minio.DataModel.Args;
 using Minio.DataModel.Args;
-using Minio.DataModel.Encryption;
 using Minio.Exceptions;
 using Minio.Exceptions;
 using System;
 using System;
+using System.Collections;
+using System.Collections.Generic;
 using System.IO;
 using System.IO;
+using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using UnityEngine;
 using UnityEngine;
+using UnityEngine.Networking;
+using XRTool.Util;
 
 
-public class TestMinIO : MonoBehaviour
+public class TestMinIO : MonoSingleton<TestMinIO>
 {
 {
-    private string endpoint;
-    private string accessKey;
-    private string secretKey;
-    private string minioToken;
-    private string bucketName;
-    private string objectName;
-    private string contentType;
-    private string tmpSecretId;
-    private string tmpSecretKey;
-    private string host;
+    private IMinioClient minio;
     private string path;
     private string path;
-    private MinioClient minio;
+    private string bucket;
+    private string host;
+
+    private string tmpSecretId;
+    string tmpSecretKey;
+    private string minioToken;
+
+    private int projectId;
+    private bool isminioUpdate;
+    private bool isUpdate;
 
 
+    private Thread thread;
     private void Start()
     private void Start()
     {
     {
-        endpoint = "api-fat2.ghz-tech.com";
-        accessKey = "2RB1QSM6ZTPQPJIA32K3";
-        secretKey = "c1e274Rj0ObD10cHOygHXV2wMZHcFubes0jOza6r";
-        minioToken = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiIyUkIxUVNNNlpUUFFQSklBMzJLMyIsImV4cCI6MTY5OTgwOTE0MSwicGFyZW50IjoiZ2h6Iiwic2Vzc2lvblBvbGljeSI6ImV5SjJaWEp6YVc5dUlqb2lNakF4TWkweE1DMHhOeUlzSW5OMFlYUmxiV1Z1ZENJNlczc2lZV04wYVc5dUlqcGJJbk16T2tkbGRFSjFZMnRsZEV4dlkyRjBhVzl1SWl3aWN6TTZSMlYwVDJKcVpXTjBJaXdpY3pNNlVIVjBUMkpxWldOMElpd2ljek02VEdsemRFSjFZMnRsZENKZExDSmxabVpsWTNRaU9pSkJiR3h2ZHlJc0luSmxjMjkxY21ObElqcGJJbUZ5YmpwaGQzTTZjek02T2pvcUlsMTlYWDA9In0.SNxgRP-vBxKvBRwo2pWGcpD3Yap7bjN34jbsluY4pEa45zPmyRSWW-PxvMc69lTaXub2ijYgyPFwOe0iVi7ZMQ";
-        bucketName = "ghz";
-        objectName = "110901.jpg";
-        contentType = "application/octet-stream";
-        Active();
-        /*
-        */
-        InspectionCredential();
+        thread = new Thread(DoSomeWork);
+        thread.Start();
     }
     }
 
 
-    private void InspectionCredential()
+    void DoSomeWork()
+    {
+        while (true)
+        {
+            if (minio == null)
+            {
+            }
+            else
+            {
+                if (Nowfd != null && !isUpdate)
+                {
+                    isUpdate = true;
+                    Run().Wait();
+                }
+                if (gfdQueue.Count > 0 && !isDownLoad)
+                {
+                    isDownLoad = true;
+                    nowgfd = gfdQueue.Dequeue();
+                    RunFile().Wait();
+                }
+            }
+            Thread.Sleep(1000);
+        }
+    }
+
+    void initMinIo(Action<bool> callBack)
     {
     {
         JsonData data = new JsonData();
         JsonData data = new JsonData();
-        data["inspectionId"] = 10;
-        GameStart.Instance.StartCoroutine(HttpTool.Instance.SendHttp("/cmcc-endustry/v1/storage/inspectionCredential", data.ToJson(), async (string str) =>
-        {
-            JsonData d = JsonMapper.ToObject(str);
-            //minioToken = d["data"]["credentials"]["token"].ToString();
-            tmpSecretId = d["data"]["credentials"]["tmpSecretId"].ToString();
-            //tmpSecretKey = d["data"]["credentials"]["tmpSecretKey"].ToString();
-            host = d["data"]["host"].ToString();
-            bucketName = d["data"]["bucket"].ToString();
-            path = d["data"]["path"].ToString();
-            Debug.Log(str);
-            bool isHttps = host.Contains("https");
-            //var endpoint = host.Split("//")[1];
-            //var accessKey = tmpSecretId;//"tr6Nh5D8bnlGaLJE6vb5";
-            //var secretKey = tmpSecretKey;// "aVOYdXLnX4MCiKbit8aomZNWvAx8YSpzhiwzFhrI";
-            //Active();
-            
-            minio = (MinioClient)new MinioClient()
-                            .WithEndpoint(endpoint)
-                            .WithCredentials(accessKey, secretKey)
-                            .WithSessionToken(minioToken)
-                            .WithSSL(isHttps)
-                            .Build();
-            //  Run((MinioClient)minio).Wait();
-            var getListBucketsTask = await minio.ListBucketsAsync().ConfigureAwait(false);
-            foreach (var bucket in getListBucketsTask.Buckets)
+        data["inspectionId"] = projectId;
+        GameStart.Instance.StartCoroutine(HttpTool.Instance.SendHttp(HttpActionLang.storage_inspectionCredential, data.ToJson(), async (string str) =>
+        {
+            try
+            {
+
+                JsonData d = JsonMapper.ToObject(str);
+                minioToken = d["data"]["credentials"]["token"].ToString();
+                tmpSecretId = d["data"]["credentials"]["tmpSecretId"].ToString();
+                tmpSecretKey = d["data"]["credentials"]["tmpSecretKey"].ToString();
+                host = d["data"]["host"].ToString();
+                bucket = d["data"]["bucket"].ToString();
+                path = d["data"]["path"].ToString();
+                Debug.Log(str);
+                bool isHttps = host.Contains("https");
+                var endpoint = host.Split("//")[1];
+                var accessKey = tmpSecretId;//"tr6Nh5D8bnlGaLJE6vb5";
+                var secretKey = tmpSecretKey;// "aVOYdXLnX4MCiKbit8aomZNWvAx8YSpzhiwzFhrI";
+                Debug.Log("endpoint===>" + endpoint + "    isHttps==>" + isHttps);
+                minio = new MinioClient()
+                                    .WithEndpoint(endpoint)
+                                    .WithCredentials(accessKey, secretKey)
+                                    .WithSessionToken(minioToken)
+                                    .WithSSL(isHttps)
+                                    .Build();
+                TimerMgr.Instance.CreateTimer(() =>
+                {
+
+                    minio = null;
+                }, 1200);
+                callBack?.Invoke(true);
+            }
+            catch
             {
             {
-                Debug.LogError($"Bucket:{bucket.Name}");
+                callBack?.Invoke(false);
+
             }
             }
-            Active();
+
         }));
         }));
     }
     }
 
 
-    private void Active()
+    Queue<FileData> fdQueue = new Queue<FileData>();
+    void putFile(string filePath, string fileName, Action<string> callBack)
     {
     {
-        try
+        FileData fd = new FileData();
+        fd.filePath = filePath;
+        fd.fileName = fileName;
+        fd.callBack = callBack;
+        fdQueue.Enqueue(fd);
+    }
+    string DicName = "XunJian";
+    public void saveFile(byte[] bytes, int projectId, string Index, int imgIndex, Action<string> callBack)
+    {
+        this.projectId = projectId;
+        if (!Directory.Exists(Application.persistentDataPath + "/" + DicName))
+            Directory.CreateDirectory(Application.persistentDataPath + "/" + DicName);
+
+        string fileName = DicName + "_" + projectId + "_" + Index + "_" + imgIndex + ".png";
+        string filePathname = Application.persistentDataPath + "/" + DicName + "/" + fileName;
+        //  if (File.Exists(filePathname))
+        //      File.Delete(filePathname);
+        File.WriteAllBytes(filePathname, bytes);
+
+        // PlayerPrefs.SetString(fileName, filePathname);
+        putFile(filePathname, fileName, callBack);
+
+    }
+    /// <summary>
+    /// 运行模式下Texture转换成Texture2D
+    /// </summary>
+    /// <param name="texture"></param>
+    /// <returns></returns>
+    private Texture2D TextureToTexture2D(Texture texture)
+    {
+        Texture2D texture2D = new Texture2D(texture.width, texture.height, TextureFormat.RGBA32, false);
+        RenderTexture currentRT = RenderTexture.active;
+        RenderTexture renderTexture = RenderTexture.GetTemporary(texture.width, texture.height, 32);
+        Graphics.Blit(texture, renderTexture);
+
+        RenderTexture.active = renderTexture;
+        texture2D.ReadPixels(new Rect(0, 0, renderTexture.width, renderTexture.height), 0, 0);
+        texture2D.Apply();
+
+        RenderTexture.active = currentRT;
+        RenderTexture.ReleaseTemporary(renderTexture);
+
+        return texture2D;
+    }
+
+    /// <summary>
+    /// 获取文件
+    /// </summary>
+    /// <param name="projectId">巡检ID</param>
+    /// <param name="Index">步骤ID</param>
+    /// <param name="imgIndex">步骤ID内图片ID</param>
+    /// <param name="callBack"></param>
+    public void getFile(int projectId, string Index, int imgIndex, Action<Texture2D> callBack)//, string path
+    {
+        this.projectId = projectId;
+
+
+
+
+        string fileName = DicName + "_" + projectId + "_" + Index + "_" + imgIndex + ".png";
+        string filePathname = PlayerPrefs.GetString(fileName);
+        if (filePathname != "")
         {
         {
-            /*
-            var minio = (MinioClient)new MinioClient()
-                               //.WithEndpoint(endpoint)
-                                .WithEndpoint(host)
-                                .WithCredentials(accessKey, secretKey)
-                                .WithSessionToken(minioToken)
-                                .WithSSL()
-                                .Build();
-            */
-            SetObjectRun(minio).Wait();
-            //GetObjectRun(minio, "bluebucketone", "BlueIOTest.jpg", "C:\\Users\\lsxk0\\Desktop\\DownAPK\\1107.jpg").Wait();
+            StartCoroutine(_GetTexture(filePathname, callBack));
         }
         }
-        catch (Exception ex)
+        else
         {
         {
-            Debug.LogError("host:"+ host);
-            Debug.LogError("bucketName:" + bucketName);
-            Debug.LogError("path:" + path);
-            Debug.LogError($"SetObjectRun Error----{ex.Message}");
+            GetFileData gfd = new GetFileData();
+            gfd.bucket = bucket;
+            gfd.objectName = DicName + "_" + projectId + "_" + Index + "_" + imgIndex + ".png";
+            gfd.callBack = callBack;
+            gfdQueue.Enqueue(gfd);
         }
         }
     }
     }
+    GetFileData nowgfd;
+    Queue<byte[]> backQueue = new Queue<byte[]>();
+    Queue<GetFileData> gfdQueue = new Queue<GetFileData>();
+    // File uploader task.
+    private async Task RunFile()
+    {
+        Debug.LogError(bucket);
+        Debug.LogError(path + "/" + nowgfd.objectName);
+        try
+        {
+
+            StatObjectArgs statObjectArgs = new StatObjectArgs()
+                                              .WithBucket(bucket)
+                                              .WithObject(path + "/" + nowgfd.objectName);
+            await minio.StatObjectAsync(statObjectArgs);
+
+            // Get input stream to have content of 'my-objectname' from 'my-bucketname'
+            GetObjectArgs getObjectArgs = new GetObjectArgs()
+                                              .WithBucket(bucket)
+                                              .WithObject(path + "/" + nowgfd.objectName)
+                                              .WithCallbackStream(async (stream) =>
+                                              {
+                                                  backQueue.Enqueue(StreamToBytes(stream));
+
+                                              });
+            await minio.GetObjectAsync(getObjectArgs);
+
+        }
+        catch
+        {
+            backQueue.Enqueue(null);
 
 
+        }
+    }
+    static byte[] StreamToBytes(Stream stream)
+    {
+        byte[] bytes = new byte[stream.Length];
+        stream.Read(bytes, 0, bytes.Length);
+        stream.Seek(0, SeekOrigin.Begin);
+        return bytes;
+    }
     /// <summary>
     /// <summary>
-    ///  文件上传
+    /// 请求图片
     /// </summary>
     /// </summary>
-    private async Task SetObjectRun(MinioClient minio)
+    /// <param name="url">图片地址,like 'http://www.my-server.com/image.png '</param>
+    /// <param name="action">请求发起后处理回调结果的委托,处理请求结果的图片</param>
+    /// <returns></returns>
+    IEnumerator _GetTexture(string url, Action<Texture2D> actionResult)
     {
     {
-        Debug.LogError("SetObjectRun");
-
-        //var location = "us-east-1";
-        var filePath = "C:\\Users\\lsxk0\\Desktop\\图片\\IMG_20190113_082755.jpg";
-        //var filePath = Application.persistentDataPath + "/IMG.jpg";
-
-        try
+#if UNITY_ANDROID
+        using (UnityWebRequest request = new UnityWebRequest(url))
         {
         {
-            // 在服务器上制作一个bucket(如果还没有)
-            var beArgs = new BucketExistsArgs()
-                .WithBucket(bucketName);
-            bool found = await minio.BucketExistsAsync(beArgs).ConfigureAwait(false);
-            if (!found)
+            DownloadHandlerTexture downloadHandlerTexture = new DownloadHandlerTexture(true);
+            request.downloadHandler = downloadHandlerTexture;
+            yield return request.SendWebRequest();
+            if (string.IsNullOrEmpty(request.error))
             {
             {
-                var mbArgs = new MakeBucketArgs()
-                    .WithBucket(bucketName);
-                await minio.MakeBucketAsync(mbArgs).ConfigureAwait(false);
+                Texture2D localTexture = downloadHandlerTexture.texture;
+                actionResult?.Invoke(localTexture);
             }
             }
-            // 将文件上传到bucket
+            else
+            {
+                actionResult?.Invoke(null);
+                Debug.Log("_GetTexture:" + request.error);
+            }
+        }
+        /*
+        WWW www = new WWW(url);
+        yield return www;
+        Texture2D texture2D = new Texture2D(450, 300);
+        if (www.isDone)
+        {
+            actionResult?.Invoke(texture2D);
+            //texture2D.LoadImage(www.bytes);
+        }
+        */
+#else
+        UnityWebRequest uwr = new UnityWebRequest(url);
+        DownloadHandlerTexture downloadTexture = new DownloadHandlerTexture(true);
+        uwr.downloadHandler = downloadTexture;
+        yield return uwr.SendWebRequest();
+        Texture2D t = null;
+        if (!(uwr.isNetworkError || uwr.isHttpError))
+        {
+            t = downloadTexture.texture;
+        }
+        else
+        {
+            Debug.Log("下载失败,请检查网络,或者下载地址是否正确: " + uwr.error);
+        }
+
+        if (actionResult != null)
+        {
+            actionResult(t);
+        }
+#endif
+    }
+    // File uploader task.
+    private async Task Run()
+    {
+        try
+        {
+
+            var getListBucketsTask = await minio.ListBucketsAsync().ConfigureAwait(false);
+            var bucketName = bucket;
+            var objectName = path + "/" + Nowfd.fileName;
+            var filePath = Nowfd.filePath;
+            var contentType = "application/octet-stream";
+
+            // Make a bucket on the server, if not already present.
+
+            // Upload a file to bucket.
             var putObjectArgs = new PutObjectArgs()
             var putObjectArgs = new PutObjectArgs()
                 .WithBucket(bucketName)
                 .WithBucket(bucketName)
                 .WithObject(objectName)
                 .WithObject(objectName)
                 .WithFileName(filePath)
                 .WithFileName(filePath)
                 .WithContentType(contentType);
                 .WithContentType(contentType);
             await minio.PutObjectAsync(putObjectArgs).ConfigureAwait(false);
             await minio.PutObjectAsync(putObjectArgs).ConfigureAwait(false);
-            Debug.LogError("Successfully uploaded " + objectName);
+            Debug.Log("33333333333333333");
+
+            PlayerPrefs.SetString(Nowfd.fileName, Nowfd.filePath);
+            isUpdate = false;
+            Nowfd.callBack?.Invoke(Nowfd.fileName);
+            Nowfd = null;
         }
         }
-        catch (MinioException e)
+        catch
         {
         {
-            Debug.LogError("Upload Error----");
-            Debug.LogError($"File Upload Error: {e.Message}");
+
+            Nowfd.callBack?.Invoke(null);
+            isUpdate = false;
+            Nowfd = null;
         }
         }
     }
     }
-
-    /// <summary>
-    /// 将对象从bucket下载到本地文件
-    /// </summary>
-    public async Task GetObjectRun(
-        IMinioClient minio,
-        string bucketName = "my-bucket-name",
-        string objectName = "my-object-name",
-        string fileName = "local-filename",
-        IServerSideEncryption sse = null)
+    bool isDownLoad;
+    FileData Nowfd;
+    private void Update()
     {
     {
-        try
+        if (fdQueue.Count > 0 && Nowfd == null)
         {
         {
-            File.Delete(fileName);
-            var args = new GetObjectArgs()
-                .WithBucket(bucketName)
-                .WithObject(objectName)
-                .WithFile(fileName)
-                .WithServerSideEncryption(sse);
-            _ = await minio.GetObjectAsync(args).ConfigureAwait(false);
-            Debug.LogError($"Downloaded the file {fileName} from bucket {bucketName}");
+            Nowfd = fdQueue.Dequeue();
         }
         }
-        catch (Exception e)
+        if (minio == null)
         {
         {
-            Debug.LogError($"[Bucket]  Exception: {e}");
+            if (projectId != 0 && !isminioUpdate)
+            {
+                isminioUpdate = true;
+                initMinIo((bool b) =>
+                {
+                    isminioUpdate = false;
+                });
+            }
+        }
+        if (backQueue.Count > 0)
+        {
+            byte[] bytes = backQueue.Dequeue();
+
+            if (bytes != null)
+            {
+
+                Debug.Log("444444444444");
+                Texture2D t2d = new Texture2D(10, 10);
+                t2d.LoadImage(bytes);
+                t2d.Apply();
+                nowgfd.callBack?.Invoke(t2d);
+            }
+            else
+
+            {
+                Debug.Log("55555555555555");
+                nowgfd.callBack?.Invoke(null);
+
+            }
+
+
+            isDownLoad = false;
+            nowgfd = null;
         }
         }
     }
     }
+
+    public class FileData
+    {
+        public string filePath;
+        public string fileName;
+        public Action<string> callBack;
+    }
+
+    public class GetFileData
+    {
+        public string bucket;
+        public string objectName;
+        public Action<Texture2D> callBack;
+    }
+
 }
 }

+ 43 - 4
Assets/Game/PrefabTemplate/借用_XunjianToogleUI.prefab

@@ -1332,6 +1332,7 @@ GameObject:
   - component: {fileID: 790488171327746282}
   - component: {fileID: 790488171327746282}
   - component: {fileID: 1969936950275804296}
   - component: {fileID: 1969936950275804296}
   - component: {fileID: 7281372740226316556}
   - component: {fileID: 7281372740226316556}
+  - component: {fileID: 1536265452858920543}
   m_Layer: 5
   m_Layer: 5
   m_Name: Screenshot_2_Btn
   m_Name: Screenshot_2_Btn
   m_TagString: Untagged
   m_TagString: Untagged
@@ -1453,6 +1454,18 @@ MonoBehaviour:
           m_StringArgument: 
           m_StringArgument: 
           m_BoolArgument: 1
           m_BoolArgument: 1
         m_CallState: 2
         m_CallState: 2
+--- !u!114 &1536265452858920543
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 2089683519190997672}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: d8c7c4bbd06faa94e97b0cba16e43648, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
 --- !u!1 &2273837713236204869
 --- !u!1 &2273837713236204869
 GameObject:
 GameObject:
   m_ObjectHideFlags: 0
   m_ObjectHideFlags: 0
@@ -3305,6 +3318,7 @@ GameObject:
   - component: {fileID: 5248638956000783540}
   - component: {fileID: 5248638956000783540}
   - component: {fileID: 2159213327334610182}
   - component: {fileID: 2159213327334610182}
   - component: {fileID: 1067969030643694660}
   - component: {fileID: 1067969030643694660}
+  - component: {fileID: 8162851721584913344}
   m_Layer: 5
   m_Layer: 5
   m_Name: Screenshot_0_Btn
   m_Name: Screenshot_0_Btn
   m_TagString: Untagged
   m_TagString: Untagged
@@ -3426,6 +3440,18 @@ MonoBehaviour:
           m_StringArgument: 
           m_StringArgument: 
           m_BoolArgument: 1
           m_BoolArgument: 1
         m_CallState: 2
         m_CallState: 2
+--- !u!114 &8162851721584913344
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 5347234164656521551}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: d8c7c4bbd06faa94e97b0cba16e43648, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
 --- !u!1 &5437390303013259983
 --- !u!1 &5437390303013259983
 GameObject:
 GameObject:
   m_ObjectHideFlags: 0
   m_ObjectHideFlags: 0
@@ -3772,6 +3798,7 @@ GameObject:
   - component: {fileID: 4875757004267314246}
   - component: {fileID: 4875757004267314246}
   - component: {fileID: 3532761808821666237}
   - component: {fileID: 3532761808821666237}
   - component: {fileID: 8872112054106962604}
   - component: {fileID: 8872112054106962604}
+  - component: {fileID: 4642103229494756710}
   m_Layer: 5
   m_Layer: 5
   m_Name: Screenshot_1_Btn
   m_Name: Screenshot_1_Btn
   m_TagString: Untagged
   m_TagString: Untagged
@@ -3893,6 +3920,18 @@ MonoBehaviour:
           m_StringArgument: 
           m_StringArgument: 
           m_BoolArgument: 1
           m_BoolArgument: 1
         m_CallState: 2
         m_CallState: 2
+--- !u!114 &4642103229494756710
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 5825461600815543364}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: d8c7c4bbd06faa94e97b0cba16e43648, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
 --- !u!1 &6256463971550066987
 --- !u!1 &6256463971550066987
 GameObject:
 GameObject:
   m_ObjectHideFlags: 0
   m_ObjectHideFlags: 0
@@ -4485,10 +4524,10 @@ MonoBehaviour:
   WarningPanel_go: {fileID: 3706178895091204087}
   WarningPanel_go: {fileID: 3706178895091204087}
   LabelText_Input: {fileID: 975195068224255630}
   LabelText_Input: {fileID: 975195068224255630}
   mErrorBtn_go: {fileID: 7477279148625475104}
   mErrorBtn_go: {fileID: 7477279148625475104}
-  ScreenshotList:
-  - {fileID: 2159213327334610182}
-  - {fileID: 3532761808821666237}
-  - {fileID: 1969936950275804296}
+  XunJianUIItemTexture_List:
+  - {fileID: 8162851721584913344}
+  - {fileID: 4642103229494756710}
+  - {fileID: 1536265452858920543}
 --- !u!1 &7584859786364747502
 --- !u!1 &7584859786364747502
 GameObject:
 GameObject:
   m_ObjectHideFlags: 0
   m_ObjectHideFlags: 0

+ 13 - 13
Assets/Game/ShowXunJian/StartXunJian.cs

@@ -1,14 +1,9 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using Blue;
 using Blue;
-using System.IO;
 using UnityEngine;
 using UnityEngine;
 using UnityEngine.Events;
 using UnityEngine.Events;
 using UnityEngine.UI;
 using UnityEngine.UI;
 using TMPro;
 using TMPro;
-using UnityEngine.Networking;
-using System.Collections;
-using BestHTTP.JSON;
-
 namespace GHZLangChao
 namespace GHZLangChao
 {
 {
     public class StartXunJian : AbstractController
     public class StartXunJian : AbstractController
@@ -44,10 +39,19 @@ namespace GHZLangChao
         private void Awake()
         private void Awake()
         {
         {
             Instance = this;
             Instance = this;
+            if (mInspectionService == null)
+                mInspectionService = this.GetService<IInspectionService>();
 
 
-            var step = PlayerPrefs.GetInt("ShowXunJianStep");
-            ToggleList[step-1].isOn = true;
-            currentUIItem = ItemList[step-1];
+            if(mInspectionService.InspectionInfo.id==PlayerPrefs.GetInt("XunJianInspectionInfoID"))
+            {
+                var step = PlayerPrefs.GetInt("ShowXunJianStep");
+                if (step != 0)
+                {
+                    ToggleList[step - 1].isOn = true;
+                    currentUIItem = ItemList[step - 1];
+                }
+                //Debug.LogError("step:"+ step);
+            }
         }
         }
         void Start()
         void Start()
         {
         {
@@ -69,15 +73,13 @@ namespace GHZLangChao
             Titile_Btn.onClick.AddListener(ClickTitle);
             Titile_Btn.onClick.AddListener(ClickTitle);
             //CancelBtn.onClick.AddListener(ClickCancel);
             //CancelBtn.onClick.AddListener(ClickCancel);
 
 
-            if (mInspectionService == null)
-                mInspectionService = this.GetService<IInspectionService>();
             Init(mInspectionService.InspectionInfo);
             Init(mInspectionService.InspectionInfo);
 
 
         }
         }
         private void Update()
         private void Update()
         {
         {
-            if (Test) return;
 #if UNITY_EDITOR
 #if UNITY_EDITOR
+            if (Test) return;
             return;
             return;
 #endif
 #endif
             OnReset?.Invoke();
             OnReset?.Invoke();
@@ -142,7 +144,6 @@ namespace GHZLangChao
             }
             }
         }
         }
 
 
-
         private void ClickSave()
         private void ClickSave()
         {
         {
             var sprite = this.GetUtility<IRawImageForSpriteUtility>().SwitchSprite(ShowRawImage);
             var sprite = this.GetUtility<IRawImageForSpriteUtility>().SwitchSprite(ShowRawImage);
@@ -158,7 +159,6 @@ namespace GHZLangChao
             {
             {
                 arrayImageIndex -= 3;
                 arrayImageIndex -= 3;
             }
             }
-
         }
         }
         public void SetIndex(int index)
         public void SetIndex(int index)
         {
         {