//TODO Optimize public static BatchRequestBody GetBatchRequestBody(Spreadsheet spreadsheet) { var requestData = new BatchRequestBody(); foreach (var googleSheet in spreadsheet) { var valueRange = new ValueRange(); valueRange.range = googleSheet.Name + "!A1:Z1000"; foreach (var googleSheetRow in googleSheet.Rows) { var row = new List <object>(); foreach (var googleSheetCell in googleSheetRow) { row.Add(googleSheetCell.Value); } valueRange.Add(row); } requestData.Add(valueRange); } return(requestData); }
private void UpdateInvidualObjectBoxDim(GstuSpreadSheet sheet) { BatchRequestBody updateRequest = new BatchRequestBody(); //Update the obj's scale in scene objToUpdate.objTransform.localScale = new Vector2(float.Parse(boxXDimInput.text), float.Parse(boxYDimInput.text)); updateRequest.Add(sheet[objToUpdate.UUID, "Box Dim"].AddCellToBatchUpdate(associatedSheet, warehouseItemsWorksheet, objToUpdate.objTransform.localScale.ToString())); updateRequest.Send(associatedSheet, warehouseItemsWorksheet, null); }
private void UpdateWarehouseData(GstuSpreadSheet sheet) { BatchRequestBody updateRequest = new BatchRequestBody(); foreach (KeyValuePair <string, WarehouseObject> pair in objectsInWarehouse) { //Add the updated data to the bach request updateRequest.Add(sheet[pair.Key, "Position"].AddCellToBatchUpdate(associatedSheet, associatedWorksheet, pair.Value.objTransform.position.ToString())); } //Send the request updateRequest.Send(associatedSheet, associatedWorksheet, null); }
private void UpdateIndvidualObjectUUID(GstuSpreadSheet sheet) { BatchRequestBody updateRequest = new BatchRequestBody(); updateRequest.Add(sheet[objToUpdate.UUID, "UUID"].AddCellToBatchUpdate(associatedSheet, warehouseItemsWorksheet, itemKeyInput.text)); objectsInWarehouse.Remove(objToUpdate.UUID); objectsInWarehouse.Add(itemKeyInput.text, objToUpdate); objToUpdate.UUID = itemKeyInput.text; updateRequest.Send(associatedSheet, warehouseItemsWorksheet, null); }
private void UpdateAnimalInformation(GstuSpreadSheet ss) { BatchRequestBody updateRequest = new BatchRequestBody(); updateRequest.Add(ss[animal.name, "Health"].AddCellToBatchUpdate(animal.associatedSheet, animal.associatedWorksheet, animal.health.ToString())); updateRequest.Add(ss[animal.name, "Defence"].AddCellToBatchUpdate(animal.associatedSheet, animal.associatedWorksheet, animal.health.ToString())); updateRequest.Add(ss[animal.name, "Attack"].AddCellToBatchUpdate(animal.associatedSheet, animal.associatedWorksheet, animal.health.ToString())); updateRequest.Send(animal.associatedSheet, animal.associatedWorksheet, null); ///Although this does work if requires that the list is set up in the correct order to write the data correctly, the above solution provides a more robust solution as the cells /// already know what to update. /*string cellRef = ss[animal.name, "Name"].CellRef(); //get the cell ref where the animal start, i know this because name is my first field for the data * List<string> list = new List<string>(); * list.Add(animal.name); * list.Add(animal.health.ToString()); * list.Add(animal.attack.ToString()); * list.Add(animal.defence.ToString()); * SpreadsheetManager.Write(new GSTU_Search(animal.associatedSheet, animal.associatedWorksheet, cellRef), list, null);*/ }
private void UpdateWarehouseData(GstuSpreadSheet sheet) { //Begin wiping old data-------------------------------------------------------------------------------------------------- BatchRequestBody updateRequest = new BatchRequestBody(); foreach (var warehouseUUID in sheet.columns["UUID"]) { if (warehouseUUID.value != "UUID") { updateRequest.Add(sheet[warehouseUUID.value, "Box Dim"].AddCellToBatchUpdate(associatedSheet, warehouseItemsWorksheet, "")); updateRequest.Add(sheet[warehouseUUID.value, "Position"].AddCellToBatchUpdate(associatedSheet, warehouseItemsWorksheet, "")); updateRequest.Add(sheet[warehouseUUID.value, "UUID"].AddCellToBatchUpdate(associatedSheet, warehouseItemsWorksheet, "")); } } updateRequest.Send(associatedSheet, warehouseItemsWorksheet, null); //End wiping old data------------------------------------------------------------------------------------------------------- //Begin importing new data-------------------------------------------------------------------------------------------------- List <List <string> > warehouseObjectImportList = new List <List <string> >(); foreach (KeyValuePair <string, WarehouseObject> pair in objectsInWarehouse) { List <string> temp = new List <string>() { pair.Value.UUID, pair.Value.objTransform.localScale.ToString(), pair.Value.objTransform.position.ToString() }; warehouseObjectImportList.Add(temp); } SpreadsheetManager.Write(new GSTU_Search(associatedSheet, warehouseItemsWorksheet, "A2"), new ValueRange(warehouseObjectImportList), null); //End importing new data---------------------------------------------------------------------------------------------------- }