
Quote from CN_Iceman on September 17, 2021, 7:17 pmHi to all.
Some time ago I made a program that allowed you to download a publication in PDF.
The user selects the day of the month and the year and the program downloads the file and displays it.
The path to the file originally looked something like this:
http://miserver.es/intranet/2021/02/PUB_20210201.pdfMy download link looked like this:
http://miserver.es/intranet/[YY]/[MM]/PUB_[YY][MM][DD].pdfObviously [YY] is the year, [MM] the month and [DD] is the day. Everything worked perfectly.
Now the link has changed and they have complicated my life because it includes a new parameter, "the number". (Later I will explain what that "the number" is.):
http://miserver.es/intranet/2021/02/PUB_20210201_20.pdfMy new link would now be something like this:
http://miserver.es/intranet/[YY]/[MM]/PUB_[YY][MM][DD]_[The_Number].pdfOk, so far the easy part. Let us now go to the real problem that I have not been able to solve. I am totally blocked.
There are some conditions:
- These PDF files were previously on paper and don't count. Only those that are in digital format (in PDF) and can be downloaded count.
- The first 5 PDF files were created in 2000, on these dates:
- January 11, 2000 (The Number 6)
- February 03, 2000 (The Number 23)
- March 21, 2000 (The Number 56)
- April 19, 2000 (The Number 77)
- June 01, 2000 (The Number 106)
- The files are only generated from Monday to Friday, which means that on Saturday and Sunday there are no PDF files to download.
- There is a group of holidays that there is no PDF file available either. The holidays where there is no PDF file are these:
- January 1st
- April 13th
- July 16th
- August 15th
- October 12nd
- November 1st
- December 06
- December 08
- December 25
- "The Number" is the day of the year without counting Saturdays, Sundays and holidays.
In my program the user has two options to download the PDF file. Either download today's PDF file or select the download day from a calendar.
The problem I have now is how to make the program obtain that "The Number" with the conditions that I have previously set above.
I have read this post several times and I think it is understood and I have explained the problem well.
Can anyone help me? Thanks in advance.
Greetings.
Hi to all.
Some time ago I made a program that allowed you to download a publication in PDF.
The user selects the day of the month and the year and the program downloads the file and displays it.
The path to the file originally looked something like this:
http://miserver.es/intranet/2021/02/PUB_20210201.pdf
My download link looked like this:
http://miserver.es/intranet/[YY]/[MM]/PUB_[YY][MM][DD].pdf
Obviously [YY] is the year, [MM] the month and [DD] is the day. Everything worked perfectly.
Now the link has changed and they have complicated my life because it includes a new parameter, "the number". (Later I will explain what that "the number" is.):
http://miserver.es/intranet/2021/02/PUB_20210201_20.pdf
My new link would now be something like this:
http://miserver.es/intranet/[YY]/[MM]/PUB_[YY][MM][DD]_[The_Number].pdf
Ok, so far the easy part. Let us now go to the real problem that I have not been able to solve. I am totally blocked.
There are some conditions:
In my program the user has two options to download the PDF file. Either download today's PDF file or select the download day from a calendar.
The problem I have now is how to make the program obtain that "The Number" with the conditions that I have previously set above.
I have read this post several times and I think it is understood and I have explained the problem well.
Can anyone help me? Thanks in advance.
Greetings.

Quote from Vadim on September 20, 2021, 8:07 pm@cn_iceman
Try the asDateTime plugin (Andrei Solodyankin)
https://visualneo.com/product/asdatetime
Try the asDateTime plugin (Andrei Solodyankin)
Quote from Gaev on September 21, 2021, 3:13 pm@cn_iceman
I have read this post several times and I think it is understood and I have explained the problem well.
Can anyone help me? Thanks in advance.You explained the requirement very well; however, in order to suggest an optimal design solution, can you tell us ...
1) how many files are involved; if there are files from the year 2000, are we talking of approximately 5,250 files ? (21 years times 250)
2) is there a different set of holidays for each year ?
3) when a user picks a date that has no related file, do you just respond with a "File Not Found" error ?
4) how much control do you have over writing additional data (files) on the server ?
5) are you able to download a list of the available files ?
I have read this post several times and I think it is understood and I have explained the problem well.
Can anyone help me? Thanks in advance.
You explained the requirement very well; however, in order to suggest an optimal design solution, can you tell us ...
1) how many files are involved; if there are files from the year 2000, are we talking of approximately 5,250 files ? (21 years times 250)
2) is there a different set of holidays for each year ?
3) when a user picks a date that has no related file, do you just respond with a "File Not Found" error ?
4) how much control do you have over writing additional data (files) on the server ?
5) are you able to download a list of the available files ?

