public SearchViewController ()
		{
			previousSearchRequests = new List<CKRecord> ();

			if (CKContainer.DefaultContainer != null)
				cloudManager = new CloudManager ();
		}
		public async override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			this.Title = "Cloud Beacons";
			cloudAPI = new CloudManager ();
			beaconManager = new BeaconManager ();
		
			try
			{
				 cloudAPI.FetchEstimoteBeaconsWithCompletion(new ArrayCompletionBlock(delegate {
					try
					{
						TableView.ReloadData();
					}
					catch
					{
						new UIAlertView ("Error", "Unable to fetch cloud beacons, ensure you have set Config in AppDelegate", null, "OK").Show ();
					}

				}));
				TableView.ReloadData();
			}
			catch(Exception ex) {
				new UIAlertView ("Error", "Unable to fetch cloud beacons, ensure you have set Config in AppDelegate", null, "OK").Show ();
			}
		}
		public async override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			this.Title = "Cloud Nearables";
			nearableManager = new NearableManager ();
		
			try
			{
                var cloudApi = new CloudManager ();
                nearables = await cloudApi.FetchEstimoteNearablesAsync ();

				TableView.ReloadData();
			}
			catch(Exception ex) {
				new UIAlertView ("Error", "Unable to fetch cloud nearable, ensure you have set Config in AppDelegate", null, "OK").Show ();
			}
		}
		public override async void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			this.TableView = new UITableView (this.View.Bounds, UITableViewStyle.Grouped);
			this.TableView.WeakDataSource = this;
			this.TableView.WeakDelegate = this;

			this.TableView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

			this.Title = "Cloud Beacons";
			cloudAPI = new CloudManager ();
		
			try {
                beacons = await cloudAPI.FetchEstimoteBeaconsAsync ();					
				TableView.ReloadData ();				
			} catch {
				new UIAlertView ("Error", "Unable to fetch cloud beacons, ensure you have set Config in AppDelegate", null, "OK").Show ();
			}
		}
