public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            base.OnStartCommand(intent, flags, startId);
            try
            {
                var rec = intent.GetParcelableExtra("receiverTag");
                ResultSender = (ResultReceiver)rec;
                if (PostUpdater != null)
                {
                    PostUpdater.ResultSender = ResultSender;
                }
                else
                {
                    MainHandler.PostDelayed(new ApiPostUpdaterHelper(new Handler(), ResultSender), AppSettings.RefreshChatActivitiesSeconds);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            //MainHandler.PostDelayed(new PostUpdaterHelper(Application.Context, new Handler(), ResultSender), AppSettings.RefreshChatActivitiesSeconds);

            return(StartCommandResult.Sticky);
        }
Exemplo n.º 2
0
        public async Task SendRequestAsync(QueryProcessRequest <IReadOnlyCollection <EntityIdentity> > request)
        {
            Requires.NotNull(request, nameof(request));

            foreach (EntityIdentity requestId in request.RequestData)
            {
                if (requestId.KeysCount == 2 &&
                    requestId.TryGetValue(ProjectModelIdentityKeys.ProjectPath, out string path) &&
                    requestId.TryGetValue(ProjectModelIdentityKeys.PropertyPageName, out string propertyPageName))
                {
                    try
                    {
                        IEntityValue?propertyPageValue = await PropertyPageDataProducer.CreatePropertyPageValueAsync(
                            request.QueryExecutionContext.EntityRuntime,
                            requestId,
                            _projectService,
                            _queryCacheProvider,
                            path,
                            propertyPageName,
                            _properties);

                        if (propertyPageValue is not null)
                        {
                            await ResultReceiver.ReceiveResultAsync(new QueryProcessResult <IEntityValue>(propertyPageValue, request, ProjectModelZones.Cps));
                        }
                    }
                    catch (Exception ex)
                    {
                        request.QueryExecutionContext.ReportError(ex);
                    }
                }
            }

            await ResultReceiver.OnRequestProcessFinishedAsync(request);
        }
        public async Task SendRequestAsync(QueryProcessRequest <IEntityValue> request)
        {
            if ((request.RequestData as IEntityValueFromProvider)?.ProviderState is (IPropertyPageQueryCache cache, Rule schema, string propertyName))
            {
                try
                {
                    IEnumerable <IEntityValue> propertyValues = await UIPropertyValueDataProducer.CreateUIPropertyValueValuesAsync(
                        request.RequestData,
                        cache,
                        schema,
                        propertyName,
                        _properties);

                    foreach (IEntityValue propertyValue in propertyValues)
                    {
                        await ResultReceiver.ReceiveResultAsync(new QueryProcessResult <IEntityValue>(propertyValue, request, ProjectModelZones.Cps));
                    }
                }
                catch (Exception ex)
                {
                    request.QueryExecutionContext.ReportError(ex);
                }
            }

            await ResultReceiver.OnRequestProcessFinishedAsync(request);
        }
        protected override void OnHandleIntent(Android.Content.Intent intent)
        {
            var errorMessage = string.Empty;

            mReceiver = intent.GetParcelableExtra(Constants.Receiver) as ResultReceiver;

            if (mReceiver == null)
            {
                Log.Wtf(TAG, "No receiver received. There is nowhere to send the results.");
                return;
            }

            var location = (Location)intent.GetParcelableExtra(Constants.LocationDataExtra);

            if (location == null)
            {
                errorMessage = GetString(Resource.String.no_location_data_provided);
                Log.Wtf(TAG, errorMessage);
                DeliverResultToReceiver(Result.FirstUser, errorMessage);
                return;
            }

            var geocoder = new Geocoder(this, Java.Util.Locale.Default);

            List <Address> addresses = null;

            try {
                addresses = new List <Address> (geocoder.GetFromLocation(location.Latitude, location.Longitude, 1));
            } catch (IOException ioException) {
                errorMessage = GetString(Resource.String.service_not_available);
                Log.Error(TAG, errorMessage, ioException);
            } catch (IllegalArgumentException illegalArgumentException) {
                errorMessage = GetString(Resource.String.invalid_lat_long_used);
                Log.Error(TAG, string.Format("{0}. Latitude = {1}, Longitude = {2}", errorMessage,
                                             location.Latitude, location.Longitude), illegalArgumentException);
            }

            if (addresses == null || addresses.Count == 0)
            {
                if (string.IsNullOrEmpty(errorMessage))
                {
                    errorMessage = GetString(Resource.String.no_address_found);
                    Log.Error(TAG, errorMessage);
                }
                DeliverResultToReceiver(Result.FirstUser, errorMessage);
            }
            else
            {
                Address address          = addresses.FirstOrDefault();
                var     addressFragments = new List <string> ();

                for (int i = 0; i < address.MaxAddressLineIndex; i++)
                {
                    addressFragments.Add(address.GetAddressLine(i));
                }
                Log.Info(TAG, GetString(Resource.String.address_found));
                DeliverResultToReceiver(Result.Canceled, string.Join("\n", addressFragments));
            }
        }
        public async Task ReceiveResultAsync(QueryProcessResult <IEntityValue> result)
        {
            Requires.NotNull(result, nameof(result));
            result.Request.QueryExecutionContext.CancellationToken.ThrowIfCancellationRequested();
            if (((IEntityValueFromProvider)result.Result).ProviderState is UnconfiguredProject project)
            {
                await _coreExecutor.ExecuteAsync(project);
            }

            await ResultReceiver.ReceiveResultAsync(result);
        }
Exemplo n.º 6
0
        public static void AssertNoErrors(this TaskResult result)
        {
            Assert.NotNull (result, "Task results should not be null.");

            if (result.ContainsError())
            {
                var receiver = new ResultReceiver();
                result.SendSubResultsTo(receiver);
                Assert.Fail(receiver.Message);
            }
        }
Exemplo n.º 7
0
        protected override void OnStart()
        {
            base.OnStart();

            _resultReceiver = (ResultReceiver)this.Intent.GetParcelableExtra(PermissionsHelper.KeyResultsReceiver);

            var permissions = this.Intent.GetStringArrayExtra(PermissionsHelper.KeyPermissions);

            _requestCode = this.Intent.GetIntExtra(PermissionsHelper.KeyRequestCode, 0);

            ActivityCompat.RequestPermissions(this, permissions, _requestCode);
        }
Exemplo n.º 8
0
        public async Task ReceiveResultAsync(QueryProcessResult <IEntityValue> result)
        {
            result.Request.QueryExecutionContext.CancellationToken.ThrowIfCancellationRequested();

            if (((IEntityValueFromProvider)result.Result).ProviderState is UnconfiguredProject project &&
                project.Services.ExportProvider.GetExportedValueOrDefault <ILaunchSettingsProvider>() is ILaunchSettingsProvider launchSettingsProvider)
            {
                await ExecuteAsync(launchSettingsProvider, result.Request.QueryExecutionContext.CancellationToken);
            }

            await ResultReceiver.ReceiveResultAsync(result);
        }
		protected override void OnHandleIntent (Android.Content.Intent intent)
		{
			var errorMessage = string.Empty;

			mReceiver = intent.GetParcelableExtra (Constants.Receiver) as ResultReceiver;

			if (mReceiver == null) {
				Log.Wtf (TAG, "No receiver received. There is nowhere to send the results.");
				return;
			}

			var location = intent.GetParcelableExtra (Constants.LocationDataExtra) as Location;

			if (location == null) {
				errorMessage = GetString (Resource.String.no_location_data_provided);
				Log.Wtf (TAG, errorMessage);
				DeliverResultToReceiver (Result.FirstUser, errorMessage);
				return;
			}

			var geocoder = new Geocoder (this, Java.Util.Locale.Default);

			List<Address> addresses = null;

			try {
				addresses = new List<Address> (geocoder.GetFromLocation (location.Latitude, location.Longitude, 1));
			} catch (IOException ioException) {
				errorMessage = GetString (Resource.String.service_not_available);
				Log.Error (TAG, errorMessage, ioException);
			} catch (IllegalArgumentException illegalArgumentException) {
				errorMessage = GetString (Resource.String.invalid_lat_long_used);
				Log.Error (TAG, string.Format ("{0}. Latitude = {1}, Longitude = {2}", errorMessage, location.Latitude, location.Longitude), illegalArgumentException);
			}

			if (addresses == null || addresses.Count == 0) {
				if (string.IsNullOrEmpty (errorMessage)) {
					errorMessage = GetString (Resource.String.no_address_found);
					Log.Error (TAG, errorMessage);
				}
				DeliverResultToReceiver (Result.FirstUser, errorMessage);
			} else {
				var address = addresses.FirstOrDefault ();
				var addressFragments = new List<string> ();

				for (int i = 0; i < address.MaxAddressLineIndex; i++) {
					addressFragments.Add (address.GetAddressLine (i));
				}
				Log.Info (TAG, GetString (Resource.String.address_found));
				DeliverResultToReceiver (Result.Canceled,
					string.Join ("\n", addressFragments));
			}
		}
Exemplo n.º 10
0
        public void TestSquareRoot()
        {
            var invoker = new CommandInvoker();
            var result  = new ResultReceiver();

            var number = new Number {
                EnteredNumber = 4, IsCalculated = false
            };

            invoker.IncludeOperations(new SquareRootCommand(result, number));
            invoker.CalculatingOperations();

            Assert.AreEqual(2.0, result.Answer);
        }
Exemplo n.º 11
0
        //depunere
        public bool EfectueazaTranzactie(double sum, ContDTO source)
        {
            //compune o comanda si serializeaz-o
            String serializedCommand = new SerializedCommandDTO(sum, source).Serialize();

            //trimite comanda pe coada de comenzi. Procesatorul de comenzi va pune un rezultatt pe coada de rezultate
            CmdSender.Send(serializedCommand);
            //cere rezultatul
            SerializedResultDTO res = ResultReceiver.Receive(); //astepta raspunsul de pe coada de raspunsuri

            //modifica fisierele conform rezultatului comenzii
            _writeRepo.AdaugaTranzactie(res.tranzactii[0], res.conturi[0].iban);
            _writeRepo.ActualizareContInLista(source, res.conturi[0].Sold);
            return(true);
        }
Exemplo n.º 12
0
        public async Task ReceiveResultAsync(QueryProcessResult <IEntityValue> result)
        {
            Requires.NotNull(result, nameof(result));
            result.Request.QueryExecutionContext.CancellationToken.ThrowIfCancellationRequested();
            if (((IEntityValueFromProvider)result.Result).ProviderState is UnconfiguredProject project)
            {
                if (await _coreExecutor.ExecuteAsync(project))
                {
                    project.GetQueryDataVersion(out string versionKey, out long versionNumber);
                    result.Request.QueryExecutionContext.ReportUpdatedDataVersion(versionKey, versionNumber);
                }
            }

            await ResultReceiver.ReceiveResultAsync(result);
        }
Exemplo n.º 13
0
        public async Task ReceiveResultAsync(QueryProcessResult <IEntityValue> result)
        {
            result.Request.QueryExecutionContext.CancellationToken.ThrowIfCancellationRequested();
            if (((IEntityValueFromProvider)result.Result).ProviderState is ContextAndRuleProviderState state)
            {
                var cache = state.ProjectState;
                if (await cache.GetSuggestedConfigurationAsync() is ProjectConfiguration configuration &&
                    await cache.BindToRule(configuration, state.Rule.Name, state.PropertiesContext) is IRule boundRule &&
                    boundRule.GetProperty(_executableStep.PropertyName) is IProperty property)
                {
                    await property.SetValueAsync(_executableStep.Value);
                }
            }

            await ResultReceiver.ReceiveResultAsync(result);
        }
Exemplo n.º 14
0
        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            try
            {
                var rec = intent.GetParcelableExtra("receiverTag");
                ResultSender = (ResultReceiver)rec;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            MainHandler.PostDelayed(new ApiPostUpdaterHelper(Application.Context, MainHandler, ResultSender), AppSettings.RefreshChatActivitiesSeconds);

            return(base.OnStartCommand(intent, flags, startId));
        }
        public async Task SendRequestAsync(QueryProcessRequest <IEntityValue> request)
        {
            if ((request.RequestData as IEntityValueFromProvider)?.ProviderState is T providerState)
            {
                try
                {
                    foreach (IEntityValue categoryValue in await CreateValuesAsync(request.QueryExecutionContext, request.RequestData, providerState))
                    {
                        await ResultReceiver.ReceiveResultAsync(new QueryProcessResult <IEntityValue>(categoryValue, request, ProjectModelZones.Cps));
                    }
                }
                catch (Exception ex)
                {
                    request.QueryExecutionContext.ReportError(ex);
                }
            }

            await ResultReceiver.OnRequestProcessFinishedAsync(request);
        }
        public async Task SendRequestAsync(QueryProcessRequest <IEntityValue> request)
        {
            if ((request.RequestData as IEntityValueFromProvider)?.ProviderState is (IPropertyPageQueryCache _, Rule rule))
            {
                try
                {
                    foreach (IEntityValue categoryValue in CategoryDataProducer.CreateCategoryValues(request.RequestData, rule, _properties))
                    {
                        await ResultReceiver.ReceiveResultAsync(new QueryProcessResult <IEntityValue>(categoryValue, request, ProjectModelZones.Cps));
                    }
                }
                catch (Exception ex)
                {
                    request.QueryExecutionContext.ReportError(ex);
                }
            }

            await ResultReceiver.OnRequestProcessFinishedAsync(request);
        }
Exemplo n.º 17
0
        public void TestDivide()
        {
            var invoker = new CommandInvoker();
            var result  = new ResultReceiver();

            var numbers = new List <Number>
            {
                new Number {
                    EnteredNumber = 4, IsCalculated = false
                },
                new Number {
                    EnteredNumber = 2, IsCalculated = false
                }
            };

            invoker.IncludeOperations(new DivideCommand(result, numbers));
            invoker.CalculatingOperations();

            Assert.AreEqual(2.0, result.Answer);
        }
Exemplo n.º 18
0
        public async Task SendRequestAsync(QueryProcessRequest <IEntityValue> request)
        {
            Requires.NotNull(request, nameof(request));
            if ((request.RequestData as IEntityValueFromProvider)?.ProviderState is (IPropertyPageQueryCache _, Rule schema, string propertyName))
            {
                try
                {
                    foreach (IEntityValue propertyEditor in UIPropertyEditorDataProducer.CreateEditorValues(request.RequestData, schema, propertyName, _properties))
                    {
                        await ResultReceiver.ReceiveResultAsync(new QueryProcessResult <IEntityValue>(propertyEditor, request, ProjectModelZones.Cps));
                    }
                }
                catch (Exception ex)
                {
                    request.QueryExecutionContext.ReportError(ex);
                }
            }

            await ResultReceiver.OnRequestProcessFinishedAsync(request);
        }
        public async Task SendRequestAsync(QueryProcessRequest <IEntityValue> request)
        {
            Requires.NotNull(request, nameof(request));
            if ((request.RequestData as IEntityValueFromProvider)?.ProviderState is (ProjectConfiguration configuration, ProjectSystem.Properties.IProperty property))
            {
                try
                {
                    foreach (IEntityValue dimension in ConfigurationDimensionDataProducer.CreateProjectConfigurationDimensions(request.QueryExecutionContext.EntityRuntime, configuration, property, _properties))
                    {
                        await ResultReceiver.ReceiveResultAsync(new QueryProcessResult <IEntityValue>(dimension, request, ProjectModelZones.Cps));
                    }
                }
                catch (Exception ex)
                {
                    request.QueryExecutionContext.ReportError(ex);
                }
            }

            await ResultReceiver.OnRequestProcessFinishedAsync(request);
        }
Exemplo n.º 20
0
        public async Task SendRequestAsync(QueryProcessRequest <IEntityValue> request)
        {
            Requires.NotNull(request, nameof(request));

            if ((request.RequestData as IEntityValueFromProvider)?.ProviderState is ValueEditor editor)
            {
                try
                {
                    foreach (IEntityValue metadataValue in UIEditorMetadataProducer.CreateMetadataValues(request.RequestData.EntityRuntime, editor, _properties))
                    {
                        await ResultReceiver.ReceiveResultAsync(new QueryProcessResult <IEntityValue>(metadataValue, request, ProjectModelZones.Cps));
                    }
                }
                catch (Exception ex)
                {
                    request.QueryExecutionContext.ReportError(ex);
                }
            }

            await ResultReceiver.OnRequestProcessFinishedAsync(request);
        }
        public async Task SendRequestAsync(QueryProcessRequest <IReadOnlyCollection <EntityIdentity> > request)
        {
            foreach (EntityIdentity requestId in request.RequestData)
            {
                try
                {
                    IEntityValue?entityValue = await TryCreateEntityOrNullAsync(request.QueryExecutionContext, requestId);

                    if (entityValue is not null)
                    {
                        await ResultReceiver.ReceiveResultAsync(new QueryProcessResult <IEntityValue>(entityValue, request, ProjectModelZones.Cps));
                    }
                }
                catch (Exception ex)
                {
                    request.QueryExecutionContext.ReportError(ex);
                }
            }

            await ResultReceiver.OnRequestProcessFinishedAsync(request);
        }
        public async Task SendRequestAsync(QueryProcessRequest <IEntityValue> request)
        {
            Requires.NotNull(request, nameof(request));

            if ((request.RequestData as IEntityValueFromProvider)?.ProviderState is (ProjectConfiguration _, ProjectSystem.Properties.IEnumProperty enumProperty))
            {
                try
                {
                    IEnumerable <IEntityValue> supportedValues = await SupportedValueDataProducer.CreateSupportedValuesAsync(request.RequestData.EntityRuntime, enumProperty, _properties);

                    foreach (IEntityValue supportedValue in supportedValues)
                    {
                        await ResultReceiver.ReceiveResultAsync(new QueryProcessResult <IEntityValue>(supportedValue, request, ProjectModelZones.Cps));
                    }
                }
                catch (Exception ex)
                {
                    request.QueryExecutionContext.ReportError(ex);
                }
            }

            await ResultReceiver.OnRequestProcessFinishedAsync(request);
        }
        public async Task SendRequestAsync(QueryProcessRequest <IEntityValue> request)
        {
            Requires.NotNull(request, nameof(request));

            if ((request.RequestData as IEntityValueFromProvider)?.ProviderState is UnconfiguredProject project)
            {
                try
                {
                    IEnumerable <IEntityValue> propertyPageValues = await PropertyPageDataProducer.CreatePropertyPageValuesAsync(request.RequestData, project, _properties);

                    foreach (IEntityValue propertyPageValue in propertyPageValues)
                    {
                        await ResultReceiver.ReceiveResultAsync(new QueryProcessResult <IEntityValue>(propertyPageValue, request, ProjectModelZones.Cps));
                    }
                }
                catch (Exception ex)
                {
                    request.QueryExecutionContext.ReportError(ex);
                }
            }

            await ResultReceiver.OnRequestProcessFinishedAsync(request);
        }
Exemplo n.º 24
0
        public void TestAddAndSub()
        {
            var invoker = new CommandInvoker();
            var result  = new ResultReceiver();

            var addNumbers = new List <Number>
            {
                new Number {
                    EnteredNumber = 1, IsCalculated = false
                },
                new Number {
                    EnteredNumber = 2, IsCalculated = false
                }
            };
            var addCommand = new AddCommand(result, addNumbers);

            invoker.IncludeOperations(addCommand);
            invoker.CalculatingOperations();

            Assert.AreEqual(3.0, result.Answer);
            invoker.RemoveOperation(addCommand);


            var subNumbers = new List <Number>
            {
                new Number {
                    EnteredNumber = 3, IsCalculated = false
                }
            };

            invoker.IncludeOperations(new SubtractCommand(result, subNumbers));
            invoker.CalculatingOperations();

            Assert.AreEqual(0.0, result.Answer);
            invoker.RemoveOperation(addCommand);
        }
Exemplo n.º 25
0
 public ApiPostUpdaterHelper(Context activity, Handler mainHandler, ResultReceiver resultSender)
 {
     MainHandler  = mainHandler;
     Activity     = activity;
     ResultSender = resultSender;
 }
        protected override void OnHandleWork(Intent intent)
        {
            _receiver = intent.GetParcelableExtra(Constants.RECEIVER) as ResultReceiver;

            if (_receiver == null)
            {
                Log.Wtf(FETCH_ADDRESS_JIS, "No receiver received. There is nowhere to send the results.");
                return;
            }

            var location = (Location)intent.GetParcelableExtra(Constants.LOCATION_DATA_EXTRA);

            string errorMessage;

            if (location == null)
            {
                errorMessage = GetString(Resource.String.info_could_not_find_you);
                Log.Wtf(FETCH_ADDRESS_JIS, errorMessage);
                DeliverResultToReceiver(Result.FirstUser, errorMessage);
                return;
            }

            if (location.Accuracy > 35)
            {
                errorMessage = GetString(Resource.String.info_getting_your_location);
                Log.Wtf(FETCH_ADDRESS_JIS, errorMessage);
                DeliverResultToReceiver(Result.FirstUser + 1, null, location);
                return;
            }

            try
            {
                #region Old Code

                //                var addresses = new List<Address>(geocoder.GetFromLocation(location.Latitude, location.Longitude, 5));
                //                if (addresses.Count == 0)
                //                {
                //                    if (string.IsNullOrEmpty(errorMessage))
                //                    {
                //                        errorMessage = GetString(Resource.String.no_address_found);
                //                        Log.Error(FETCH_ADDRESS_JIS, errorMessage);
                //                    }
                //
                //                    DeliverResultToReceiver(Result.FirstUser, location);
                //                }
                //                else
                //                {
                //                    var addressFragments = new List<string>();
                //                    foreach (Address address in addresses)
                //                    {
                //                        if (address == null) continue;
                //                        for (var i = 0; i <= address.MaxAddressLineIndex; i++)
                //                        {
                //                            addressFragments.Add(address.GetAddressLine(i));
                //                        }
                //                    }
                //
                //                    Log.Info(FETCH_ADDRESS_JIS, GetString(Resource.String.address_found));
                //                    DeliverResultToReceiver(Result.Canceled, location);
                //                }

                #endregion

                Community getCyclesCommunity = Community.IsInCyclesCommunity(location);
                DeliverResultToReceiver(Result.Canceled, getCyclesCommunity, location);
            }

            #region Old Code

            //            catch (IOException ioException)
//            {
//                errorMessage = GetString(Resource.String.info_could_not_find_you);
//                Log.Error(FETCH_ADDRESS_JIS, errorMessage, ioException);
//                DeliverResultToReceiver(Result.FirstUser, errorMessage);
//            }
//            catch (IllegalArgumentException illegalArgumentException)
//            {
//                errorMessage = GetString(Resource.String.info_could_not_find_you);
//                Log.Error(FETCH_ADDRESS_JIS,
//                    $"{errorMessage}. Latitude = {location.Latitude}, Longitude = {location.Longitude}",
//                    illegalArgumentException);
//                DeliverResultToReceiver(Result.FirstUser, errorMessage);
//            }

            #endregion

            catch (Exception e)
            {
                errorMessage = GetString(Resource.String.info_could_not_find_you);
                Log.Error(FETCH_ADDRESS_JIS,
                          $"{errorMessage}. Latitude = {location.Latitude}, Longitude = {location.Longitude}",
                          e);
                DeliverResultToReceiver(Result.FirstUser, errorMessage);
            }
        }
Exemplo n.º 27
0
 public Task OnRequestProcessFinishedAsync(IQueryProcessRequest request)
 {
     return(ResultReceiver.OnRequestProcessFinishedAsync(request));
 }
Exemplo n.º 28
0
 public override void OnCommand(IPlayer player, string command, Bundle extras, ResultReceiver cb)
 {
     base.OnCommand(player, command, extras, cb);
 }
 public ApiPostUpdaterHelper(Handler mainHandler, ResultReceiver resultSender)
 {
     MainHandler  = mainHandler;
     ResultSender = resultSender;
 }
Exemplo n.º 30
0
        protected override void OnHandleIntent(Intent intent)
        {
            Log.Debug(TAG, "onHandleIntent(intent=" + intent.ToString() + ")");

            ResultReceiver receiver = (ResultReceiver)intent.GetParcelableExtra(EXTRA_STATUS_RECEIVER);

            if (receiver != null)
            {
                receiver.Send(StatusRunning, Bundle.Empty);
            }

            Context context      = this;
            var     prefs        = GetSharedPreferences(Prefs.IOSCHED_SYNC, FileCreationMode.Private);
            int     localVersion = prefs.GetInt(Prefs.LOCAL_VERSION, VERSION_NONE);

            try {
                // Bulk of sync work, performed by executing several fetches from
                // local and online sources.

                long startLocal = Java.Lang.JavaSystem.CurrentTimeMillis();
                bool localParse = localVersion < VERSION_CURRENT;
                Log.Debug(TAG, "found localVersion=" + localVersion + " and VERSION_CURRENT=" + VERSION_CURRENT);
                if (localParse)
                {
                    // Load static local data
                    mLocalExecutor.Execute(Resource.Xml.blocks, new LocalBlocksHandler());
                    mLocalExecutor.Execute(Resource.Xml.rooms, new LocalRoomsHandler());
                    mLocalExecutor.Execute(Resource.Xml.tracks, new LocalTracksHandler());
                    mLocalExecutor.Execute(Resource.Xml.search_suggest, new LocalSearchSuggestHandler());
                    mLocalExecutor.Execute(Resource.Xml.sessions, new LocalSessionsHandler());

                    // Parse values from local cache first, since spreadsheet copy
                    // or network might be down.
//	                mLocalExecutor.execute(context, "cache-sessions.xml", new RemoteSessionsHandler());
//	                mLocalExecutor.execute(context, "cache-speakers.xml", new RemoteSpeakersHandler());
//	                mLocalExecutor.execute(context, "cache-vendors.xml", new RemoteVendorsHandler());

                    // Save local parsed version
                    prefs.Edit().PutInt(Prefs.LOCAL_VERSION, VERSION_CURRENT).Commit();
                }

                Log.Debug(TAG, "local sync took " + (Java.Lang.JavaSystem.CurrentTimeMillis() - startLocal) + "ms");

                // Always hit remote spreadsheet for any updates
                long startRemote = Java.Lang.JavaSystem.CurrentTimeMillis();
//		        mRemoteExecutor.executeGet(WORKSHEETS_URL, new RemoteWorksheetsHandler(mRemoteExecutor));
                Log.Debug(TAG, "remote sync took " + (Java.Lang.JavaSystem.CurrentTimeMillis() - startRemote) + "ms");
            } catch (Exception e) {
                Log.Error(TAG, "Problem while syncing", e);

                if (receiver != null)
                {
                    // Pass back error to surface listener
                    Bundle bundle = new Bundle();
                    bundle.PutString(Intent.ExtraText, e.ToString());
                    receiver.Send(StatusError, bundle);
                }
            }

            // Announce success to any surface listener
            Log.Debug(TAG, "sync finished");
            if (receiver != null)
            {
                receiver.Send(StatusFinished, Bundle.Empty);
            }
        }
Exemplo n.º 31
0
 public void OnCommand(IPlayer p0, string p1, Bundle p2, ResultReceiver p3)
 {
 }
 public Task OnRequestProcessFinishedAsync(IQueryProcessRequest request)
 {
     _coreExecutor.OnAfterExecutingBatch();
     return(ResultReceiver.OnRequestProcessFinishedAsync(request));
 }