ShellToast.NavigationUri ignored - the toast takes me to MainPage.xaml // WP7.1 Mango - scheduled-tasks

I've been playing with the background tasks and everything is fine (but bizzar), but now I try to do something like this:
protected override void OnInvoke(ScheduledTask task)
{
if (task is PeriodicTask)
{
ShellToast t = new ShellToast();
t.Content = "AAAAAAAAAAAAAAAAAAAAA";
t.Title = "mytitle";
t.NavigationUri = new Uri("/GotHereFromToastLink.xaml?someParam=" + 123, UriKind.Relative);
t.Show();
}
NotifyComplete();
}
Which SHOULD take me to GoHereFromToastLink.xaml when I press the toast notification, but instead it always takes me to MainPage.xaml - anybody knows if this is a bug? Or am I doing something incorrectly?

After contacting some really helpful MS guys I got a response - It's a known issue (aka bug) and it's already fixed but they don't have a date on the update to the Mango SDK but this will be working properly in the final release of the Mango toolset.
So for now - just ignore it.

I have the same problem!
Found out that the reason is the relative URI. I assume you have used another absolute URI in your application?

Related

Eclipse removing white spaces when saving

I have a big issue. I develop in eclipse ide environment, mostly on windows but also on linux. This seems to be a general issue.
Before I save my project on eclipse I have certain spaces between functions or in the code somewhere. I don't want to reformat the code that is in place.
However, every single time I try to save my project. Those spaces disappear, and I cannot find the place where I should change this auto-formatting in my eclipse properties.
Please see example bellow:
First of all I don't touch the code but I receive it as bellow and have to make modifications elsewhere. So at the initial state of my file I have somewhere in the code two functions [functionOne, functionTwo]. Those two functions are separated by a new line [NL] and 6 spaces. The problem appears when I save my project and as you can see the two functions are not separated anymore by the same number of spaces.
Before saving my project:
public void functionOne(){
int i = 0;
while(i<150)
{
//blabla...
}
}
NL:123456
public void functionTwo(){
int i = 0;
while(i<150)
{
//blabla...
}
}
After saving my project:
public void functionOne(){
int i = 0;
while(i<150)
{
//blabla...
}
}
NL:1
public void functionTwo(){
int i = 0;
while(i<150)
{
//blabla...
}
}
I'm starting to be sick of this issue and really need help to solve this.
Not forgetting to mention that absolutely no "Save actions" is enabled!
I don't see anything on my format options neither, but I could be wrong.
Could someone please help me to find a solutions to this problem?
Best regards,
Greg
So that wasn't the "Save actions" but some plugin that I was using. Didn't had the time to check which one it is I just uninstalled the rarely/unused once. And for the moment it seems to work. I'll check later if the problem remains/reappears.
Thanks for your help.
Best regards,
Gregory

condition not working sometimes with gwt

I'm having a rare issue in my code, I have a method that makes a very simple validation based on a string variable:
private void showNextStep(String psCondition,String poStepName){
int liCurrentStep=Integer.valueOf(poStepName);
String lsNextTrueStep=moSteps[liCurrentStep][4];
String liNextFalseStep=moSteps[liCurrentStep][5];
if ("Yes".equals(psCondition)){
moFrmStepsContainer.getField(liNextFalseStep).hide();
moFrmStepsContainer.getField(lsNextTrueStep).show();
}else{
moFrmStepsContainer.getField(liNextFalseStep).show();
moFrmStepsContainer.getField(lsNextTrueStep).hide();
}
}
Now, here is the ticky part: if I execute the application without debugging mode, it does the validation right all the time, how ever if don't it always goes to the else block (or at least I think) I tried to use JS alerts (I have a class that calls JS methods) to debug manually and check the valors of the variables; the valors where all right and the validation was also good. This means that only debugging or putting alerts before at the beggining of the IF block it does the validation right, otherwise it always goes to the ELSE, what do you think it could be?
It might be worth mentioning this is a web application made in netbeans 6.9, using the framework GWT 2.1. This application runs in firefox 25.0.1
Thank you!
UPDATE
Here is the code of the event that calls my method
final ComboBoxItem loYesNo=new ComboBoxItem("cmbYesNo" + moSteps[liStepIndex][0],"");
loYesNo.setValueMap("Yes","No");
loYesNo.setVisible(false);
loYesNo.setAttribute("parent", liStepIndex);
loYesNo.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent poEvent){
String lsStepName=loYesNo.getName();
FormItem loItem=moFrmStepsContainer.getField(lsStepName);
String liStepNumber=String.valueOf(loItem.getAttributeAsInt("parent"));
showNextStep((String)poEvent.getItem().getValue(),liStepNumber);
}
});

