NotesCalendarEntry with recurring event - xpages

Hello I need to solve my old question XPages search calendar range datetime
So I have rewrite my code for use NotesCalendar class and now this code return correctly the events (include the recurring/repeat event)
var startDateTime:NotesDateTime = session.createDateTime(new Date(2016,0,1));
var endDateTime:NotesDateTime = session.createDateTime(new Date(2016,1,1));
var cal:NotesCalendar = session.getCalendar(mailDB);
cal.readRange(startDateTime,endDateTime) //work correctly and return VCAL
but I need to read every Calendar Entries for create my JSON object so I have add this code:
var vect:java.util.Vector=cal.getEntries(startDateTime,endDateTime)
for(j=0;j<vect.size();j++){
var cale:NotesCalendarEntry = vect.elementAt(j);
cale.read(); //this return NULL in recurring Event and work in other case
cale.recycle();
}
This is my VCAL generate from cal.readRange(startDateTime,endDateTime)
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
DTSTART:20160131T080000Z
TRANSP:TRANSPARENT
RECURRENCE-ID:20160131T080000Z
DTSTAMP:20160203T084615Z
CLASS:PRIVATE
SUMMARY:test repeat event
UID:134A501D66B80411C1257E520058802B-Lotus_Notes_Generated
X-LOTUS-SUMMARYDATAONLY:TRUE
X-LOTUS-APPTTYPE:4
BEGIN:VALARM
ACTION:DISPLAY
TRIGGER:-PT1H
DESCRIPTION:test repeat event
END:VALARM
END:VEVENT
BEGIN:VEVENT
DTSTART:20160131T090000Z
DTEND:20160131T100000Z
TRANSP:OPAQUE
DTSTAMP:20160203T084615Z
SEQUENCE:0
CLASS:PRIVATE
SUMMARY:private test public appointment
UID:4C5E7D5116C19E7EC1257F4E00301400-Lotus_Notes_Generated
X-LOTUS-SUMMARYDATAONLY:TRUE
X-LOTUS-APPTTYPE:0
END:VEVENT
BEGIN:VEVENT
DTSTART:20160201T070000Z
DTEND:20160201T080000Z
TRANSP:OPAQUE
DTSTAMP:20160203T084615Z
SEQUENCE:0
CLASS:PUBLIC
SUMMARY:public test -appointment
UID:802CB03D0FE29EC7C1257F4C005B9344-Lotus_Notes_Generated
X-LOTUS-SUMMARYDATAONLY:TRUE
X-LOTUS-APPTTYPE:0
END:VEVENT
END:VCALENDAR
If I need to read every recurring events, I think that I need to use the function cale.read("20160131T080000Z") passing the RECURRENCE-ID.
But how can I in NotesCalendarEntry get this parameter my FOR statment?
Thank a lot
P.S. I can use Ical4j Java library I know. is this only solution?

Hello I have solve my problem.
I have found a JavaScript library that convert VCAL into JSON object.
I have convert this JavaScript client library in SSJS code and voila!
Now work perfect and in simple mode!

Related

How to I program a web-browser to perform a series of actions?

