async Task <bool> IsUserRegisteredInTheCloud(ILoginProvider loginProvider)
        {
            ICloudTable <UserDetails> Table = GetTable <UserDetails>();
            string  tableId = loginProvider.RetrieveTableIdFromSecureStore();
            Account account = loginProvider.RetreiveAccountFromSecureStore();

            if (tableId == null)
            {
                ICollection <UserDetails> tempUserDetailsList = await Table.ReadAllItemsAsync();

                UserDetails userDetails = tempUserDetailsList.FirstOrDefault(x => x.userId == client.CurrentUser.UserId);
                account.Properties.Add("table_id", userDetails.Id);
                loginProvider.SaveAccountInSecureStore(account);
                App.UserDetails = userDetails;
            }
            else
            {
                UserDetails tempUserDetails = await Table.ReadItemAsync(tableId);

                App.UserDetails = tempUserDetails;
            }

            if (App.UserDetails != null)
            {
                return(true);
            }
            return(false);
        }
Exemple #2
0
        public async void QueryForPartiesAttending()
        {
            ICloudService cloudService                 = ServiceLocator.Instance.Resolve <ICloudService>();
            ICloudTable <PartyDetails> Table           = cloudService.GetTable <PartyDetails>();
            ICollection <PartyDetails> attendeeDetails = await Table.ReadAllItemsAsync();

            List <PartyDetailsItem> carouselItems  = new List <PartyDetailsItem>();
            List <Image>            carouselImages = new List <Image>();

            if (attendeeDetails == null || attendeeDetails.Count < 0)
            {
                return;
            }

            ICollection <PartyDetails> partiesAttending = new List <PartyDetails>();
            ICollection <PartyDetails> partiesHosting   = new List <PartyDetails>();

            foreach (var item in attendeeDetails)
            {
                if (item.userId == App.UserDetails.userId)
                {
                    partiesHosting.Add(item);
                }
                else
                {
                    partiesAttending.Add(item);
                }
            }

            ImageHelper.LoadedImages.Clear();
            PartiesAttending.AddRange(partiesAttending);
            PartiesHosting.AddRange(partiesHosting);
        }
Exemple #3
0
        public AzureFunctionsFabric(
            ISerializerFactorySelector serializerFactorySelector,
            INumericIdGenerator idGenerator,
            ITransitionRunner transitionRunner,
            IAzureWebJobsEnviromentalSettings azureWebJobsEnviromentalSettings,
            ICloudStorageAccountFactory cloudStorageAccountFactory,
            AzureFunctionsFabricSettings settings,
            IServiceProxyBuilder serviceProxyBuilder,
            IRoutineMethodResolver routineMethodResolver,
            IMethodInvokerFactory methodInvokerFactory,
            IServiceRegistry serviceRegistry)
        {
            _transitionRunner      = transitionRunner;
            _idGenerator           = idGenerator;
            _settings              = settings;
            _serviceProxyBuilder   = serviceProxyBuilder;
            _routineMethodResolver = routineMethodResolver;
            _methodInvokerFactory  = methodInvokerFactory;
            _serviceRegistry       = serviceRegistry;

#warning Need configurable serializer
            // Hard-code this for now.
            _defaultSerializer = serializerFactorySelector.Select("dasyncjson").Create();

            _storageAccountConnectionString = azureWebJobsEnviromentalSettings.DefaultStorageConnectionString;
            _storageAccount = cloudStorageAccountFactory.Create(_storageAccountConnectionString);

            //#warning make sure that site name is alpha-numeric and does not start with a number
            //            var prefix = azureWebJobsEnviromentalSettings.WebSiteName.ToLowerInvariant();
            var prefix = "";
            _routinesTable = _storageAccount.TableClient.GetTableReference(prefix + "routines");
            _servicesTable = _storageAccount.TableClient.GetTableReference(prefix + "services");
        }