Quote from CN_Iceman on September 21, 2021, 5:52 pmQuote from Vadim on September 20, 2021, 8:07 pm@cn_iceman
Try the asDateTime plugin (Andrei Solodyankin)
https://visualneo.com/product/asdatetimeThanks @vadim, I'll check that plugin.Quote from Gaev on September 21, 2021, 3:13 pm
You explained the requirement very well; however, in order to suggest an optimal design solution, can you tell us ...
1) how many files are involved; if there are files from the year 2000, are we talking of approximately 5,250 files ? (21 years times 250)
2) is there a different set of holidays for each year ?
3) when a user picks a date that has no related file, do you just respond with a "File Not Found" error ?
4) how much control do you have over writing additional data (files) on the server ?
5) are you able to download a list of the available files ?
- That's right. The document is a daily newsletter. Formerly it was only on paper, but since 2000 it is digital. The idea is that the user can consult the document of the selected day. All files are hosted on a server and a new one is added every day.
- No, the holidays are the same every year.
- If the user selects a day that there is no PDF file (for example a weekend or a holiday), a message is displayed informing that there is no PDF file that day.
- Zero. It is impossible to write on the server. I can only download the PDF files.
- No I can not.
Thank's for the help @gaev
Quote from Vadim on September 20, 2021, 8:07 pmTry the asDateTime plugin (Andrei Solodyankin)
https://visualneo.com/product/asdatetime
Quote from Gaev on September 21, 2021, 3:13 pm
You explained the requirement very well; however, in order to suggest an optimal design solution, can you tell us ...
1) how many files are involved; if there are files from the year 2000, are we talking of approximately 5,250 files ? (21 years times 250)
2) is there a different set of holidays for each year ?
3) when a user picks a date that has no related file, do you just respond with a "File Not Found" error ?
4) how much control do you have over writing additional data (files) on the server ?
5) are you able to download a list of the available files ?
Thank's for the help @gaev

Quote from CN_Iceman on September 21, 2021, 6:10 pm@vadim
I've seen almost all Andrei Solodyankin plugins, but I think I missed this one (asDateTime) that you told me about.
I have been testing it and I think it can be adapted to my needs. Anyway, I still don't know how to include the day number ...
Greetings.
I've seen almost all Andrei Solodyankin plugins, but I think I missed this one (asDateTime) that you told me about.
I have been testing it and I think it can be adapted to my needs. Anyway, I still don't know how to include the day number ...
Greetings.
Quote from Gaev on September 21, 2021, 7:05 pm@cn_iceman
Thank you for the clear answers.
I think it would be too onerous to try and write logic (scripts) to calculate a sequence number associated with a date.
It might be simpler if you had a reference file that identified these numbers for each day e.g. ...
20210921_5034
20210922_5035
etc.... in order to avoid having one big file, you could have one for every month e.g. ...
References202108.txt
References202109.txt
etc.Then, your script could ...
- obtain the year and month from the selected date
- read the appropriate reference file
- search it for the matching dateThe reference file could also be an Access database (mdb).
You could also choose to store just the references corresponding to the first day of the month, and then calculate the reference for the N th day of that month ... less any holidays in that month.
Thank you for the clear answers.
I think it would be too onerous to try and write logic (scripts) to calculate a sequence number associated with a date.
It might be simpler if you had a reference file that identified these numbers for each day e.g. ...
20210921_5034
20210922_5035
etc.
... in order to avoid having one big file, you could have one for every month e.g. ...
References202108.txt
References202109.txt
etc.
Then, your script could ...
- obtain the year and month from the selected date
- read the appropriate reference file
- search it for the matching date
The reference file could also be an Access database (mdb).
You could also choose to store just the references corresponding to the first day of the month, and then calculate the reference for the N th day of that month ... less any holidays in that month.

