Пример #1
0
 public async Task <string> UpdateProducts(BatchObject <T6> pb, Dictionary <string, string> parms = null)
 {
     return(await API.SendHttpClientRequest("products/batch", RequestMethod.PUT, pb, parms).ConfigureAwait(false));
 }
Пример #2
0
 public async Task <string> UpdateCustomers(BatchObject <T2> cb, Dictionary <string, string> parms = null)
 {
     return(await API.SendHttpClientRequest("customers/batch", RequestMethod.POST, cb, parms).ConfigureAwait(false));
 }
Пример #3
0
 public async Task <string> UpdateOrders(BatchObject <T3> ob, Dictionary <string, string> parms = null)
 {
     return(await API.SendHttpClientRequest("orders/batch", RequestMethod.PUT, ob, parms).ConfigureAwait(false));
 }
Пример #4
0
 public void SetCharacter(char c)
 {
     charRenderable = new BatchObject(Mesh.Character(font, c));
     charRenderable.SetColor(color);
 }
Пример #5
0
 public FileIO(BatchLine bl, BatchObject bo)
 {
     this.batLine = bl;
     this.batObj  = bo;
 }
Пример #6
0
 public EnemyPointer(Game game)
 {
     this.game = game;
     pointer   = new BatchObject(UISpriteManager.Get("UI_enemy_arrow")[0]);
 }
Пример #7
0
        public async Task <IActionResult> HandleBatchRequest(
            int hostId,
            string repositoryName,
            [FromBody] BatchRequest request)
        {
            GitHost host = await this.context.GitHost.FindAsync(hostId).ConfigureAwait(false);

            if (host == null)
            {
                return(this.NotFound(new ErrorResponse {
                    Message = "Not a valid host id."
                }));
            }

            var serverBatchRequest = new BatchRequest
            {
                Objects   = new List <ObjectId>(),
                Operation = request.Operation,
                Transfers = request.Transfers
            };

            foreach (ObjectId objectId in request.Objects)
            {
                if (request.Operation == BatchRequestMode.Download &&
                    this.fileManager.IsFileStored(repositoryName, objectId, FileLocation.Permanent))
                {
                    continue;
                }

                serverBatchRequest.Objects.Add(objectId);
            }

            try
            {
                IDictionary <ObjectId, IBatchObject> batchObjects = new Dictionary <ObjectId, IBatchObject>();
                if (serverBatchRequest.Objects.Count > 0)
                {
                    BatchTransfer serverResults =
                        await this.lfsClient.RequestBatchAsync(host, repositoryName, serverBatchRequest).ConfigureAwait(false);

                    foreach (IBatchObject serverResult in serverResults.Objects)
                    {
                        batchObjects.Add(serverResult.Id, serverResult);

                        if (serverResult is BatchObject batchObject)
                        {
                            foreach (BatchObjectAction action in batchObject.Actions)
                            {
                                await this.fileManager.SaveFileAsync(
                                    repositoryName,
                                    serverResult.Id,
                                    FileLocation.Metadata,
                                    this.transferSerialiser.ToString(action),
                                    action.Mode.ToString().ToLowerInvariant()).ConfigureAwait(false);
                            }
                        }
                    }
                }

                var returnResult = new BatchTransfer();
                returnResult.Mode    = TransferMode.Basic;
                returnResult.Objects = new List <IBatchObject>();

                foreach (ObjectId pendingObjectId in request.Objects)
                {
                    batchObjects.TryGetValue(pendingObjectId, out IBatchObject batchObjectBase);
                    var batchObject = batchObjectBase as BatchObject;

                    if (batchObjectBase is BatchObjectError errorResult)
                    {
                        returnResult.Objects.Add(errorResult);
                    }
                    else
                    {
                        switch (request.Operation)
                        {
                        case BatchRequestMode.Upload:
                            returnResult.Objects.Add(batchObject);
                            break;

                        case BatchRequestMode.Download:
                        {
                            var returnBatchObject = new BatchObject {
                                Id = pendingObjectId, Actions = new List <BatchObjectAction>()
                            };
                            var action = new BatchObjectAction
                            {
                                Mode = BatchActionMode.Download,
                                HRef =
                                    $"{this.Request.Scheme}://{this.Request.Host}/api/{hostId}/{repositoryName}/info/lfs/{pendingObjectId.Hash}/{pendingObjectId.Size}"
                            };

                            returnBatchObject.Actions.Add(action);
                            returnResult.Objects.Add(returnBatchObject);
                            break;
                        }
                        }
                    }
                }

                return(this.Ok(returnResult));
            }
            catch (ErrorResponseException ex)
            {
                this.logger.LogWarning(null, ex, $"Received a error response with message {ex.Message}");
                return(this.StatusCode(ex.StatusCode ?? DefaultErrorCode, ex.ErrorResponse));
            }
            catch (StatusCodeException ex)
            {
                this.logger.LogWarning(null, ex, $"Received a status code error with message {ex.Message}");
                return(this.StatusCode(ex.StatusCode ?? DefaultErrorCode, new ErrorResponse {
                    Message = ex.Message
                }));
            }
        }
Пример #8
0
 public async Task <string> UpdateWebhooks(BatchObject <T14> obj, Dictionary <string, string> parms = null)
 {
     return(await API.SendHttpClientRequest("webhooks/batch", RequestMethod.PUT, obj, parms));
 }
Пример #9
0
 public async Task <string> UpdateCoupons(BatchObject <T1> cb, Dictionary <string, string> parms = null)
 {
     return(await API.SendHttpClientRequest("coupons/batch", RequestMethod.PUT, cb, parms));
 }
Пример #10
0
 public async Task <string> UpdateTaxRates(BatchObject <T12> tb, Dictionary <string, string> parms = null)
 {
     return(await API.SendHttpClientRequest("taxes/batch", RequestMethod.PUT, tb, parms));
 }
Пример #11
0
 public async Task <string> UpdateProductTags(BatchObject <T11> pb, Dictionary <string, string> parms = null)
 {
     return(await API.SendHttpClientRequest("products/tags/batch", RequestMethod.PUT, pb, parms));
 }
Пример #12
0
 public async Task <string> UpdateProductShippingClasses(BatchObject <T10> sb, Dictionary <string, string> parms = null)
 {
     return(await API.SendHttpClientRequest("products/shipping_classes/batch", RequestMethod.PUT, sb, parms));
 }
Пример #13
0
 public async Task <string> UpdateProductAttributes(BatchObject <T8> ab, Dictionary <string, string> parms = null)
 {
     return(await API.SendHttpClientRequest("products/attributes/batch", RequestMethod.PUT, ab, parms));
 }
Пример #14
0
 public async Task <string> UpdateProductCategories(BatchObject <T7> cb, Dictionary <string, string> parms = null)
 {
     return(await API.SendHttpClientRequest("products/categories/batch", RequestMethod.PUT, cb, parms));
 }