Exemple #4
0
        /// <summary>
        ///     Get the inbound shipments from the read-only inbound shipment repository.
        /// </summary>
        /// <returns>If success, all inbound shipments. Else, an empty list.</returns>
        public async Task <IList <InboundShipment> > GetInboundShipments(string filter = null)
        {
            filter = filter?.ToLower();

            try
            {
                var filteredItems = await _inboundShipmentRepository
                                    .ReadInboundShipmentsWithFilter(filter).ConfigureAwait(false);

                // sort by shipment flag and document number
                filteredItems = filteredItems.OrderBy(item => item.DocumentNumber).ToList();

                _receiptWorkItemTable = _receiptWorkItemTable ?? await _cloudService.GetTableAsync <ReceiptWorkItem>().ConfigureAwait(false);

                // Ensure that inbound shipments without remaining quantities are not returned.
                return((await Task.WhenAll(filteredItems
                                           .Select(FilterOnQuantityRemaining)
                                           ).ConfigureAwait(false))?.Where(item => item != null).ToArray());
            }
            catch (Exception ex)
            {
                _logService.WriteErrorLogEntry($"Failed to read inbound shipments: {ex}");
                ex.Report();
                return(new List <InboundShipment>());
            }
        }
Exemple #5
0
        /// <summary>
        ///     Get the inbound shipments from the read-only inbound shipment repository.
        /// </summary>
        /// <param name="documentNumber">The InboundShipment document number or PO number.</param>
        /// <returns>If success, all inbound shipments for the document number. Else, an empty list.</returns>
        public async Task <IList <InboundShipment> > GetInboundShipmentsForDocumentNumber(string documentNumber)
        {
            try
            {
                var filteredItems = await _inboundShipmentRepository
                                    .ReadInboundShipmentsWithFilter(null);

                // filter by shipment flag and document number
                filteredItems = filteredItems.Where(item => item.ShipmentFlag && item.DocumentNumber == documentNumber).ToList();

                _receiptWorkItemTable = _receiptWorkItemTable ?? await _cloudService.GetTableAsync <ReceiptWorkItem>().ConfigureAwait(false);

                // Ensure that inbound shipments without remaining quantities are not returned.
                filteredItems = (await Task.WhenAll(filteredItems
                                                    .Select(FilterOnQuantityRemaining)
                                                    ))?.Where(item => item != null).ToArray();

                // Now we update the QtyReceived number so that we create workitems properly in bulk
                foreach (var inboundShipment in filteredItems)
                {
                    inboundShipment.QtyReceived = await _inboundShipmentRepository.GetRemainingShipmentQuantity(inboundShipment).ConfigureAwait(false);
                }

                return(filteredItems);
            }
            catch (Exception ex)
            {
                _logService.WriteErrorLogEntry($"Failed to read inbound shipments: {ex}");
                ex.Report();
                return(new List <InboundShipment>());
            }
        }
        public async Task SyncOfflineCacheAsync()
        {
            Debug.WriteLine("SyncOfflineCacheAsync: Initializing...");
            await InitializeAsync();

            if (!(await CrossConnectivity.Current.IsRemoteReachable(Client.MobileAppUri.Host, 443)))
            {
                Debug.WriteLine($"Cannot connect to {Client.MobileAppUri} right now - offline");
                return;
            }

            // Push the Operations Queue to the mobile backend
            Debug.WriteLine("SyncOfflineCacheAsync: Pushing Changes");
            await Client.SyncContext.PushAsync();

            // Pull each sync table
            //Debug.WriteLine("SyncOfflineCacheAsync: Pulling tasks table");
            //var taskTable = await GetTableAsync<TodoItem>(); await taskTable.PullAsync();

            Debug.WriteLine("SyncOfflineCacheAsync: Pulling sharing spaces table");
            sharingSpaceTable = await GetTableAsync <SharingSpace>(); await sharingSpaceTable.PullAsync();

            Debug.WriteLine("SyncOfflineCacheAsync: Pulling users table");
            var userTable = await GetTableAsync <User>(); await userTable.PullAsync();

            Debug.WriteLine("SyncOfflineCacheAsync: Pulling objects table");
            objectTable = await GetTableAsync <Models.Object>(); await objectTable.PullAsync();
        }