Quote from CN_Iceman on September 21, 2021, 7:22 pmThanks @gaev for the ideas. I think I understand the approach you want to give to the problem.
I'm going to study it and I'll tell you something.Greetings.
Thanks @gaev for the ideas. I think I understand the approach you want to give to the problem.
I'm going to study it and I'll tell you something.
Greetings.

Quote from Vadim on September 21, 2021, 8:42 pm@cn_iceman
@gaev is right, there are different ways to solve the problem. I offer one of the options (attached). In the demo example there is a button that creates the desired text file, in which the number you are looking for is the line number. The file creates dates before January 1, 2030 (you can change that). Only my numbers differ by one (apparently I did not fully understand the condition, but you can correct the code). Then you don't need to create this text file, you can just use it. To get the number of the day you need to enter the desired date in the input field (eg 21.09.2021) and click "Get number...". I use a ListBox object to quickly find the number. In the "Result" field will be the number you are looking for.
@gaev is right, there are different ways to solve the problem. I offer one of the options (attached). In the demo example there is a button that creates the desired text file, in which the number you are looking for is the line number. The file creates dates before January 1, 2030 (you can change that). Only my numbers differ by one (apparently I did not fully understand the condition, but you can correct the code). Then you don't need to create this text file, you can just use it. To get the number of the day you need to enter the desired date in the input field (eg 21.09.2021) and click "Get number...". I use a ListBox object to quickly find the number. In the "Result" field will be the number you are looking for.
Uploaded files:

Quote from CN_Iceman on September 21, 2021, 9:02 pmOh! Thank you very much @gaev for the example.
At first the program did not work correctly due to a syntax problem. I guess because of the language or the localization. I have changed the (.) by (/) on dates and now it works. That is resolved.
I have seen how you have tried to solve the problem, but it is not what I need, although I think that by modifying some lines I will be able to adapt it to what I really need.
I think I did not explain that the counter of the number of the day is reset with each year.
I am making a spreadsheet to see it more clearly and with the help of your example code I think I can get something out.
Again thank you very much for the help.
Oh! Thank you very much @gaev for the example.
At first the program did not work correctly due to a syntax problem. I guess because of the language or the localization. I have changed the (.) by (/) on dates and now it works. That is resolved.
I have seen how you have tried to solve the problem, but it is not what I need, although I think that by modifying some lines I will be able to adapt it to what I really need.
I think I did not explain that the counter of the number of the day is reset with each year.
I am making a spreadsheet to see it more clearly and with the help of your example code I think I can get something out.
Again thank you very much for the help.
Quote from Gaev on September 21, 2021, 9:08 pm@cn_iceman
Oh! Thank you very much gaev for the example.
LOL, I think it was Vadim whose example you are referring to.
Oh! Thank you very much gaev for the example.
LOL, I think it was Vadim whose example you are referring to.

Quote from CN_Iceman on September 21, 2021, 9:21 pmQuote from Gaev on September 21, 2021, 9:08 pmLOL, I think it was Vadim whose example you are referring to.
Oh...it is true!!
@vadim I'm sorry for the mistake.
Thank you very much for the example...Now the bad news.
While I have been making the spreadsheet, I have found errors in the PDF file names.
It seems that those names are put by someone manually rather than automatically.
The problem is that that way a new variable comes into play that is unpredictable.
I have been putting the initial number of each month and calculating the remaining numbers. When I saw that they did not match me, I tried to download the files of a month one by one and I found the fault.
For example: on March 11, 2020 the number is 49, on the 12th it should be 50 and it appears 51. On the 13th it appears as 53 when it should be 51... a disaster.
It has occurred to me that my program tries to try to download the file trying with several numbers forwards and several backwards, I don't know if I explain myself ... I would try to download:
20200311_48.pdf
20200311_49.pdf
20200311_50.pdf
20200311_51.pdf
20200311_52.pdfIt's the only thing I can think of right now.
Quote from Gaev on September 21, 2021, 9:08 pmLOL, I think it was Vadim whose example you are referring to.
Oh...it is true!!
@vadim I'm sorry for the mistake.
Thank you very much for the example...
Now the bad news.
While I have been making the spreadsheet, I have found errors in the PDF file names.
It seems that those names are put by someone manually rather than automatically.
The problem is that that way a new variable comes into play that is unpredictable.
I have been putting the initial number of each month and calculating the remaining numbers. When I saw that they did not match me, I tried to download the files of a month one by one and I found the fault.
For example: on March 11, 2020 the number is 49, on the 12th it should be 50 and it appears 51. On the 13th it appears as 53 when it should be 51... a disaster.
It has occurred to me that my program tries to try to download the file trying with several numbers forwards and several backwards, I don't know if I explain myself ... I would try to download:
20200311_48.pdf
20200311_49.pdf
20200311_50.pdf
20200311_51.pdf
20200311_52.pdf
It's the only thing I can think of right now.
Quote from Gaev on September 22, 2021, 1:11 am@cn_iceman
I feel your pain.
Looks like the owners do not want people to do any kind of automated downloads.
If these files are allowed to be downloaded, how do "mere human beings" figure out what the corresponding "sequence" numbers should be ?
I can't think of a better method of "collecting the file names" than your "scatter gun" approach.
Good luck in your hunt.
I feel your pain.
Looks like the owners do not want people to do any kind of automated downloads.
If these files are allowed to be downloaded, how do "mere human beings" figure out what the corresponding "sequence" numbers should be ?
I can't think of a better method of "collecting the file names" than your "scatter gun" approach.
Good luck in your hunt.

