How to send email notification to users few days before expiry date in alfresco - windows-10

I want to send email notification to users say 'X' days prior to their document expiry date. How can it be achieved on alfresco 5.2 community and windows platform?

You can create scheduled job which will run at specific time.
https://docs.alfresco.com/content-services/5.2/develop/repo-ext-points/scheduled-jobs/
Within job write logic to get document which is going to expire within some time.
Ex.
DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
SearchService searchService = serviceRegistry.getSearchService();
SearchParameters searchParameters = new SearchParameters();
searchParameters.setLanguage(SearchService.LANGUAGE_LUCENE);
searchParameters.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
LocalDateTime now = LocalDateTime.now().plusMonths(1);
String date= now.format(DATE_FORMATTER);
String query=""
searchParameters.setQuery(query);
ResultSet rs = searchService.query(searchParameters);
This will find document which is going to expire in next 1 month.

Related

How to get Tweet from date x to date y

def search_for_a_tweet(bearer_token, query,D1,D2):
url = "https://api.twitter.com/1.1/statuses/user_timeline.json"
formed_url ='?screen_name='+query+'&count=300&fromDate=D1&toDate=D2'
search_results = search_for_a_tweet(bearer_token,'TOIIndiaNews','201808060000','201808070000')
Here I get only current date tweet.
Help me for this.
You should use the search API instead : https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets.html
To get tweets from a specific user within a period, the q parameter will be for example :
q=from:user since:2018-08-15 until:2018-08-18
(urlencode the query before to send it).
But with public API you will get only last 7 days.
So you can perform the query on the official Twitter web site :
https://twitter.com/search?f=tweets&vertical=default&q=from%3Arealdonaldtrump%20since%3A2018-08-15%20until%3A2018-08-17

Stripe cancel subscription at specific date

I'm using StripeAPI in PHP and I don't know how can I stop a customer subscription at a specific date.
I know there is an option for cancel subscription immediatly :
$subscription = \Stripe\Subscription::retrieve('sub_49ty4767H20z6a');
$subscription->cancel();
Or for cancel subscription at the end of the current billing period (for the duration of time the customer has already paid for) with :
$subscription->cancel(['at_period_end' => true]);
With this option, the cancellation is scheduled.
But how can I cancel a subscription at a specific date? In my system, a user can ask for a cancellation but he has to wait for a specific date (something like at least stay X months as a subscriber)
Do you know how can I do that? Thanks!
Stripe just added this to their API and I happened to stumble upon it. They have a field called "cancel_at" that can be set to a date in the future. They don't have this attribute listed in their documentation since it is so new. You can see the value in the response object here:
https://stripe.com/docs/api/subscriptions/create?lang=php
I've tested this using .NET and can confirm it sets the subscription to expire at value you provide.
Ah, yes. Good question. Here's a check/execute example:
$today = time();
$customer = \Stripe\Customer::retrieve('Their Customer ID');
$signUpDate = $customer->subscriptions->data[0]->created;
// This will define the date where you wish to cancel them on.
// The example here is 30 days from which they initially subscribed.
$cancelOnDate = strtotime('+30 day', $signUpDate);
// If today is passed or equal to the date you defined above, cancel them.
if ($today >= $cancelOnDate) {
$subscription = \Stripe\Subscription::retrieve('sub_49ty4767H20z6a');
$subscription->cancel();
}
Here's an example of setting cancellation upon them subscribing:
$today = time();
// Cancel them 30 days from today
$cancelAt = strtotime('+30 day', $today);
$subscription = \Stripe\Subscription::create(array(
"customer" => 'Their Customer ID',
"plan" => 'xxxxxxxxx',
"cancel_at" => $cancelAt
));
Maybe a little bit late, but I had the same problem and checked your post for help. We want to offer a season pass for the users, so if they cancel the subscription the payment will end at the end of the season, for example every year in June.
After a lot of research I have found a solution in the laravel docs, that might help. For my solution it was not cancel_at but cancelAt. Not much difference, but helped me a lot :)
$subscription = $user->subscription('default')->cancelAt(
Carbon::create(2021,6,30)
);
Best,
Timo

Is there any way I can ask queries to Notes Database