Exemple #7
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();
            userTable = await CloudService.GetTableAsync <User>();

            User currentUser = await userTable.ReadItemAsync(Settings.UserId);

            await UpdateUserLocation(currentUser);

            try
            {
                List <SharingSpace> sharingspaces = await _apiServices.GetNearbyEvents(Settings.AccessToken, "500");

                if (sharingspaces == null)
                {
                    await Application.Current.MainPage.DisplayAlert("No nearby events", "No nearby events.", "OK");

                    Navigation.InsertPageBefore(new HomePage(), this);
                    await Navigation.PopAsync();
                }
                Navigation.InsertPageBefore(new EventJoinPage(sharingspaces), this);
                await Navigation.PopAsync();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error: " + ex.Message);
                await Application.Current.MainPage.DisplayAlert("Getting events failed", ex.Message, "OK");

                // do nothing
            }
        }
 public static ICloudTableEntitySegmentedRangeQuery PrepareEntitySegmentedRangeQueryByRows(
     this ICloudTable table,
     string partitionKey,
     string fromRowKey,
     string toRowKey)
 {
     return(table.PrepareEntitySegmentedRangeQueryByRows(partitionKey, fromRowKey, toRowKey, EmptyArray.Get <string>()));
 }
        public static ICloudTableEntityQuery PrepareEntityPointQuery(
            this ICloudTable table,
            string partitionKey)
        {
            Require.NotNull(table, "table");

            return(table.PrepareEntityPointQuery(partitionKey, EmptyArray.Get <string>()));
        }
        protected JournalTableOperation(ICloudTable table, string streamName)
        {
            Require.NotNull(table, "table");
            Require.NotEmpty(streamName, "steamName");

            m_table      = table;
            m_streamName = streamName;
        }
Exemple #11
0
        public async Task <List <PartyDetailsItem> > GetCarouselItemsAsync(List <PartyDetails> partyList)
        {
            if (partyList == null || partyList.Count < 1)
            {
                await Application.Current.MainPage.DisplayAlert("Alert!", "No Parties Found", "OK");

                throw new NullReferenceException();
            }
            //First convert parties to CarouselParties
            List <PartyDetailsItem> tempCarouselList = new List <PartyDetailsItem>();

            foreach (var item in partyList)
            {
                PartyDetailsItem tempItem = new PartyDetailsItem(item);
                await tempItem.InitializeCard();

                tempItem.index = tempCarouselList.Count;
                tempCarouselList.Add(tempItem);
            }

            //Get Table with attendee details
            var cloudService = ServiceLocator.Instance.Resolve <ICloudService>();
            ICloudTable <AttendeeDetails> Table = cloudService.GetTable <AttendeeDetails>();


            //Find out which parties the user is attending
            try
            {
                //var searchResults = await App.UserDetailsUserIdSearchIndexClient.Documents.SearchAsync<AttendeeDetails>(App.userDetails.Id);
                //ObservableRangeCollection<PartyDetails> partiesAttending = PartiesAttending;
                //ObservableRangeCollection<PartyDetails> partiesHosting = PartiesHosting;
                //
                //if (partiesAttending != null && partiesAttending.Count > 0)
                //{
                //    var myParties = from m in tempCarouselList
                //                    let fr = (from f in partiesAttending select f.partyId)
                //                    where fr.Contains(m.partyId)
                //                    select m.isThisUserAttending == true;
                //    //myParties;
                //}
                //
                //if (partiesHosting != null && partiesHosting.Count > 0)
                //{
                //    var myParties = from m in tempCarouselList
                //                    let fr = (from f in partiesHosting select f.userId)
                //                    where fr.Contains(App.userDetails.userId)
                //                    select m.isThisUserHosting = true;
                //    //myParties;
                //}

                //User found for every match make party special
            }catch (Exception ex)
            {
                Console.WriteLine($"[Login] Error = {ex.Message}");
            }
            CarouselItems = tempCarouselList;
            return(tempCarouselList);
        }
