Financial App - Recurring - vb.net

I'm making a financial app and I run into some problems with recurring money like fixed payment, salary, bank saving, ... I tried to add these payments on a certain day by comparing the current day and day of payments. The code is something like this:
If Date.Now.Day = GetPayDate(date) then
//code here //
It's in a start up event and it works but the problem is if users don't open the app on that day, the app will ignore and nothing will be added.
I'm using ADO.net with sql database. It's an app on local client without real time data.
In order to work correctly, users don't have to log on but the app must be run, so I tried to fix it by adding an auto start function on it. But it's not an option because users may not use computer for few days.
Is there any other way to resolve this problem? I just need some solutions or ideas about it, so even if users don't use the app in 2 or 3 months, it still calculate everything once they log on.

Sounds like you really need a windows service that runs on startup, or a scheduled task. A windows service is a type of C# / VB.Net application that's designed to run in the background, and has no UI. The Windows task scheduler can start a program on a regular basis.
For more info about windows services, see https://msdn.microsoft.com/en-us/library/zt39148a%28v=vs.110%29.aspx. For more information on scheduled tasks, see http://www.7tutorials.com/task-scheduler. For a discussion about which is better, see Which is better to use for a recurring job: Service or Scheduled Task?
Or you could compare the current date to >= the pay date if you don't mind paying a few days late.

Related

Azure S2 Database Automatically creating and deleting a database every day

I currently have an Azure S2 database running via the new Azure Portal.
I notice my billing was higher than it should be and after investigating further, I noticed there were new databases appearing every day then disappearing.
Basically, something is running a CreateDatabase and DeleteDatabase event every evening, and I'm being charged an extra hour each day.
Microsofts response is:
"Our Operations Team investigated the issue and found that these databases did indeed exist in a 1 hour windows at midnight PST every day. It looks like you may have some workload which is doing this unknowingly or an application with permissions which is unknowingly creating these databases and then dropping them. "
I haven't set up any scripts to do this, and I have no apps running that could be doing this.
How can I find out what's happening?
Regards
Ben

VB.NET: Display SQL Server Table Row Count in Real Time?

I've got an app at work I support that uses a SQL Server 2008 DB (vendor created/supported app). One of the things this app does is load records into ETL tables in the DB all day to be moved to a data warehouse.
Unfortunately, the app is having lots of problems with the ETL tables right now and the vendor has no monitoring solution. I have no accesses to the DB to add a stored procedure or anything, but I can run a count * on the ETL tables to see if things are getting out of hand.
I have managed to write a VB.NET app that will return the COUNT of rows in these ETL tables so I can keep an eye on things, but it will only return the counts if I fire a button event.
I've never written an app that runs/updates "in real time" before, and I'm looking for some guidance on how I can create an app that would update these COUNT values in as close to real time as possible.
Any guidance would be greatly appreciated!
You could achieve that by writing a Console application, since you seem used to .Net.
The console application runs and you can read the values by using console.writeline() and console.readline() in your program.cs. Or you could update the record counts in a table or send an email.
When you say real time, the console application can be scheduled to run - e.g. through creating a task in task scheduler or sql agent, or it can be run by launching the exe. A rough example is that, you could send yourself an email every 10 minutes by creating a task that launches the console ap every 10 minutes.
If you're using a Windows Forms app, just add in a Timer object that fires the SQL query off. As an added bonus, you could include fields on the form to control how often the timer fires to get the resolution that's right for you.
You can use the Timer control in Console apps too, of course.

Periodic Email Notifications (Windows Azure .Net)

