figuring out whether submissions were made on time or late [closed] - c#

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I have a set of requirements which I can't yet decide the best way to implement.
I have a table in the database for submissions, including the date a submission was made (Submission.Name, Submission.Date).
Each year, we want the user to make 2 submissions, one by April 1, and one by December 1
The requirements indicate that we show the user a notification on the home page, which can be one of three:
- submission completed for current period (green)
- submission pending by end of current period (blue)
- submission outstanding from previous period (red)
There is one additional rule which is that if a submission is overdue by more than 3 months, then
we should display the submission pending notification (blue) for the upcoming deadline instead of the red one.
The problem is when trying to determine if a submission that is in the first 3 months of the current period should be counted towards the current period or if it was just a late submission for the period before (which would have been overdue).
Checking previous periods for whether or not they were overdue might also require checking their previous
period ...etc. making it more complicated than I hoped.
The options so far look like either to query the table using EntityFramework to calculate the state, or to implement this logic in code, however, both options appear non-trivial so far.
Can anyone see a better approach to this kind of problem? Or does anyone have any Linq tricks to do this in one shot?
Edit: we want 2 submissions per year, but the user is free to make more than 1 submission per period, and hence why it's difficult trying to interpret how the submissions correlate back to overdue periods
Thanks in advance

Can't you just add a new field to your database, "LastSubmissionPeriod" and set it to
April 1, or December 1 so you know which period has been filled?

Related