Quote from Vadim on September 22, 2021, 6:38 am@cn_iceman
You can try to make a program that will download files by the names that your algorithm expects and if the expected file is not detected, the program makes a record of the file so you can check the file name manually and fix the day number. This way you can catch all the exceptions to the rules and create a list of file names like on the server. This will take time, but at least you will have a complete and correct list.
Of course, you can add a "probing" function - if the file with the desired date is not found by the specified number, the program may try to download it under the neighboring numbers (I think you suggested this approach). This can help in the case of downloading new files, whose numbers on the server may be in error.
You can try to make a program that will download files by the names that your algorithm expects and if the expected file is not detected, the program makes a record of the file so you can check the file name manually and fix the day number. This way you can catch all the exceptions to the rules and create a list of file names like on the server. This will take time, but at least you will have a complete and correct list.
Of course, you can add a "probing" function - if the file with the desired date is not found by the specified number, the program may try to download it under the neighboring numbers (I think you suggested this approach). This can help in the case of downloading new files, whose numbers on the server may be in error.

Quote from CN_Iceman on September 22, 2021, 10:56 amQuote from Gaev on September 22, 2021, 1:11 amLooks like the owners do not want people to do any kind of automated downloads.The truth is that PDF files are restricted access, but I have legal access, no problem with that. The same with the users to whom the program is directed. There is nothing illegal in what I am doing, don't worry.Quote from Vadim on September 22, 2021, 6:38 am@cn_iceman
You can try to make a program that will download files by the names that your algorithm expects and if the expected file is not detected, the program makes a record of the file so you can check the file name manually and fix the day number. This way you can catch all the exceptions to the rules and create a list of file names like on the server. This will take time, but at least you will have a complete and correct list.
Of course, you can add a "probing" function - if the file with the desired date is not found by the specified number, the program may try to download it under the neighboring numbers (I think you suggested this approach). This can help in the case of downloading new files, whose numbers on the server may be in error.
I think your first approach is the one that convinces me the most. It seems to me that I am going to try to do it that way.
I will keep you posted. Thanks again guys.
Quote from Gaev on September 22, 2021, 1:11 amLooks like the owners do not want people to do any kind of automated downloads.
Quote from Vadim on September 22, 2021, 6:38 amYou can try to make a program that will download files by the names that your algorithm expects and if the expected file is not detected, the program makes a record of the file so you can check the file name manually and fix the day number. This way you can catch all the exceptions to the rules and create a list of file names like on the server. This will take time, but at least you will have a complete and correct list.
Of course, you can add a "probing" function - if the file with the desired date is not found by the specified number, the program may try to download it under the neighboring numbers (I think you suggested this approach). This can help in the case of downloading new files, whose numbers on the server may be in error.
I think your first approach is the one that convinces me the most. It seems to me that I am going to try to do it that way.
I will keep you posted. Thanks again guys.
Quote from Gaev on September 22, 2021, 3:31 pm@cn_iceman
There is nothing illegal in what I am doing, don't worry.
I wasn't suggesting that you were attempting something illegal; just that some website owners want to discourage automated downloads (and go to great lengths to make page/file names as illogical as they can).
Still does not answer the question ... how do human users know what url to to enter for a particular year/month/day ? ... do they enter the date (or choose from a list) and then the server side script attaches the sequence number ? ... if so, you might be able to examine the resulting client-server request, and use that to make the request.
There is nothing illegal in what I am doing, don't worry.
I wasn't suggesting that you were attempting something illegal; just that some website owners want to discourage automated downloads (and go to great lengths to make page/file names as illogical as they can).
Still does not answer the question ... how do human users know what url to to enter for a particular year/month/day ? ... do they enter the date (or choose from a list) and then the server side script attaches the sequence number ? ... if so, you might be able to examine the resulting client-server request, and use that to make the request.

