Is there a way to get only the files out of a directory which are younger than a specific age?
So this method will produce this result, but it will get all files first and then disregard those who dont fit, which is quite inefficient.
Dim Files = dir.GetFiles().Where(Function(x) x.LastWriteTime >= ts) 'dir: DirectoryInfo, ts: DateTime
Related
Looking at this answer, it is shown how to include EXDATE in the string format option in FullCalendar.
But FullCalendar provides a convenient alternative to the long string. They allow you to use an object instead. Unfortunately their documentation doesn't really cover anything beyond that:
The rrule property accepts whatever the rrule lib accepts for a new
RRule. See the docs. You can specify a string or an object.
The events we use are pretty heavy already and I would love to avoid adding additional complexity that would involve me writing some kind of mapper to generate this string.
I would like to know how to be able to exclude a list a of dates from a recurrence rule using the object format.
I've tried providing a date object of the specific date. I've tried providing an ISO string. I've tried including them in an array.
Update
This is the latest iteration that I'm trying:
...
const rruleSet = new RRuleSet();
rruleSet.rrule(new RRule(options));
// Repeat every day except on Nov 22, 2019
rruleSet.exdate(new Date(Date.UTC(2019, 10, 22)));
event.duration = {
seconds: event.event_length,
};
event.rrule = rruleSet.toString();
...
This renders the recurring dates (time is a little off) but the date that I'm trying to exclude still renders.
In order for your exclusion rule to match the generated event, you must include the specific time as well. I expect this is because if you had events repeating multiple times in the day it wouldn't know which one you were trying to exclude.
(If your events were "all-day" style events, without a specific start time, then setting just the date in exdate would be ok.)
Therefore, changing
rruleSet.exdate(new Date(Date.UTC(2019, 10, 22)));
to
rruleSet.exdate(new Date(Date.UTC(2019, 10, 22, 10, 30)));
will solve your problem
Demo: https://codepen.io/ADyson82/pen/jOORaOZ
Hey community,
Since a few days I'm stuck while trying to get the date of a .jpg or .png image file, when the picture was taken.
I believe it was called DateTimeOriginal.
What I'm trying to do, is getting just this one specific info, DateTimeOriginal, not more, not less.
This is part of a selfmade project, a program to sort pictures by the date when they were taken.
I'm programming with VB, and for the exif data I'm calling a batch file.
So i know how to use the exiftool. It's common use is:
exiftool file.jpg
But I need something like:
exiftool -DateTimeOriginal file.jpg >> DateTaken.txt
I have tried this one, but I'm not getting the Date, I only got a list of any jpg found in the directory, but without metadata.
I was searching so long for any option like this, but I can't find anything useful. Perhaps there is another, more efficient way to get metadata of an image, only using VB.
Has anyone an advise or other idea?
Thanks
You have the correct command to get the DateTimeOriginal tag from a file (exiftool -DateTimeOriginal file.jpg). But you say you are getting a list of filenames in a directory, which sounds like you're passing a directory name, not a file name. If you wish to get DateTimeOriginal for only those files in a directory that have a value in the tag, use exiftool -if "$DateTimeOriginal" -DateTimeOriginal C:/path/to/dir. Any file that doesn't have a DateTimeOriginal will not be listed then.
One thing to note is that the windows "Date Taken" property will be filled by a variety of metadata tags depending upon the filetype. For example, in PNG files, Windows will use PNG:CreationTime. In jpg files, Windows will use, in order, EXIF:DateTimeOriginal, IPTC:DateCreated + IPTC:TimeCreated, XMP:CreateDate, EXIF:CreateDate, and then XMP:DateTimeOriginal tags.
After a bit of digging, I found that you can get a list of properties if a bitmap.
Unfortunately the property IDs are numeric and rather cryptic.
Have a look here to find out more
After a bit more digging, it seems that the propertyId &h132 (a hexadecimal number) is the date stored as an array of integers in ascii encoding. This function finds propertyid &h132 and returns the date info as a string in year:month:date hour:minute:second format.
You might get variations with localization.. for example using /,: or - for the date separators etc, so, to parse it as a date type, you might need to work around that.
Public Function GetImageTakenDate(theimage As Bitmap) As String
Dim propItems As List(Of PropertyItem) = theimage.PropertyItems.ToList
Dim dt As PropertyItem = propItems.Find(Function(x) x.Id = &H132)
Dim datestring As String = ""
For Each ch As Integer In dt.Value
datestring += Chr(ch)
Next
datestring = datestring.Remove(datestring.Length - 1)
Return datestring
End Function
I'm just looking to be able to sort the results of a BatchedJoinBlock (http://msdn.microsoft.com/en-us/library/hh194683.aspx) so that the different results of the different targets stay together. I will explain! Example in some pseudo-code:
Dim batchedJoin = New BatchedJoinBlock(Of String, object)(4)
batchedJoin.Target1.Post("String1Target1")
batchedJoin.Target2.Post(CType(BuildIt, StringBuilder1))
batchedJoin.Target1.Post("String1Target2")
batchedJoin.Target2.Post(CType(BuildIt, StringBuilder2))
Dim results = batchedJoin.Receive()
'This sorts one result...
Dim SortByResult = results.Item1.OrderBy(Function(item) item.ToString, New NaturalStringComparer)
Basically I've got a string and an object, the SortByResult variable above sorts the strings exactly as I'd like them to sort. I'm looking for a way to get the objects that used to be at the same index number in target2 into the same order. e.g. if "String1Target1" changes order I'd like to somehow reliably refer to/pair it together with "StringBuilder1". The actual end result just needs to be that the objects (target2) are sorted in the order that is dictated by the strings being sorted (target1). Something like:
Dim EndResult = results.Item2.OrderBy(strings in target1)
but I'll gladly take an intermediate solution! I've also tried using a dictionary (results.Item2.ToDictionary) with the string as a key (which would also be a fine solution) but it's a bit beyond my ken using lamba expressions in the proper context. I can realistically do this in several steps with a list or something, but I'm trying to get something more efficient/learn something, and it seems like there's a lot of default options with the results of the jointblock that I'm just not experienced enough to use. Thanks in advance for any help you can provide!
To me, it looks like you don't actually want BatchedJoinBlock, because the two pieces of data always come together. A better option for that would be a BatchBlock of Tuple<string, object>. When you have that, you can then use LINQ directly to sort each batch:
results.OrderBy(Function(tuple) tuple.Item1)
Does anyone know of a method that allows you to search a string through a text file using StreamReader that allows you to account for multiple instances of finding the results. Basically I am creating a booking application and each time a customer books a seat, their PrimaryKey, FirstName, LastName and the co-ordinates of the seat on a data grid (which I have used as a method to book seats) are generated then saved to a text file.
I want the ability to be able to read multiple instances of a PrimaryKey then find the seat co-ordinates of each line that this PrimaryKey is listed on and repopulate another similar datagridview with these co-ordinates which is all going to be driven by a combobox index change.
It seems a bit complicated to understand but if anyone can help then please let me know.
I just need the knowhow of how to search multiple instances, so after its found the string once then look through the rest of the file to find another instance, I can do the rest by myself.
I'm coding using Visual Basic.Net
Yes it's possible to search multiple times through a file, but you'd either have to reopen the file, or rewind the stream (FileStream.Seek).
Wildly inefficient though.
If it has to remain an unsorted and unstructured file, build an in memory index to it.
If your key is an integer, create a Dictionary<int,int> of Key and Position in the stream.
Then when you want find key X you use FileStream.Seek to move to it, and read a line to get the data. If you find yourself grouping by say aeroplaneID, build a Dictionary<Int, List<Int,Int>>
where the key is the aeroplane id and the list is a list of primary keys and positions in the file.
You could push all that off to a background thread. You could try and get really clever and build them up as you need them. Personally though I'd be trying to move my storage to a more suitable format. You aren't struggling to do this because you've missed a class, you are struggling because you shouldn't.
Something like
Dictionary<int, int> _fileIndex = new Dictionary<int,int>();
using(FileStream fs = new FileStream(DataFileName,FileMode.Open,FileAccess.Read))
{
StreamReader reader = new StreamReader(fs);
int lastPosition = 0;
string currentLine = null;
while(currentLine = reader.ReadLine() != null)
{
String[] data = currentLine.Split(new char[] {','});
int key = int.Parse(data[0]);
fileIndex.Add(key,lastPosition);
lastPosition = fs.Position;
}
}
NB didn't test the above and there should be a bit more error checking in it. If there's alot of data in the line, then might be better off not suing split and just pulling out everything up to the correct delimiter. Also be careful how many indexes you keep live, wouldn't be long before they used up more space than just reading the entire thing in to memory.
Then you could create a class or structure to implement a line in the file, and write a bit of code
to use FileStream.Seek) to get there. If you wanted to load up a bunch of 'em it would make sense to get your list of positions of each one in the file and then sort them in order, then you could rip through the file in it's 'order' picking them out.
How do I get the work and absence days of an employee with VBA from MS-Project? (an employee is a ressource)
Some additional infos:
I know how to get tasks
Dim ts as Tasks
Set ts = ActiveProject.Tasks
and I know how to get ressources from my project file:
Dim rs as Resources
Set rs = ActiveProject.ressources
but I do not find a (trivial) way to get work and absence days from this variables.
You need to look at the Resource object to find the working and non-working days:
ActiveProject.Resources.Item(1).Calendar
In this trivial example we're picking up the first resource in the project and pulling out it's associated Calendar.
A resource calendar will have a base calendar from which it inherits:
...Calendar.BaseCalendar
and both the resource calendar and the base calendar define working days, working weeks and exceptions. Exceptions are typically how periods of absence are defined... i.e. they are exceptions to the normal pattern of work:
...Calendar.WorkWeeks
...Calendar.WeekDays
...Calendar.Exceptions
The answer already provided information to get one started, but does not actually answer the question. As stated, "Exceptions" are indeed how periods of absence are defined but to determine if a given date is an absence day from the exception object will take a not-insignificant amout of parsing code.
It would be a lot simpler and much more reliable to determine workdays empirically. Assuming variable "cal" is the calendar in question declare a variable (say "d") of type long then loop from some start date to some end date-1 and determine if that date is a workday or not using Application.datedifference (d, d+1, cal). A non work day will yield 0.