Alarm feature with Mango update - alarm

In the mango update will it be possible to start the app and set an alarm for e.g. 09:00 the next morning. Then close the app and go to sleep.
The next morning the alarm should start with sounds (wav files) contained in the application (and not default wp7 sounds)?
Ive seen at the docs and found out the Reminder class would needed to be used. But I didnt get if this will be possible....

Here's a sample of code taken from Derik's reference in the comment above that will, I think, do what you're looking for:
string alarmTimeString = DateTime.Now.AddDays(1).ToString("M/dd/yyyy") + " 09:00";
DateTime alarmTime = DateTime.Parse(alarmTimeString);
Reminder reminder = new Reminder("WakeUpTime")
{
Title = "Time to wake up!",
Content = "It's time for you to wake up and get to work!",
BeginTime = alarmTime,
ExpirationTime = alarmTime.AddHours(1)
};
ScheduledActionService.Add(reminder);
Thanks Derek for pointing us in the right direction!

Related

Round shipping cost in Shopware 5 based on condition

I need to round the shipping costs when an article is added till the order is completed based on if certain condition is active. I already tried subscribing the following events:
'sOrder::getOrderById::after' => 'afterGetOrder',
'Shopware_Modules_Order_SaveOrder_FilterParams' => 'filterOrderParams'
with the following implementation:
public function filterOrderParams(\Enlight_Event_EventArgs $args)
{
$return = $args->getReturn();
$return['invoice_shipping'] = ceil($return['invoice_shipping']);
$return['invoice_shipping_net'] = ceil($return['invoice_shipping_net']);
$subject->sShippingcostsNumeric = ceil($subject->sShippingcostsNumeric);
$subject->sShippingcostsNumericNet = ceil($subject->sShippingcostsNumericNet);
$args->setReturn($return);
}
public function afterGetOrder(\Enlight_Hook_HookArgs $args)
{
if (!$this->checkIfActive()) {
return;
}
$return = $args->getReturn();
$return['invoice_shipping'] = ceil($return['invoice_shipping']);
$return['invoice_shipping_net'] = ceil($return['invoice_shipping_net']);
$args->setReturn($return);
}
But it does not seem to be working. I also tried
Shopware()->Modules()->Order()->sShippingcosts = ceil($sBasket['sShippingcosts']); but nothing. I know there is an event on order save, which I can hook and change the parameters, but that is too late as the cost in the cart and checkout would not be rounded up (not until the order is completed)
So is there a way to round shipping costs in shopware 5 ?
EDIT: Ideally it would also be great if the changes are stored in database directly so any further manipulation on the order shows / updates the correct rounded values.
For anyone looking, I ended up changing the template variable in the Frontend_Checkout event subscriber and letting it change the value in the database on Shopware_Modules_Order_SaveOrder_FilterParams. Hope it helps someone. Took me a while to figure this out. This hook sOrder::getOrderById::after was not needed at all, and doesn't seem to be working either.

Regex is working in regex101.com but not in google scripts

