I am using extjs 4.1.1 calendar ( scheduler ) for keeping the track of people schedule but i can into trouble as i cant figure out how to restrict the booking time slot for individual
example.
User A can book the slot between 3pm to 4 pm on monday to wednesday.
User B Can book slots between 1 am to 5 am on monday and saturday
image link
http://i.stack.imgur.com/tuCVV.png
This may be more complicated than you really want to work with, but we had to do this in our app, the only real way to do it is to override their Extensible.calendar.dd.DropZone class and overwrite the onNodeOver method with your own logic, hope you understand the Extjs well :) :
Ext.override("Extensible.calendar.dd.DropZone", {
onNodeOver : function(n, dd, e, data){
//change anything in this logic with the logic you want....
//but preferrably, don't change anything and use callOverridden and then add your stuff as extras
var D = Extensible.Date,
start = data.type == 'eventdrag' ? n.date : D.min(data.start, n.date),
end = data.type == 'eventdrag' ? D.add(n.date, {days: D.diffDays(data.eventStart, data.eventEnd)}) :
D.max(data.start, n.date);
if(!this.dragStartDate || !this.dragEndDate || (D.diffDays(start, this.dragStartDate) != 0) || (D.diffDays(end, this.dragEndDate) != 0)){
this.dragStartDate = start;
this.dragEndDate = D.add(end, {days: 1, millis: -1, clearTime: true});
this.shim(start, end);
var range = Ext.Date.format(start, this.dateFormat);
if(D.diffDays(start, end) > 0){
end = Ext.Date.format(end, this.dateFormat);
range = Ext.String.format(this.dateRangeFormat, range, end);
}
var msg = Ext.String.format(data.type == 'eventdrag' ? this.moveText : this.createText, range);
data.proxy.updateMsg(msg);
}
return this.dropAllowed;
}
});
Related
I have a table of orders where orders are stored with the timestamp of when the order was created. The restaurant shift starts from 12:00 PM noon and ends at 2:00 AM the next day (this is adjustable and they can changed the shift timings).
Now, I want a reporting listing all the orders for the current day but starting from 12:00 PM and I also want the orders for 2 hours of the next day as well.
There are 3 scenarios here:
The user sees the report at 5:00 AM. He should see 0 orders.
The user sees the report at 6:00 PM. He should see all the orders for that day starting from 12:00 PM.
The user sees the report at 1:00 AM. He should see all the orders for today starting from 12:00 in the night + the orders for yesterday starting from 12:00 PM
How can I implement this logic?
Remember that the shift timings are flexible and can also start and ends the same day i.e. 9:00 AM - 11:00 PM
I was looking for a quick answer but when I didn't get any reply, I decided to do it myself
We will create shift divisions. If a shift is spread over 2 days (12pm to 2am), we'll have 2 divisions otherwise we'll have only 1 division. The divisions will be stored in an array.
We will loop through the divisions and see if the current hour falls in any of the divisions.
Here is the code I wrote (Node.js):
static getOutletCurrentDateRange(brand: Brand, outlet: Outlet): DateRange {
let divisions: ShiftDivision[] = [];
if (outlet.endTime > 24) {
divisions.push({ start: outlet.startTime, end: 24 });
divisions.push({ start: 24, end: outlet.endTime });
}
else {
divisions.push({ start: outlet.startTime, end: outlet.endTime });
}
console.log("divisions: ", divisions);
let current = moment().hour() + (brand.utcDifference || 300)/60;
if (current > 23) {
current = current - 24;
}
console.log("current", current);
let index = 0;
let found = false;
while (!found && index < divisions.length) {
if (current >= divisions[index].start && current <= divisions[index].end) {
console.log("found at index", index);
found = true;
}
else {
index++;
}
current += 24;
}
if (!found) {
return { start: null, end: null }
}
let startDate = moment();
startDate.minute(0);
startDate.second(0);
let endDate = moment();
endDate.minute(0);
endDate.second(0);
if (index == 0) {
console.log("yes 0");
console.log(divisions.length);
startDate.hour(divisions[0].start);
if (divisions.length > 1) {
endDate.hour(divisions[1].end);
}
else {
endDate.hour(divisions[0].end);
}
}
if (index == 1) {
console.log("yes 1");
startDate.hour(divisions[0].start);
endDate = endDate.add(1, "days");
endDate.hour(divisions[1].end);
}
startDate.minutes(-1 * (brand.utcDifference || 300));
endDate.minutes(-1 * (brand.utcDifference || 300));
console.log("here", startDate, endDate);
return { start: startDate, end: endDate };
}
If anyone have a better solution or can improve this solution, he's more than welcomed :)
public pageReference getData(){
date sd = date.parse(sDate).toStartOfWeek();
date ed = date.parse(eDate);
hList = new list<Hours__c>([SELECT Name,Employee__r.Id,Date_worked__c,Employee__r.Offshore__c,Employee__r.Name,Employee__r.Department__c,Employee_Name__c,hours__c,Minutes__c,Hours_Decimal__c FROM Hours__c WHERE Type_of_Hours__c = 'Work' AND Date_worked__c >= :sd AND Date_worked__c <= :ed AND Employee__r.Department__c IN :selected ORDER BY Employee__r.Department__c,Date_worked__c,Employee__r.Name LIMIT 3000]);
wrap = new list<wrapper>();
string tempDepartment;
string tempEmpName;
date tempWorkDate;
date tempStart = sd;
decimal offshore = 0;
decimal onshore = 0;
decimal totalOffshore = 0;
decimal totalOnShore = 0;
decimal dateCount = 0;
decimal aggreagteTotal = 0;
integer hitLimit = 3000;
integer rpwp = 0;
integer compareRPWP = 0;
boolean fired = false;
boolean dateChanged = false;
boolean dateCountis13 = false;
map<date,integer> mapDateCount = new map<date,integer>();
if(hList.size() > 0 && hList.size() < hitLimit){
noResults = false;
for(Hours__c h: hList){
//initiate a new wrapper for each department as a primary header
if( (h.Employee__r.Department__c != null && ((tempDepartment != null && tempDepartment != h.Employee__r.Department__c) || ( tempDepartment == null)) ) ){
fired = true;
tempDepartment = h.Employee__r.Department__c;
wrap.add(new wrapper(null,null,null,null,null,tempDepartment,'','','',null,'',''));
}else{
fired = false;
}
if(fired || dateCountis13){
dateCountis13 = false;
dateCount = 0;
totalOffshore = 0;
totalOnShore = 0;
}
//initiate a new wrapper for each new week period, total employee hours for each week period for each department
if(fired || (h.Date_worked__c != null && ((tempWorkDate != null && tempWorkDate != h.Date_worked__c) || ( tempWorkDate == null)) ) || (h.Employee__r.Department__c != null && ((tempDepartment != null && tempDepartment != h.Employee__r.Department__c) || ( tempDepartment == null)) ) ){
dateChanged = true;
tempWorkDate = h.Date_worked__c;
offshore = 0;
onshore = 0;
rpwp = 0;
dateCount++;
for(Hours__c h1: hList){
//get count of each record that is inside a given week period
if(h1.Date_worked__c == tempWorkDate && h1.Employee__r.Department__c == tempDepartment){
rpwp++;
}
//logic for totaling offshore hours by date and department
if(h1.Date_worked__c == tempWorkDate && h1.Employee__r.Offshore__c && h1.Employee__r.Department__c == tempDepartment){
offshore += h1.Hours_Decimal__c != null ? h1.Hours_Decimal__c : 0;
}
//logic for totaling onshore hours by date and department
if(h1.Date_worked__c == tempWorkDate && h1.Employee__r.Offshore__c == false && h1.Employee__r.Department__c == tempDepartment){
onshore += h1.Hours_Decimal__c != null ? h1.Hours_Decimal__c : 0;
}
}
system.debug('rpwp: ' + rpwp);
wrap.add(new wrapper(h.Date_worked__c.toStartOfWeek(),h.Date_worked__c,onshore,offshore,null,'total','','','',null,'',''));
totalOffshore += offshore;
totalOnShore += onshore;
system.debug('OffShore: ' + offshore + ' ' + tempWorkDate.format());
system.debug('OnShore: ' + onshore + ' ' + tempWorkDate.format());
}else{
dateChanged = false;
}
//initiate a new wrapper for each record and give the ability to open and collapse all records under a given total week period
// functionality now does an aggregate total of employee's that have multiple hour entrees for each week period.
if( dateChanged || (h.Employee__r.Name != null && ((tempEmpName != null && tempEmpName != h.Employee__r.Name) || ( tempEmpName == null)) ) ){
tempEmpName = h.Employee__r.Name;
aggreagteTotal = 0;
for(Hours__c h2: hList){
if(tempEmpName == h2.Employee__r.Name && tempWorkDate == h2.Date_worked__c){
aggreagteTotal += h2.Hours_Decimal__c;
}
}
if(h.Employee__r.Offshore__c){
wrap.add(new wrapper(h.Date_worked__c.toStartOfWeek(),h.Date_worked__c,0,h.hours__c,aggreagteTotal,'collapse',h.Employee__r.Name,h.Employee__r.Id,h.Name,h.Employee__r.Offshore__c,h.Employee__r.Department__c,h.Date_worked__c.format() ));
}else{
wrap.add(new wrapper(h.Date_worked__c.toStartOfWeek(),h.Date_worked__c,h.hours__c,0,aggreagteTotal,'collapse',h.Employee__r.Name,h.Employee__r.Id,h.Name,h.Employee__r.Offshore__c,h.Employee__r.Department__c,h.Date_worked__c.format() ));
}
}
//compare record count on the outside loop to record count on the inner loop and set compare iterator to 0 if the date changes
if(dateChanged){
compareRPWP = 0;
}
compareRPWP++;
system.debug('compareRPWP: ' + compareRPWP );
//if on the 13th week -- initiate a new wrapper and get quarterly totals -- compare record count so that inner loop matches outer loop
if( (dateCount == 13 && compareRPWP == rpwp) ){
system.debug('totalOffshore: ' + totalOffshore );
system.debug('totalOnShore: ' + totalOnShore );
dateCountis13 = true;
wrap.add(new wrapper(null,null,totalOnShore,totalOffshore,null,'quarter',tempDepartment,'','',null,'',''));
}
}
}else if(hList.size() <= 0){
noResults = true;
bannerMessage = 'Oops! No record found.';
}else if(hList.size() >= hitLimit){
noResults = true;
bannerMessage = 'Oops! 3000 Record limit hit.';
}else{
noResults = true;
bannerMessage = 'Oops! 50000 record limit hit.';
}
system.debug('wrap: ' + wrap);
system.debug('hList: ' + hList);
return null;
}
Here is my working method inside my class. Essentially I am doing a query on a custom object Hours__c. What I want to do is have the output on the table be first nested by each employee department. Then Nested by each work period, with all hours worked by that department for each work period. I essentially achieved this from the start by ordering the query that way. Now it was about how to make the logic grab it at the time I needed. But it also needed to aggregate the total hours if employees had more than one hour record per week period. I also finally after every 13 weeks output a total of hours for that quarter.
Here is a screencast of my custom report if you are interested in seeing what I achieved on the front-end but what I want to achieve on the backend and in a more effecient manner. The problem with my logic, is while it works, if there is a lot of data being queried. This logic is pretty slow. Because first it loops the query results once. but inside the first for loop I loop the same query 2 different times... ::slaps head:: ...I know it is terrible.
So I want to see maybe if there is a more effecient way of achieving this with potentially a map or another wrapper class? Because it is all in one wrapper class too. I use front end logic to sort out the table based on results in the wrapper class. I just hide and show rows. Like i said, it works just not as effecient as I would like my logic to run.
here is the screen cast:
https://screencast-o-matic.com/watch/cF60cwYAiB
My first idea is about preparing new Map<Date, List<Hour__c>> dateWorkedToHoursMap map in controller just after your SOQL. With this map you will be able to get quickly Hour__c records by specic Date (Date_worked__c) and go only through them in your sub for loops.
public class Controller {
// (...)
Map<Date, List<Hour__c>> dateWorkedToHoursMap; // New map in controller
// (...)
// Updated "getData()" method which will prepare "dateWorkedToHoursMap"
// map just after SOQL and then will use in both sub for loops
public pageReference getData() {
// (...)
// Your SOQL for Hour__c records
// dateWorkedToHoursMap = prepareDateWorkedToHoursMap(hList);
// (...)
// main for through hList
// (...)
// 1 sub for through list returned by: dateWorkedToHoursMap.get(h.Date_worked__c)
// (...)
// 2 sub for through list returned by: dateWorkedToHoursMap.get(h.Date_worked__c)
// (...)
// end of main for
}
// New "prepareDateWorkedToHoursMap()" method used to prepare "dateWorkedToHoursMap" map
private void prepareDateWorkedToHoursMap(List<Hour__c> hours) {
dateWorkedToHoursMap = new Map<Date, List<Hour__c>>();
for(Hour__c hour : hours) {
if(hour.Date_worked__c != null) {
if(!dateWorkedToHoursMap.containsKey(hour.Date_worked__c)) {
dateWorkedToHoursMap.put(hour.Date_worked__c, new List<Hour__c>());
}
dateWorkedToHoursMap.get(hour.Date_worked__c).add(h);
}
}
}
}
If you think that it will be better then you can try to prepare map like:
Map<String, Map<Date, List<Hour__c>>> departmentToDateWorkedToHoursMap
And then you should be able to quickly get the list of Hour__c records based on DEPARTMENT and DATE WORKED.
I'm trying to map the max number of consecutive days with rain <1 mm in Google Earth Engine.
This is the link to the code
https://code.earthengine.google.com/22b5c20d2700a2ffb5989f892838ac58
First I reclassify the collection with 0 if rain <=1 and 1 if >1.
Then I run the code that should count the days of the longest dry period, but it is able to do so only if the dry period reach the end of the time period.
For instance if I am looking for the longest dry period in 4 days timestep i get the following series:
rain days 1 2 3 4 output
0,0,1,1 = 0 dry days
0,1,0,0 = 2 dry days
0 = rain<=1 and
1 = rain>1 (as per the first step)
Does anyone can help in solving this?
Thanks
I don't think you were far off in your code that you provided. To keep track of the dry spells you have to use .iterate(). I took a stab at your application in a little different way where instead of classifying the data before the iteration, I calculate which pixels are dry each day and carry over the accumulated days that a pixel is dry, otherwise it is set to zero:
// DATA
var collection = ee.ImageCollection("UCSB-CHG/CHIRPS/DAILY");
// Define time range
var startyear = 2000;
var endyear = 2017;
var startmonth = 1;
var endmonth = 12;
// Set date in ee date format
var startdate = ee.Date.fromYMD(startyear,startmonth,1);
var enddate = ee.Date.fromYMD(endyear,endmonth,31);
// Filter data
var datain_t = collection.filterDate(startdate, enddate)
.filter(ee.Filter.calendarRange(startmonth,endmonth, 'month'))
.select("precipitation").map(function(img){
return img.addBands(ee.Image.constant(0).uint8().rename('counter'));
})
.sort('system:time_start');
// // START
var dataset = datain_t
.filterDate("2016-08-01","2016-08-30")
.sort('system:time_start:');
print(dataset,"dataset");
var precipThresh = 1; // mm
function drySpells(img, list){
// get previous image
var prev = ee.Image(ee.List(list).get(-1));
// find areas gt precipitation threshold (gt==0, lt==1)
var dry = img.select('precipitation').lt(precipThresh);
// add previous day counter to today's counter
var accum = prev.select('counter').add(dry).rename('counter');
// create a result image for iteration
// precip < thresh will equal the accumulation of counters
// otherwise it will equal zero
var out = img.select('precipitation').addBands(
img.select('counter').where(dry.eq(1),accum)
).uint8();
return ee.List(list).add(out);
}
// create first image for iteration
var first = ee.List([ee.Image(dataset.first())]);
// apply dry speall iteration function
var maxDrySpell = ee.ImageCollection.fromImages(
dataset.iterate(drySpells,first)
).max(); // get the max value
// display results
Map.addLayer(maxDrySpell.select('counter'),{min:0,max:30,palette:'#9ecae1,#ffffff,#ffeda0,#feb24c,#f03b20'},'Max Dry Spells');
Here is the link to the code: https://code.earthengine.google.com/80b4c0f7e82a5f0da316af1d2a55dd59
Don't try to run this analysis for too long of a time period or Earth Engine will give an error. I hope this helps!
Hi I am new in angular and making my first module. This article is very helpfull. I want to filter my data by lastweek records. I have already found days by current date and given date in mysql query, On button click I am just setting value like DisTopic=1 and this works fine.
May you please tell me how can I apply filter for a range like day>=1 && day<=7
I am using below:-
filter:{'topic': DisTopic,'attachment':attch, 'days':day}
Please help me.
Solution 1: with angular-filter module
As stated by other users, you could indeed do that with a custom filter. However, if you find yourself writing a lot of custom filters, I'll advise you have a look at angular-filter module. With this module you can do what you need with the pick filter :
<div ng-repeat="task in tasks | pick: 'days >= 1 && days <= 7'">{{task.name}}</div>
See demo fiddle
Solution 2: Custom filter with parameters
Template:
<div ng-repeat="task in tasks | dayFilter: 1 : 7">{{task.name}}</div>
Javascript:
app.filter('dayFilter', function() {
return function(input, startDay, endDay) {
var filterFunction = function (item) {
return item.days >= startDay && item.days <= endDay;
};
return input.filter(filterFunction);
};
});
See updated demo fiddle
Custom filter example, you can modify as per your need.
Controller
$scope.search = function (item) {
if ($scope.searchUser == null || $scope.searchUser.trim() == "")
return true;
if (item.FirstName.toLowerCase().indexOf($scope.searchUser.toLowerCase()) != -1 || item.LastName.toLowerCase().indexOf($scope.searchUser.toLowerCase()) != -1 || item.Role.toLowerCase().indexOf($scope.searchUser.toLowerCase()) != -1) {
return true;
}
return false;
};
and than call it in your view
| filter:search
So, depending on your requirement, you can pass as many parameters and modify method in controller.
//Below code solve my problem.
Date.prototype.getWeek = function () {
// Create a copy of this date object
var target = new Date(this.valueOf());
// ISO week date weeks start on monday
// so correct the day number
var dayNr = (this.getDay() + 6) % 7;
// ISO 8601 states that week 1 is the week
// with the first thursday of that year.
// Set the target date to the thursday in the target week
target.setDate(target.getDate() - dayNr + 3);
// Store the millisecond value of the target date
var firstThursday = target.valueOf();
// Set the target to the first thursday of the year
// First set the target to january first
target.setMonth(0, 1);
// Not a thursday? Correct the date to the next thursday
if (target.getDay() !== 4) {
target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7);
}
// The weeknumber is the number of weeks between the
// first thursday of the year and the thursday in the target week
return Math.ceil((firstThursday - target) / 604800000) - 1; // 604800000 = 7 * 24 * 3600 * 1000
};
I have an algorithm which scans through data read from a .csv file(approx 3700 lines) and assess's which trading week of the year each entry is in by running a count++ for every Sunday of that year and assigning the count value as the trading week when the date falls within that week.
It's working but performance is lagging. It is the 3rd function running using Task.Factory.StartNew (I have also tried parallel.Invoke).
Results of timing tests.
before: 00:00:05.58
after: 00:00:23.27
UPDATE
Added break after each trading week is set. Time improved but still slow.
new time: 00:00:15.74
For our purposes the 1st week of the year is week 1(not 0) and is defined as from the first day of the year until the Sunday. If the first day of the year is a Sunday the length of week 1 is 1 day.
private void SetDefiniteWeeks()
{
string FileLoc = FilePath + Market + ".csv";
string[] Data = File.ReadAllLines(FileLoc);
var FileData = from D in Data
let DataSplit = D.Split(',')
select new
{
Date = DateTime.Parse(DataSplit[0]),
ClosingPrice = double.Parse(DataSplit[4])
};
//assign each date to it's relevant week
TradingWeek TW;
List<TradingWeek> tradingWeek = new List<TradingWeek>();
foreach (var pe in FileData)
{
// DateTime dt = pe.Date;
int Year = pe.Date.Year;
string End_of_Week = "Sunday";
int WeekCount = 0;
DateTime LoopDate_Begin = new DateTime(Year,1,1);
DateTime LoopDate_End = new DateTime(Year,12,31);
do
{
if (LoopDate_Begin.DayOfWeek.ToString() == End_of_Week)
{
WeekCount++;
if (LoopDate_Begin.DayOfYear > pe.Date.DayOfYear && LoopDate_Begin.DayOfYear < (pe.Date.DayOfYear + 7))
{
TW = new TradingWeek { Week = WeekCount, Date = pe.Date };
tradingWeek.Add(TW);
break;
}
}
LoopDate_Begin = LoopDate_Begin.AddDays(1);
} while (LoopDate_Begin.Date.ToString() != LoopDate_End.Date.ToString());
}
}
Please help.
UPDATE
NEW TIME
00:00:06.686
A vast improvement. Thanks all for your help.
Revised code:
CalendarWeekRule cw = CalendarWeekRule.FirstDay;
var calendar = CultureInfo.CurrentCulture.Calendar;
var trad_Week = (from pe in FileData
select new TradingWeek
{
Date = pe.Date,
Week = (calendar.GetWeekOfYear(pe.Date, cw,DayOfWeek.Sunday))
}).ToList();
Im not sure if this is what you want but after reading the comments I got the feeling that this might work (?)
var calendar = CultureInfo.CurrentCulture.Calendar;
var tradingWeek = (from pe in FileData
select new TradingWeek
{
Date = pe.Date,
Week = calendar.GetWeekOfYear(pe.Date, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
}).ToList();
Edit: Changed to CalendarWeekRule.FirstDay since it's (more?) what OP is looking for.
Three quick thoughts:
Why are you only adding one day each time and checking to see if it's Sunday. Surely once you have found your first Sunday you can add seven days to find the next one?
If you order your pes by DateTime before you start then you don't need to restart at the beginning of the year for each one, you can pick up where you left off.
As Nicolas says, break after adding the trading week. No need to go through the rest of the year after you already know what the answer is.
I guess you'll end up with something like this (may or may not actually work, but should be close enough)
TradingWeek TW;
List<TradingWeek> tradingWeek = new List<TradingWeek>();
string End_of_Week = "Sunday";
var orderedData = FileData.OrderBy(x => x.Date)
DateTime LoopDate_Begin = new DateTime(orderedData[0].Date.Year,1,1);
int WeekCount = 1;
while (LoopDate_Begin.DayOfWeek.ToString() != End_of_Week)
{
LoopDate_Begin = LoopDate_Begin.AddDays(1);
}
foreach (var pe in orderedData)
{
do
{
if (LoopDate_Begin.DayOfYear > pe.Date.DayOfYear && LoopDate_Begin.DayOfYear < (pe.Date.DayOfYear + 7))
{
TW = new TradingWeek { Week = WeekCount, Date = pe.Date };
tradingWeek.Add(TW);
break;
}
WeekCount++;
LoopDate_Begin = LoopDate_Begin.AddDays(7);
} while (true); //need to be careful here
}
if I get you correctly, you don't need to look any further as soon as you've added your TradingWeek
So, you can
break;
after
tradingWeek.Add(TW);
You could then even leave out the
&& LoopDate_Begin.DayOfYear < (pe.Date.DayOfYear + 7)
condition since the first part is going to be true only once: for your desired interval.
You might even go for a loopless approach by dividing the number of days since your starting week by 7 - and doing some cleaning up work ;)
Can you get rid of your do loop altogether by calculating the Week Number directly? Something like the accepted answer here.
Following #nicolas78's response, something like this should work
int Year = pe.Date.Year;
DateTime Year_Begin = new DateTime(Year,1,1);
int Jan1DayOfWeek = Year_Begin.DayOfWeek;
foreach (var pe in FileData)
{
int WeekCount = (pe.Date.DayOfYear - Jan1DayOfWeek) % 7 + 1;
TradingWeek TW = new TradingWeek { Week = WeekCount, Date = pe.Date };
tradingWeek.Add(TW);
}
Depending on how DayOfWeek and DayOfYear count, that is from 0 or 1, and how your mod operation work, you may need to tweak the WeekCount computation a bit.
There's a built-in feature to get the week of the year based on the date in .NET. An example is shown below, but it may need some tweaking to fit your business scenario:
System.Globalization.CultureInfo myCI = new System.Globalization.CultureInfo("en-US");
int week = myCI.Calendar.GetWeekOfYear(DateTime.Now.ToUniversalTime(), System.Globalization.CalendarWeekRule.FirstFourDayWeek, System.DayOfWeek.Sunday);
You don't need to count at all - just do a quick calculation. This assumes that a partial week at the start of the year is week 1 and week 2 begins on the first Monday.
List<TradingWeek> tradingWeek = new List<TradingWeek>();
foreach (var pe in FileData)
{
var date = pe.Date;
while (date.DayOfWeek != DayOfWeek.Sunday)
date = date.AddDays(1);
var week = date.DayOfYear/7+1;
var TW = new TradingWeek {Week = week, Date = pe.Date};
tradingWeek.Add(TW);
}