예제 #5
0
        public void StartScanning(int milliSecond = 0)
        {
            BeaconManager = new BeaconManager();
            BeaconManager.ReturnAllRangedBeaconsAtOnce = true;
            BeaconRegion = new CLBeaconRegion(new NSUuid(App.Self.BEACON_ID), "beacons");
            CheckForBluetooth();
            BeaconRegion.NotifyEntryStateOnDisplay = true;
            BeaconRegion.NotifyOnEntry = true;
            BeaconRegion.NotifyOnExit = true;

            AppDelegate.Self.LocationManager.DidStartMonitoringForRegion += (object sender, CLRegionEventArgs e) =>
            AppDelegate.Self.LocationManager.RequestState(e.Region);

            CloudManager = new CloudManager();

            try
            {
                var beacons = CloudManager.FetchEstimoteBeaconsAsync().ContinueWith(t =>
                    {
                        if (t.IsCompleted)
                        {
                            var list = t.Result;
                            foreach (var b in list)
                            {
                                App.Self.Beacons.Add(new BeaconData
                                    {
                                        MacAddress = b.MacAddress.ToString(),
                                        Major = (int)b.Major, MeasuredPower = (int)b.Power, Minor = (int)b.Minor,
                                        Name = b.Name, /*Rssi = e.Region.Rssi,*/ ProximityUUID = b.ToString(),
                                        Region = new RegionData
                                        {
                                            Major = (int)b.Major, Minor = (int)b.Minor,
                                            Identifier = b.Name, ProximityUUID = b.ProximityUUID.ToString()
                                        }
                                    });
                            }
                        }
                    }).ConfigureAwait(true);
            }
            catch
            {
                new UIAlertView("Error", "Unable to fetch cloud beacons, ensure you have set Config in AppDelegate", null, "OK").Show();
            }

            AppDelegate.Self.LocationManager.RegionEntered += (object sender, CLRegionEventArgs e) =>
            {
                if (e.Region.Identifier == App.Self.BEACON_ID)
                {
                    Console.WriteLine("beacon region entered");
                }
            };

            AppDelegate.Self.LocationManager.DidDetermineState += (object sender, CLRegionStateDeterminedEventArgs e) =>
            {

                switch (e.State)
                {
                    case CLRegionState.Inside:
                        Console.WriteLine("region state inside");
                        break;
                    case CLRegionState.Outside:
                        Console.WriteLine("region state outside");
                        break;
                    case CLRegionState.Unknown:
                    default:
                        Console.WriteLine("region state unknown");
                        break;
                }
            };

            AppDelegate.Self.LocationManager.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) =>
            {
                if (e.Beacons.Length > 0)
                {

                    CLBeacon beacon = e.Beacons[0];
                    switch (beacon.Proximity)
                    {
                        case CLProximity.Immediate:
                            message = "Immediate";
                            break;
                        case CLProximity.Near:
                            message = "Near";
                            break;
                        case CLProximity.Far:
                            message = "Far";
                            break;
                        case CLProximity.Unknown:
                            message = "Unknown";
                            break;
                    }

                    if (previousProximity != beacon.Proximity)
                    {
                        Console.WriteLine(message);
                    }
                    previousProximity = beacon.Proximity;
                }
            };

            //if (BeaconManager.IsAuthorizedForMonitoring && BeaconManager.IsAuthorizedForRanging)
            //{
            BeaconRegion = new CLBeaconRegion(new NSUuid(App.Self.BEACON_ID), "BeaconSample");
            BeaconManager.RangedBeacons += (object sender, RangedBeaconsEventArgs e) =>
            {
                foreach (var beacon in App.Self.Beacons)
                {
                    var found = e.Beacons.FirstOrDefault(t => (int)t.Major == beacon.Major);
                    var idx = e.Beacons.ToList().IndexOf(found);
                    if (found != null)
                    {
                        if (idx < App.Self.Beacons.Count)
                        {
                            App.Self.Beacons[idx].Rssi = (int)found.Rssi;
                        }
                    }
                }
            };

            BeaconManager.EnteredRegion += (sender, e) =>
            {
                if (App.Self.Beacons.Count != 0)
                {
                    var exists = (from beacon in App.Self.Beacons
                                                 where beacon.Major == (int)e.Region.Major
                                                 select beacon).FirstOrDefault();
                    //var exists = App.Self.Beacons.FirstOrDefault(t => t.Major == e.Beacons.FirstOrDefault(w => w.Major));
                    if (exists == null)
                        App.Self.Beacons.Add(exists);
                    else
                    {
                        var index = App.Self.Beacons.IndexOf(exists);
                        if (index != -1)
                            App.Self.Beacons[index] = exists;
                    }
                }
                else
                {
                    App.Self.Beacons.Add(new BeaconData
                        {
                            /*MacAddress = beacon.MacAddress.ToString(),*/
                            Major = (int)e.Region.Major, MeasuredPower = (int)e.Region.Radius, Minor = (int)e.Region.Minor,
                            /*Name = beacon.Name, Rssi = e.Region.Rssi,*/ ProximityUUID = e.Region.ProximityUuid.ToString(),
                            Region = new RegionData
                            {
                                Major = (int)e.Region.Major, Minor = (int)e.Region.Minor,
                                Identifier = e.Region.Identifier, ProximityUUID = e.Region.ProximityUuid.ToString()
                            }
                        });
                }
            };

            BeaconManager.ExitedRegion += (sender, e) =>
            {
                if (App.Self.Beacons.Count != 0)
                {
                    var exists = (from b in App.Self.Beacons
                                                 let reg = b.Region
                                                 where reg.Identifier == e.Region.Identifier
                                                 select reg).FirstOrDefault();
                    if (exists != null)
                    {
                        var index = App.Self.Beacons.IndexOf(App.Self.Beacons.FirstOrDefault(t => t.Region.Major == (int)e.Region.Major));
                        App.Self.Beacons.RemoveAt(index);
                    }
                }
            };
            //}
        }
        public async override Task AdvanceDemoAsync()
        {
            switch (currentAppState)
            {
            case AppState.DemoStepCreateSession:
                if (CloudManager.Session == null)
                {
                    await CloudManager.CreateSessionAsync();
                }
                currentCloudAnchor = null;
                currentAppState    = AppState.DemoStepConfigSession;
                break;

            case AppState.DemoStepConfigSession:
                ConfigureSession();
                currentAppState = AppState.DemoStepStartSession;
                break;

            case AppState.DemoStepStartSession:
                await CloudManager.StartSessionAsync();

                currentAppState = AppState.DemoStepCreateLocationProvider;
                break;

            case AppState.DemoStepCreateLocationProvider:
                locationProvider = new PlatformLocationProvider();
                CloudManager.Session.LocationProvider = locationProvider;
                currentAppState = AppState.DemoStepConfigureSensors;
                break;

            case AppState.DemoStepConfigureSensors:
                SensorPermissionHelper.RequestSensorPermissions();
                ConfigureSensors();
                currentAppState = AppState.DemoStepCreateLocalAnchor;
                break;

            case AppState.DemoStepCreateLocalAnchor:
                if (spawnedObject != null)
                {
                    currentAppState = AppState.DemoStepSaveCloudAnchor;
                }
                break;

            case AppState.DemoStepSaveCloudAnchor:
                currentAppState = AppState.DemoStepSavingCloudAnchor;
                await SaveCurrentObjectAnchorToCloudAsync();

                break;

            case AppState.DemoStepStopSession:
                CloudManager.StopSession();
                CleanupSpawnedObjects();
                await CloudManager.ResetSessionAsync();

                locationProvider = null;
                currentAppState  = AppState.DemoStepCreateSessionForQuery;
                break;

            case AppState.DemoStepCreateSessionForQuery:
                ConfigureSession();
                locationProvider = new PlatformLocationProvider();
                CloudManager.Session.LocationProvider = locationProvider;
                ConfigureSensors();
                currentAppState = AppState.DemoStepStartSessionForQuery;
                break;

            case AppState.DemoStepStartSessionForQuery:
                await CloudManager.StartSessionAsync();

                currentAppState = AppState.DemoStepLookForAnchorsNearDevice;
                break;

            case AppState.DemoStepLookForAnchorsNearDevice:
                currentAppState = AppState.DemoStepLookingForAnchorsNearDevice;
                currentWatcher  = CreateWatcher();
                break;

            case AppState.DemoStepLookingForAnchorsNearDevice:
                break;

            case AppState.DemoStepStopWatcher:
                if (currentWatcher != null)
                {
                    currentWatcher.Stop();
                    currentWatcher = null;
                }
                currentAppState = AppState.DemoStepStopSessionForQuery;
                break;

            case AppState.DemoStepStopSessionForQuery:
                CloudManager.StopSession();
                currentWatcher   = null;
                locationProvider = null;
                currentAppState  = AppState.DemoStepComplete;
                break;

            case AppState.DemoStepComplete:
                currentCloudAnchor = null;
                currentAppState    = AppState.DemoStepCreateSession;
                CleanupSpawnedObjects();
                break;

            default:
                Debug.Log("Shouldn't get here for app state " + currentAppState.ToString());
                break;
            }
        }