EDIT: I'm not looking for Facebook APIs! I'm simply using Facebook as an example. I intend to get my browser to perform actions on different websites that likely have no APIs.
Let's say I wish to create a program that will log into Facebook, lookup my friends list, visit each one of their profiles, extract the date + text of each post and write this to a file.
I have an idea how the algorithm should work. But I have absolutely no clue how to interface my code with the browser itself.
Now I'm a Java programmer, so I would very much imagine the pesudo code in Java would be to create a Browser Object then convert the current page's contents to HTML code so that the data can be parsed. I provided an example code below of what I think it ought to look like.
However is this the right way that I should be doing it? If it is, then where can I find a web browser object? Are there any parsers I can use to 'read' the content? How do I get it to execute javascript such as clicking on a 'Like' button?
Or are there other ways to do it? Is there a GUI version and then I can simply command the program to go to X/Y pixel position and click on something. Or is there a way to write the code directly inside my FireFox and run it from there?
I really have no clue how to go about doing this. Any help would be greatly appreciated! Thanks!
Browser browser = new Browser();
browser.goToUrl("http://facebook.com");
//Retrieve page in HTML format to parse
HtmlPage facebookCom = browser.toHtml();
//Set username & password
TextField username = facebookCom.getTextField("username");
TextField password = facebookCom.getTextField("password");
username.setText("user123");
password.setText("password123");
facebookCom.updateTextField("username", username);
facebookCom.updateTextField("password", password);
//Update HTML contents
browser.setHtml(facebookCom);
// Click the login button and wait for it to load
browser.getButton("login").click();
while (browser.isNotLoaded()) {
continue;
}
// Click the friends button and wait for it to load
browser.getButton("friends").click();
while (browser.isNotLoaded()) {
continue;
}
//Convert the current page (Friends List) into HTML code to parse
HtmlPage facebookFriends = browser.toHtml();
//Retrieve the data for each friend
ArrayList<XMLElement> friendList = facebookFriends.getXmlElementToArray("friend");
for (XMLElement friend : friendList) {
String id = friend.getId();
//Visit the friend's page
browser.goToUrl("http://facebook.com/" + id);
while (browser.isNotLoaded()) {
continue;
}
//Retrieve the data for each post
HtmlPage friendProfile = browser.toHtml();
ArrayList<XMLElement> friendPosts = friendProfile.getXmlElementToArray("post");
BufferedWriter writer = new BufferedWriter(new File("C:/Desktop/facebook/"+id));
//Write the date+text of every post to a text file
for (XMLElement post : friendPosts) {
String date = post.get("date");
String text = post.get("text");
String content = date + "\n" + text;
writer.append(content);
}
}
I think you are thinking about this the wrong way. You wouldn't really want to write a program to scrap the screen via the browser. It looks like you could take advantage of facebooks rest api and query for the data you are looking for. A link to get a users posts via rest api:
https://developers.facebook.com/docs/graph-api/reference/v2.6/user/feed
You could get their users id's from this endpoint:
https://developers.facebook.com/docs/graph-api/reference/friend-list/
Then plug the user ids into the first rest endpoint that was linked. Once you get your data coming back correctly via the rest api its fairly trivial to write that data out to a file.

Emails with event invite generated by MVC application not synced with calendar in outlook.com

