IEnumerator SwitchCoroutine(ExpenseListElement element, Project prevProject) { ExpenseList.RemoveListElement(element); prevProject.ItemCount--; element.Item.Project.ItemCount++; List <Project> projects = new List <Project>(); projects.Add(prevProject); projects.Add(element.Item.Project); Task task = projects.SaveAllAsync(); while (!task.IsCompleted) { yield return(null); } if (task.Exception != null) { DefaultAlert.Present("Sorry!", "An error occured and we " + "could not update the projects' item count"); } }
IEnumerator UpdateClients(ProjectListElement element, Client previous) { LoadAlert.Instance.StartLoad("Updating Clients...", null, -1); List <Client> updates = new List <Client>(); previous.ProjectCount--; element.Project.Client.ProjectCount++; updates.Add(previous); updates.Add(element.Project.Client); Task updateClient = updates.SaveAllAsync(); while (!updateClient.IsCompleted) { yield return(null); } LoadAlert.Instance.Done(); if (updateClient.Exception == null) { ProjectList.RemoveListElement(element); } }
// Store all game objects with the BuildingBlock-tag using Parse IEnumerator SubmitSceneToParse_Local() { List <ParseBuildingBlock> newBlocks = new List <ParseBuildingBlock> (); var gameObjectBlocks = GameObject.FindGameObjectsWithTag("BuildingBlock"); foreach (var gameObjectBlock in gameObjectBlocks) { bool blockExists = false; //iterate all blocks, if a block does not exist then add it to newblocks array, otherwise update its values foreach (var block in AppModel.currentBlocks) { if (block.ObjectId == gameObjectBlock.GetComponent <BuildingBlock>().objectId) { if (block.posX != gameObjectBlock.transform.position.x || block.posY != gameObjectBlock.transform.position.y || block.rotZ != gameObjectBlock.transform.rotation.z) { block.posX = gameObjectBlock.transform.position.x; block.posY = gameObjectBlock.transform.position.y; block.rotZ = gameObjectBlock.transform.rotation.eulerAngles.z; block.SaveAsync().ContinueWith(t => { }); } blockExists = true; break; } } if (blockExists) { continue; } //add the block as a new item ParseBuildingBlock newBlock = new ParseBuildingBlock(); newBlock.matchId = AppModel.currentMatch.ObjectId; newBlock.originalPosX = gameObjectBlock.GetComponent <BuildingBlock>().originalPosX; newBlock.originalPosY = gameObjectBlock.GetComponent <BuildingBlock>().originalPosY; newBlock.originalRotZ = gameObjectBlock.GetComponent <BuildingBlock>().originalRotZ; newBlock.posX = gameObjectBlock.transform.position.x; newBlock.posY = gameObjectBlock.transform.position.y; newBlock.rotZ = gameObjectBlock.transform.rotation.eulerAngles.z; newBlock.index = gameObjectBlock.GetComponent <BuildingBlock>().index; newBlock.SetBuildingBlockType(gameObjectBlock.GetComponent <BuildingBlock>().buildingBlockType); newBlocks.Add(newBlock); } //if newblocks array has objects, upload them if (newBlocks.Count() > 0) { newBlocks.SaveAllAsync().ContinueWith(t => { }); } //change turn for the match object, then return to matches screen AppModel.currentMatch ["playerTurn"] = AppModel.currentOpponent; var updateTurn = AppModel.currentMatch.SaveAsync(); while (!updateTurn.IsCompleted) { yield return(null); } if (!updateTurn.IsCanceled && !updateTurn.IsFaulted) { headerText.text = "Waiting for " + AppModel.currentOpponent["displayName"].ToString(); refreshImage.gameObject.SetActive(true); refreshImage.transform.parent.gameObject.SetActive(true); } // Activate back button GameObject.Find("BackButton").GetComponent <Button>().interactable = true; }
private async void Button_Click_1(object sender, RoutedEventArgs e) { string parsedStream; StorageFolder tempFolder = ApplicationData.Current.LocalFolder; StorageFile file = await tempFolder.GetFileAsync("pontos.json"); var buffer = await FileIO.ReadBufferAsync(file); using (var dr = DataReader.FromBuffer(buffer)) { var bytes1251 = new Byte[buffer.Length]; dr.ReadBytes(bytes1251); parsedStream = Encoding.GetEncoding("ISO-8859-1").GetString(bytes1251, 0, bytes1251.Length); } JsonClass lm = JsonConvert.DeserializeObject<JsonClass>(parsedStream); List<Pluviometro> lstUp = new List<Pluviometro>(); foreach (Placemark item in lm.Placemark) { Pluviometro pv = new Pluviometro(); string[] str = item.name.Split('-'); string[] strRaio = item.LookAt.range.Split('.'); pv.idEstacao = Convert.ToInt32(str[0].Substring(str[0].Length - 2)); pv.nomeLocal = str[1]; pv.raio = Convert.ToInt32(strRaio[0]); pv.latLng = new ParseGeoPoint(Convert.ToDouble(item.LookAt.latitude), Convert.ToDouble(item.LookAt.longitude)); lstUp.Add(pv); } await lstUp.SaveAllAsync(); }
static void sendHeroDataToParse(Dictionary<string, string> saveData, string heroId) { List<ParseObject> dataObj = new List<ParseObject> (); foreach (KeyValuePair<string,string> pair in saveData) { ParseObject PO = new ParseObject(TABLE_NAME); PO[HERO_ID_COLUMN] = heroId; PO[ATTRIBUTE_NAME_COLUMN] = pair.Key; PO[ATTRIBUTE_VALUE_COLUMN] = pair.Value; dataObj.Add(PO); } dataObj.SaveAllAsync (); }