Selecting a Table from Azure SQL Database with Xamarin Forms [closed] - azure

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Trying to select a table called Pregunta with some questions in my azure database to display it in a combobox in my application.
The code is as follow:
Method for Selecting the Pregunta Table:
public static async Task<ObservableCollection<Pregunta>> SelectQuestions()
{
try
{
return await client.GetTable<Pregunta>().ToCollectionAsync();
}
catch (MobileServiceInvalidOperationException msioe)
{
var response = await msioe.Response.Content.ReadAsStringAsync();
return null;
}
catch (Exception ex)
{
return null;
}
}
Displaying items in the Combobox:
protected override async void OnAppearing()
{
base.OnAppearing();
ObservableCollection<Pregunta> questions = await Pregunta.SelectQuestions();
PreguntaEntry.DataSource = questions;
}
I got no errors, but it retrives nothing, the question variable value is null when trying to display it.
I will appreciate any help as I'm new with Azure.

Solution:
Make sure that the string varibale questions in my app table model was named same as the database.
Through the Syncfusion document, I think you should use PreguntaEntry.ComboBoxSource:
protected override async void OnAppearing()
{
base.OnAppearing();
ObservableCollection<Pregunta> questions = await Pregunta.SelectQuestions();
PreguntaEntry.ComboBoxSource= questions;
}

Related

Initialize method in javafx [duplicate]

This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 5 years ago.
Can one controller class have two or more initialize () ?
Can multiple statements be in a single initialize() ?
#question 2...This is my controller class:
#Overide
public void initialize(URL url,ResourceBundle rb)
{
//adding itemList variable to itemBox
try{
itemBox.setValue("Gari");
itemBox.setItems(itemList);
}
catch(Exception e){
System.out.println(e);
}
//Animation for changing scene
String filename = url.getFile().substring(URL.getFile().lastIndexOf('/')+1, URL.getFile().length());
if(filename.equals("FXML.fxml")){
//calling fadeTransition method
fadeTrans(anchorPane);
}
else if(filename.equals("SignUp_In.fxml")){
fadeTrans (anchorPaneSignUp_In);
}
}
and it returns this error message:
java.lang.NullPointerException
Here, the multiple statements are adding itemList to itemBox and changing scene with animation
no
yes
Just some more characters to get over the minimum.

