Push Notification showing localization constant instead of message - iphone

I have a serious problem I have not found any questions about on the net. When I push a localized message it only works for Swedish and not English. I have another that says that it only shows a constant for their Swedish Iphone 4. I have also tested on Iphone 3g and it has the same problem as my iphone 4, works in swedish not in english.
When displaying a popup for Iphone 4 in English, I only get the localization key I supply in my notification from the server.
Here is the string of the notification in C# that I push from a Windows Server. The extra parameters for my iphone app works totally fine in any language so it seems it has nothing to do with the server side part of the push.
int total = notification.AmountScheduledEvent + notification.AmountCourseResult + notification.AmountExam;
string locKey = (total > 1 ? "PushMessageMultiple" : "PushMessageSingle");
string msg = "{\"aps\":{"+
"\"alert\": {"+
"\"loc-key\":\"" + locKey + "\","+
"\"loc-args\":[\"" + total + "\"]},"+
"\"badge\":" + total + ","+
"\"sound\":\"default\"},"+
"\"amountSchedule\":" + notification.AmountScheduledEvent + ","+
"\"amountCourseResult\":" + notification.AmountCourseResult + ","+
"\"amountExam\":" + notification.AmountExam + "}";
In my Localizable.strings in sv.lproj:
/* push stuff */
"PushMessageMultiple" = "%# nya händelser";
"PushMessageSingle" = "1 ny händelse";
In my Localizable.strings in en.lproj:
/* push stuff */
"PushMessageMultiple" = "%# new events";
"PushMessageSingle" = "1 new event";
Here is a picture of the screen with a notification that works (Swedish)
http://img267.imageshack.us/i/img0014b.png/
Here is a picture of the screen with a notification that doesn't work (English)
http://img696.imageshack.us/i/img0015i.png/
Any idea why I get a constant instead of a message?

