Can't show Toast Notification if Param content greater than 430 Characters - c#

I'm developing wp8 app. I have some problem. I create Toast Notification for my app. then...
If my app in running: that ok.
But when my app close, or at home screen, or my phone is off. The Toast Notification can show if my param string is less than 430 characters, or no unicode character.
This is my server send toast code:
// Create the toast message.
string toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<wp:Notification xmlns:wp=\"WPNotification\">" +
"<wp:Toast>" +
"<wp:Text1>" + TextBoxTitle.Text.ToString() + "</wp:Text1>" +
"<wp:Text2>" + TextBoxSubTitle.Text.ToString() + "</wp:Text2>" +
"<wp:Param>[My String]</wp:Param>" +
"</wp:Toast>" +
"</wp:Notification>";
So my toast notification can alert in this cases:
"<wp:Param>[String great than 430 chars]</wp:Param>"
"<wp:Param>"Sài Gòn"</wp:Param>"
Can anyone help me?

Related

Running a python script asynchronously from WPF App

I am trying to run a python script asynchronously from my WPF App because the task is time-consuming and running in synchronously causes the UI of the App to become unresponsive. Asynchronously code from the web page is not working, however. I'm working with the code form the link below. Any help is much appreciated.
https://www.codeproject.com/Articles/25983/How-to-Execute-a-Command-in-C
I'm calling the method from the web page with this code snippet:
Click2Input3 = path + #"tensorflow\classifiers\" + name2 + #"\retrained_labels.txt";
Click2Input4 = path + #"tensorflow\classifiers\" + name2 + #"\retrained_graph.pb";
toEx2 = Click2Input + " " + Click2Input2 + " " + input2 + " " + Click2Input3 + " " + Click2Input4 + " " + inputDestination;
textOut.Text = toEx2;
ExecuteCommandSync(toEx2);
textOut.Text = result;
Which in essence just does this:
C:\Users\AppData\Local\Programs\Python\Python35\python.exe C:\Users\Desktop\test\examples\image_retraining\retrain.py --bottleneck_dir=C:\Users\Desktop\test\dif_images\bottlenecks --how_many_training_steps=500 --model_dir=C:\Users\Desktop\test\images\inception --output_graph=C:\Users\Desktop\test\dif_images\retrained_graph.pb --output_labels=C:\Users\Desktop\test\dif_images\retrained_labels.txt --image_dir=C:\Users\Desktop\test\dif_images\star_wars
Have you tried
System.Diagnostics.Process.Start(toEx2);
Are you trying to get the results of the python execution back into WPF?

Why I got the OAuthException(Error code 803) When I post the User Location Details into Facebook wall?

I am Developing Universal Windows Apps Using C# and XAML.
when I post the user Current location details into Facebook wall, at that time I got the Exception like OAuthException shown in below image..
enter image description here
Regarding above Exception I wrote some line code below....
PropertySet parameters = new PropertySet();
parameters.Add("message", "Need Help, Am In Emergency. "+" " + "This is my current location " + geocoordinate.Point.Position.Latitude.ToString("0.00") + "," + geocoordinate.Point.Position.Longitude.ToString("0.00"));
parameters.Add("link", "http://maps.google.com/?q=" + App.pos.Coordinate.Point.Position.Latitude.ToString("0.00") + "," + App.pos.Coordinate.Point.Position.Longitude.ToString("0.00"));
// Set Graph api path
string path = "/" +App.sess.User.Name + "/feed";
FBSingleValue sval = new FBSingleValue(path, parameters, new FBJsonClassFactory(FBReturnObject.FromJson));
FBResult fbresult = await sval.PostAsync();
How to solve Above issue?

Azure Send Push Notification Error

I was able to send push notifications to my users successfully. But approx. 20 minutes later I did not. Always gives me TargetInvocationException error.
I use a notification hub in my Windows Phone app. I send notifications from my desktop application by using FullAccessed connection string and hub name.
I removed some unnecessary code lines (to understand easily) below.
NotificationHubClient hub = NotificationHubClient
.CreateClientFromConnectionString(sConStr, sHubName);
string toast = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<wp:Notification xmlns:wp=\"WPNotification\">" +
"<wp:Toast>" +
"<wp:Text1>" + txtHeader.Text + "</wp:Text1>" +
"<wp:Text2>" + txtContent.Text + "</wp:Text2>" +
"</wp:Toast> " +
"</wp:Notification>";
await hub.SendMpnsNativeNotificationAsync(toast);
Here is a screenshot.

Passing long querystrings over urls shows page not found error(404)

I have a "error.aspx" page which is there to mail me if any exception is caught. When I open the page manually, mysite.com/error.aspx, the page opens fine but when it is redirected by a catch block with the exception.message and exception.stackTrace as querystrings, I get an error "page not found". Are the querystrings directing the browser to open a different url? It works fine when run on localhost, though.
public void send_error(Exception ex)
{
Response.Redirect("error.aspx?time=" + DateTime.Now.ToString() + "&ex=" + ex.Message + "&st=" + ex.StackTrace.Replace("\n", " "), false);
}
If you check this Article, you will see that the max query length of url string is 2048 symbols for Internet explorer. Probably the url is bigger and because of that you have this problem. One solution is to save the desire message in the session as string and after that retrieve it on other pages.
string errorMessage = DateTime.Now.ToString() + " " + ex.Message + " " + ex.StackTrace.Replace("\n", " ");
Session["__ErrMessage"] = errorMessage;
When you are in other pages you can access this string like this:
string errMessage = "";
if(Session["__ErrMessage"] != null)
errMessage = Session["ErrMessage"].ToString();

Facebook C# SDK get user language/region

I'm using the Facebook C# SDK. How can I get language of the user, so I can display all messages accordingly without forcing the user to choose his preferred language manually?
If you are developing a web app, then you can use Accept-Language Http header to detect the language
EDIT 1
For winforms application, you can use System.Globalization.CultureInfo.CurrentCulture.Name .
EDIT2
To get the locale using FB REST API :
dynamic fbResult = new Uri("https://graph.facebook.com/AngelaMerkel?access_token=AAABkECTD......").GetDynamicJsonObject();
Console.WriteLine(
fbResult.locale ?? "-" + " > " + //<----
fbResult.location.country + " " + //<----
fbResult.location.city + " " + //<----
fbResult.name + " " +
fbResult.gender + " " +
fbResult.link + " " +
fbResult.updated_time);
You can find info about my extension method GetDynamicJsonObject here

Categories