예제 #7
0
        public LocalStoreItemProps(Func <string, bool> isEnabledPropFunc)
        {
            var props = new DavProperty <T>[]
            {
                new DavIsreadonly <T>
                {
                    Getter = (_, item) => !item.IsWritable
                },

                // RFC-2518 properties
                new DavCreationDate <T>
                {
                    Getter = (_, item) => item.FileInfo.CreationTimeUtc,
                    Setter = (_, item, value) =>
                    {
                        item.FileInfo.CreationTimeUtc = value;
                        return(DavStatusCode.Ok);
                    }
                },
                new DavDisplayName <T>
                {
                    Getter = (_, item) => item.FileInfo.Name
                },
                new DavGetContentLength <T>
                {
                    Getter = (_, item) => item.FileInfo.Size
                },
                new DavGetContentType <T>
                {
                    Getter = (_, item) => item.DetermineContentType()
                },
                new DavGetEtag <T>
                {
                    // Calculating the Etag is an expensive operation,
                    // because we need to scan the entire file.
                    IsExpensive = true,
                    Getter      = (_, item) => item.CalculateEtag()
                },
                new DavGetLastModified <T>
                {
                    Getter = (_, item) => item.FileInfo.LastWriteTimeUtc,
                    Setter = (context, item, value) =>
                    {
                        //item._fileInfo.LastWriteTimeUtc = value;

                        var  cloud = CloudManager.Instance((HttpListenerBasicIdentity)context.Session.Principal.Identity);
                        bool res   = cloud.SetFileDateTime(item.FileInfo, value).Result;
                        return(res
                            ? DavStatusCode.Ok
                            : DavStatusCode.InternalServerError);
                    }
                },

                new DavLastAccessed <T>
                {
                    Getter = (_, collection) => collection.FileInfo.LastWriteTimeUtc,
                    Setter = (_, collection, value) =>
                    {
                        collection.FileInfo.LastWriteTimeUtc = value;
                        return(DavStatusCode.Ok);
                    }
                },

                new DavGetResourceType <T>
                {
                    Getter = (_, _) => null
                },

                // Default locking property handling via the LockingManager
                new DavLockDiscoveryDefault <T>(),
                new DavSupportedLockDefault <T>(),

                // Hopmann/Lippert collection properties
                // (although not a collection, the IsHidden property might be valuable)
                new DavExtCollectionIsHidden <T>
                {
                    Getter = (_, _) => false //(item._fileInfo.Attributes & FileAttributes.Hidden) != 0
                },

                // Win32 extensions
                new Win32CreationTime <T>
                {
                    Getter = (_, item) => item.FileInfo.CreationTimeUtc,
                    Setter = (context, item, value) =>
                    {
                        //item._fileInfo.CreationTimeUtc = value;

                        var  cloud = CloudManager.Instance((HttpListenerBasicIdentity)context.Session.Principal.Identity);
                        bool res   = cloud.SetFileDateTime(item.FileInfo, value).Result;
                        return(res
                            ? DavStatusCode.Ok
                            : DavStatusCode.InternalServerError);
                    }
                },
                new Win32LastAccessTime <T>
                {
                    Getter = (_, item) => item.FileInfo.LastAccessTimeUtc,
                    Setter = (_, item, value) =>
                    {
                        item.FileInfo.LastAccessTimeUtc = value;
                        return(DavStatusCode.Ok);
                    }
                },
                new Win32LastModifiedTime <T>
                {
                    Getter = (_, item) => item.FileInfo.LastWriteTimeUtc,
                    Setter = (_, item, value) =>
                    {
                        item.FileInfo.LastWriteTimeUtc = value;
                        return(DavStatusCode.Ok);
                    }
                },
                new Win32FileAttributes <T>
                {
                    Getter = (_, _) => FileAttributes.Normal, //item._fileInfo.Attributes,
                    Setter = (_, _, _) => DavStatusCode.Ok
                },
                new DavSharedLink <T>
                {
                    Getter = (_, item) => !item.FileInfo.PublicLinks.Any()
                        ? string.Empty
                        : item.FileInfo.PublicLinks.First().Uri.OriginalString,
                    Setter = (_, _, _) => DavStatusCode.Ok
                }
            };

            _props = props.Where(p => isEnabledPropFunc?.Invoke(p.Name.ToString()) ?? true).ToArray();
        }
        public async override Task AdvanceDemoAsync()
        {
            switch (currentAppState)
            {
            case AppState.DemoStepCreateSessionForQuery:
                CloudManager.StopSession();
                currentWatcher = null;

                ConfigureSession();
                // currentAppState = AppState.DemoStepStartSessionForQuery;
                currentAppState = AppState.DemoStepBusy;
                await CloudManager.StartSessionAsync();

                loaderText.text = "Localizing...";
                loaderPanel.SetActive(true);
                moveDeviceAnim.SetActive(true);

                currentAppState = AppState.DemoStepLookingForAnchor;
                if (currentWatcher != null)
                {
                    currentWatcher.Stop();
                    currentWatcher = null;
                }
                currentWatcher = CreateWatcher();
                if (currentWatcher == null)
                {
                    Debug.Log("Either cloudmanager or session is null, should not be here!");
                    feedbackBox.text = "YIKES - couldn't create watcher!";
                    currentAppState  = AppState.DemoStepLookingForAnchor;
                }
                currentAppState = AppState.DemoStepCreateSessionForQuery;
                break;

            case AppState.DemoStepStartSessionForQuery:
                currentAppState = AppState.DemoStepBusy;
                await CloudManager.StartSessionAsync();

                currentAppState = AppState.DemoStepLookForAnchor;
                break;

            case AppState.DemoStepLookForAnchor:
                currentAppState = AppState.DemoStepLookingForAnchor;
                if (currentWatcher != null)
                {
                    currentWatcher.Stop();
                    currentWatcher = null;
                }
                currentWatcher = CreateWatcher();
                if (currentWatcher == null)
                {
                    Debug.Log("Either cloudmanager or session is null, should not be here!");
                    feedbackBox.text = "YIKES - couldn't create watcher!";
                    currentAppState  = AppState.DemoStepLookForAnchor;
                }
                break;

            case AppState.DemoStepLookingForAnchor:
                break;

            case AppState.DemoStepDeleteFoundAnchor:
                currentAppState = AppState.DemoStepBusy;
                await CloudManager.DeleteAnchorAsync(currentCloudAnchor);

                CleanupSpawnedObjects();
                currentAppState = AppState.DemoStepStopSessionForQuery;
                break;

            case AppState.DemoStepStopSessionForQuery:
                currentAppState = AppState.DemoStepBusy;
                CloudManager.StopSession();
                currentWatcher  = null;
                currentAppState = AppState.DemoStepComplete;
                break;

            case AppState.DemoStepComplete:
                currentAppState    = AppState.DemoStepBusy;
                currentCloudAnchor = null;
                CleanupSpawnedObjects();
                currentAppState = AppState.DemoStepCreateSessionForQuery;
                break;

            case AppState.DemoStepBusy:
                break;

            default:
                Debug.Log("Shouldn't get here for app state " + currentAppState.ToString());
                break;
            }
        }
        /// <summary>
        /// Helper method that configures an ApplicationBuilder object with the given options
        /// </summary>
        /// <typeparam name="T">The type built by the ApplicationBuilder</typeparam>
        /// <param name="builder">The extended ApplicationBuilder</param>
        /// <param name="authorityUri">The URI of the Azure Active Directory Authority</param>
        /// <param name="redirectUri">The Redirect URI for authentication</param>
        /// <param name="tenantId">The ID of the Azure Active Directory Tenant</param>
        /// <param name="environment">Information about the configured cloud environment</param>
        /// <returns></returns>
        internal static T WithPnPAdditionalAuthenticationSettings <T>(this AbstractApplicationBuilder <T> builder,
                                                                      Uri authorityUri, Uri redirectUri, string tenantId, Microsoft365Environment?environment) where T : AbstractApplicationBuilder <T>
        {
            if (tenantId == null)
            {
                throw new ArgumentNullException(nameof(tenantId));
            }

            if (environment.HasValue && environment.Value != Microsoft365Environment.Production)
            {
                if (tenantId.Equals(AuthGlobals.OrganizationsTenantId, StringComparison.InvariantCultureIgnoreCase))
                {
                    builder = builder.WithAuthority($"https://{CloudManager.GetAzureADLoginAuthority(environment.Value)}/{AuthGlobals.OrganizationsTenantId}/");
                }
                else
                {
                    builder = builder.WithAuthority(authorityUri?.ToString() ?? $"https://{CloudManager.GetAzureADLoginAuthority(environment.Value)}", tenantId, true);
                }
            }
            else
            {
                if (tenantId.Equals(AuthGlobals.OrganizationsTenantId, StringComparison.InvariantCultureIgnoreCase))
                {
                    builder = builder.WithAuthority(AadAuthorityAudience.AzureAdMultipleOrgs);
                }
                else
                {
                    builder = builder.WithAuthority(authorityUri?.ToString() ?? "https://login.microsoftonline.com", tenantId, true);
                }
            }

            if (redirectUri != null)
            {
                builder = builder.WithRedirectUri(redirectUri.ToString());
            }

            return((T)builder);
        }
