private int GeneratePartInfo()
        {
            long partNum = m_qwFileSize / m_dataSize;

            for (int i = 0; i < partNum; i++)
            {
                FilePartInfo stInfo = new FilePartInfo();
                stInfo.DataSize = m_dataSize;
                stInfo.IsSend   = 0;
                stInfo.Offset   = m_dataSize * i;
                this.m_arrPartInfo.Add(stInfo);
            }
            if (partNum * m_dataSize < m_qwFileSize)
            {
                FilePartInfo stInfo = new FilePartInfo();
                stInfo.DataSize = m_qwFileSize - partNum * m_dataSize;
                stInfo.IsSend   = 0;
                stInfo.Offset   = partNum * m_dataSize;
                this.m_arrPartInfo.Add(stInfo);
            }
            return(0);
        }
        public int PartUpload(int iIndex)
        {
            if (m_strFileSha == "")
            {
                return(-1);
            }

            int     retryLimit = MAX_RETRY_TIME;
            JObject jsonobj    = new JObject();
            Dictionary <String, Object> mapVals = new Dictionary <String, Object>();

            InitCommPara(mapVals);
            while (true)
            {
                FilePartInfo partInfo = m_arrPartInfo[iIndex];
                if (partInfo.IsSend == 1)
                {
                    Console.WriteLine("sent fileInfo " + m_iSendBolock + " " + m_iFinishBlock);
                    return(0);
                }
                FileStream stFile = new System.IO.FileStream(m_strFilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                stFile.Seek(partInfo.Offset, 0);
                byte[] buf = new byte[(int)partInfo.DataSize];
                int    ret = stFile.Read(buf, 0, (int)partInfo.DataSize);
                stFile.Close();
                if (ret != partInfo.DataSize)
                {
                    return(-2001);
                }
                mapVals["Action"]   = m_strPartUploadCmd;
                mapVals["dataSize"] = partInfo.DataSize;
                mapVals["offset"]   = partInfo.Offset;
                Stream stInput = new MemoryStream(buf);
                String strMd5  = calStreamShaMd5(stInput, "MD5");
                mapVals["dataMd5"] = strMd5.ToLower();
                String strSign = GetReqSign(mapVals);
                String strReq  = GetReqUrl(mapVals, strSign);
                try
                {
                    ret = SendData(strReq, buf, (int)(partInfo.DataSize), ref jsonobj);
                    if (ret != 0 && retryLimit > 0)
                    {
                        retryLimit--;
                        if (retryLimit <= 0)
                        {
                            return(-2100 + ret);
                        }
                        continue;
                    }
                }
                catch (Exception e)
                {
                    if (retryLimit > 0)
                    {
                        retryLimit--;
                        if (retryLimit <= 0)
                        {
                            return(-2003);
                        }
                        continue;
                    }
                }
                int retCode = (int)jsonobj.SelectToken("code");
                if (retCode == 0)
                {
                    Interlocked.Add(ref m_iSendBolock, 1);
                    Interlocked.Add(ref m_iFinishBlock, 1);
                    Console.WriteLine("fileInfo " + m_iSendBolock + " " + m_iFinishBlock);
                    partInfo.IsSend = 1;
                }
                else
                {
                    int canRetry = (int)jsonobj.SelectToken("canRetry");
                    if (canRetry == 1 && retryLimit > 0)
                    {
                        retryLimit--;
                        if (retryLimit <= 0)
                        {
                            return(-2002);
                        }
                        continue;
                    }
                }
                return(0);
            }
        }