I am creating ASP.NET MVC5 application. One functionality is to send emails with event invitations. In Gmail client such generated email works fine. But in outlook.com even if the email has correct buttons - accept/tentative/decline - clicking on them won't sync that into the calendar itself.
I took some inspiration here:
StackOverflow Q1
StackOverflow Q2
StackOverflow Q3
Here is my current implementation:
I am using DDay.ical library for creating the event:
IICalendar iCal = new iCalendar();
iCal.Version = "2.0";
iCal.Method = "REQUEST";
iCal.ProductID = "my#product.com";
Event evt = iCal.Create<Event>();
evt.UID = Guid.NewGuid().ToString();
evt.Class = "PUBLIC";
evt.Created = new iCalDateTime(DateTime.Now);
evt.DTStamp = new iCalDateTime(DateTime.Now);
evt.Start = new iCalDateTime(DateTime.Now.AddHours(2));
evt.End = new iCalDateTime(DateTime.Now.AddHours(4));
evt.Location = "Party room";
evt.Description = "Awesome party";
evt.Summary = "Lets get wasted";
evt.Priority = 5;
evt.Transparency = TransparencyType.Transparent;
string res = new iCalendarSerializer().SerializeToString(iCal);
return res;
I am packing this event into email as an alternative view:
MailMessage email = new MailMessage();
email.To.Add(addressesToJoined);
email.Subject = Party;
email.Body = "";
if (!String.IsNullOrEmpty(calendarEvent))
{
System.Net.Mime.ContentType calendarType = new System.Net.Mime.ContentType("text/calendar");
calendarType.Parameters.Add("method", "REQUEST");
AlternateView ICSview = AlternateView.CreateAlternateViewFromString(calendarEvent, calendarType);
email.AlternateViews.Add(ICSview);
}
And here is the .ics itself:
BEGIN:VCALENDAR
VERSION:2.0
METHOD:REQUEST
PRODID:my#product.com
BEGIN:VEVENT
CLASS:PUBLIC
CREATED:20151115T152442
DESCRIPTION:Awesome party
DTEND:20151115T192442
DTSTAMP:20151115T142442Z
DTSTART:20151115T172442
LOCATION:Party room
PRIORITY:5
SEQUENCE:0
SUMMARY:Lets get wasted
TRANSP:Transparent
UID:1735cdca-cb36-4e6b-a1ec-4fb4149f798a
END:VEVENT
END:VCALENDAR
When this email comes to Gmail client, I can correctly see the invitation with option to add event into calendar, which works fine.
But in outlook.com even when the email itself is correctly recognized as invitation and I can see accept/tentative/decline buttons it does not work as expected. When I click for example accept option, new response email is created and when I send it out, I would expect, the event will be set in my calendar, however there is no event synced.
Can someone please see why events are not synced in calendar in outlook.com?
Also, is there possibility in outlook.com to just set event in calendar, without sending response email? - invitations are auto-generated from system no need for response.
Thanks
Finally I've found a solution - there was missing ORGANIZER parameter of the VEVENT part in .ics. Gmail is able to handle that, Outlook.com not. So the trick was to add following line when setting DDay.iCal.Event object:
evt.Organizer = new Organizer("organizer#mail.com");
Everything else remained untouched so the final look of the .ics which works in both - Gmail and Outlook.com is this:
BEGIN:VCALENDAR
VERSION:2.0
METHOD:REQUEST
PRODID:my#product.com
BEGIN:VEVENT
CLASS:PUBLIC
CREATED:20151115T152442
DESCRIPTION:Awesome party
DTEND:20151115T192442
DTSTAMP:20151115T142442Z
DTSTART:20151115T172442
LOCATION:Party room
ORGANIZER:mailto:organizer#email.com
PRIORITY:5
SEQUENCE:0
SUMMARY:Lets get wasted
TRANSP:Transparent
UID:1735cdca-cb36-4e6b-a1ec-4fb4149f798a
END:VEVENT
END:VCALENDAR
Now it works fine.

Accessing current user information for a netsuite html form using suitescript