Exemple #12
0
        public AzureHttpMessageStore(ICloudTable table, ICloudBlobContainer blobContainer, bool useCompression)
        {
            Guard.ArgumentNotNull(table, "table");
            Guard.ArgumentNotNull(blobContainer, "blobContainer");

            _table          = table;
            _blobContainer  = blobContainer;
            _useCompression = useCompression;
        }
 public AzureStorageFabricConnectorWithConfiguration(
     ServiceId serviceId,
     INumericIdGenerator idGenerator,
     ICloudQueue transitionsQueue,
     ICloudTable routinesTable,
     ISerializer serializer,
     AzureStorageFabricConnectorConfiguration originalConfiguration)
     : base(serviceId, idGenerator, transitionsQueue, routinesTable, serializer)
 {
     Configuration = originalConfiguration;
 }
 public AzureStorageTransitionCarrier(
     RoutineEventEnvelope eventEnvelope,
     ICloudTable routinesTable,
     ICloudTable servicesTable,
     ISerializer serializer)
 {
     _eventEnvelope = eventEnvelope;
     _routinesTable = routinesTable;
     _servicesTable = servicesTable;
     _serializer    = serializer;
 }
        public static ICloudTableEntityRangeQuery PrepareEntityRangeQueryByPartition(
            this ICloudTable table,
            string partitionKey,
            string[] properties)
        {
            Require.NotNull(table, "table");
            Require.NotNull(partitionKey, "partitionKey");

            return(table.PrepareEntityFilterRangeQuery(
                       "PartitionKey eq '{0}'".FormatString(partitionKey),
                       properties));
        }
        /// <summary>
        ///     Constructor.
        /// </summary>
        /// <param name="cloudTable">Cloud table.</param>
        /// <param name="entityConverter">Entity converter.</param>
        /// <param name="partitioner">Batch partitioner.</param>
        internal TableRequestSequentialExecutor(ICloudTable cloudTable, ITableEntityConverter <T> entityConverter, ITableBatchPartitioner partitioner)
            : base(cloudTable, entityConverter)
        {
            if (partitioner == null)
            {
                throw new ArgumentNullException("partitioner");
            }

            _cloudTable      = cloudTable;
            _entityConverter = entityConverter;
            _partitioner     = partitioner;
        }
 public AzureStorageFabricConnector(
     ServiceId serviceId,
     INumericIdGenerator idGenerator,
     ICloudQueue transitionsQueue,
     ICloudTable routinesTable,
     ISerializer serializer)
 {
     _serviceId        = serviceId;
     _idGenerator      = idGenerator;
     _transitionsQueue = transitionsQueue;
     _routinesTable    = routinesTable;
     _serializer       = serializer;
 }
        private static async Task InsertValues(ICloudTable table, string partition)
        {
            foreach (var i in Enumerable.Range(1, 20))
            {
                var operation = table.PrepareBatchOperation();

                foreach (var j in Enumerable.Range(1, 100))
                {
                    operation.Insert(partition, i + ":" + j, EmptyDictionary.Get<string, object>());
                }

                await operation.ExecuteAsync();
            }
        }
Exemple #19
0
        /// <summary>
        ///     Constructor.
        /// </summary>
        /// <param name="cloudTable">Cloud table.</param>
        /// <param name="entityConverter">Entity converter.</param>
        internal TableRequestExecutorBase(ICloudTable cloudTable, ITableEntityConverter <T> entityConverter)
        {
            if (cloudTable == null)
            {
                throw new ArgumentNullException(nameof(cloudTable));
            }

            if (entityConverter == null)
            {
                throw new ArgumentNullException(nameof(entityConverter));
            }

            _cloudTable      = cloudTable;
            _entityConverter = entityConverter;
        }
        /// <summary>
        ///     Constructor.
        /// </summary>
        /// <param name="cloudTable">Cloud table.</param>
        /// <param name="entityConverter">Entity converter.</param>
        public TableRequestExecutorFactory(ICloudTable cloudTable, ITableEntityConverter <T> entityConverter)
        {
            if (cloudTable == null)
            {
                throw new ArgumentNullException(nameof(cloudTable));
            }

            if (entityConverter == null)
            {
                throw new ArgumentNullException(nameof(entityConverter));
            }

            CloudTable       = cloudTable;
            _entityConverter = entityConverter;
            _partitioner     = new TableBatchPartitioner();
        }
