Ejemplo n.º 1
0
 /// <summary>
 /// excute request
 /// </summary>
 /// <param name="cosRequest"></param>
 /// <param name="cosResult"></param>
 /// <exception cref="COSXML.CosException.CosClientException">CosClientException</exception>
 /// <exception cref="COSXML.CosException.CosServerException">CosServerException</exception>
 public void Excute(CosRequest cosRequest, CosResult cosResult)
 {
     try
     {
         Request request = CreateRequest(cosRequest);
         //extern informations exchange
         //cosResult.ExternInfo(cosRequest);
         Response response;
         if (cosRequest is GetObjectRequest)
         {
             GetObjectRequest getObjectRequest = cosRequest as GetObjectRequest;
             response = new CosResponse(cosResult, getObjectRequest.GetSaveFilePath(), getObjectRequest.GetLocalFileOffset(),
                                        getObjectRequest.GetCosProgressCallback());
         }
         else
         {
             response = new CosResponse(cosResult, null, -1L, null);
         }
         cosRequest.BindRequest(request);
         CommandTask.Excute(request, response, config);
     }
     catch (CosServerException)
     {
         throw;
     }
     catch (CosClientException)
     {
         throw;
     }
     catch (Exception ex)
     {
         throw new CosClientException((int)CosClientError.BAD_REQUEST, ex.Message, ex);
     }
 }
Ejemplo n.º 2
0
        // public void Execute(Request request, Response response)
        // {

        //     try
        //     {
        //         CommandTask.Excute(request, response, config);
        //     }
        //     catch (CosServerException)
        //     {
        //         throw;
        //     }
        //     catch (CosClientException)
        //     {
        //         throw;
        //     }
        //     catch (Exception ex)
        //     {
        //         throw new CosClientException((int)CosClientError.BadRequest, ex.Message, ex);
        //     }
        // }

        public void InternalSchedue(CosRequest cosRequest, CosResult cosResult, COSXML.Callback.OnSuccessCallback <CosResult> successCallback, COSXML.Callback.OnFailedCallback failCallback, QCloudCredentialProvider credentialProvider)
        {
            try
            {
                Request request = CreateRequest(cosRequest, credentialProvider);
                cosResult.ExternInfo(cosRequest);
                Response response;

                if (cosRequest is GetObjectRequest)
                {
                    GetObjectRequest getObjectRequest = cosRequest as GetObjectRequest;

                    response = new CosResponse(cosResult, getObjectRequest.GetSaveFilePath(), getObjectRequest.GetLocalFileOffset(),
                                               getObjectRequest.GetCosProgressCallback(), successCallback, failCallback);
                }
                else
                {
                    response = new CosResponse(cosResult, null, -1L, null, successCallback, failCallback);
                }

                cosRequest.BindRequest(request);
                CommandTask.Schedue(request, response, config);
            }
            catch (CosServerException serverException)
            {
                //throw serverException;
                failCallback(null, serverException);
            }
            catch (CosClientException clientException)
            {
                //throw clientException;
                failCallback(clientException, null);
            }
            catch (Exception ex)
            {
                //throw new CosClientException((int)CosClientError.BAD_REQUEST, ex.Message, ex);
                failCallback(new CosClientException((int)CosClientError.BadRequest, ex.Message, ex), null);
            }
        }