예제 #1
0
        public List <T> GetObjectChunkUploadClassList <T>(string chunkKeyCurrentComplete, List <T> listEntity) where T : class
        {
            List <T> result = new List <T>();

            if (listEntity == null)
            {
                if (!string.IsNullOrEmpty(chunkKeyCurrentComplete))
                {
                    string[] checkChunk = chunkKeyCurrentComplete.ToString().Split("_");
                    string   key1       = string.Empty;
                    string   key2       = string.Empty;
                    if (checkChunk.Count() > 1)
                    {
                        key1 = checkChunk[0];
                        key2 = checkChunk[1];
                        if (key2.ToString().ToLower().Contains("complete"))
                        {
                            string[] checkChunkDetail = key2.ToString().Split("|");
                            int      maxCount         = 0;
                            if (checkChunkDetail.Count() > 1)
                            {
                                maxCount = Convert.ToInt32(checkChunkDetail[1]);
                                ChunkDataInfo dataInfo = new ChunkDataInfo
                                {
                                    ChunkKey      = key1,
                                    ChunkMaxCount = maxCount
                                };
                                ChunkDataResult resultTemp = CompressObject.GetInstance.ChunkDataUploadSvrVerify(dataInfo);
                                result = CompressObject.GetInstance.ConvertChunkDataResultToList <T>(resultTemp);
                            }
                        }
                    }
                }
            }
            result = listEntity;
            return(result);
        }
예제 #2
0
 public byte[] GetObjectChunkUploadByte(string chunkKeyCurrentComplete, byte[] bite)
 {
     byte[] result = null;
     if (bite == null)
     {
         if (!string.IsNullOrEmpty(chunkKeyCurrentComplete))
         {
             string[] checkChunk = chunkKeyCurrentComplete.ToString().Split("_");
             string   key1       = string.Empty;
             string   key2       = string.Empty;
             if (checkChunk.Count() > 1)
             {
                 key1 = checkChunk[0];
                 key2 = checkChunk[1];
                 if (key2.ToString().ToLower().Contains("complete"))
                 {
                     string[] checkChunkDetail = key2.ToString().Split("|");
                     int      maxCount         = 0;
                     if (checkChunkDetail.Count() > 1)
                     {
                         maxCount = Convert.ToInt32(checkChunkDetail[1]);
                         ChunkDataInfo dataInfo = new ChunkDataInfo
                         {
                             ChunkKey      = key1,
                             ChunkMaxCount = maxCount
                         };
                         ChunkDataResult resultTemp = CompressObject.GetInstance.ChunkDataUploadSvrVerify(dataInfo);
                         result = CompressObject.GetInstance.ConvertChunkDataResultToByteArray(resultTemp);
                     }
                 }
             }
         }
     }
     result = bite;
     return(result);
 }
예제 #3
0
        public ChunkDataResult ChunkDataResultClientVerify(List <ChunkData> listChunk)
        {
            ChunkDataResult dataResult = new ChunkDataResult();
            IEqualityComparer <ChunkData> customComparer =
                new PropertyComparer <ChunkData>("ChunkCurrent");
            IEnumerable <ChunkData> distinctChunkData = listChunk.Distinct(customComparer);

            if (distinctChunkData.Count() > 0)
            {
                string strChunked64Base = string.Empty;
                string tempForByte      = string.Empty;
                foreach (var item in distinctChunkData)
                {
                    strChunked64Base += item.DataChunk;
                }
                if (!string.IsNullOrEmpty(strChunked64Base))
                {
                    tempForByte = this.DeCompressedData(strChunked64Base);
                }
                dataResult.FileNameWithExt = listChunk[0].FileName;
                dataResult.DataChunk       = tempForByte;
            }
            return(dataResult);
        }
예제 #4
0
        public ChunkDataResult ChunkDataUploadSvrVerify(ChunkDataInfo chunk)
        {
            // if you want to call this methode... just make sure all your loop ChunkDataUploadSvrAsync has been finished
            ChunkDataResult dataResult = new ChunkDataResult();

            string chunkKey   = chunk.ChunkKey;
            int    chunkCount = chunk.ChunkMaxCount;

            byte[]           byteData  = null;
            List <ChunkData> listChunk = new List <ChunkData>();
            int    tryTimes            = 0;
            int    maxTryTimes         = 6;// max 1 minute for waiting
            string tempForByte         = string.Empty;

            while (true)
            {
                tryTimes++;
                for (int i = 0; i < chunkCount; i++)
                {
                    object obj = cacher.GetValue(chunkKey + "_" + (i + 1).ToString());
                    if (obj != null)
                    {
                        listChunk.Add((ChunkData)obj);
                    }
                    else
                    {
                        string a = string.Empty;
                    }
                }
                if (listChunk.Count == chunkCount)
                {
                    break;
                }
                if (tryTimes == maxTryTimes)
                {
                    break;
                }
                listChunk = new List <ChunkData>();
                Task.Delay(10000);
            }
            if (listChunk.Count > 0)
            {
                string strChunked64Base = string.Empty;//it's str64base
                var    makna            = listChunk.OrderBy(a => a.ChunkCurrent).ToList();
                foreach (var item in listChunk.OrderBy(a => a.ChunkCurrent).ToList())
                {
                    strChunked64Base = strChunked64Base + item.DataChunk;
                }
                if (!string.IsNullOrEmpty(strChunked64Base))
                {
                    tempForByte = this.DeCompressedData(strChunked64Base);
                    //  var sshasil = Newtonsoft.Json.JsonConvert.DeserializeObject<List<RFIDTagStorage_Testing>>(sss);
                    byteData = Convert.FromBase64String(strChunked64Base);
                }
                dataResult.FileNameWithExt = listChunk[0].FileName;
                dataResult.DataChunk       = tempForByte;
            }


            return(dataResult);
        }
예제 #5
0
        public byte[] ConvertChunkDataResultToByteArray(ChunkDataResult chunkData)
        {
            string deCompress = (chunkData.DataChunk);

            return(Newtonsoft.Json.JsonConvert.DeserializeObject <byte[]>(deCompress));
        }
예제 #6
0
        public List <T> ConvertChunkDataResultToList <T>(ChunkDataResult chunkData) where T : class
        {
            string deCompress = (chunkData.DataChunk);

            return(Newtonsoft.Json.JsonConvert.DeserializeObject <List <T> >(deCompress));
        }