silverstripe dopublish function for ModelAdmin managed Pages

in the silverstripe backend I´m managing certain PageTypes via a ModelAdmin. That works fine so far, the only thing i can´t figure out is how to make a Page being "Published" when saving it.
Thats my code:
class ProjectPage extends Page {
public function onAfterWrite() {
$this->doPublish();
parent::onAfterWrite();
}
}
At the moment I can still see the ModelAdmin-created Pages in the Sitetree and I can see they are in Draft Mode. If I use the code above I get this error:
Maximum execution time of 30 seconds exceeded in
.../framework/model/DataList.php
Many thx,
Florian
the reason why you get "Maximum execution time exceeded" is because $this->doPublish(); calls $this->write(); which then calls $this->onAfterWrite();. And there you have your endless loop.
So doing this in onAfterWrite() or write() doesn't really work
you should just display the save & publish button instead of the save button
But I guess its easier said than done.
Well adding a button is actually just a few lines, but we also need a provide the functions that do what the button says it does.
This sounds like the perfect call for creating a new Module that allows proper handling of Pages in model admin. I have done this in SS2.4, and I have a pretty good idea of how to do it in SS3, but no time this week, poke me on the silverstripe irc channel on the weekend, maybe I have time on the weekend.
I found the same need/lack and I built a workaround that seems to work for me, maybe it can be useful.
public function onAfterWrite()
{
if(!$this->isPublished() || $this->getIsModifiedOnStage())
{
$this->publish('Stage', 'Live');
Controller::curr()->redirectBack();
}
parent::onAfterWrite();
}
Create a class that extends ModelAdmin and define an updateEditForm function to add a publish button to the actions in the GridFieldDetailForm component of the GridField.
public function updateEditForm($form) {
if ( ! singleton($this->owner->modelClass)->hasExtension('Versioned') ) return;
$gridField = $form->Fields()->fieldByName($this->owner->modelClass);
$gridField->getConfig()->getComponentByType('GridFieldDetailForm')->setItemEditFormCallback(function ($form) {
$form->Actions()->push(FormAction::create('doPublish', 'Save & Publish'));
});
}
Then create a class that extends GridFieldDetailForm_ItemRequest to provide an action handler for your publish button.
public function doPublish($data, $form) {
$return = $this->owner->doSave($data, $form);
$this->owner->record->publish('Stage', 'Live');
return $return;
}
Make sure the extensions are applied and you're done.
Or, you could just grab all the code you need from GitHub.

Watin Unit Tests with Nunit Timing problem

