Solved

VB.NET program help

Posted on 2011-03-22
2
284 Views
Last Modified: 2012-05-11
I have an ASP.NET app, I need some help in achieving this particular logic of code.

I have an arraylist which holds a custom object Sample ( SampleTest, Frequency)
Here is some data from the Arraylist

1) Sample A, MWF
2)SampleB, TTH
3)Sample C, Daily
4) SampleD, Weekly
5) Sample e , Monthly

I need to create one or more SampleOrders between two dates supplied. All days are valid working days

So my method has the following

Function CreateOrders (arrayList, StartDate and EndDate) As OrderList
END Function

In the above test data assumimg there are 61 days, with Start date 03/01/2011 and end date 04/30/2011, would result in 61 orders.

But on 03/01 being a Tuesday we would have the Order having the following SAmpleTests
Sample C, Sample B, Sample D, and Sample E (weekly and monthly test always begin on the StartDate entered)

on 3/2 being a Wed We would have an Order with
Sample C, Sample A

3/3 Order
Sample C, Sample B

3/4 Order
Sample C

3/5 Order
Sample C

3/6 Order
Sample C

3/7 Order
Sample C

3/8 Order
Sample C, Sample B, Sample D

4/1
Sample C, Sample E

In the above scenario we would have weekly sample test - Sample D done on 3/1, 3/8, 3/15. 3/22, 3/29 , 4/5, 4/12, 4/19, 4/26.
The monthly would occur on 3/1/ and 4/1

I need to be able to group these tests into Orders, with the Order date the tests need to be conducted based on the fequency.



0
Comment
Question by:countrymeister
2 Comments
 
LVL 7

Accepted Solution

by:
foobarr earned 500 total points
ID: 35189256
Well it sounds as though you will need to do a bit of date calculations

dim tempDate as DateTime
Dim tempList as ArrayList

tempDate = StartDate

While tempDate <= EndDate

tempList.add(tempDate.ToString("yyyy-MM-dd"))

'These will handle Sample A & B scenarios
tempList.add(ArrayListLookUp(tempDate.DayOfWeek.ToString())) 'You will send whatever day of the week it is to handle Sample A & B.  You will need to perhaps parse the string to wahtever you use for your frequency string.


'Handle the Daily one
'Do your ArraylistLookup and reutrn the value and add to your List
tempList.add(ArrayListLookUp("Daily"))

'Handle the Weekly one.  We are substracting the startdate - the current temporary running date and then mod it by 7.   So if remainder is 0 we know its been 7 days
If tempDate.Subtract(StartDate.Now).Days mod 7 = 0 Then
    tempList.add(ArrayListLookup("Weekly"))
End If

'Monthly you did not mention how you are calculating it, but you could use the same logic as below and go.
If tempDate.Substract(StartDate.Now).Days mod 30 = 0 then
   tempList.add(ArrayListLookup("Monthly"))
end if

tempDate.addDays(1)

Next


In your ArrayListLookup, pass in your searching filter, and then in your SampleData arraylist, lookup the filter and return the Sample name

Function ArrayListLookup(filter as string) as string
  dim i as integer
  dim sampleName as string

  for i = 0 to SampleData.count - 1
    if SampleData(i).GetFrequency() = filter then  'Get Frequency could be the name in your Sample Object that will return the frequency
       sampleNAme = SampleData(i).GetSampleValue() 'GetSampleValue could be the name in your Sample Object that will return the sample a -> e.  These are functions (getters) in your object class Sample
        exit for
    end if
  next

return sampleName
end function



sooo...

after all this the expected structured result in the tempList arraylist would be.  (Note I just am writing SAmple A -> E just wanted to show you what your arraylist would look like structurally...)

2011-03-22
Sample A
Sample B
Sampel C
2011-03-23
Sample D
Sample E
2011-03-24
Sample A
Sample B
Sample C
etc.
etc.

0
 
LVL 1

Author Closing Comment

by:countrymeister
ID: 35223214
just got some overview on the code
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Visual Studio Publish Web Configuration does not contain Release 5 24
Name space syntax error 12 43
ASP.net Javascript use multiple sliders 2 19
C# Single Form 8 28
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now