The problem:
I had a similar problem to this thread - my Regex works like a charm in regex101, but returns null in google scripts.
I'm trying to return the next line on a number of items:
Confirmation code
Check-in
Checout
Payout
Number of Guest
Payout
Here is the data I am searching in:
New booking confirmed!Jake arrives Oct 22
Send a message to confirm check-in details or welcome Jake.
Jake Flake
Phoenix, California, United States
Airbnb member since 2015
Send Jake a message:
https://www.airbnb.com/z/q/;laskdf;lksjdf
The Getaway
https://www.airbnb.com/manage-listing/asdflkjsdf;lkajsfd
Trip details
Check-in
Sun, Oct 22
Anytime after 4PM
Checkout
Thu, Oct 26
11AM
Guests
13
Confirmation code
H7XS0SA8
View itinerary
https://www.airbnb.com/reservation/itinerary?code=aasdfasdf
Payment
$275.50 x 4 nights
$1102.00
Cleaning Fees
$180.00
Guest Pays
$1282.00
Airbnb Fees
-$38.46
You earn
$1243.54
On the day after your guest checks in, the payment method you supplied will be credited. For details, see your transaction history.
Your guest paid $161.15 in Occupancy Taxes. Airbnb remits these taxes on your behalf.
Get ready for Jake’s arrival
Provide Directions
Confirm that your guest knows how to get to your place.
Tidy Up
Clean up all shared spaces. Make sure your guest has clean linens and towels.
Customer Support
Visit Help Center
https://www.airbnb.com/help?eal_exp=asdfasdf
Contact Airbnb
https://www.airbnb.com/help/contact_us?eal_exp=asdfasdf
Thanks,
The Airbnb Team
Email preferences
https://www.airbnb.com/users/notifications?eal_exp=asdfasdf
Airbnb
My code that works:
function getNumberofGuests(message_body) {
var num_guests = message_body.match("Guests[\r\n]+([^\r\n]+)")[1];
Logger.log("num_guests: " + num_guests);
return num_guests;
}
Logs -- num_guests: 13
The same code in a similar senario that doesn't work:
function getReservationID(message_body) {
var reservationID = message_body.match("Confirmation\scode[\r\n][^\r\n]+")[1];
Logger.log("reservationID: " + reservationID);
return reservationID;
Logs -- reservationID: null
PS
The formatting of the body in this display is off for some reason, and I tried for 30 minutes but still couldn't fix it. In the message_body, it should be a new line after "Check-in", "Checkout", "Guests", "Confirmation code", etc. - there is a new line after every element that is currently showing a space.
I also tried the space character regex, and still got null:
var regExp = new RegExp("Confirmation\scode[\s]^[^\s]+", 'g')
After taking a look at the code and trying it out, you're getting the null because of what you changed in the match method. The reason why num_guests works is because that it's set up in a way that looks for the word "Guests" and the next line is the result from the array (notice the [1] on the end of the line). That same concept/regex works for the confirmation code portion as well, but you put in the "\s" and changed the order of some parentheses. Since the search code is in double quotes, you don't need the "\s". Basically, you have "Confirmation\scode" when you want "Confirmation code". Although it works in regex101, trying in the Google Apps Script environment will produce actual results.
I loaded the data into a file and then loaded the file into variable dt in the following code:
function getMyData()
{
var ss=SpreadsheetApp.getActive();
var sh=ss.getActiveSheet()
var dt=myUtilities.loadFile('regex.txt');
var guests = dt.match(/^Guests (\d+)/m)[1];
var cf=dt.match(/^Confirmation code ([0-9A-Z]+)/m)[1];
var ui=HtmlService.createHtmlOutput(dt).append(Utilities.formatString('<br /><strong>Matches:</strong><br />Guests=%s<br />Confirmation Code=%s',guests,cf));
SpreadsheetApp.getUi().showModelessDialog(ui, 'Input Data & Extracted Parameters');
}
After playing with the regexs for a while I got this output which includes a copy of the data:
(The m flag is for multiline).
I missed some of the data the first time around.
Here's the new code with some of your additional parameters:
function getMyData()
{
var ss=SpreadsheetApp.getActive();
var sh=ss.getActiveSheet()
var dt=myUtilities.loadFile('regex.txt');
var guests = dt.match(/^Guests (\d+)/m)[1];
var cf=dt.match(/^Confirmation code ([0-9A-Z]+)/m)[1];
var chout=dt.match(/^Checkout (.*)$/m)[1];
var chin=dt.match(/^Trip details (.*)$/m)[1];
var payout=dt.match(/Guest Pays ([$.0-9]+)/m)[1];
var ui=HtmlService.createHtmlOutput(dt).append(Utilities.formatString('<br /><strong>Matches:</strong><br />Guests=%s<br />Confirmation Code=%s<br />Checkout=%s<br />Checkin=%s<br />Payout=%s',guests,cf,chout,chin,payout)).setWidth(1200);
SpreadsheetApp.getUi().showModelessDialog(ui, 'Input Data and Extracted Parameters');
}
And here's the output:
I'm guessing that you can figure out how to get the rest of them yourself.

MAPI, HrQueryAllRows: Filter messages on subject

I'm pretty much new to MAPI and haven't wrote much C++ Code.
Basically I want to read all emails in the inbox and filter them based on their subject text. So far I'm using the source code provided at the microsoft msdn website which basically reads all emails from the inbox. What I want now is to not get all emails but filter them on the subject, lets say: I want all emails in my Inbox with the subject title "test".
So far I figuered out that the following line of code retrieves all the mails:
hRes = HrQueryAllRows(lpContentsTable, (LPSPropTagArray) &sptCols, &sres, NULL, 0, &pRows);
The parameter &sres is from the type SRestriction.
I tried to implement a filter on 'test' in the subject:
sres.rt = RES_CONTENT;
sres.res.resContent.ulFuzzyLevel = FL_FULLSTRING;
sres.res.resContent.ulPropTag = PR_SUBJECT;
sres.res.resContent.lpProp = &SvcProps;
SvcProps.ulPropTag = PR_SUBJECT;
SvcProps.Value.lpszA = "test";
ScvProps is from the type SPropValue.
If i execute the application then I get 0 lines returned. If I change the String test to an empty String then I get all emails.
I'm assuming i'm using the "filter" option wrong, any ideas?
Edit: When I change the FuzzyLevel to:
sres.res.resContent.ulFuzzyLevel = FL_SUBSTRING;
then I can look for subjects that contain a single character but as soon as I add a second character I get 0 rows as result. I'm pretty sure this is just some c++ stuff that I don't understand that causes all this problems ...
I figured the problem out.
Replacing
sres.res.resContent.ulFuzzyLevel = FL_FULLSTRING;
sres.res.resContent.ulPropTag = PR_SUBJECT;
SvcProps.ulPropTag = PR_SUBJECT;
with
sres.res.resContent.ulFuzzyLevel = FL_SUBSTRING;
sres.res.resContent.ulPropTag = PR_SUBJECT_A;
SvcProps.ulPropTag = PR_SUBJECT_A;
fixed the problem.

Public Insights

With the new ability for anyone to see certain insights from pages without admin permissions, I was curious if this extends to the graph api, specifically in regards to the graph of fan growth. If you hover your mouse over a data point, it'll tell you the new fans / 7 days of that particular point in time -- is there any way to query this automatically with either fql or the regular graph api?
I've tried SELECT metric, value FROM insights WHERE object_id = 224383614973 AND metric = 'page_fan_adds' AND end_time=1342915199 AND period=86400 to query the McDonald's Canada new fans for a one-day period, but it requires a valid access_token.
Sorry for the late reply but it might help someone. You can use the graph explorer to build your FQL query:
https://developers.facebook.com/tools/explorer/?method=GET&path=CocaColaCanada%2Finsights
Also all the metrics for the page start with page_ and are available here:
https://developers.facebook.com/docs/reference/api/insights/#page_stories
Some of them are not public.
In all cases you need valid access_token
UPDATE:
I've run a script for macdonald using the 233 metrics that facebook offers to see which one are public metrics for a page. Here is the result:
McDonalds(233 metrics)
application_active_users: no
application_active_users_locale: no
application_active_users_city: no
application_active_users_country: no
application_active_users_gender: no
application_active_users_age: no
application_active_users_gender_age: no
application_installed_users: no
application_installed_users_locale: no
application_installed_users_city: no
application_installed_users_country: no
application_installed_users_gender: no
application_installed_users_age: no
application_installed_users_gender_age: no
application_installation_adds: no
application_installation_adds_unique: no
application_installation_removes: no
application_installation_removes_unique: no
application_tos_views: no
application_tos_views_unique: no
application_permission_views_top: no
application_permission_views_top_unique: no
application_permission_grants_top: no
application_permission_grants_top_unique: no
application_block_adds: no
application_block_adds_unique: no
application_block_removes: no
application_block_removes_unique: no
application_mobile_app_installs: no
application_like_adds: no
application_like_adds_unique: no
application_like_removes: no
application_like_removes_unique: no
application_comment_adds: no
application_comment_adds_unique: no
application_photos: no
application_photos_unique: no
application_shares: no
application_shares_unique: no
application_status_updates: no
application_status_updates_unique: no
application_stream_stories: no
application_stream_stories_unique: no
application_feed_form_views: no
application_feed_form_views_unique: no
application_feed_form_views_login: no
application_feed_form_views_login_unique: no
application_feed_form_views_logout: no
application_widget_activity_views: no
application_widget_activity_views_unique: no
application_widget_activity_views_login: no
application_widget_activity_views_login_unique: no
application_widget_activity_views_logout: no
application_widget_activity_views_external_referrals: no
application_widget_comments_views: no
application_widget_comments_views_unique: no
application_widget_comments_views_login: no
application_widget_comments_views_login_unique: no
application_widget_comments_views_logout: no
application_widget_fan_views: no
application_widget_fan_views_unique: no
application_widget_fan_views_login: no
application_widget_fan_views_login_unique: no
application_widget_fan_views_logout: no
application_widget_fan_views_external_referrals: no
application_widget_like_views: no
application_widget_like_views_unique: no
application_widget_like_views_login: no
application_widget_like_views_login_unique: no
application_widget_like_views_logout: no
application_widget_like_views_external_referrals: no
application_widget_live_stream_views: no
application_widget_live_stream_views_unique: no
application_widget_live_stream_views_login: no
application_widget_live_stream_views_login_unique: no
application_widget_live_stream_views_logout: no
application_widget_live_stream_views_external_referrals: no
application_widget_recommendation_views: no
application_widget_recommendation_views_unique: no
application_widget_recommendation_views_login: no
application_widget_recommendation_views_login_unique: no
application_widget_recommendation_views_logout: no
application_widget_recommendation_views_external_referrals: no
application_widget_share_views: no
application_widget_share_views_unique: no
application_widget_views: no
application_widget_views_unique: no
application_widget_views_login: no
application_widget_views_login_unique: no
application_widget_views_logout: no
application_opengraph_action_create: no
application_opengraph_action_delete: no
application_opengraph_object_create: no
application_opengraph_object_update: no
application_opengraph_story_impressions: no
application_opengraph_story_click: no
application_opengraph_story_like: no
application_opengraph_story_unlike: no
application_opengraph_story_comment: no
application_opengraph_story_hide: no
application_opengraph_story_hide_all: no
application_opengraph_story_report_spam: no
application_opengraph_link_impression: no
application_opengraph_link_click: no
application_opengraph_timeline_impressions: no
application_opengraph_timeline_spam: no
application_opengraph_timeline_clicked: no
application_canvas_views: no
application_canvas_views_unique: no
application_canvas_views_login: no
application_canvas_views_login_unique: no
application_canvas_views_logout: no
application_canvas_views_internal_referrals: no
application_canvas_views_external_referrals: no
application_tab_views: no
application_tab_views_unique: no
application_api_calls: no
application_api_calls_top: no
application_api_calls_unique: no
application_api_errors: no
application_api_errors_rate: no
application_api_errors_top: no
application_api_time_average: no
application_canvas_errors: no
application_canvas_errors_rate: no
application_canvas_time_average: no
page_fans_locale: no
page_fans_city: no
page_fans_country: ok
page_fans_gender_age: no
page_fan_adds: no
page_fan_adds_unique: no
page_fans_by_like_source: no
page_fans_by_like_source_unique: no
page_fan_removes: no
page_fan_removes_unique: no
page_friends_of_fans: no
page_tab_views_login_top_unique: no
page_tab_views_login_top: no
page_views: no
page_views_unique: no
page_views_login: no
page_views_login_unique: no
page_views_logout: no
page_views_external_referrals: no
page_posts_impressions: no
page_posts_impressions_unique: no
page_posts_impressions_paid: no
page_posts_impressions_paid_unique: no
page_posts_impressions_organic: no
page_posts_impressions_organic_unique: no
page_posts_impressions_viral: no
page_posts_impressions_viral_unique: no
page_posts_impressions_frequency_distribution: no
post_stories: no
post_storytellers: no
post_stories_by_action_type: no
post_storytellers_by_action_type: no
post_impressions: no
post_impressions_unique: no
post_impressions_paid: no
post_impressions_paid_unique: no
post_impressions_fan: no
post_impressions_fan_unique: no
post_impressions_fan_paid: no
post_impressions_fan_paid_unique: no
post_impressions_organic: no
post_impressions_organic_unique: no
post_impressions_viral: no
post_impressions_viral_unique: no
post_impressions_by_story_type: no
post_impressions_by_story_type_unique: no
post_consumptions: no
post_consumptions_unique: no
post_consumptions_by_type: no
post_consumptions_by_type_unique: no
post_engaged_users: no
post_negative_feedback: no
post_negative_feedback_unique: no
post_negative_feedback_by_type: no
post_negative_feedback_by_type_unique: no
domain_feed_clicks: no
domain_feed_views: no
domain_stories: no
domain_widget_comments_adds: no
domain_widget_comments_views: no
domain_widget_comments_feed_views: no
domain_widget_comments_feed_clicks: no
domain_widget_like_views: no
domain_widget_likes: no
domain_widget_like_feed_views: no
domain_widget_like_feed_clicks: no
domain_widget_send_views: no
domain_widget_send_clicks: no
domain_widget_send_inbox_views: no
domain_widget_send_inbox_clicks: no
page_stories: no
page_storytellers: no
page_stories_by_story_type: no
page_storytellers_by_story_type: no
page_storytellers_by_age_gender: no
page_storytellers_by_country: ok
page_storytellers_by_locale: no
page_impressions: no
page_impressions_unique: no
page_impressions_paid: no
page_impressions_paid_unique: no
page_impressions_organic: no
page_impressions_organic_unique: no
page_impressions_viral: no
page_impressions_viral_unique: no
page_impressions_by_story_type: no
page_impressions_by_story_type_unique: no
page_impressions_by_city_unique: no
page_impressions_by_age_gender_unique: no
page_impressions_frequency_distribution: no
page_impressions_viral_frequency_distribution: no
page_engaged_users: no
page_consumptions: no
page_consumptions_unique: no
page_consumptions_by_consumption_type: no
page_consumptions_by_consumption_type_unique: no
page_places_checkin_total: no
page_places_checkin_total_unique: no
page_places_checkin_mobile: no
page_places_checkin_mobile_unique: no
page_places_checkins_by_age_gender: no
page_places_checkins_by_locale: no
page_places_checkins_by_country: no
page_negative_feedback: no
page_negative_feedback_unique: no
page_negative_feedback_by_type: no
page_negative_feedback_by_type_unique: no
Started at: 2013-04-17 02:14:29
Ended at: 2013-04-17 02:17:13
Second elapsed: 164s
enter code here

Resolving incidents (closing cases) in CRM4 through webservices?

I'm trying to resolve/close Dynamics CRM4 cases/incidents through webservices.
A single SetStateIncidentRequest is not enough and returns a Server was unable to process request error message. I think it has something to do with active workflows that trigger on case's attribute changes. I don't know if there's anything else preventing the request to work.
Since it is possible to close those cases through the GUI, I guess there's a "correct" set of steps to follow in order to achieve it through CrmService; unfortunately, I've been googleing it for a while without finding what I want. Could anybody help me, please?
To resolve a case in CRM (in VB.NET), I do the following:
Try
Dim activity As New incidentresolution
Dim closeRequest As New CloseIncidentRequest
Dim closeResponse As New CloseIncidentResponse
Dim strErrors As String = String.Empty()
activity.incidentid = New Lookup
activity.incidentid.type = EntityName.incident.ToString
activity.incidentid.Value = //[GUID OF INCIDENT]
activity.ownerid = New Owner
activity.ownerid.type = EntityName.systemuser.ToString
activity.ownerid.Value = //[GUID OF USER PERFORMING ACTION]
activity.statecode = New IncidentResolutionStateInfo
activity.statecode.Value = 1 //Resolved
activity.statuscode = New Status
activity.statuscode.Value = 5 //Problem Solved
closeRequest.IncidentResolution = activity
closeRequest.Status = 5 //Problem Solved
// IF REQUIRED:
activity.timespent = New CrmNumber
activity.timespent.Value = //[INTEGER REPRESENTING No. OF MIN SPENT ON CASE]
closeResponse = objCrm.Execute(closeRequest)
Catch ex As System.Web.Services.Protocols.SoapException
Dim root As XmlElement = ex.Detail
strErrors = strErrors & vbCrLf & vbCrLf & root.ChildNodes(0).ChildNodes(3).InnerText
Return False
End Try
Here's a tip - catch the SoapException and examine the Detail.OuterXML property and you will get a more detailed error message. It's possible you're not building your request correctly.
Indeed, I didn't know that there exists a CloseIncidentRequest class to use with the CrmService.Execute() method. Most probably the SetStateIncidentRequeset won't work because it's expected that incident resolutions are created that way. Pity that names for classes and actions aren't used consistently (case/incident, resolution/closing)...