Try to use:
NSLocalizedString(#"PushMessageMultiple",#"");
This will dynamicaly get the correct string.

Related

Select HtmlToPdf - Html page saved in development and not saved but shown in production

I've got a problem with saving and NOT displaying a page that I want converted to pdf. The code I use works fine from within Visual Studio but not from IIS. On the development machine it converts the HTML page, saves the pdf and then redirects. On a 'production' machine with IIS it shows the html page (FactuurPDF) but stops there.
What I want is the behaviour on the development machine.
This is my code:
// other stuff
HtmlToPdf converter = new HtmlToPdf();
var TxtUrl = "";
TxtUrl = "https://localhost:44368/Facturen/FactuurPDF" + "?id=" + id + "&fact=" + fact;
PdfDocument doc = converter.ConvertUrl(TxtUrl);
var dat = DateTime.Today.ToString("yyyy-MM-dd");
doc.Save(#Path.Combine(_env.WebRootPath, "Verzondenfacturen/Fact_" + id + "_" + dat + ".pdf"));
doc.Close();
//other stuff (email pdf and update database)
return LocalRedirect("/Facturen/Index");
I hope anybody has a clue.
Setting the converter.Options.MaxPageLoadTime = 10 solved the problem.

Trigger an Email when text changes in formatted cell?

I've been tasked with setting up a GoogleSheet that contains information about my team's software and the expiry date of their licenses. I have set up the Sheet so when it reaches an expiry date it changes a column to read "Expired".
What I'd like to happen is that when the cell text changes to "Expired" it send me an email to alert me.
I found some tips online and tried a script but can't seem to get it to function as expected.
Here's what my Google Sheet looks like:
Here's the code i've been trying to adapt:
function sendMailEdit(e){
if (e.range.columnStart != 6 || e.value != "Expired") return;
const rData = e.source.getActiveSheet().getRange(e.range.rowStart,1,1,5).getValues();
let lictyp = rData[0][2];
let swpi = rData[0][1];
let name = rData[0][0];
let msg = "The " + lictyp + "license for " + swpi + "will expire in 10 days time for " + name + "." + "Contact IT to renew licence asap. Kind Regards, LICENSE NINJA!";
Logger.log(msg);
GmailApp.sendEmail("myemail#address.com", "License Expiry Alert", msg)
}

Properly attaching pictures to an email with google scripts

I'm trying to make a script with google forms and sheets to help with the automation and tracking our technicians pictures on the jobsite.
The setup is they take pictures of the jobsite and fill out a google form with the information and attach the pictures there. When the form gets submitted, it runs this script to send an email to a predetermined email that everyone in the office can see.
So far I am able to get the email to send the information from the form besides the pictures.
The information for the attached pictures come in as a drive url that is all dumped into one cell as a string.
"https://drive.google.com/open?id=xxxxxxxx, https://drive.google.com/open?id=yyyyyyyy, https://drive.google.com/open?id=zzzzzzzz"
I convert this string to an array using .split(" ,) which outputs this.
[https://drive.google.com/open?id=xxxxxxxx, https://drive.google.com/open?id=yyyyyyyy, https://drive.google.com/open?id=zzzzzzzz]
I then iterate through the array and use.slice(33) to get rid of the url so all that I'm left with is the drive id (there is probably a better way of doing this but it works for now).
[xxxxxxxx, yyyyyyyy, zzzzzzzz]
This is the part where I'm having trouble.
I then iterate agian through that array and grab the driveID and the get the file as a JPEG.
I then use .push to put it into another array that I'm using to attachment them to the email.
The issue is that I think I'm not doing this step properly by not pushing the correct thing into the array and/or assuming that MailApp.sendEmail can even take an array for attachments.
I'm also not entirely sure how [Blobs] work and how to use them properly and that's probably where I'm getting stuck.
Again, this is code is made with very little experience and could probably be optimized futher but at the moment, I just need to have it attach the pictures properly to show that it works.
function onFormSubmit(e) {
//for testing purposes
var values = e.namedValues;
//gets the form's values
var pureValues = e.values;
//sets the values
var email = pureValues[1];
var woNum = pureValues[2];
var firstN = pureValues[3];
var lastN = pureValues[4];
var desc = pureValues[5];
var superDuperRawPics = pureValues[6];
//splits the picture urls into an array
var superRawPics = superDuperRawPics.split(", ");
//slices the url part off to get the drive ID
var i, rawPics =[]
for (i = 0; i < superRawPics.length; ++i) {
rawPics.push(superRawPics[i].slice(33))
}
//takes the array of ID's and gets the drive file
var j, picAttach =[]
for (j = 0; j < rawPics.length; ++j) {
var driveID = DriveApp.getFileById(rawPics[j]);
var drivePic = driveID.getAs(MimeType.JPEG);
picAttach.push(drivePic);
}
//sets the subject of the email to be Jobsite Pictures and the work number
var subject = "Jobsite Pictures" + " " + woNum;
//sets the body of the email
var body = "Technician: " + email + " \n" +
"WO#: " + woNum + " \n" +
"Customer: " + firstN + " " + lastN + " \n" +
"Description: " + desc;
//for checking if the vars are set correctly
Logger.log(superDuperRawPics);
Logger.log(superRawPics);
Logger.log(rawPics);
Logger.log(picAttach);
Logger.log(subject);
Logger.log(body);
//sends email to me with the new info
MailApp.sendEmail('example#domian.com', subject, body, {attachments: [picAttach]});
}
If you just want to attach them then use options attachments
I was being dumb and added brackets to the attachments: when it didn't need them.
The correct way is this.
MailApp.sendEmail('example#domian.com', subject, body, {attachments: picAttach});
Changing this has the script sending emails with the pictures attached.

WebUI.getText() returns empty String

I want to get the text of my TestObject, I use WebUI.getText(). My code works fine for one of my pages but fails for another page. I can't figure out why it fails, everything is literally the same and it should not fail. This is what I am doing:
#Keyword
public boolean verifyIPAddr(Socket socket){
//create test object for the ip header
TestObject ipHeader = new TestObject().addProperty("id", ConditionType.EQUALS, 'ipaddr-in-header')
WebUI.waitForElementPresent(ipHeader, 20, FailureHandling.OPTIONAL)
//get text (IP) from ipHeader
String ipHeaderStr = WebUI.getText(ipHeader)
KeywordUtil.logInfo("ipHeaderStr: " + ipHeaderStr.toString())
//split the ipHeaderStr so that "IP: " portion can be removed and only "0.0.0.0" portion is left
String[] ipHeaderStrArr = ipHeaderStr.split(' ')
//store the ip in a variable
String guiIPAddress = ipHeaderStrArr[1]
//get the socket side ip
String cassetteIP = socket.getInetAddress().getHostAddress()
KeywordUtil.logInfo(" address:" + cassetteIP)
//validate that both are the same
if(cassetteIP.equals(guiIPAddress)){
KeywordUtil.logger.logPassed(guiIPAddress + " IP from GUI matches: " + cassetteIP + " from socket")
return true;
}
else{
KeywordUtil.logger.logFailed(guiIPAddress + " IP from GUI does not match: " + cassetteIP + " IP from socket")
return false
}
}
]2
I am 100% it has something to do with WebUI.getText() but it's confusing me because it works for one page but fails for the other.
The following is the HTML for the working page:
The following is the HTML for the page that is not working:
Update:
I just noticed that the one that was failing, fails sometimes and sometimes it passes, I still want to know how I can guarantee the behavior to stay stable.
There are a couple of things you can try:
You can add a delay before getting the text of the element:
WebUI.delay(30)
You can prolong the wait
WebUI.waitForElementPresent(ipHeader, 60, FailureHandling.OPTIONAL)
The reason is, Katalon (Selenium) code often depends on elements outside of its sphere of influence, like load times, network traffic, computer hardware, competing race-conditions, etc.
So, even with same code, sometimes the wait times will differ and that's why it is better to use flexible waits (like waitForElement*() methods).

ASP.net MVC wkhtmltopdf system process font issue

I'm using the wkhtmltopdf application to convert my ASP.net MVC 2 rendered HTML into a PDF and display the PDF instead of the standard view for better print ability. Everything works great minus one thing. When I run wkhtmltopdf as a process in my MVC application on our webserver it does not display the installed barcode font in the PDF.
Here is the code for the process.
public void HtmlToPdf(string url, string appPath)
{
string message = null;
// to build command argument
StringBuilder argument = new StringBuilder();
// input html file
string switches = "";
switches += "--print-media-type ";
switches += "--margin-top 10mm --margin-bottom 10mm --margin-right 10mm --margin-left 10mm ";
switches += "--page-size Letter ";
switches += "--load-error-handling ignore ";
switches += "--username admin ";
switches += "--password pass ";
argument.Append(switches + " " + url + " " + "C:\\PDF\\temp.pdf");
// to call the exe to convert
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.FileName = "C:\\wkhtmltopdf\\wkhtmltopdf.exe";
p.StartInfo.WorkingDirectory = "C:\\wkhtmltopdf";
p.StartInfo.Arguments = argument.ToString();
p.Start();
p.WaitForExit();
message = p.StandardError.ReadToEnd();
if (string.IsNullOrEmpty(message))
{
message = p.StandardOutput.ReadToEnd();
}
else
{
System.Diagnostics.Debug.WriteLine(message);
}
}
Not really sure why it wont show the barcode because it shows in the when you render the html but not in when the wkhtmltopddf converts it to pdf. It also works correctly if you run wkhtmltopdf out side of my MVC application.
-Thanks for any help
Have you tried it in a while with an updated version of wkhtmltopdf?
Which version was this a problem with? I recently tried to generate using a random font I downloaded and it worked fine.
If you generate the PDF on a server the server needs the font too, I assume you know that but someone else reading might not realize it :)
Could I get the font in question to test on my system?
Was the conversion done in what environment? (Most likely not Linux due to asp.net, but asking just in case)