Can Reminder be updated for windows phone - windows-phone-7

Would appreciate you help for the following.
I have created a reminder but I want to update it before or after the reminder nofiticaton has activated. here the code.
Problem : it wont work even if there is no compilation error for this code.
var Myreminders = ScheduledActionService.GetActions()
.Where(a => a.BeginTime.Month == month);
foreach (Reminder r in Myreminders)
{
string strMyRmd;
strMyRmd = r.Name.ToString();
if ( strMyRmd == "MyName1" )
{
r.Title = "Today Shopping";
}
}
Thanks

I believe (I can't test this from my computer but have confirmed this works with Background Agents) that you need to find your Reminder, remove it from the scheduled action service, update and re add it.
var reminder = (Reminder)ScheduledsActionService.Find("MyReminder");
ScheduledActionService.Remove("MyReminder");
reminder.Title = "Updated Title";
ScheduledActionService.Add(reminder);

According to the remarks section in ScheduledActionService.GetActions Method documentation page:
The Scheduled Action Service does not maintain a reference to the
objects returned by this method, and therefore the properties of the
objects are not updated to reflect the current state after the call to
GetActions. To obtain an object that is updated by the system as its
state changes, use Find(String) instead.
So, just use Find(String) instead.

Related

Nopcommerce update customise table when check out

I am newbie for nopcommerce.
Any Idea to check and update customise table when check out?
My case is like that:
I have create a new table name as "DailyLimit" table in my db.
Table field have ID,Date,DailyLimit.
when checkout product, I need to check the "Date" of Daily limit. If daily limit <= 0, then it will pop-up a alert, else it will update to DailyLimit field.
PS:I already create a date checkout attribute and make it as session.
For the Checkout controller I have add the availableQty variable pass to model.
public ActionResult OnePageCheckout(){
//validation
var cart = _workContext.CurrentCustomer.ShoppingCartItems
.Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart)
.LimitPerStore(_storeContext.CurrentStore.Id)
.ToList();
//Problem here
var availableQtyFromDB = "SELECT DailyLimit FROM deliveryTbl WHERE date =Session["DeliveryDateForDesley"]" //problem here
if (cart.Count == 0)
return RedirectToRoute("ShoppingCart");
if (!_orderSettings.OnePageCheckoutEnabled)
return RedirectToRoute("Checkout");
if ((_workContext.CurrentCustomer.IsGuest() && !_orderSettings.AnonymousCheckoutAllowed))
return new HttpUnauthorizedResult();
var model = new OnePageCheckoutModel
{
ShippingRequired = cart.RequiresShipping(),
DisableBillingAddressCheckoutStep = _orderSettings.DisableBillingAddressCheckoutStep,
availableQty = availableQtyFromDB
};
return View(model);
}
But I have no idea how to write the how to SELECT statement in this controller.
And no idea how to update the daily limit.
Interesting question. Based on your code, I assume you haven't worked much with EF framework. when i started working with nopcommerce, i was like that too. But best thing in nopcommerce is most of common problems were solved in somewhere other part of the application.
First, blindly writing SQL in controller wont help much. Good way to learn is to have a look at
.LimitPerStore(_storeContext.CurrentStore.Id)
Method and how they have done the query/selection using Entity framework. They have done that for per store. You need to do it per day. That will help you to alight your solution in line with nopcommerce architecture.
Source: Ex-nopCommerce Developer for 3 years.

Cannot specify child attributes in the columnset for Retrieve

In attempting to merge contacts in Microsoft CRM, I am using the following code -
//c1ID and c2ID are GUIDs of duplicated contacts.
EntityReference target = new EntityReference();
target.LogicalName = Contact.EntityLogicalName;
target.Id = c2ID;
MergeRequest merge = new MergeRequest();
// SubordinateId is the GUID of the account merging.
merge.SubordinateId = c1ID;
merge.Target = target;
merge.PerformParentingChecks = true;
Contact updater = new Contact();
Contact updater2 = new Contact();
updater = (Contact)xrmSvc.ContactSet.Where(c => c.ContactId.Equals(c1ID)).First();
updater2 = (Contact)xrmSvc.ContactSet.Where(c => c.ContactId.Equals(c2ID)).First();
MergeResponse mergedR = (MergeResponse)xrmSvc.Execute(merge);
When I try my Execute call here,I get this error -
Cannot specify child attributes in the columnset for Retrieve. Attribute: owneridname.
Am I not setting something correctly?
Having updatecontent does not change the issue. In fact, I get the error on lookups entered into the updatecontent. I find you have to build new entityreferences:
if (match.Contains("new_mostrecentcampaign"))
master["new_mostrecentcampaign"] =
new EntityReference(match.GetAttributeValue<EntityReference>("new_mostrecentcampaign").LogicalName
, match.GetAttributeValue<EntityReference>("new_mostrecentcampaign").Id);
...
Merge.UpdateContent = master
...
I realize this is a pretty old question, but for those of you who have run into the same issue in 2021 and beyond, here's the reason this error happens.
TL;DR: Ensure the EntityReference values for the attributes does not specify the Name property.
Explanation:
Everything that gets added to the Entity set to UpdateContent will be applied to the Target contact. When programmatically executing a MergeRequest within a plugin/workflow, the attributes of the UpdateContent get applied (as desired).
Where this breaks down is for EntityReference value types (lookups). The internal Microsoft code that performs this operation tries to interpret all properties of the EntityReference object, including Name.
So when the existing values from the SubordinateId contact are pulled using IOrganizationService.Retrieve (to dynamically get the latest version), the Name property is automatically set for those lookup attributes (the child record). This operation is not valid, even though it's not the user code that's directly executing it.
This brings us full circle to explain the original error:
Cannot specify child attributes in the columnset for Retrieve
I wish I had some documentation for this, but although the official documentation notes that the UpdateContent is optional, experience proves that it is in fact necessary. In the MergeRequests I've tested, I always include that property in the request, and there's a post in the MSDN forums for Dynamics 3.0 that suggests the same.
In fact, when I try to merge two contacts in my org without UpdateContent assigned, I actually get a FaultException saying the following:
Required field 'UpdateContent' is missing
Even though the documentation says it's optional!
So I'd suggest populating the UpdateContent property with something as in the below and see if that works:
var merge = new MergeRequest
{
// SubordinateId is the GUID of the account merging.
SubordinateId = c1ID,
Target = target,
PerformParentingChecks = true,
UpdateContent = new Contact()
};

