Commit addd716d authored by Stojcheska Teodora's avatar Stojcheska Teodora
Browse files

Changed UI, changed folder structure, added .gitignore

parent 5e8009fc
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# My Specific
instructions.txt
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Nuget personal access tokens and Credentials
nuget.config
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
.idea/
*.sln.iml

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31229.75
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scheduler", "Scheduler\Scheduler.csproj", "{1F6FE665-3863-440A-97E8-12B5F87E0078}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1F6FE665-3863-440A-97E8-12B5F87E0078}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F6FE665-3863-440A-97E8-12B5F87E0078}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F6FE665-3863-440A-97E8-12B5F87E0078}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F6FE665-3863-440A-97E8-12B5F87E0078}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7F49CCE7-A332-47C1-9A48-AADACCDE928E}
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
\ No newline at end of file
......@@ -23,15 +23,22 @@ public class Calendar
this.currentDate = DateTime.Now; // format dd.mm.yyyy hh:mm:ss
}
private Calendar clone()
{
Calendar calendar;
// make a clone and in _addTask
return null;
}
// TODO: Check the case when we add a task for today since this function will be returning 0
private int numberOfDaysInRange(DateTime startingDate, DateTime endDate) => (endDate.Date - startingDate.Date).Days + 1;
private static int numberOfDaysInRange(DateTime startingDate, DateTime endDate) => (endDate.Date - startingDate.Date).Days + 1;
private bool isDateValid(DateTime startingDate, DateTime endDate) => numberOfDaysInRange(startingDate, endDate) > 0;
private bool shouldAddDay(Task task) => days[days.Count - 1].hoursToShift * -1 < task.duration;
// Make an indexer?
private Day getDayByDate(DateTime date)
public Day getDayByDate(DateTime date)
{
foreach(Day day in days)
{
......@@ -117,7 +124,7 @@ public class Calendar
}
else
{
// remove task
// remove task - nothing
}
}
......@@ -229,18 +236,12 @@ public class Calendar
}
catch (NoSpaceForTaskExeption exception)
{
WriteLine("Exception");
WriteLine(task.name);
print();
Day day = findTaskInDay(task);
day.removeTask(task);
deleteReorderCalendar(exception.day.nextDay, day.hoursToShift * -1, day.nextDay);
// from day in the addTask from when I thorow the exeption until the day that I have here from which I remove the task
/*
Options:
-Modify task
-Add hours to the day
-Delete task
-Add hours equally to each day from the current date up until the deadline of the task
*/
deleteReorderCalendar(exception.day.nextDay, day.hoursToShift * -1, day);
}
}
......@@ -262,10 +263,11 @@ public class Calendar
}
else
{
for(int i = 0; i < numberOfDaysInRange(task.deadline, days[days.Count - 1].date) * -1 + 1; ++i)
for(int i = 0; i <= numberOfDaysInRange(task.deadline, days[days.Count - 1].date) * -1 + 1; ++i)
{
Day newDay = new Day(days[days.Count - 1].date.AddDays(1), new List<Task>(), defaultWorkingHoursInterval, defaultWorkingHours);
days[days.Count - 1].nextDay = newDay;
newDay.prevDay = days[days.Count - 1];
days.Add(newDay);
}
day = getDayByDate(task.deadline);
......@@ -295,6 +297,7 @@ public class Calendar
if (hours < task.duration)
{
WriteLine("No space to add task");
validDays[validDays.Count - 1].addTask(task, validDays[validDays.Count - 1].tasks.Count);
throw new NoSpaceForTaskExeption("There is no space to add the task which needs to be added as the last task in the calendar", d, task, hours - task.duration);
}
}
......@@ -312,6 +315,7 @@ public class Calendar
if (numberOfDaysInRange(day.tasks[i].deadline, task.deadline) <= 0 && day.tasks[i].type != Type.FIXED)
{
day.addTask(task, i);
// if there isn't enough space to add the task just don't add it -> similar to temp
if (day.isDayFull(0))
{
reorderCalendar(day, day.hoursToShift, true, null);
......@@ -347,7 +351,8 @@ public class Calendar
{
Day dirDay = day.nextDay;
if (dirDay == null || dirDay.Equals(returnPoint)) { return; }
// dirDay.Equals(returnPoint)
if (dirDay == null || day.hoursToShift <= 0) { return; }
List<Task> tasks = new List<Task>();
......@@ -361,6 +366,7 @@ public class Calendar
if (!isDateValid(dirDay.date, curTask.deadline))
{
foreach (Task task in tasks) { day.addTask(task, day.tasks.Count); }
throw new NoSpaceForTaskExeption("There is no space to add the task, error occured during shifting the tasks", day, curTask, hours);
}
......@@ -386,8 +392,10 @@ public class Calendar
else
{
int curTaskHours = curTask.duration;
// TODO: Problem
if (curTask.isSplit)
{
curTask.splitTaskPtr.duration += curTask.duration;
}
else
......@@ -408,11 +416,15 @@ public class Calendar
reorderCalendar(dirDay, dirDay.hoursToShift, next, null);
}
// bool done which become truw when we reach the day from which we've removed the task i.e. the shift hours are <= 0
void deleteReorderCalendar(Day day, int hours, Day returnPoint)
{
int h = hours;
Day dirDay = day.prevDay;
if (dirDay == null || dirDay.Equals(returnPoint)) { return; }
// dirDay.Equals(returnPoint)
// TODO: Stop day i.e. base case || day.hoursToShift == 0
if (dirDay == null || day.Equals(returnPoint)) { return; }
List<Task> tasks = new List<Task>();
// for loop is retarded when I delete the element
......@@ -426,35 +438,16 @@ public class Calendar
if (curTask.duration > hours)
{
WriteLine(dirDay.tasks[dirDay.tasks.Count - 1]);
// only the first element can be split
if (dirDay.tasks[dirDay.tasks.Count - 1].isSplit && i == 0)
{
curTask.duration -= hours;
dirDay.tasks[dirDay.tasks.Count - 1].duration += hours;
tasks.Add(dirDay.tasks[dirDay.tasks.Count - 1]);
dirDay.removeTask(dirDay.tasks[dirDay.tasks.Count - 1]);
}
else
{
Task shiftSplitTask = new Task(curTask.name, curTask.deadline, hours, curTask.type, true);
shiftSplitTask.splitTaskPtr = curTask;
curTask.duration -= hours;
Task shiftSplitTask = new Task(curTask.name, curTask.deadline, hours, curTask.type, true);
shiftSplitTask.splitTaskPtr = curTask;
curTask.duration -= hours;
tasks.Add(shiftSplitTask);
}
tasks.Add(shiftSplitTask);
hours = 0;
}
else
{
int curTaskHours = curTask.duration;
if (dirDay.tasks[dirDay.tasks.Count - 1].isSplit && i == 0)
{
dirDay.tasks[dirDay.tasks.Count - 1].mergeTasks(dirDay.tasks[dirDay.tasks.Count - 1], dirDay.tasks[dirDay.tasks.Count - 1].splitTaskPtr);
curTask = dirDay.tasks[dirDay.tasks.Count - 1];
dirDay.removeTask(dirDay.tasks[dirDay.tasks.Count - 1]);
}
tasks.Add(curTask);
hours -= curTaskHours;
day.removeTask(curTask);
......@@ -464,20 +457,22 @@ public class Calendar
}
// or should I just check here if the first task in tasks is split with the last task in dirDay and them just add the hours and isSplit and remove the from tasks and don't add it to dirDay again?
/*if (dirDay.tasks[dirDay.tasks.Count - 1].isSplit)
// changes are not saved in task2
if (dirDay.tasks.Count != 0 && dirDay.tasks[dirDay.tasks.Count - 1].isSplit)
{
dirDay.tasks[dirDay.tasks.Count - 1].isSplit = tasks[0].isSplit;
dirDay.tasks[dirDay.tasks.Count - 1].splitTaskPtr = tasks[0].splitTaskPtr;
dirDay.tasks[dirDay.tasks.Count - 1].duration += tasks[0].duration;
tasks.RemoveAt(0);
}*/
}
for (int i = 0; i < tasks.Count; ++i)
{
dirDay.addTask(tasks[i], dirDay.tasks.Count);
}
deleteReorderCalendar(dirDay, dirDay.hoursToShift, null);
// h
deleteReorderCalendar(dirDay, h, returnPoint);
}
private Day findTaskInDay(Task task)
......@@ -499,26 +494,31 @@ public class Calendar
// NOTE: Helper function until I make the interface
public void deleteTask(Day day, Task task)
{
// use findTaskInDay to find the day when you're given only the task
for (int i = 0; i < day.tasks.Count; ++i)
int additional = 0;
if (task.isSplit)
{
if (day.tasks[i].Equals(task))
{
day.removeTask(task);
deleteReorderCalendar(days[days.Count - 1], task.duration, day.prevDay);
}
day.nextDay.removeTask(task.splitTaskPtr);
task.isSplit = false;
additional = task.splitTaskPtr.duration;
deleteReorderCalendar(days[days.Count - 1], task.splitTaskPtr.duration, day.nextDay);
}
day.removeTask(task);
deleteReorderCalendar(days[days.Count - 1], task.duration, day);
}
public void deleteTaskRunHelper(Task task)
{