Quote from CN_Iceman on September 22, 2021, 4:44 pmDon't worry Gaev, no problem.
As for how to select the document it is very simple. On the website there is a calendar where you select the year, the month and then the day. When you click on the day you want, a download button appears.
I already have that part ready. I have made a calendar appear and you select the date ... it is the happy number that is after the date, the one that I cannot guess, especially now that I have seen that it does not follow a defined pattern ...
Don't worry Gaev, no problem.
As for how to select the document it is very simple. On the website there is a calendar where you select the year, the month and then the day. When you click on the day you want, a download button appears.
I already have that part ready. I have made a calendar appear and you select the date ... it is the happy number that is after the date, the one that I cannot guess, especially now that I have seen that it does not follow a defined pattern ...

Quote from CN_Iceman on September 22, 2021, 4:56 pmI am going to explain why I am trying to do this program. In fact, the program was working fine until the new changes appeared.
In my work, there is an official daily bulletin where various issues are reflected, such as issues related to personnel, promotions, courses, rewards and even sanctions. You cannot request a course until it appears in the newsletter. If you pass the course, until it appears in the bulletin, it is as if you had not done it, you do not have it recognized.
Each of the workers must have a copy of these documents in which it appears. For example, I have been designated to take several courses, or when I have had a promotion... I should have those documents.
It is easy to download the documents on the official website, but my program, in addition to downloading those documents, can view them. And not only that, you can add specific dates to your work history and the program will automatically download the necessary PDF files.
I am going to explain why I am trying to do this program. In fact, the program was working fine until the new changes appeared.
In my work, there is an official daily bulletin where various issues are reflected, such as issues related to personnel, promotions, courses, rewards and even sanctions. You cannot request a course until it appears in the newsletter. If you pass the course, until it appears in the bulletin, it is as if you had not done it, you do not have it recognized.
Each of the workers must have a copy of these documents in which it appears. For example, I have been designated to take several courses, or when I have had a promotion... I should have those documents.
It is easy to download the documents on the official website, but my program, in addition to downloading those documents, can view them. And not only that, you can add specific dates to your work history and the program will automatically download the necessary PDF files.

Quote from CN_Iceman on September 22, 2021, 5:03 pmQuote from Vadim on September 22, 2021, 6:38 am@cn_iceman
You can try to make a program that will download files by the names that your algorithm expects and if the expected file is not detected, the program makes a record of the file so you can check the file name manually and fix the day number. This way you can catch all the exceptions to the rules and create a list of file names like on the server. This will take time, but at least you will have a complete and correct list.
Of course, you can add a "probing" function - if the file with the desired date is not found by the specified number, the program may try to download it under the neighboring numbers (I think you suggested this approach). This can help in the case of downloading new files, whose numbers on the server may be in error.
I think I will finally try to do what you suggest here. I will first make a small program to generate a list of downloads from 2000 to now and from here on it will be the trial and error method.
I think this is going to be the best option.
Quote from Vadim on September 22, 2021, 6:38 amYou can try to make a program that will download files by the names that your algorithm expects and if the expected file is not detected, the program makes a record of the file so you can check the file name manually and fix the day number. This way you can catch all the exceptions to the rules and create a list of file names like on the server. This will take time, but at least you will have a complete and correct list.
Of course, you can add a "probing" function - if the file with the desired date is not found by the specified number, the program may try to download it under the neighboring numbers (I think you suggested this approach). This can help in the case of downloading new files, whose numbers on the server may be in error.
I think I will finally try to do what you suggest here. I will first make a small program to generate a list of downloads from 2000 to now and from here on it will be the trial and error method.
I think this is going to be the best option.