What is the best way to notify a user when a SQL Server database table cell is still empty after a certain period of time? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I am building an ASP.NET Core web app in C#. Clients can add an "inquiry" and the target response time is less than 30 minutes. Table "Inquiries" has many columns, among them: Id, Inquiry, and Reply.
Here is the scenario:
10h00: Client A adds an inquiry
10h09: No reply yet
10h10: Employee B gets notified that an inquiry has been added and has no reply yet
10h04: No reply yet
10h09: No reply yet
10h20: Employee B gets notified that an inquiry has been added and has no reply yet
10h21: Employee B adds reply and stops getting notified (B was getting notified every 10 minutes)
What would you say is the best approach to get this to work? I suppose I can write a C# function to check for empty "Reply" cells every 30 seconds, but I think it would exhaust memory when the database grows bigger, right? Can you point me in the right direction?
There are a few options here for this.
Personally, I would schedule an event in a secondary service to trigger tasks at a time window, but that may be overkill in your case.
Within your Inquiries, you (you probably already have this field) can use a last modified or last updated field to determine when this row was altered last via a calculation.
If you don't have a requirement of Source Control for your DB script, you can use stored procedures to manage this data and control the creating of these date/time stamps.
I would recommend updating your query to have a where clause on both the Last Updated time AND the null condition. This way there is no unnecessary records being processed and checked.
POST EDIT Alteration:
It seems like you have a creation date of events within the database, compare them to the current time on your retrieval query for determining an alert status.
About memory/performance impact:
The (C# application) memory impact will be based on the number of items returned, and not the number of items in the Database. So, if you add a where clause onto your query, you'll be able to ensure that the memory isn't allocated to misc. objects.

How to create and simulate fictive time for a business simulation game [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am total beginner in C#, except that I went through the Microsoft courses and finished some basic projects. Now I thought to try something on my own, creating a very basic business simulation game with a c# form in Visual Studio.
I asked Google but had a hard time to find what I am looking for. I do basically want to start off with a system that simulates days. Let's say I have a button that I can press to play forward, and when I do this, a pre-defined date like 1 January 2017 should increase with +1 day ticks as long as I don't click on that button again to pause the game. This is for example how it works in the game Europa Universalis IV, except that I can even increase the speed by 5 levels in that game, but this would be a bit too much now.
I just want to understand how the basic concept of a simulated date in economy based, or strategy based games is working. I featured out that they do even use 28 days in February in Europa Universalis IV... so, how is the time or date game logic working. I'd like to create this system too to understand it. I guess I need a form project, 1 button, 1 timer and 1 label.
Can someone point me into the right direction?
Several things.
You need a timer to drive this.
You probably want to run increments smaller than 1 day, say 1 hour
This is a VERY rough outline
On button click, timer.Enabled = !timer.Enabled (this reverses the timer state, you probably want to update UI and such as well)
In the timer_Elapsed event, you want to update your game state (e.g. _now = _now.AddHours(1); UpdateState(); UpdateUI();)

C# Calculator Text Input Validation [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am currently writing a calculator application. One part of this application is a Simple Calculator that works like the calculator in windows (using windows 8). It can parse the numbers entered in the textbox. However, if the user does not enter in the correct form such as 5 * * 5 it will give an error. I want it to check the character entered before to see if its an operator and if it is, replace it such as 5 * / 5 to become 5 / 5 as the user is typing. Also it will need to check the parenthesis are in the correct order such as () or () not )(. The other thing it will need to check is that the number being entered only has one decimal point. For example, 4.38585 + 5.32948. I have already limited key entries to only numbers and operators. I have checked this for some time now, but have not seen any solutions.
If you're going to allow the user to enter an expression and then make him press a "calculate" button, then you should not validate things on the fly. Let the user make mistakes, since he will anyway. The user will want to go back and edit the text that he's entered. Your editing rules will make that difficult or impossible. Or worse, inconsistent.
For example, say that the user enters 4.35*7.29.
Then he realizes that he wanted to divide. But your editing rules won't let him delete the * because that would make for an invalid number. And he can't enter the / first and then delete, because doing so would give /* or */, both of which are invalid. Are you going to allow the temporary invalid expression when editing, but not allow it when the user is typing? That would be inconsistent, and wouldn't prevent your evaluator from having to do the error checking again and notify the user.
Limit keystrokes to numbers and operators if you like, but don't try to validate the form of what the user inputs. Let him type **)9(// if he wants. Handle the error when you're parsing--AFTER the user has pressed the calculate button.
Now, if your application works like Windows Calculator in that it keeps a running total as the user enters values and operators, that's a different matter. But what you're talking about would just be frustrating. I certainly wouldn't want to use it.

badges / achievements [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
i'm looking to implement a similar thing to stackoverflow badges. you could also equate them to achievements in games.
but am not sure how to design the database/code/tracking for them.
i get what i should do for badges such as:
Altruist × 1456 First bounty you manually awarded on another person's question
because they are a one time event, but how to handle others such as:
Analytical × 16389 Visited every section of the FAQ
Electorate × 1783 Voted on 600 questions and 25% or more of total votes are on questions
Outspoken × 188 Posted 10 messages in chat that were starred by 10 different users
etc...
how to handle them, how to keep track of progress for each, etc... is there a tutorial or something that can help me figure out a design pattern for them?
For the given examples, there are essentially two mechanisms you are going to need.
I don't know how it's done on SO, this is just a suggestion of a solution.
Let's look at 'Analytical' first. You are going to have to record by means of a simple flag when a user visits a particular area in the FAQ. Let's envisage a DB table with a field for each FAQ section and a user ID. This starts off as "N" (or 0, or however you want to represent your flag). When a user visits that area, you call code to flip that field to "Y". When all fields are "Y" then you can award that badge.
As for 'electorate' and 'Outspoken', you can retrieve this information by means of a query on your existing data, assuming the queries themseves are not too burdensome. You are going to need to consider when to run these checks. This essentially boils down to two options.
1) When the an action is performed that might get a badge awarded (i.e. visit section of FAQ, Vote on a Question, Question starred by someone else)
2) Periodically (hourly, daily, etc) run a check for all your badges against current data.
Bear in mind that badges are one-way in Stackoverflow, so if you are wanting to be equivalent then you don't have to consider logic to 'un-award' badges.

How do I track a repeating calendar event in C# / SQL Server? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'd like to display a repeating event on a date/time display in an app. This date time display can take the form of a calendar, but it could also just be a list of upcoming events.
What is the best way to handle tracking this event that can repeat?
For example: Should the event be stored once in the database and projected out / repeated several times in the display code? Should the event be stored several times and then just rendered?
I did something like this before and I based my schema off of SQL Servers sysschedules table.
http://technet.microsoft.com/en-us/library/ms178644.aspx
The schema linked above will allow you to store the schedule for a job (event). Then you can calculate what dates the event occurs on based off of the schedule. This may be a lengthy calculation, so I would try to cache that result somewhere.
I think it depends on type of event it is. Is it like Christmas where once it comes along and happens you really aren't interested in it until the next occurrence? Or is it a task like, "Make sure I call my mom every month", where if it happens and you missed it you wouldn't want it to go away?
One way I recently implemented the latter was to have a record that had next_occurrence (date), reoccurence_period (weekly, monthly, yearly, etc) columns. So that as the next occurence approched it would show up in the list. Once it passed the list item would have a recycle icon that once pressed would update the record to the next future occurence.
Again, i'm not sure if this applies to your situation, but it worked well for mine.

Categories