Remove reminder - windows-phone-7.1

Is there anyway to remove a reminder/alarm that has been created from my application? And maybe make it possible for the user to list all reminders/alarms that has been created.

Did you try this ?
if (ScheduledActionService.Find("Your Alarm Name") != null)
ScheduledActionService.Remove("Your Alarm Name");

Related

ItemAdd Event on Redemption Folder - how to use properly with Console Application

I have a .Net Console Application that emails documents using Redemption with Outlook. I attach the "Items.ItemAdd" event to the relevant folder. The event never fires.
But in my test harness which is a WPF application, using the same method and the same references etc, it does work.
Does the event actually work in a console app? Is there an example of the correct way, or of an alternate way?
Your app needs to run the Windows message loop for the events to work.
OK thanks for that hint. I tried various things and eventually it seems to work as below:
DispatcherOperation op = System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => { SomeMethod(someArgs); }));
DispatcherOperationStatus status = op.Status;
while (status != DispatcherOperationStatus.Completed && status != DispatcherOperationStatus.Aborted)
{
status = op.Wait(TimeSpan.FromMilliseconds(10000));
if (status == DispatcherOperationStatus.Completed || status == DispatcherOperationStatus.Aborted)
{
// do your final code
}
}

How to change a modx revolution users class_key when newly created VIA the manager?

I'm trying to change a new user's class_key value when they are created VIA the manager.
In a plugin that fires on the onUserSave event:
<?php
$uid = $_POST['id'];
$sql = "update modx_users set `class_key` = 'extUser' where id = $uid;";
$modx->log(modX::LOG_LEVEL_ERROR, 'query = ' . $sql);
$query = $modx->query($sql);
return;
Which works when you EDIT an EXISTING user, but does not work if you try to CREATE a NEW user.
Any thoughts on how to do this?
None of the system events look like they fire when a new user is created.
Looking at the user/create processor, you would need to listen for OnUserFormSave which is fired after saving the new user.
I haven't tested this, but in your plugin you have access to $modx->event. Log the output of this for the OnUserFormSave event, hopefully it should include a 'data' property containing the new user object. The object should contain the new user id.
Let me know how that goes!
Update
I've tested this out. As expected, you have access to the new user id, user object (and much more) in the $modx->event object:
if ($modx->event->name == 'OnUserFormSave') {
// id of user you've just created
$newUserId = $modx->event->name->params->id;
// full modUser object is available here
$newUserObj = $modx->event->name->params->user;
}
In plugin with OnUserSave event:
$scriptProperties['user']->set('class_key','extUser');
That's it nothing more.
You cannot call
$scriptProperties['user']->save();
in OnUserSave as other examples elsewhere have shown.

Activity Log is not Inserted in Nopcommerce

I am using Nopcommerce 2.65.
I have created new page at admin side of Nopcommerce.
Now I am trying to add Log of that page in Activity Log.
but In Activity log Record is not Inserted because in Insert method it finds Systemkeyword and it found NULL
I am calling Insert Activity Method Like:
_customerActivityService.InsertActivity("AddNewQuote", _localizationService.GetResource("Custom.ActivityLog.AddQuote"), quote.Id);
At Definition side of InsertActivityLog
var activityType = activityTypes.ToList().Find(at => at.SystemKeyword == systemKeyword);
if (activityType == null || !activityType.Enabled)
return null;
Please Suggest
You have to add the activity type record with this system name "AddNewQuote" to the [ActivityLogType] table

SfDoctrineGuard Permission

I use SfDoctrine guard in my test project. I use also SfForkedApply for registration and managing accounts. I set 3 type permissions: "user","creator","administrator".
My question is : When i Create account whit sfForkedApply , How to set automaticly "User" permission to this new user .
Don't know your exact details, but your would probably need to override the doSave method of the 'user register' form and set the user permission.
Vlad you help me very much :) In doSave i added 4 rows and evriting is ok :) this is the code. It work :)
public function doSave($con = null)
{
$user = new sfGuardUser();
$user->setUsername($this->getValue('username'));
$user->setPassword($this->getValue('password'));
$user->setEmailAddress( $this->getValue('email') );
// They must confirm their account first
$user->setIsActive(false);
$user->save();
$this->getObject()->setUserId($user->getId());
//THIS LINE I ADDED
$permission = new sfGuardUserPermission();
$permission->setPermissionId('1');
$permission->setUserId($user->getId());
$permission->save();
return parent::doSave($con);
}

Cannot insert duplicate key

I am getting this error ...
Violation of PRIMARY KEY constraint 'PK_Members'. Cannot insert duplicate key in object 'dbo.Members'.
The statement has been terminated.
When I try to use the Membership and Role Providers in ASP.NET MVC. It happens when calling the GetUser method from inside the RoleProvider.
var member = System.Web.Security.Membership.GetUser(email) as Models.Member;
//var member = (
// from m in DataContext.Members
// where m.Email == email
// select m).Single();
var role = (
from r in DataContext.Roles
where r.Name == roleName
select r).Single();
member.Groups.Add(new Models.Group(role));
DataContext.SubmitChanges();
It looks like the problem is in the code
member.Groups.Add(new Models.Group(role));
Based on the error message returned by the sql, Read operation like GetUser won't throw this type of error.
I suspect it's because you are adding a group that exists already.
Maybe you should check for the existance of the role before trying to add it.
Hope this helps.
A good way to debug this is to use SQL profiler to determine what SQL code is being run against the database.
I would suspect you are trying to save a record somewhere that has the same primary key already in the database.
SQL Profiler = http://msdn.microsoft.com/en-us/library/ms181091.aspx
Are you sure you are not trying to enter a number into the PRIMARY KEY field that is already there? If it is auto_increment, just enter 0 and it will make the value of that field, the last number+1
Hope this helps :)
If the exception is an SqlException you might get its error number for duplicate records which is 2627. You might catch the exception and verify it and display and manage any error accordingly. I Hope this helps.
catch (SqlException ex)
{
if (ex.Number == 2627)
{
MessageBox.Show("This record exists: "+ex.Message, "Error");
}
else
{
MessageBox.Show(ex.Message, "Error")
}
}
I am a newbie at this but I am going to give this a try, sorry if it doesn't work for you.
I think that instead of using,
member.Groups.Add(new Models.Group(role));
You should use the following (if you are updating the database):
member.Groups.Entry(new Models.Group(role));
And if the above code doesn't work, try this (if you are adding to the database):
// First, search for the particular obj you want to insert
var checkModels = member.Groups.Find(new Models.Groups(roles));
// If the obj doesn't already exist, add it to the database
if(checkModels == null){
member.Groups.Add(new Models.Group(role));
}
// If the obj does exist already, then update it
else{
member.Groups.Entry(new Models.Group(role)).State = EntityState.Modified;
}

Resources