private static async Task<int> MainExec() { Exception ex = null; try { var client = new AmazonS3Client( "", "", RegionEndpoint.EUWest1); var ca = new CloudSync( new S3StorageProvider(client, "spielbucket", "bin"), new FileSystemStorageProvider(@"D:\sync"), Ctc.Token); ca.ActionFinished += (sender, e) => { double kbs = e.Action.Properties.Size/e.Duration.TotalMilliseconds; Console.WriteLine("{0,6:f0} ms - {1,5:f0} KB/s - {2}", e.Duration.TotalMilliseconds, kbs, e.Action); }; IList<StorageAction> result = ca.ComputeDestinationActions().Result; foreach (StorageAction storageAction in result) { Console.WriteLine(storageAction); } Console.WriteLine("continue to sync"); Console.ReadLine(); ca.ExecuteSync(result).Wait(); } catch (Exception e) { ex = e; } if (Ctc.IsCancellationRequested) { Console.WriteLine("User cancelled"); return 1; } if (ex != null) { Console.Error.WriteLine("General error"); Console.Error.WriteLine(ex); return 100; } return 0; }
// Use this for initialization void Start() { for (int i = 0; i < buttons.Length; i++) { buttonsPositions[i] = buttons[i].GetComponent <RectTransform>().anchoredPosition; buttonsAlphas[i] = buttons[i].GetComponent <Image>().color.a; } ratePlaceFormDest = ratePlaceForm.anchoredPosition; ratePlaceFormStartPos = ratePlaceFormDest; cs = Extensions.CloudSync(); }
// Use this for initialization void Start() { thisCanvasGroup = this.GetComponent <CanvasGroup>(); uiController.Initialize(); /* SHOWING MENU TUTORIAL ONLY WHEN FIRST USED */ if (!PlayerPrefs.HasKey("NotFirstLogin")) { uiController.menuTutorialShow(); PlayerPrefs.SetInt("NotFirstLogin", 1); } cs = Extensions.CloudSync(); }
// Use this for initialization void Start() { rt = this.GetComponent <RectTransform>(); Vector2 pos = rt.anchoredPosition * mainCanvas.scaleFactor; Vector2 size = rt.sizeDelta * mainCanvas.scaleFactor; minX = Screen.width / 2 - pos.x - size.x / 2; maxX = Screen.width / 2 + pos.x + size.x / 2; minY = Screen.height / 2 - pos.y - size.y / 2; maxY = Screen.height / 2 + pos.y + size.y / 2; cs = Extensions.CloudSync(); }
// This method will be used to execute the statement, but will only be called by another method in the class. private void InternalExecution() { try { // Set the Select Listener with Cloud Sync. CloudSync.SetSelectListener(this); // Here we will Execute the Query. // Reset the Session so it is clean. if (IsSuccessful()) { SQLiteCommand dbSess = cdb.GetSession(); dbSess.Reset(); // Create the SQL Statement. string sql = GetSQL(); dbSess.CommandText = sql; // Bind the Params. foreach (string paramName in bindObjs.Keys) { // Bind the Params. SQLiteParameter sqlParam = new SQLiteParameter(paramName, bindObjs[paramName]); // Add the Param to the Command. dbSess.Parameters.Add(sqlParam); } // Lets prepare the statement. dbSess.Prepare(); // Lets Execute the Query. SQLiteDataReader sdr = dbSess.ExecuteReader(); // Check if the user is waiting for the result. onDataResult?.Invoke(CloudDB.SQLiteReaderToRows(sdr)); } else { // The Select was not Successful. onDataResult?.Invoke(new List <Row>()); } } catch (Exception e) { // There was an Error. AddStatus("Execution Err : " + e.StackTrace + " ::: " + e.Message); onDataResult?.Invoke(new List <Row>()); } }
public void Initialize() { cs = Extensions.CloudSync(); poiFilters = cs.Filters; statsScreen.sizeDelta = this.GetComponent <RectTransform>().sizeDelta; filtersScreen.sizeDelta = this.GetComponent <RectTransform>().sizeDelta; statsScreen.anchoredPosition = new Vector2(-statsScreen.sizeDelta.x, 0); filtersScreen.anchoredPosition = new Vector2(filtersScreen.sizeDelta.x, 0); helpTutorialsAlphaDest = helpTutorials.alpha; statsScreenXDest = statsScreen.anchoredPosition.x; filtersScreenXDest = filtersScreen.anchoredPosition.x; addPlaceTutorialXDest = addPlaceTutorial.anchoredPosition.x; statsScreenXStart = statsScreenXDest; filtersScreenXStart = filtersScreenXDest; addPlaceTutorialXStart = addPlaceTutorialXDest; ratePlaceTutorialXStart = ratePlaceTutorialXDest; }
IEnumerator poiCollecting(float collectTime) { while (true && img.fillAmount < 1) { img.fillAmount += 0.007f; yield return(new WaitForSeconds(collectTime * 0.005f)); } img.fillAmount = 1; isCollected = true; beingCollected = false; this.GetComponent <Animation>().Play("collect"); /*---------------------------------------------------------------------------------------------------------------------------------------------------CLOUD!-------------------*/ CloudSync cs = Extensions.CloudSync(); cs.NewCollectedPois.Add(ID); cs.LatestDiscoveryCategory = this.categoryName; PlayerPrefs.SetString("LatestDiscoveryCategory", cs.LatestDiscoveryCategory); cs.NumberOfDiscoveredPlaces++; PlayerPrefs.SetInt("NumberOfDiscoveredPlaces", cs.NumberOfDiscoveredPlaces); /*--------------------------------------------------------------------------------------------------------------------------------------------------CLOUD!-------------------*/ }
// Use this for initialization void Start() { // Set FPS Application.targetFrameRate = 60; //Kalman filter kalman = new MatrixKalmanWrapper(); // Disable screen dimming Screen.sleepTimeout = SleepTimeout.NeverSleep; destinationPoint = this.transform.position; destinationAngle = this.transform.localEulerAngles.z; userZIndex = destinationPoint.z; cs = Extensions.CloudSync(); worldObject = GameObject.FindObjectOfType <World> (); latestGooglePoisDownloadPosition = destinationPoint; kalmanTimer = Time.time; }
// This method will handle the actual execution and will me called. private void InternalExecutor() { try { // Here we will Execute the Query. if (IsSuccessful()) { SQLiteCommand dbSess = cdb.GetSession(); // Lets set the deleted time. (This will be used to reject any deletes trying to be run twice) deletedTimeI = Helper.CurrentTimeMillis(); try { // Here we will Generate the SQL Statement. // Add the RLS System. if (CloudDB.IsSyncable(tableName)) { // The table required RLS. if (rlsID == 0) { // The user should not be allowed to execute this statement. AddStatus("RLS NOT Provided"); } else { // The RLS is Provided AddWhere(new Where("rls_id_", Where.Type.EQUAL, rlsID)); AddWhere(new Where("rls_type_", Where.Type.EQUAL, rlsType)); } } } catch (Exception e) { // There was an Error. isError = true; AddStatus("SQL Security : " + e.Message); } // Lets create the Statement. dbSess.CommandText = GetSQL(); // Bind the Params of the Where clause. foreach (string paramName in whereBindObjs.Keys) { // Bind the Params. SQLiteParameter sqlParam = new SQLiteParameter(paramName, whereBindObjs[paramName]); // Add the Param to the Command. dbSess.Parameters.Add(sqlParam); } // Lets prepare the statement. dbSess.Prepare(); // Lets Get the Data that will be deleted. List <Row> deletedRows = new List <Row>(); try { // Lets get the updated rows. // Lets Create the Statement to read from the updated table. StringBuilder sqlBuilder = new StringBuilder(); sqlBuilder.Append("SELECT * FROM ") .Append(tableName) .Append(" WHERE ") .Append(whereClauseBuilder); // Lets Get the Session Object. SQLiteCommand readSess = cdb.GetSession(); // Create the Statement. readSess.CommandText = sqlBuilder.ToString(); // Bind the Columns Params. foreach (string paramName in whereBindObjs.Keys) { // Bind the Params. SQLiteParameter sqlParam = new SQLiteParameter(paramName, whereBindObjs[paramName]); // Add the Param to the Command. readSess.Parameters.Add(sqlParam); } // Lets Prepare the Statement. readSess.Prepare(); // Lets execute the query. SQLiteDataReader sdr = readSess.ExecuteReader(); // Lets read the data and add the data to the Rows List. deletedRows = CloudDB.SQLiteReaderToRows(sdr); // Reset the Session. readSess.Reset(); } catch (Exception e) { // There was an Error. } // Lets Execute the Query. // The user is not asking to create a reader, just to insert the value. int deletedRowsNum = dbSess.ExecuteNonQuery(); // Send to the Receiver if the user has set a insert result listener. onDataDeleted?.Invoke(deletedRows); try { // Checking about the deleted rows. if (deletedRows.Count == deletedRowsNum) { AddStatus("All the Deletes worked perfectly."); } else if (deletedRows.Count > deletedRowsNum) { AddStatus("All the Rows Required didn't get deleted"); } else { AddStatus("All the Rows Deleted, have not been sent to the user."); } } catch (Exception er) { // There was an Error } // Reset the Session if another similar query is to be run. dbSess.Dispose(); // If the data is to be synced with the server, we will sync it with the server. if (syncable && deletedRowsNum > 0) { // The data is to be synced with the Cloud Server. CloudSync.Sync(this, deletedRows); } } else { // The Delete System Failed somewhere. AddStatus("Err : Delete Failure"); } } catch (Exception e) { // There was an Error. AddStatus("Err : " + e.Message + " : " + e.StackTrace); } }
// Here we will run an internal executor to run the actual execution of the statement. private int InternalExecutor() { try { // Here we will Execute the Statement, and bind the Params. // Lets create the Statement. if (IsSuccessful()) { // Reset the Session So if Any uncompleted Call does'nt interupt this call. SQLiteCommand dbSess = cdb.GetSession(); dbSess.Reset(); // Check if the table is a syncable table. if (CloudDB.IsSyncable(tableName)) { // The table is a syncable table. // Lets Add the RLS system. if (rlsID == 0 || rlsType == 0) { // The table is a syncable table, but the RLS Values are not provided. // So we will not let it complete the process. isError = true; AddStatus("User NOT Authenticated to Write in this RLS"); } else { // The user has provided the RLS Data. PutColumnInternal(new ColumnData("rls_id_", rlsID)); PutColumnInternal(new ColumnData("rls_type_", rlsType)); } // Now lets generate the Sync ID. if (GetSyncID() == null || GetSyncID().Trim().Length != 36) { // The sync id has not been set. // Lets set it. SetSyncID(Guid.NewGuid().ToString()); } PutColumnInternal(new ColumnData("sync_id_", GetSyncID())); // Lets set the Update Time. try { if (updateTimeI == 0) { // Lets Create an Update Time. updateTimeI = Helper.CurrentTimeMillis(); } PutColumnInternal(new ColumnData("update_time_", updateTimeI)); } catch (Exception er) { // There was an Error. } } else { // Lets set the Other Data Points if they are given explicitly. if (updateTimeI != 0) { PutColumnInternal(new ColumnData("update_time_", updateTimeI)); } } // Set the Tenant ID. if (CloudDB.IsMultiTenant(tableName)) { // The table is multi-tenant. PutColumnInternal(new ColumnData("tenant_id_", tenantID)); } // The Insert Statement Generating was succesful, we can run the Statement. string sql = GetSQL(); breadCrumb.BC.Debug("INSERT SQL : " + sql); dbSess.CommandText = sql; // Bind the Params. foreach (string paramName in bindObjs.Keys) { // Bind the Params. SQLiteParameter sqlParam = new SQLiteParameter(paramName, bindObjs[paramName]); // Add the Param to the Command. dbSess.Parameters.Add(sqlParam); } // Lets prepare the statement. dbSess.Prepare(); int inserted = -1; // Lets Execute the Query. // The user is not asking to create a reader, just to insert the value. inserted = dbSess.ExecuteNonQuery(); // Send to the Receiver if the user has set a insert result listener. onDataInserted?.Invoke(inserted); // If the data is to be synced with the server, we will sync it with the server. if (syncable) { // The data is to be synced with the Cloud Server. CloudSync.Sync(this); } return(inserted); } else { // The Insert Statement Generation was not successful. return(-1); } } catch (Exception e) { // THere was an Error. Console.WriteLine("Err : " + e.Message + " : " + e.StackTrace); AddStatus("Err : " + e.Message + " : " + e.StackTrace); return(-1); } }
IEnumerator Start() { cs = Extensions.CloudSync(); // First, check if user has location service enabled if (!Input.location.isEnabledByUser) { txt.text = "Location service disabled! Enable location in settings!"; #if UNITY_EDITOR world.Initialize(currentPos); #endif // Windows store implementation here #if NETFX_CORE WSANativeDialog.ShowDialog("Wrong settings!", "Enable localization in settings!"); #endif #if UNITY_ANDROID AndroidNativeFunctions.ShowAlert("Please enable localization in settings.", "Alert!", "OK", null, null, null); #endif yield break; } // Start service before querying location Input.location.Start(0.5f, 0.5f); txt.text = "Initializing"; // Wait until service initializes while (Input.location.status == LocationServiceStatus.Initializing) { txt.text += "."; if (txt.text.Contains("....")) { txt.text = "Initializing"; } yield return(new WaitForSeconds(1)); } if (Input.location.status == LocationServiceStatus.Failed) { txt.text = "Positioning failed, check settings and relaunch application!"; // Windows store implementation here #if NETFX_CORE WSANativeDialog.ShowDialog("GPS error!", "Please check Your settings!"); #endif #if UNITY_ANDROID AndroidNativeFunctions.ShowAlert("Localization failed, please check Your settings.", "Alert!", "OK", null, null, null); #endif yield break; } // Wait for fix while (Input.location.lastData.horizontalAccuracy > 70) { txt.text = "Waiting for GPS fix..., " + "current GPS accuracy (needed < 70): " + Input.location.lastData.horizontalAccuracy + ", if it takes too long, try restarting MiCity!"; yield return(new WaitForSeconds(1)); } if (Input.location.status == LocationServiceStatus.Running) { world.Initialize(new Vector2(Input.location.lastData.longitude, Input.location.lastData.latitude)); currentPosLONLAT = new Vector2(Input.location.lastData.longitude, Input.location.lastData.latitude); cs.UserPathCoordinates.Add(new Vector2(Input.location.lastData.longitude, Input.location.lastData.latitude)); lastTimestamp = System.DateTime.UtcNow.Subtract(new System.DateTime(1970, 1, 1)).TotalSeconds; txt.text = "Initialized!"; yield break; } }
/* POIs STYLING */ public bool Initialize(Vector2 coord, string id, Dictionary <string, string> properties, Vector2 pos, Sprite[] POIsprites, Canvas poiCanvas, Transform userPos, AnimationClip[] POIAnims, UiController uiController, RateButtonsController rtController) { this.Id = id; this.Coords = coord; this.userPosition = userPos; this.uiController = uiController; this.rtController = rtController; if (properties.ContainsKey("kind")) { this.Kind = properties ["kind"]; } else if (properties.ContainsKey("types")) { string[] splitted = properties ["types"].Split(','); this.Kind = ""; foreach (string str in splitted) { if (str != "point_of_interest" && str != "establishment") { this.Kind = this.Kind + str + ","; } } if (this.Kind.Length > 0) { this.Kind = this.Kind.Remove(this.Kind.Length - 1); } } if (properties.ContainsKey("name:en")) { this.Name = properties["name:en"]; } else if (properties.ContainsKey("name")) { this.Name = properties["name"]; } else if (properties.ContainsKey("cuisine")) { this.Name = properties["cuisine"].Replace("_", " ").ToUpperInvariant(); } else if (properties.ContainsKey("attraction")) { this.Name = properties["attraction"].Replace("_", " ").ToUpperInvariant(); } if (this.Name == null || this.Name.Length == 0) { Destroy(this.gameObject); return(false); } this.Name = ParseUnicodeEscapes(this.Name); anim = this.GetComponent <Animation>(); anim.AddClip(POIAnims[0], "in"); anim.AddClip(POIAnims[1], "out"); anim.AddClip(POIAnims[2], "collect"); img = this.GetComponent <Image>(); Sprite[] poiSpriteSet = new Sprite[3]; /* CHECKING POI CATEGORY */ if (Array.IndexOf(culture, Kind) > -1 || culture.Intersect(Kind.Split(',')).Any()) { categoryID = 0; CategoryName = "Culture"; } else if (Array.IndexOf(history, Kind) > -1 || history.Intersect(Kind.Split(',')).Any()) { categoryID = 4; CategoryName = "History"; } else if (Array.IndexOf(nature, Kind) > -1 || nature.Intersect(Kind.Split(',')).Any()) { categoryID = 5; CategoryName = "Nature"; } else if (Array.IndexOf(sports, Kind) > -1 || sports.Intersect(Kind.Split(',')).Any()) { categoryID = 7; CategoryName = "Sport"; } else if (Array.IndexOf(food, Kind) > -1 || food.Intersect(Kind.Split(',')).Any()) { categoryID = 3; CategoryName = "Food"; } else if (Array.IndexOf(nightlife, Kind) > -1 || nightlife.Intersect(Kind.Split(',')).Any()) { categoryID = 6; CategoryName = "Nightlife"; } else if (Array.IndexOf(drink, Kind) > -1 || drink.Intersect(Kind.Split(',')).Any()) { categoryID = 2; CategoryName = "Drink"; } else if (Array.IndexOf(entertainment, Kind) > -1 || entertainment.Intersect(Kind.Split(',')).Any()) { categoryID = 1; CategoryName = "Entertainment"; } /* IF POI CATEGORY WAS ASSIGNED */ if (categoryID > -1) { poiSpriteSet[0] = POIsprites[categoryID]; poiSpriteSet[1] = POIsprites[categoryID + categoriesNum]; poiSpriteSet[2] = POIsprites[categoryID + categoriesNum * 2]; /* NORMAL POI STYLE, SIZE, POSITION */ img.sprite = poiSpriteSet[0]; this.transform.position = new Vector3(pos.x, pos.y, -5); this.GetComponent <RectTransform>().sizeDelta = Vector2.zero; /* POI FILL */ GameObject poiFill = (GameObject)Instantiate(this.gameObject, this.transform.position, this.transform.rotation); poiFill.isStatic = true; poiFill.transform.SetParent(this.transform); poiCollect = poiFill.AddComponent <PoiCollect>(); poiCollect.Initialize(poiSpriteSet[1], poiSpriteSet[2], this.Id, this.CategoryName); /* ------------------------------------------------------------------------------CLOUD!!!---------------------------------------------------------------------- */ CloudSync cs = Extensions.CloudSync(); if (cs.AllCollectedPois.Contains(this.Id)) { onScreen = true; poiCollect.instantCollectPOI(); } /*-------------------------------------------------------------------------------------------------------------------------------------CLOUD!-------------------*/ return(true); } /* IF POI CATEGORY WASN'T ASSIGNED, JUST DESTROY IT */ else { Destroy(this.gameObject); return(false); } }