I am working on fetching meetings given two dates: e.g. fetch all the meetings that are in the current month.
Suppose that I have around 45 meetings in the specified period. My web service is taking a lot of time.
This is how I'm doing it right now:
I fetch all the documents in the calendar view.
Check all the documents for the start Date and end date.
If any of the meetings fall in the specified period i am constructing an array and i am returning that array.
Is this correct?
This way is correct, but very inefficient. Better use the NotesDatabase- Class and create a Query to use with the search- method:
Here an example in LotusScript (as you do not specify a language)
Dim ses as New NotesSession
Dim db as NotesDatabase
Dim dc as NotesDocumentCollection
Dim strQuery as String
Set db = ses.CurrentDatabase
strQuery = {Form = "Appointment" & _
(StartDate >= [01.01.2014] & StartDate < [01.02.2014]) | _
(EndDate >= [01.01.2014] & EndDate < [01.02.2014])}
Set dc = db.Search( strQuery , Nothing, 0 )
'- Cycle through this collection...
Of course you need to dynamically adjust the strQuery by building it from todays date... But this will be much more performant than your version.
It is correct, but not very performant when you have a lot of documents. Basically you will create a view with first column the meeting (start)date, sorted. In LotusScript you can acces the view, set the "cursor" of the first meeting that matches the starting date and then step thru the view until you reach a date after the end date.
Read about view´s GetDocumentByKey method. Further here: http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=%2Fcom.ibm.designer.domino.main.doc%2FH_LOCATING_DOCUMENTS_WITHIN_A_VIEW_OR_FOLDER.html
Hmmm ... thinking a litlle further, what happens if you have a start date but no matching meeting ... so refer to FTSearch() method.
If you are using Notes / Domino 9.0 or later, you should use the built-in calendar classes. These are available either from LotusScript or Java. Here's an example using Java. Given a database object and a date range, it prints all the entries in the range:
private static void printRange(Database database, DateTime start, DateTime end) throws NotesException {
// Get the calendar object from the database
NotesCalendar calendar = database.getParent().getCalendar(database);
if ( calendar != null ) {
// Get a list of calendar entries
Vector<NotesCalendarEntry> entries = calendar.getEntries(start, end);
if ( entries != null ) {
// For each entry ...
Iterator<NotesCalendarEntry> iterator = entries.iterator();
while (iterator.hasNext()) {
NotesCalendarEntry entry = iterator.next();
// Read the iCalendar representation
String icalendar = entry.read();
// Get the Notes UNID
Document doc = entry.getAsDocument();
String unid = doc.getUniversalID();
// Print UNID and iCalendar to console
System.out.println("Entry UNID: " + unid);
System.out.println(icalendar);
}
}
}
}
The NotesCalendar and NotesCalendarEntry interfaces are in the lotus.domino package. If you are using LotusScript, there are classes of the same name and with the same methods.
A couple of warnings about the above code:
It doesn't handle the nuances of repeating entries. You can have multiple instances of a repeating entry in the same time range. In Notes these entries might have the same UNID. You should test your code with repeating entries to make sure you understand the nuances.
The example doesn't recycle the Document, NotesCalendarEntry and NotesCalendar objects as it should. I skipped this for simplicity, but if you are using the Notes Java classes, you definitely need to use recycle() correctly. It will save headaches down the road.

QueryScheduleRequest not working in Microsoft CRM 2011

I basically want to check if a particular user is free in a provided time range using QueryScheduleRequest. For this I am using the following piece of code to retrieve available timings of the user on today's date:
QueryScheduleRequest scheduleRequest = new QueryScheduleRequest
{
ResourceId = userResponse.UserId,
Start = DateTime.Today,
End = DateTime.Today,
TimeCodes = new TimeCode[] { TimeCode.Available}
};
QueryScheduleResponse scheduleResponse = (QueryScheduleResponse)serviceProxy.Execute(scheduleRequest);
However, I am not getting proper response in scheduleResponse as seen in CRM service calendar. The start and end dates are also getting changed in the response. For eg, say I enter Start and End date as 12th in scheduleRequest but in scheduleResponse they get changed to 12th and 13th respectively. I have checked that I am referring the correct user.
This is how the user's schedule looks like in CRM (Work Hours:10am to 7pm):
And this is how the result in scheduleResponse looks like:
Observe the dates and schedule getting changed. Is there any other way in which I can achieve this functionality?
Basically Dynamics CRM stores all dates in the database as UTC time.Crm Users has to convert into Users LocalTime.
After getting scheduleResponse. You can Use the below Code to get User Start time and End Time.
QueryScheduleResponse scheduleResponse = (QueryScheduleResponse)service.Execute(scheduleRequest);
foreach (var getTimings in scheduleResponse.TimeInfos)
{
DateTime startTime =Convert.ToDateTime(getTimings.Start.Value.ToLocalTime());
DateTime endTime = Convert.ToDateTime(getTimings.Start.Value.ToLocalTime());
}
Note:we have ExpandCalendarRequest Class also to Retrieve User Available Timings

List all occurrences of outlook recurring appointments

MS Outlook provides MAPI to access outlook calendar items. With calendar items it can find all recurring and non-recurring appointments of outlook. In case of recurring appointments all occurrences of recurring appointments can be found using GetOccurence function of RecurrencePattern of AppointmentItem. GetOccurence function will take the date and time to return the occurrence on that date. If occurence exists, it will return otherwise it will give exception.
If all the occurences of a recurring appointment have same StartTime and EndTime then providing starttime input to GetOccurence, works perfectly fine. But if one particular occurence StartTime and EndTime is modified then GetOccurence will not return that occurrence. The other way could be to check occurence for every 30 minute interval on the every day. But this approach seems not to be an efficient.
Anyone have better idea to do this?
_ApplicationPtr olApp("Outlook.Application");
_NameSpacePtr olMAPI;
olMAPI = olApp->GetNamespace("MAPI");
hr = olMAPI->Logon("","",false,false);
MAPIFolderPtr olCalendarFolder = olMAPI->GetDefaultFolder(olFolderCalendar);
_ItemsPtr olCalendarItems = olCalendarFolder->GetItems();
_AppointmentItemPtr olAppt = (_AppointmentItemPtr) olCalendarItems->GetFirst();
RecurrencePatternPtr recurPattern = olAppt->GetRecurrencePattern();
_AppointmentItemPtr _olAppt = recurPattern->GetOccurrence(recurPattern->GetPatternStartDate()+recurPattern->GetStartTime());
Sure, use the RecurrencePattern.Exceptions collection - see http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.exceptions.aspx

Resources