Amazon Web Services MQTT [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 days ago.
Improve this question
I am working on a amazon based web services where i have to send and receive some information to Amazon IOT and then receive some message from there. I have problem in connecting to IOT , can any one help me with MQTT and IOT.
Try this. it may help you.
credentialsProvider = new CognitoCachingCredentialsProvider(
getApplicationContext(), // context
COGNITO_POOL_ID, // Identity Pool ID
MY_REGION // Region);
Region region = Region.getRegion(MY_REGION);
// MQTT Client
mqttManager = new AWSIotMqttManager(clientId, CUSTOMER_SPECIFIC_ENDPOINT);
// Set keepalive to 10 seconds. Will recognize disconnects more quickly but will also send
// MQTT pings every 10 seconds.
mqttManager.setKeepAlive(10);
mIotAndroidClient = new AWSIotClient(credentialsProvider);
mIotAndroidClient.setRegion(region);
try {
mqttManager.connect(clientKeyStore, new AWSIotMqttClientStatusCallback() {
#Override
public void onStatusChanged(final AWSIotMqttClientStatus status,
final Throwable throwable) {
Log.d(LOG_TAG, "Status = " + String.valueOf(status));
runOnUiThread(new Runnable() {
#Override
public void run() {
if (status == AWSIotMqttClientStatus.Connecting) {
} else if (status == AWSIotMqttClientStatus.Connected) {
tvStatus.setText("Connected");
} else if (status == AWSIotMqttClientStatus.Reconnecting) {
if (throwable != null) {
Log.e(LOG_TAG, "Connection error.", throwable);
}
tvStatus.setText("Reconnecting");
} else if (status == AWSIotMqttClientStatus.ConnectionLost) {
if (throwable != null) {
Log.e(LOG_TAG, "Connection error.", throwable);
}
}
}
});
}
});
} catch (final Exception e) {
}

Re-implement JavaFX showAndWait [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I want to achieve the functionality of Stage.showAndWait() without using the method itself.
I have an application and I need a way of displaying something within the same stage and block the thread displaying the content until a button is pressed.
The thread displaying the content naturally needs to be tha JavaFX application thread - which of course won't handle the buttons as long as it is blocked.
Stage.showAndWait describes its inner workings as "This method temporarily blocks processing of the current event, and starts a nested event loop to handle other events." I see that the method calls "Toolkit.getToolkit().enterNestedEventLoop(this)", which is pretty implementation specific. Are there any other options? Is functionality like this exposed anywhere in the API?
Edit:
Since my question was misleading, I try to rephrase it more to the point from my current perspective:
Is there a public API for Toolkit.getToolkit().enterNestedEventLoop() and Toolkit.getToolkit().exitNestedEventLoop() ?
For my rephrased question:
Is there a public API for Toolkit.getToolkit().enterNestedEventLoop() and Toolkit.getToolkit().exitNestedEventLoop() ?
Since then the API has been made public in:
javafx.application.Platform.enterNestedEventLoop()
It isn't really clear what you are trying to do, but it sounds like you have some long running process that is building up some kind of data, and then you want the user to control how that built up data is delivered to the screen. In that case, then you need to run a background task to build the data, transfer that data to some element that is available to the FXAT, and then use the action event of a button to move the data onto the screen. Something like this:
public class LongTask extends Application {
StringProperty results = new SimpleStringProperty("");
public static void main(String[] args) {
launch(args);
}
#Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Hello World!");
TextArea textArea = new TextArea();
BorderPane root = new BorderPane();
root.setCenter(textArea);
Button button = new Button("More Data");
root.setBottom(button);
button.setOnAction(evt -> textArea.setText(results.get()));
primaryStage.setScene(new Scene(root, 300, 250));
primaryStage.show();
Task<Void> sleeper = new Task<Void>() {
#Override
protected Void call() throws Exception {
for (int iteration = 0; iteration < 1000; iteration++) {
try {
Thread.sleep(5000);
int i = iteration;
Platform.runLater(() -> results.set(results.get() + "\nIteration " + i));
} catch (InterruptedException e) {
}
}
return null;
}
};
new Thread(sleeper).start();
}
}
Technically, you don't need to make "results" a property, nor do you need to update it through Platform.runlater(). Using Platform.runlater() guarantees that you won't have concurrency issues with results. Also, if you bind "results" to anything, then you'll need to use Platform.runlater() to modify it.

Spell check with google dictionary [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am creating an application in which I have to check the word typed by user is correct or not using Google dictionary. If the word typed by user is correct, then a toast will be displayed. I am not getting any proper solution on my Google search. So please give me some idea if it is possible.
#Override
public void onGetSuggestions(final SuggestionsInfo[] arg0) {
isSpellCorrect = false;
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < arg0.length; ++i) {
// Returned suggestions are contained in SuggestionsInfo
final int len = arg0[i].getSuggestionsCount();
if(editText1.getText().toString().equalsIgnoreCase(arg0[i].getSuggestionAt(j))
{
isSpellCorrect = true;
break;
}
}
}
You can find the whole project from this link. In above project you can see string is appended. Instead just change the above method onGetSuggestions..

Azure Web Role "warm up" strategies [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I found that making requests to our web role after periods on inactivity would result in a very slow request (up to 30 seconds). After that initial request, the role would perform as it should.
After much Googling, I came across four different strategies (listed below):
(a) Disabling IIS idle timeout in RoleEntryPoint.OnStart()
public override bool OnStart()
{
using (var server = new ServerManager())
{
server.ApplicationPoolDefaults.ProcessModel.IdleTimeout = TimeSpan.Zero;
server.CommitChanges();
}
return base.OnStart();
}
This also requires that the role runs at an elevated level.
(b) Perform regular requests in the RoleEntryPoint.Run()
public override void Run()
{
var localuri = new Uri(string.Format("https://{0}/Help", RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["HttpsIn"].IPEndpoint));
while (true)
{
try
{
var request = (HttpWebRequest)WebRequest.Create(localuri);
request.Method = "GET";
var response = request.GetResponse();
}
catch { }
System.Threading.Thread.Sleep(3000);
}
}
(c) Set preloadEnabled and startMode in the RoleEntryPoint.OnStart()
public override void OnStart()
{
using (var serverManager = new ServerManager())
{
foreach (var application in serverManager.Sites.SelectMany(x => x.Applications))
{
application["preloadEnabled"] = true;
}
foreach (var applicationPool in serverManager.ApplicationPools)
{
applicationPool["startMode"] = "AlwaysRunning";
}
serverManager.CommitChanges();
}
return base.OnStart();
}
(d) And lastly, using Azure's "Always On" (EDIT: This is only for Azure websites unfortunately!)
Which of these strategies should I perform?
We use a combination of a couple of those answers and it works perfectly well for us, they're very quick to change and test however, it seems to cover all bases.
public override bool OnStart()
{
ServicePointManager.DefaultConnectionLimit = 12;
if(!RoleEnvironment.IsEmulated)
{
using(ServerManager serverManager = new ServerManager())
{
foreach (var app in serverManager.Sites.SelectMany(x => x.Applications))
{
app["preloadEnabled"] = true;
}
foreach (var appPool in serverManager.ApplicationPools)
{
appPool.AutoStart = true;
appPool["startMode"] = "AlwaysRunning";
appPool.ProcessModel.IdleTimeout = TimeSpan.Zero;
appPool.Recycling.PeriodicRestart.Time = TimeSpan.Zero;
}
serverManager.CommitChanges();
}
}
return base.OnStart();
}
Have you considered using the Azure endpoint monitoring to both monitor and trigger your role to respond every 5 minutes? It's built into Azure and there's no code needed.
http://azure.microsoft.com/en-us/documentation/articles/web-sites-monitor/

Resources