I have an application written in C# ASP.Net MVC4 and running on Windows Azure Website. I would like to write a service / job to perform following:
1. Read the user information from the website database
2. Build a user-wise site activity summary
3. Generate an HTML email message that includes the summary for each user account
4. Periodically send such emails to each user
I am new to Windows Azure Cloud Services and would like to know best approach / solution to achieve the above.
Based on my study so far, I see that independent Worker Role of Cloud Services along with SendGrid and Postal would be a best fit. Please suggest.
You're on the right track, but... Remember that a Worker Role (or Web Role) is basically a blueprint for a Windows Server VM, and you run one or more instances of that role definition. And that VM, just like Windows Server running locally, can perform a bunch of tasks simultaneously. So... there's no need to create a separate worker role just for doing hourly emails. Think about it: For nearly an hour, it'll be sitting idle, and you'll be paying for it (for however many instances of the role you launch, and you cannot drop it to zero - you'll always need minimum one instance).
If, however, you create a thread on an existing worker or web role, which simply sleeps for an hour and then does the email updates, you basically get this ability at no extra cost (and you should hopefully cause minimal impact to the other tasks running on that web/worker role's instances).
One thing you'll need to do, independent of separate role or reused role: Be prepared for multiple instances. That is: If you have two role instances, they'll both be running the code to check every hour. So you'll need a scheme to prevent both instances doing the same task. This can be solved in several ways. For example: Use a queue message that stays invisible for an hour, then appears, and your code would check maybe every minute for a queue message (and the first one who gets it does the hourly stuff). Or maybe run quartz.net.
I didn't know postal, but it seems like the right combination to use.

Application security: Counting days independent of system calendar

I want to add a feature to my trial version of the application. After first activation, I want to make it limited to 90 days. But I am concerned about user's changing the date of system hence deceiving my application.
Is there any possibility to make it fool proof in a way that even if user takes the calender back, application expires after 90 days of first activation? First activation date has been saved in the database.
Thank you very much.
Furqan
In short, no, unless your application can run 24/7 and only allows itself to be started once. Even then, there'd be ways to subvert it.
#SB.101's answer is a way of checking for very simple date fiddling. It won't catch sophisticated cheats who know you're doing that and just keep setting the date to something sneaky that fools your checks. It will also annoy the odd few users who change the date on their system legitimately.
Pinging a server of yours over the internet to get the date would help, but is still able to be spoofed, and now annoys your users by forcing them to be connected to the internet (unless your application already needs that).
There is no sure-fire way of doing this. It is theoretically impossible. Remember that no matter how clever you are at checking whether the trial period has elapsed, a user can always modify or delete the recording of when the trial started!
I would advise you to just do something quick and simple, and rely on the fact that the small percentage of people who are both able to subvert your trial limitation and willing to bother doing so are unlikely to purchase the full version of your application anyway.
You can also save last run date in DB and can compare that to system date if that is newer that system date then you are deceived!
or
If you can use HTTP then can query time servers for current date time

VB.net What's the Best Technique for sending scheduled email reminders?

I've been thinking about this problem for a while now and I'm still not sure what is the best approach.
Basically I've got several hundred email addresses stored in a Database, and every week I would like to automatically send these addresses a bulletin of information. I've accomplished this with a Stored Procedure and a Scheduled Job on the DB (Oracle), but I'm sure this could be achieved better with some VB.net solution.
I've read about people writing a Windows Service, or creating a Console Application and using Windows scheduler. I'm swaying to wards the Windows Service approach but I'm not sure how to tell the service to send emails at a specific time every week. Any ideas, or is there a better approach?
Also, what would be best? Send individual emails to the addresses in the emailing list, or send one email with every address added as a BCC?
Thanks
This type of thing is one of the things that scheduled tasks are designed for. Imagine creating a service that sits there taking up memory doing absolutely nothing for 7 days, only to run for 4 minutes. Then another 7 days of waiting. While it may work, its certainly not what a service is for.
Use a scheduled task. That scheduled task could easily just start a console app which reads the database, sends the emails, and then quits as normal. Nothing wrong with using a scheduled task for something that... performs a task on a scheduled basis.
As for what is "best", there is no "best". Just what works for your situation. Do you want to send out 150 emails, so that each person sees their name on it, or send out one email with 150 BCCs, where no on sees their name on it? Whatever works the way you want it to is "best"
Have you considered using the "scheduled tasks" feature in the control panel? That's what I use for recurring program usage similar to what you've described.