예제 #10
0
        public async Task <DavStatusCode> UploadFromStreamAsync(IHttpContext httpContext, Stream inputStream)
        {
            if (!IsWritable)
            {
                return(DavStatusCode.Conflict);
            }


            // dirty hack! HIGH MEMORY CONSUME
            // mail.ru needs size of file, but some clients does not send it
            // so we'll cache file in memory
            // TODO: rewrite
            if (httpContext.Request.GetHeaderValue("Transfer-Encoding") == "chunked" && _fileInfo.Size == 0)
            {
                Logger.Log(LogLevel.Warning, () => "Client does not send file size, caching in memory!");
                var memStream = new MemoryStream();
                await inputStream.CopyToAsync(memStream).ConfigureAwait(false);

                _fileInfo.OriginalSize = new FileSize(memStream.Length);

                using (var outputStream = IsWritable
                    ? await CloudManager.Instance(httpContext.Session.Principal.Identity).GetFileUploadStream(_fileInfo.FullPath, _fileInfo.Size, null, null).ConfigureAwait(false)
                    : null)
                {
                    memStream.Seek(0, SeekOrigin.Begin);
                    await memStream.CopyToAsync(outputStream).ConfigureAwait(false);
                }
                return(DavStatusCode.Ok);
            }

            // Copy the stream
            try
            {
                var cts = new CancellationTokenSource();

                // После, собственно, закачки файла, сервер может, например, считать хэш файла (Яндекс.Диск) и это может быть долго
                // Чтобы клиент не отваливался по таймауту, пишем в ответ понемножку пробелы
                void StreamCopiedAction()
                {
                    var _ = Task.Run(() =>
                    {
                        while (!cts.IsCancellationRequested)
                        {
                            Thread.Sleep(7_000);
                            if (cts.IsCancellationRequested)
                            {
                                break;
                            }

                            httpContext.Response.Stream.WriteByte((byte)' ');
                            httpContext.Response.Stream.Flush();

                            Logger.Log(LogLevel.Debug, "Waiting for server processing file...");
                        }
                    }, cts.Token);
                }

                void ServerProcessFinishedAction()
                {
                    //Thread.Sleep(10_000);
                    cts.Cancel();
                    Logger.Log(LogLevel.Debug, "Server finished file processing");
                }


                // Copy the information to the destination stream
                using (var outputStream = IsWritable
                    ? await CloudManager.Instance(httpContext.Session.Principal.Identity).GetFileUploadStream(_fileInfo.FullPath, _fileInfo.Size, StreamCopiedAction, ServerProcessFinishedAction).ConfigureAwait(false)
                    : null)
                {
                    await inputStream.CopyToAsync(outputStream).ConfigureAwait(false);
                }
                return(DavStatusCode.Ok);
            }
            catch (IOException ioException) when(ioException.IsDiskFull())
            {
                return(DavStatusCode.InsufficientStorage);
            }
        }
 public void Create(string parentID)
 {
     CloudManager.CreateFolder(oneDriveCloud.CloudId, parentID, "aosdiosaido");//.CreateFolder(parentID, "testtttt");
 }
        private async Task CreateAnchorsDemoAsync()
        {
            switch (currentAppState)
            {
            case AppState.DemoStepCreateSession:
                CleanupSpawnedObjects();
                currentCloudAnchor = null;
                if (CloudManager.Session == null)
                {
                    await CloudManager.CreateSessionAsync();

                    ConfigureSession();
                    await CloudManager.StartSessionAsync();
                }
                else
                {
                    CloudManager.StopSession();
                    await CloudManager.ResetSessionAsync();

                    ConfigureSession();
                }
                locationProvider = new PlatformLocationProvider();
                CloudManager.Session.LocationProvider = locationProvider;

                SensorPermissionHelper.RequestSensorPermissions();
                ConfigureSensors();
                currentAppState = AppState.DemoStepCreateLocalAnchor;
                break;

            case AppState.DemoStepCreateLocalAnchor:
                if (spawnedObject != null)
                {
                    currentAppState = AppState.DemoStepSettingExplanationText;
                }

                break;

            case AppState.DemoStepSettingExplanationText:
                keyboardInputHelper = spawnedObject.GetComponentInChildren <SystemKeyboardInputHelper>();
                if (keyboardInputHelper != null && !string.IsNullOrEmpty(keyboardInputHelper.text))
                {
                    explanationText = new Dictionary <string, string>();
                    explanationText.Add("Explanation", keyboardInputHelper.text);
                    keyboardInputHelper = null;
                    currentAppState     = AppState.DemoStepSaveCloudAnchor;
                }
                break;

            case AppState.DemoStepSaveCloudAnchor:
                currentAppState = AppState.DemoStepSavingCloudAnchor;
                await SaveCurrentObjectAnchorToCloudAsync();

                currentAppState    = AppState.DemoStepReplay;
                spawnedObject      = null;
                currentCloudAnchor = null;
                break;

            case AppState.DemoStepReplay:
                break;

            case AppState.DemoStepStopSession:
                CloudManager.StopSession();
                CleanupSpawnedObjects();
                await CloudManager.ResetSessionAsync();

                locationProvider = null;
                currentAppState  = AppState.DemoStepComplete;
                break;

            case AppState.DemoStepComplete:
                currentCloudAnchor = null;
                currentAppState    = AppState.DemoStepSettingMode;
                CleanupSpawnedObjects();
                break;
            }
        }
        private async Task LocateAnchorsDemoAsync()
        {
            switch (currentAppState)
            {
            case AppState.DemoStepCreateSessionForQuery:
                CleanupSpawnedObjects();
                currentCloudAnchor = null;
                if (CloudManager.Session == null)
                {
                    await CloudManager.CreateSessionAsync();

                    ConfigureSession();
                    await CloudManager.StartSessionAsync();
                }
                else
                {
                    CloudManager.StopSession();
                    await CloudManager.ResetSessionAsync();

                    ConfigureSession();
                }
                locationProvider = new PlatformLocationProvider();
                CloudManager.Session.LocationProvider = locationProvider;
                SensorPermissionHelper.RequestSensorPermissions();
                ConfigureSensors();
                currentAppState = AppState.DemoStepLookForAnchorsNearDevice;
                break;

            case AppState.DemoStepLookForAnchorsNearDevice:
                currentAppState = AppState.DemoStepLookingForAnchorsNearDevice;
                currentWatcher  = CreateWatcher();
                break;

            case AppState.DemoStepLookingForAnchorsNearDevice:
                break;

            case AppState.DemoStepStopWatcher:
                if (currentWatcher != null)
                {
                    currentWatcher.Stop();
                    currentWatcher = null;
                }
                break;

            case AppState.DemoStepStopSessionForQuery:
                CloudManager.StopSession();
                currentWatcher   = null;
                locationProvider = null;
                currentAppState  = AppState.DemoStepComplete;
                break;

            case AppState.DemoStepComplete:
                currentCloudAnchor = null;
                currentAppState    = AppState.DemoStepSettingMode;
                CleanupSpawnedObjects();
                break;

            default:
                Debug.Log("Shouldn't get here for app state " + currentAppState.ToString());
                break;
            }
        }
