Skip to content

Commit 6ba04b3

Browse files
planockavplanockav
authored andcommitted
Add project files.
1 parent 9ddf47b commit 6ba04b3

File tree

90 files changed

+75392
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+75392
-0
lines changed

.vscode/launch.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
// Use IntelliSense to find out which attributes exist for C# debugging
6+
// Use hover for the description of the existing attributes
7+
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
8+
"name": ".NET Core Launch (web)",
9+
"type": "coreclr",
10+
"request": "launch",
11+
"preLaunchTask": "build",
12+
// If you have changed target frameworks, make sure to update the program path.
13+
"program": "${workspaceFolder}/eAndon MVC/bin/Debug/net6.0/eAndon MVC.dll",
14+
"args": [],
15+
"cwd": "${workspaceFolder}/eAndon MVC",
16+
"stopAtEntry": false,
17+
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
18+
"serverReadyAction": {
19+
"action": "openExternally",
20+
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
21+
},
22+
"env": {
23+
"ASPNETCORE_ENVIRONMENT": "Development"
24+
},
25+
"sourceFileMap": {
26+
"/Views": "${workspaceFolder}/Views"
27+
}
28+
},
29+
{
30+
"name": ".NET Core Attach",
31+
"type": "coreclr",
32+
"request": "attach"
33+
}
34+
]
35+
}

.vscode/tasks.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "build",
6+
"command": "dotnet",
7+
"type": "process",
8+
"args": [
9+
"build",
10+
"${workspaceFolder}/eAndon MVC/eAndon MVC.csproj",
11+
"/property:GenerateFullPaths=true",
12+
"/consoleloggerparameters:NoSummary"
13+
],
14+
"problemMatcher": "$msCompile"
15+
},
16+
{
17+
"label": "publish",
18+
"command": "dotnet",
19+
"type": "process",
20+
"args": [
21+
"publish",
22+
"${workspaceFolder}/eAndon MVC/eAndon MVC.csproj",
23+
"/property:GenerateFullPaths=true",
24+
"/consoleloggerparameters:NoSummary"
25+
],
26+
"problemMatcher": "$msCompile"
27+
},
28+
{
29+
"label": "watch",
30+
"command": "dotnet",
31+
"type": "process",
32+
"args": [
33+
"watch",
34+
"run",
35+
"--project",
36+
"${workspaceFolder}/eAndon MVC/eAndon MVC.csproj"
37+
],
38+
"problemMatcher": "$msCompile"
39+
}
40+
]
41+
}