How to manually load an entity as well as a related entity

I have two entity objects one that holds billing address information(TBLADDRESS) and one that holds my account addresses(TBLMYACCOUNTADDRESS).
At a point in my project i need to load the TBLADDRESS object with the corresponding values from TBLMYACCOUNTADDRESS. Both of which have a relation to LKSTATE.
My problem is i cannot populate this related entity manually. Maybe it's not possible?
Here is my script so far, hopefully it will help you better understand exactly what i am trying to accomplish:
TBLADDRESS tblBilling = new TBLADDRESS();
TBLMYACCOUNTADDRESS myAccountDefaultAddress = new TBLMYACCOUNTADDRESS();
myAccountDefaultAddress = myAccountAddress.FindAll(delegate(TBLMYACCOUNTADDRESS i) { return i.IS_DEFAULT == true; }).ToList().SingleOrDefault();
tblBilling = new TBLADDRESS();
tblBilling.FIRST_NAME = myAccountDefaultAddress.FIRST_NAME;
tblBilling.LAST_NAME = myAccountDefaultAddress.LAST_NAME;
tblBilling.COMPANY = myAccountDefaultAddress.COMPANY;
tblBilling.ADDRESS_1 = myAccountDefaultAddress.ADDRESS_1;
tblBilling.ADDRESS_2 = myAccountDefaultAddress.ADDRESS_2;
tblBilling.CITY = myAccountDefaultAddress.CITY;
tblBilling.LKSTATE.STATE_ID = myAccountDefaultAddress.LKSTATE.STATE_ID;
tblBilling.POSTAL_CODE = myAccountDefaultAddress.POSTAL_CODE;
tblBilling.PHONE = myAccountDefaultAddress.PHONE;
Question is how would i go about populating the tblBilling.LKSTATE.STATE_ID manually. Currently i get an object reference not set to an instance of an object error message, but something tells me there's more to it than that.
Thanks in Advance,
Billy
Figured it out.
All i need was the instance of the object created before assigning to it.
tblBilling.LKSTATE = new LKSTATE();
Initially i wasn't sure just how to create the instance. Pretty straightforward.

How do I retrieve just recurring event masters using Exchange Web services?