Exemple #21
0
        /// <summary>
        ///     Constructor.
        /// </summary>
        /// <param name="cloudTable">Cloud table.</param>
        /// <param name="entityConverter"></param>
        internal TableQueryProvider(ICloudTable cloudTable, ITableEntityConverter <TEntity> entityConverter)
        {
            if (cloudTable == null)
            {
                throw new ArgumentNullException(nameof(cloudTable));
            }

            if (entityConverter == null)
            {
                throw new ArgumentNullException(nameof(entityConverter));
            }

            _cloudTable      = cloudTable;
            _entityConverter = entityConverter;
            _queryTranslator = new QueryTranslator(entityConverter.NameChanges);
        }
        private static async Task <int> InsertValues(ICloudTable table, string partition, int x = 20, int y = 100)
        {
            foreach (var i in Enumerable.Range(1, x))
            {
                var operation = table.PrepareBatchOperation();

                foreach (var j in Enumerable.Range(1, y))
                {
                    operation.Insert(partition, i + ":" + j, EmptyDictionary.Get <string, object>());
                }

                await operation.ExecuteAsync();
            }

            return(x * y);
        }
        public static ICloudTableEntitySegmentedRangeQuery PrepareEntitySegmentedRangeQueryByRows(
            this ICloudTable table,
            string partitionKey,
            string fromRowKey,
            string toRowKey,
            string[] properties)
        {
            Require.NotNull(table, "table");
            Require.NotNull(fromRowKey, "fromRowKey");
            Require.NotNull(toRowKey, "toRowKey");

            return(table.PrepareEntityFilterSegmentedRangeQuery(
                       "(PartitionKey eq '{0}') and (RowKey ge '{1}' and RowKey le '{2}')".FormatString(partitionKey,
                                                                                                        fromRowKey, toRowKey),
                       properties));
        }
Exemple #24
0
        public async Task ExecuteJoinPartyCommand()
        {
            if (IsBusy)
            {
                return;
            }
            IsBusy          = true;
            joinButtonLabel = null;

            try
            {
                var loginProvider = DependencyService.Get <ILoginProvider>();

                //TODO Optimize
                string customerid;
                //loginProvider.RetreiveAccountFromSecureStore().Properties.TryGetValue(Constants.stripeAccountIdPropertyName,out customerid);
                string userTableid = loginProvider.RetrieveTableIdFromSecureStore();

                var cloudService = ServiceLocator.Instance.Resolve <ICloudService>();
                ICloudTable <AttendeeDetails> Table = cloudService.GetTable <AttendeeDetails>();

                AttendeeDetails attendeeDetails = new AttendeeDetails
                {
                    userId   = userTableid,
                    partyId  = Id, //Actually tableid
                    paid     = false,
                    accepted = false,
                    chargeId = "  ",
                };

                await Table.CreateItemAsync(attendeeDetails);

                //TODO register for notifications
            }
            catch (Exception ex)
            {
                Console.WriteLine($"[Login] Error = {ex.Message}");
            }
            finally
            {
                joinButtonLabel = Constants.joinButtonTitles[(int)Constants.JoinedPartyStates.RequestSent];
                Console.WriteLine("Join Party Command Executed");
                IsBusy = false;
            }
        }
        private async Task ExecuteCreatePartyCommand()
        {
            if (IsBusy)
            {
                return;
            }
            joinButtonLabel = "";
            IsBusy          = true;
            try
            {
                ImageSource partyHeaderSource = partyHeaderImageSource;

                string headerImagePath;

                headerImagePath = await AzureStorage.UploadFileAsync(ContainerType.Image, new MemoryStream(partyHeaderByteArray));

                Debug.WriteLine("AzureStorage Succes");

                //TODO Make sure user information is transferred to theese values
                partyDetails.picture = headerImagePath ?? " ";
                partyDetails.partyId = Guid.NewGuid().ToString();
                partyDetails.userId  = App.UserDetails.userId ?? " ";


                AzurePartyManager manager = AzurePartyManager.DefaultManager;
                var cloudService          = ServiceLocator.Instance.Resolve <ICloudService>();

                ICloudTable <PartyDetails> Table = cloudService.GetTable <PartyDetails>();
                partyDetails = await Table.CreateItemAsync(partyDetails);

                PartyDetails partyDetailsDB = partyDetails;
                await manager.InsertItemAsync(partyDetailsDB);
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"[Upload] Error = {ex.Message}");
            }
            finally
            {
                IsBusy          = false;
                joinButtonLabel = "Party Created!";
                RootPage.instance.GoToDetailPage(MasterDetailPageManager.MapPage);
            }
        }