eAndon MVC.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.4.33213.308
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eAndon MVC", "eAndon MVC\eAndon MVC.csproj", "{CC3FEC84-0971-4CE8-A19A-C73DCAC41796}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{CC3FEC84-0971-4CE8-A19A-C73DCAC41796}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{CC3FEC84-0971-4CE8-A19A-C73DCAC41796}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{CC3FEC84-0971-4CE8-A19A-C73DCAC41796}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{CC3FEC84-0971-4CE8-A19A-C73DCAC41796}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {59A7E187-DCF1-4C7E-AD6D-F9EBE6595C4F}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using System.Diagnostics;
3+
using eAndon_MVC.Models;
4+
using Microsoft.EntityFrameworkCore;
5+
6+
7+
namespace eAndon_MVC.Controllers
8+
{
9+
10+
public class HomeController : Controller
11+
{
12+
13+
private readonly MyDbContext _db;
14+
15+
public HomeController(MyDbContext db)
16+
{
17+
_db = db;
18+
}
19+
20+
public IActionResult Index()
21+
{
22+
var workcenters = _db.WorkcenterList?.OrderBy(w => w.WorkcenterRow).ToList();
23+
return View(workcenters);
24+
}
25+
26+
public IActionResult Overview()
27+
{
28+
var currentOverview = _db.WorkcenterList?.OrderBy(w => w.WorkcenterRow).ToList();
29+
var currentOverviewModel = new List<AndonTerminalModel>();
30+
31+
foreach (var workcenter in currentOverview)
32+
{
33+
var statusDefinitions = _db.StatusDefinition.ToList();
34+
35+
var statusValues = _db.WorkcenterList
36+
.Where(w => w.WorkcenterID == workcenter.WorkcenterID)
37+
.Select(w => new List<string> {
38+
statusDefinitions[0].StatusEnabled == true ? w.Status1 : "",
39+
statusDefinitions[1].StatusEnabled == true ? w.Status2 : "",
40+
statusDefinitions[2].StatusEnabled == true ? w.Status3 : "",
41+
statusDefinitions[3].StatusEnabled == true ? w.Status4 : "",
42+
statusDefinitions[4].StatusEnabled == true ? w.Status5 : "" })
43+
.FirstOrDefault();
44+
45+
// Create an instance of the custom model and populate it with the workcenter information and the status values
46+
var workcenterModel = new AndonTerminalModel
47+
{
48+
WorkcenterID = workcenter.WorkcenterID,
49+
WorkcenterName = workcenter.WorkcenterName,
50+
StatusDefinitions = statusDefinitions,
51+
StatusValues = statusValues
52+
};
53+
currentOverviewModel.Add(workcenterModel);
54+
}
55+
56+
return View(currentOverviewModel);
57+
}
58+
59+
60+
public IActionResult AndonTerminal(string workcenterID, string workcenterName)
61+
{
62+
63+
var statusDefinitions = _db.StatusDefinition.ToList();
64+
// Retrieve the status values for the workcenter from the database
65+
var statusValues = _db.WorkcenterList
66+
.Where(w => w.WorkcenterID == workcenterID)
67+
.Select(w => new List<string> { statusDefinitions[0].StatusEnabled == true ? w.Status1 : "",
68+
statusDefinitions[1].StatusEnabled == true ? w.Status2 : "",
69+
statusDefinitions[2].StatusEnabled == true ? w.Status3 : "",
70+
statusDefinitions[3].StatusEnabled == true ? w.Status4 : "",
71+
statusDefinitions[4].StatusEnabled == true ? w.Status5 : ""})
72+
.FirstOrDefault();
73+
74+
// Create an instance of the custom model and populate it with the workcenter information and the status values
75+
var model = new AndonTerminalModel
76+
{
77+
WorkcenterID = workcenterID,
78+
WorkcenterName = workcenterName,
79+
StatusDefinitions = statusDefinitions,
80+
StatusValues = statusValues
81+
};
82+
83+
return View(model);
84+
85+
}
86+
87+
public IActionResult UpdateStatus(string workcenterID, int statusIndex)
88+
{
89+
var workcenter = _db.WorkcenterList.FirstOrDefault(w => w.WorkcenterID == workcenterID);
90+
91+
var statusProperty = typeof(Workcenter).GetProperties().ElementAt(statusIndex + 3); // +3 because Status1 to Status5 are properties 3 to 7
92+
var currentStatus = (string)statusProperty.GetValue(workcenter);
93+
var newStatus = currentStatus == "green" ? "red" : "green";
94+
statusProperty.SetValue(workcenter, newStatus);
95+
96+
var logEntry = new WorkcenterStatusLog
97+
{
98+
WorkcenterID = workcenterID,
99+
StatusIndex = statusIndex,
100+
OldStatus = currentStatus,
101+
NewStatus = newStatus,
102+
ChangeDateTime = DateTime.Now
103+
};
104+
105+
_db.WorkcenterStatusLog.Add(logEntry);
106+
_db.SaveChanges();
107+
108+
return Content(newStatus);
109+
}
110+
111+
public IActionResult Log(DateTime? startDate, DateTime? endDate, string workcenterID)
112+
{
113+
var logs = _db.WorkcenterStatusLog.AsQueryable();
114+
115+
if (startDate != null)
116+
{
117+
logs = logs.Where(l => l.ChangeDateTime >= startDate);
118+
}
119+
120+
if (endDate != null)
121+
{
122+
logs = logs.Where(l => l.ChangeDateTime <= endDate);
123+
}
124+
125+
if (!string.IsNullOrEmpty(workcenterID))
126+
{
127+
logs = logs.Where(l => l.WorkcenterID == workcenterID);
128+
}
129+
130+
ViewBag.Workcenters = _db.WorkcenterList.Select(w => w.WorkcenterID).Distinct().ToList();
131+
ViewBag.StatusDefinitions = _db.StatusDefinition.ToList();
132+
133+
return View(logs.ToList());
134+
}
135+
136+
137+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
138+
public IActionResult Error()
139+
{
140+
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
141+
}
142+
}
143+
}

0 commit comments

Comments
 (0)