예제 #14
0
        /// <summary>
        /// Update is called every frame, if the MonoBehaviour is enabled.
        /// </summary>
        ///



        public async override void Update()
        {
            base.Update();

            Debug.Log(currentCloudAnchor);

            selectedModel = XRUXPicker.Instance.getSelectedModel();
            if (_currentMode != AppMode.saving)
            {
                feedbackBox.text = _currentMode.ToString();
            }

            Debug.Log(needsNewData);
            Debug.Log(_currentMode);

            if (_currentMode == AppMode.initSession)
            {
                _currentMode = AppMode.makingSession;

                currentAnchorId    = "";
                currentCloudAnchor = null;


                if (CloudManager.Session == null)
                {
                    await CloudManager.CreateSessionAsync();

                    await CloudManager.StartSessionAsync();
                }

                _currentMode = AppMode.none;
            }

            if (needsNewData && _currentMode == AppMode.none && connection.State == BestHTTP.SignalRCore.ConnectionStates.Connected)
            {
                Debug.Log("getting New data");

                _currentMode = AppMode.gettingNewData;
                needsNewData = false;
                CloudManager.StopSession();
                connection.Invoke <dynamic[]>("GetNearbyAnchors", (double)Input.location.lastData.longitude, (double)Input.location.lastData.latitude)
                .OnSuccess(async(ret) =>
                {
                    Debug.Log("got data back!!");

                    anchorsToFind = new List <string>();
                    idToModelMap  = new Dictionary <string, string>();

                    foreach (dynamic var in ret)
                    {
                        if (var["model"] != null)
                        {
                            Debug.Log(var["model"]["id"]);
                            Debug.Log(var["model"]["name"]);
                        }


                        idToModelMap.Add(var["id"], var["model"] == null ? "Default" : var["model"]["name"]);

                        anchorsToFind.Add(var["id"]);
                    }

                    SetAnchorIdsToLocate(anchorsToFind);

                    await CloudManager.ResetSessionAsync();

                    await CloudManager.StartSessionAsync()
                    .ContinueWith(state => {
                        SetGraphEnabled(true);
                        currentWatcher = CreateWatcher();
                        _currentMode   = AppMode.none;
                    });
                })
                .OnError(err =>
                {
                    Debug.Log(err);
                });
            }

            if (_currentMode == AppMode.startSaving)
            {
                Debug.Log("configuring for saving");

                spawnedObject      = null;
                currentCloudAnchor = null;

                CloudManager.StopSession();

                ConfigureSession();

                await CloudManager.StartSessionAsync().ContinueWith(state => {
                    _currentMode = AppMode.placing;
                });
            }


            if (spawnedObjectMat != null)
            {
                float rat            = 0.1f;
                float createProgress = 0f;
                if (CloudManager.SessionStatus != null)
                {
                    createProgress = CloudManager.SessionStatus.RecommendedForCreateProgress;
                }
                rat += (Mathf.Min(createProgress, 1) * 0.9f);
            }
        }
 public void Delete(string fileId)
 {
     CloudManager.Delete(oneDriveCloud.CloudId, fileId);
 }
 void Start()
 {
     parallaxManager = GameObject.Find(Strings.PARALLAXMANAGER).GetComponent<ParallaxManager>();
     cloudManager = GameObject.Find(Strings.CLOUDMANAGER).GetComponent<CloudManager>();
     ScreenSetup.CalculateSettings();
     StartCoroutine(Init());
 }
        public override void AdvanceDemo()
        {
            switch (currentAppState)
            {
            case AppState.DemoStepCreateSession:
                CloudManager.ResetSessionStatusIndicators();
                currentAnchorId    = "";
                currentCloudAnchor = null;
                currentAppState    = AppState.DemoStepConfigSession;
                break;

            case AppState.DemoStepConfigSession:
                ConfigureSession();
                currentAppState = AppState.DemoStepStartSession;
                break;

            case AppState.DemoStepStartSession:
                CloudManager.EnableProcessing = true;
                currentAppState = AppState.DemoStepCreateLocalAnchor;
                break;

            case AppState.DemoStepCreateLocalAnchor:
                if (spawnedObject != null)
                {
                    currentAppState = AppState.DemoStepSaveCloudAnchor;
                }
                break;

            case AppState.DemoStepSaveCloudAnchor:
                currentAppState = AppState.DemoStepSavingCloudAnchor;
                SaveCurrentObjectAnchorToCloud();
                break;

            case AppState.DemoStepStopSession:
                CloudManager.EnableProcessing = false;
                CleanupSpawnedObjects();
                CloudManager.ResetSession();
                currentAppState = AppState.DemoStepCreateSessionForQuery;
                break;

            case AppState.DemoStepCreateSessionForQuery:
                ConfigureSession();
                currentAppState = AppState.DemoStepStartSessionForQuery;
                break;

            case AppState.DemoStepStartSessionForQuery:
                CloudManager.EnableProcessing = true;
                currentAppState = AppState.DemoStepLookForAnchor;
                break;

            case AppState.DemoStepLookForAnchor:
                currentAppState = AppState.DemoStepLookingForAnchor;
                currentWatcher  = CloudManager.CreateWatcher();
                break;

            case AppState.DemoStepLookingForAnchor:
                break;

            case AppState.DemoStepDeleteFoundAnchor:
                Task.Run(async() =>
                {
                    await CloudManager.DeleteAnchorAsync(currentCloudAnchor);
                    currentCloudAnchor = null;
                });
                currentAppState = AppState.DemoStepStopSessionForQuery;
                CleanupSpawnedObjects();
                break;

            case AppState.DemoStepStopSessionForQuery:
                CloudManager.EnableProcessing = false;
                currentWatcher  = null;
                currentAppState = AppState.DemoStepComplete;
                break;

            case AppState.DemoStepComplete:
                currentCloudAnchor = null;
                currentAppState    = AppState.DemoStepCreateSession;
                CleanupSpawnedObjects();
                break;

            default:
                Debug.Log("Shouldn't get here for app state " + currentAppState.ToString());
                break;
            }
        }