Hi i am using WatiN (version 2.0.10.928) with NUnit (2.5.2.9222)
if I have something like
[Test]
public void WebPageTest()
{
string url = "www.google.com";
IE ie = new IE(url);
ie.TextField(Find.ByTitle("Google Search")).TypeText("Watin");
ie.Button(Find.ByName("btnG")).Click();
ie.Element(Find.ByText("WatiN")).Click();
// ie.WaitForComplete();
Assert.IsTrue(ie.Text.Contains("Welcome at the WatiN"));
ie.Close();
}
Then usually this will work and the test will pass but sometimes when I hit the assert it seems that Watin hasn't finished loading the page and is still on the previous page. I have this problem using the IE.Text or the IE.Url properties. I tried using WaitForComplete() (even though that shouldn't be neccessary) but still sometimes have the same problem.
Has Anybody had this problem with WatiN before?
Has anybody succesufully managed to use WatiN with NUnit like this? Or Maybe it would work better with a different unit testing framework like MBUnit? Has anyone had better luck with MBunit?
The test framework you use will make no difference, I'm afraid -- this is one of the "gotchas" of any screen-scraping test framework, and WaTin is no different.
The WaitForComplete() call is definitely necessary, I'm afraid.
Some of my colleagues have reported that the version of IE can make a difference; IE6 in particular has some internal timing issues that can cause problems. IE8 appears to be quite a bit better.
I've had the same problem with my tests; unfortunately it doesn't seem as though you can assume that the WaitForComplete() that's supposed to be inherent in the Click() method will function correctly. Even explicitly calling WaitForComplete() afterward hasn't always worked.
As a last resort we have used System.Threading.Thread.Sleep(int timeout_in_milliseconds) to force the browser to give the page time to load. This isn't a completely bulletproof means of doing it, but it has eliminated about 90% of these sorts of errors. For the timeout we have used anything from 500 to 2000 milliseconds, depending on how long it takes to load and how quickly we want the test to run.
Try using
[Test]
public void WebPageTest()
{
string url = "www.google.com";
IE ie = new IE(url);
ie.TextField(Find.ByTitle("Google Search")).TypeText("Watin");
var btnG = ie.Button(Find.ByName("btnG"));
btnG.ClickNoWait();
ie.WaitForComplete(400);
var elementWatin = ie.Element(Find.ByText("WatiN"));
elementWatin.ClickNoWait();
ie.WaitForComplete(400);
Assert.IsTrue(ie.Text.Contains("Welcome at the WatiN"));
ie.Close();
}
Thanks
Gandhi Rajan
I have used ie.WaitForComplete() but it still does enforce waiting, and sometimes it times out, so I use
Settings.AttachToBrowserTimeOut = 200;
Settings.WaitForCompleteTimeOut = 200;
This worked for me.

WMI and Win32_DeviceChangeEvent - Wrong event type returned?

I am trying to register to a "Device added/ Device removed" event using WMI. When I say device - I mean something in the lines of a Disk-On-Key or any other device that has files on it which I can access...
I am registering to the event, and the event is raised, but the EventType propery is different from the one I am expecting to see.
The documentation (MSDN) states : 1- config change, 2- Device added, 3-Device removed 4- Docking. For some reason I always get a value of 1.
Any ideas ?
Here's sample code :
public class WMIReceiveEvent
{
public WMIReceiveEvent()
{
try
{
WqlEventQuery query = new WqlEventQuery(
"SELECT * FROM Win32_DeviceChangeEvent");
ManagementEventWatcher watcher = new ManagementEventWatcher(query);
Console.WriteLine("Waiting for an event...");
watcher.EventArrived +=
new EventArrivedEventHandler(
HandleEvent);
// Start listening for events
watcher.Start();
// Do something while waiting for events
System.Threading.Thread.Sleep(10000);
// Stop listening for events
watcher.Stop();
return;
}
catch(ManagementException err)
{
MessageBox.Show("An error occurred while trying to receive an event: " + err.Message);
}
}
private void HandleEvent(object sender,
EventArrivedEventArgs e)
{
Console.WriteLine(e.NewEvent.GetPropertyValue["EventType"]);
}
public static void Main()
{
WMIReceiveEvent receiveEvent = new WMIReceiveEvent();
return;
}
}
Well, I couldn't find the code. Tried on my old RAC account, nothing. Nothing in my old backups. Go figure. But I tried to work out how I did it, and I think this is the correct sequence (I based a lot of it on this article):
Get all drive letters and cache
them.
Wait for the WM_DEVICECHANGE
message, and start a timer with a
timeout of 1 second (this is done to
avoid a lot of spurious
WM_DEVICECHANGE messages that start
as start as soon as you insert the
USB key/other device and only end
when the drive is "settled").
Compare the drive letters with the
old cache and detect the new ones.
Get device information for those.
I know there are other methods, but that proved to be the only one that would work consistently in different versions of windows, and we needed that as my client used the ActiveX control on a webpage that uploaded images from any kind of device you inserted (I think they produced some kind of printing kiosk).
Oh! Yup, I've been through that, but using the raw Windows API calls some time ago, while developing an ActiveX control that detected the insertion of any kind of media. I'll try to unearth the code from my backups and see if I can tell you how I solved it. I'll subscribe to the RSS just in case somebody gets there first.
Well,
u can try win32_logical disk class and bind it to the __Instancecreationevent.
You can easily get the required info
I tried this on my system and I eventually get the right code. It just takes a while. I get a dozen or so events, and one of them is the device connect code.