I've been trying to figure auto-complete some values from netsuite onto our custom html form.
After a bit of researching, I found this gem: nlapiGetContext (http://www.netsuite.com/portal/developers/resources/APIs/Dynamic%20HTML/SuiteScriptAPI/MS_SuiteScriptAPI_WebWorks.1.1.html)
which should do exactly what it says,
However, when doing a console.log dump of nlapigetcontext()
the following information is displayed, not my current logged in user information
Here is my current test script:
if (window.addEventListener) { // Mozilla, Netscape, Firefox
window.addEventListener('load', WindowLoad, false);
} else if (window.attachEvent) { // IE
window.attachEvent('onload', WindowLoad);
}
function WindowLoad(event) {
alert(nlapiGetContext().getCompany());
console.log(nlapiGetContext());
}
Any help or guidance is appreciated!
Thank you!
Where is this form located? Context will only work if you are logged into the system, so this won't apply for online customer forms, those are considered to be "outside the system".
You can write a Suitelet to retrieve data from an external form if you are only retrieving values.
I use this to get campaign information on an external landing page.
function getCamData(request, response){
if ( request.getMethod() == 'GET' ){
response.setHeader('Custom-Header-CamID', 'CamID');
var camid = request.getParameter('camid');
var rec = nlapiLoadRecord('campaign', camid);
var o = new Object();
o.thisid = camid;
o.promocode = rec.getFieldValue('campaignid');
o.phone = rec.getFieldValue('custevent_cam_1300num');
o.family = rec.getFieldValue('family');
var myString = JSON.stringify(o);
response.write (myString);
}}
You request something like this:
https://forms.netsuite.com/app/site/hosting/scriptlet.nl?script=188&deploy=1&compid=xxxxxx&h=fb8224b74b24907a79e6&camid=8020
And returns something like this:
{"thisid":"8020","promocode":"CAM999","phone":"1800 111 222","family":"12"}
Also you can do server-side posting from an external site to a NetSuite customer online form, it will capture and validate the data as far as it has the entry fields set in NS, this is a great way to avoid using those horrible iframes.
Use these functions
nlapiGetContext().getName()
nlapiGetContext().getUser()
nlapiGetContext().getRole()
nlapiGetContext().getRoleId()
nlapiGetContext().getRoleCenter()
nlapiGetContext().getEmail()
nlapiGetContext().getContact()
nlapiGetContext().getCompany()
nlapiGetContext().getContact()
nlapiGetUser()
nlapiGetDepartment()
For details check http://suitecoder.appspot.com/static/api.html

Background task in C#

public JsonResult GetScore(int StudentID = 0)
{
//fetch the score for the user
//--Call sendReport
//return the score to the calling method
}
public void SendReport(int StudentID = 0)
{
//Logic to get the detaied marks and prepare the report's PDF
//Mail the generated PDF back to student
}
In my web application, while Student clicks for score student will get his/her score on screen and will get detailed report's PDF mailed to his/her registered mail.
Now problem is I would like to run SendReport in background, so student will come to know his/her score immediately without waiting.
I've gone through this question but it gives me error of invalid argument.
public JsonResult GetScore(int StudentID)
{
//fetch the score for the user
Task.Factory.StartNew(() => SendReport(StudentID));
//return the score
}
you could just call it in a new thread
new Thread(SendReport(StudentID)).Start();
If you're looking for a quick and dirty solution to this problem, it's to make your controller look like this:
public JsonResult GetScore(int StudentID = 0)
{
//fetch the score for the user
//return the score to the calling method
}
public JsonResult SendReport(int StudentID = 0)
{
//Logic to get the detaied marks and prepare the report's PDF
//Mail the generated PDF back to student
//Return a JsonResult indicating success
}
... and then make two JQuery calls to your controller. One to get the score and one to kick off the report. You can display the score as soon as you get it, and the report will still be chugging in the background.
Bear in mind, if the report takes longer than a few seconds to generate and email, you really should consider moving that execution to a service that you simply activate via MVC, since running it in a controller method ties up web server resources until it's finished.
See the new MVC async documentation for details on doing this.

Appointment Send and Send Update

How can I know if for any appointment "Send" was clicked or " Send Update" or "Send Cancellation" was clicked.I have Application_ItemSend event which fires for both Send,Send Update and Send Cancellation. One way would be add a custom property and set some value when the appointment is initially created. But I don't seem to find a way to differentiate the button click. Is adding custom property the only way or is there any built in property which I can use. Appointment item I am assigning as below.
var appointment = Globals.MedearcOutlook2010AddIn.Application.ActiveInspector().CurrentItem as Outlook.AppointmentItem;
Thanks
You can check the MAPI property PR_MESSAGE_DELIVERY_TIME to see whether the appointment has been sent yet (isUpdate=false) or it is an update to an existing appointment (isUpdate=true). I didn't see a native property member for doing this.
string PR_MESSAGE_DELIVERY_TIME = "http://schemas.microsoft.com/mapi/proptag/0x0E060040";
bool isUpdate = false;
try
{
DateTime message_delivery = appointment.PropertyAccessor.GetProperty(PR_MESSAGE_DELIVERY_TIME);
isUpdate = true; // if it makes it here then the message has been delivered
}
catch { }

Resources