Exemple #26
0
        private async Task Connect()
        {
            try
            {
                logTable = await CloudService.GetTableAsync <Log>();

                ICollection <Log> logs = await logTable.ReadAllItemsAsync();

                Items.AddRange(logs.OrderByDescending(x => x.CreatedAt));

                if (SynthesizerSettings == null || string.IsNullOrWhiteSpace(SynthesizerSettings.AppServiceUrl) ||
                    string.IsNullOrWhiteSpace(SynthesizerSettings.SynthesizerApiUrl))
                {
                    LogAction("Settings are not configured");
                    return;
                }

                LogAction($"Connecting to {SynthesizerSettings.AppServiceUrl}");

                signalService = new SignalService(SynthesizerSettings.AppServiceUrl);
                signalService.MessageReceived += SignalMessageReceived;

                LogAction($"Connected to {SynthesizerSettings.AppServiceUrl}");

                string connectResponse = await signalService.Connect();

                LogAction(connectResponse);

                UserId = GetCurrentUserId();
                string joinGroupResponse = await signalService.JoinGroup(UserId);

                LogAction(joinGroupResponse);

                valveRestService            = new ValveRestService(SynthesizerSettings.SynthesizerApiUrl);
                oligoSynthesizerRestService = new OligoSynthesizerRestService(SynthesizerSettings.SynthesizerApiUrl, LogAction);
            }
            catch (Exception ex)
            {
                LogAction($"Connection failed: {ex.Message}");
            }
        }
        async Task RefreshPage(object sender, int index)
        {
            selectedTab = index;
            //CardListView senderListView = (CardListView)sender;

            var cloudService = ServiceLocator.Instance.Resolve <ICloudService>();
            ICloudTable <PartyDetails> table   = cloudService.GetTable <PartyDetails>();
            ICollection <PartyDetails> parties = await cloudService.RetreivePartiesWithinRange(searchPosition.Longitude, searchPosition.Latitude, Constants.defaultSearchRange, index);

            ObservableRangeCollection <CardListItem> sortedItems = new ObservableRangeCollection <CardListItem>();

            foreach (var item in parties)
            {
                PartyDetailsItem tempItem = new PartyDetailsItem(item);
                await tempItem.InitializeCard();

                CardListItem temp = new CardListItem()
                {
                    partyDetailsItem = tempItem
                };
                sortedItems.Add(temp);
            }
            ((CardListView )_items[index]).ItemsSource = sortedItems;
        }
Exemple #28
0
 public AzureTableProfileStore(ICloudTable cloudTable)
 {
     this.table = cloudTable;
 }
Exemple #29
0
        public EventStreamConsumers(ICloudTable consumerMetadataTable)
        {
            Require.NotNull(consumerMetadataTable, "consumerMetadataTable");

            m_consumerMetadataTable = consumerMetadataTable;
        }
        /// <summary>
        ///     Get the cloud table backing the work items.
        /// </summary>
        /// <returns>An asynchronous Task that returns the backing cloud table.</returns>
        private async Task <ICloudTable <ReceiptWorkItem> > GetCloudTable()
        {
            _table = _table ?? await _cloudService.GetTableAsync <ReceiptWorkItem>().ConfigureAwait(false);

            return(_table);
        }
Exemple #31
0
        public EventJournal(ICloudTable table)
        {
            Require.NotNull(table, "table");

            m_table = table;
        }
Exemple #32
0
        public PendingNotifications(ICloudTable table)
        {
            Require.NotNull(table, "table");

            m_table = table;
        }