I'm using a CalendarItemType view to retrieve calendar items. The only items I care about are those that I've created and I know that they are all weekly recurring items. I'm able to get each individual occurrence and, from any one of them the recurring master item, but I'd like to narrow the scope of my search to just those items that would match my pattern.
I've trying using the Restriction property on the FindItemType to specify a NotEqualTo restriction with a null constant for calenderRecurrenceId. This caused my request to time out. So far I've been unable to load the recurrences with the FindItemType at all and need to use a subsequent GetItemType call when I find an event that is an occurence in a recurring series.
Here's the code that I'm starting with. The code needs to work with both Exchange 2007 and Exchange 2010.
var findItemRequest = new FindItemType();
findItemRequest.ParentFolderIds = new DistinguishedFolderIdType[]
{
new DistinguishedFolderIdType()
};
((DistinguishedFolderIdType)findItemequest.ParentFolderIds[0]).Id = DistinguishedFolderIdNameType.calendar;
findItemRequest.Traversal = ItemQueryTraversalType.Shallow;
var itemShapeDefinition = new ItemResponseShapeType(
{
BaseShape = DefaultShapeNamesType.AllProperties;
}
findItemRequest.Item = calenderView;
findItemRequest.ItemShape = itemShapeDefinition;
var findItemResponse = this.esb.FindItem( findItemRequest );
Also, if you know of any good source of examples (beyond the ones in MSDN), I'd welcome them. I'm picking up someone else's code in an emergency and trying to learn Exchange Web Services on the fly.
Maybe I'm misunderstanding you, in which case I apologize.
You do NOT use the CalendarView - you use the normal IndexedPageItemView if all you want is Master Recurring Calendar items.
You use the CalendarView to expand the recurrences to individual items. However the compromise with CalendarView is NO restrictions are permitted besides Start and End Date. None.
You can search for a RecurrenceMaster by using the recurrence PidLid with an ExtendedPropertyDefinition. This works because, according to their documentation, "this property must not exist on single instance calendar items."
https://msdn.microsoft.com/en-us/library/cc842017.aspx
// https://msdn.microsoft.com/en-us/library/cc842017.aspx
ExtendedPropertyDefinition apptType = new ExtendedPropertyDefinition(
DefaultExtendedPropertySet.Appointment,
0x00008216, //PidLidAppointmentRecur
MapiPropertyType.Binary);
var restriction = new SearchFilter.Exists(apptType);
var iView = new ItemView(10);
var found = folder.FindItems(restriction, iView);
I just confirmed this works, today, when revisiting some old code that works with Office365 EWS in the cloud.
Found only property you need is RecurrenceStart property. Because EWS has limitations it is not possible to use all properties in restriction. This one working as expected.
Reference: Find master recurring appointments
You can create custom searchfilters. If you search from specific startdate OR isRecurring property you have most easy way...(SearchItems returns recurring masters)
List<SearchFilter> searchFilterCollection = new List<SearchFilter>();
SearchFilter.IsGreaterThanOrEqualTo startDatumFilter = new SearchFilter.IsGreaterThanOrEqualTo(AppointmentSchema.Start, new DateTime(2012, 9, 16));
SearchFilter.IsEqualTo masterRecurringFilter = new SearchFilter.IsEqualTo(AppointmentSchema.IsRecurring, true);
searchFilterCollection.Add(startDatumFilter);
searchFilterCollection.Add(masterRecurringFilter);
SearchFilter finalFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.Or, searchFilterCollection);
ItemView itemView = new ItemView(100000);
itemView.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties, AppointmentSchema.AppointmentType);
FindItemsResults<Item> items = _service.FindItems(WellKnownFolderName.Calendar, finalFilter, itemView);

Error when I try to read/update the .Body of a Task via EWS Managed API - "You must load or assign this property before you can read its value."

I am using the Exchange Web Services Managed API to work with Tasks (Exchange 2007 SP1). I can create them fine. However, when I try to do updates, it works for all of the fields except for the .Body field. Whenever I try to access (read/update) that field, it gives the following error:
"You must load or assign this property before you can read its value."
The code I am using looks like this:
//impersonate the person whose tasks you want to read
Me.Impersonate(userName); //home-made function to handle impersonation
//build the search filter
Exchange.SearchFilter.SearchFilterCollection filter = New Exchange.SearchFilter.SearchFilterCollection();
filter.Add(New Exchange.SearchFilter.IsEqualTo(Exchange.TaskSchema.Categories, "Sales"));
//do the search
EWS.Task exTask = esb.FindItems(Exchange.WellKnownFolderName.Tasks, filter, New Exchange.ItemView(Integer.MaxValue));
exTask.Subject = txtSubject.Text; //this works fine
exTask.Body = txtBody.Text; //This one gives the error implying that the object isn't loaded
The strange thing is that, inspecting the property bag shows that the object contains 33 properties, but {Body} is not one of them. That property seems to be inherited from the base class .Item, or something.
So, do I need to re-load the object as type Item? Or reload it via .Bind or something? Keep in mind that I need to do this with thousands of items, so efficiency does matter to me.
Calling the Load method solved my problem :)
foreach (Item item in findResults.Items)
{
item.Load();
string subject = item.Subject;
string mailMessage = item.Body;
}
I had the same problem when using the EWS. My Code is requesting the events(Appointments) from the
Outlook calendar, at the end I couldn't reach to the body of the Event itself.
The missing point in my situation was the following "forgive me if there is any typo errors":
After gathering the Appointments, which are also derived from EWS Item Class, I did the following:
1- Create a List with the type Item:
List<Item> items = new List<Item>();
2- Added all appointments to items list:
if(oAppointmentList.Items.Count > 0) // Prevent the exception
{
foreach( Appointment app in oAppointmentList)
{
items.Add(app);
}
}
3- Used the exchanged service "I have already created and used":
oExchangeService.LoadPropertiesForItems(items, PropertySet.FirstClassProperties);
now if you try to use app.Body.Text, it will return it successfully.
Enjoy Coding and Best Luck
I forgot to mention the resource:
http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/ce1e0527-e2db-490d-817e-83f586fb1b44
He mentioned the use of Linq to save the intermediate step, it will help you avoid using the List items and save some memory!
RockmanX
You can load properties using a custom property set. Some properties are Extended properties instead of FirstClassProperties.
Little example:
_customPropertySet = new PropertySet(BasePropertySet.FirstClassProperties, AppointmentSchema.MyResponseType, AppointmentSchema.IsMeeting, AppointmentSchema.ICalUid);
_customPropertySet.RequestedBodyType = BodyType.Text;
appointment.Load(_customPropertySet);

Resources