From 2f9935b4fd0c9484bc3f8d98f5dffe836fde96f3 Mon Sep 17 00:00:00 2001 From: Khalitova Angelina Date: Mon, 16 Oct 2023 20:20:21 +0400 Subject: [PATCH] reworked --- tasks/khalitova-am/lab_2/README.md | 2 +- tasks/khalitova-am/lab_2/worker-2/Program.cs | 17 ++---- tasks/tasks.sln | 59 ++++++++++++++++++++ 3 files changed, 65 insertions(+), 13 deletions(-) create mode 100644 tasks/tasks.sln diff --git a/tasks/khalitova-am/lab_2/README.md b/tasks/khalitova-am/lab_2/README.md index fee3707..4c66ec0 100644 --- a/tasks/khalitova-am/lab_2/README.md +++ b/tasks/khalitova-am/lab_2/README.md @@ -28,7 +28,7 @@ dotnet new console worker-2 1. Каталог `./data` примонтирован в каталог `/var/data` для получения исходных данных программы №1. 2. Каталог `./result` примонтирован в каталог `/var/result` для перемещения промежуточных данных, полученных программой №1, для программы №2. И также каталог `./result` получает результаты работы программы №2. -Для каждой программы были созданы файлы Dockerfile с образами ([программа №1](worker-1/Dockerfile), [программа №2](worker-1/Dockerfile)) с описанием процесса сборки. +Для каждой программы были созданы файлы Dockerfile с образами ([программа №1](worker-1/Dockerfile), [программа №2](worker-2/Dockerfile)) с описанием процесса сборки. Был создан файл [docker-compose.yml](docker-compose.yml), в котором указан манифест для запуска распределённого приложения. Был создан файл [.dockerignore](.dockerignore). diff --git a/tasks/khalitova-am/lab_2/worker-2/Program.cs b/tasks/khalitova-am/lab_2/worker-2/Program.cs index 40b6894..9593ffd 100644 --- a/tasks/khalitova-am/lab_2/worker-2/Program.cs +++ b/tasks/khalitova-am/lab_2/worker-2/Program.cs @@ -1,25 +1,18 @@ using System.Text; -string[] numbers; -using (FileStream fstream = File.OpenRead("../../../../var/result/data.txt")){ - byte[] buffer = new byte[fstream.Length]; - await fstream.ReadAsync(buffer, 0, buffer.Length); - string text = Encoding.Default.GetString(buffer); - text = text.Replace("\r\n",";"); - numbers = text.Split(new char[]{';'}); -} +int[] numbers = File.ReadAllLines("../../../../var/data/data.txt").Select(x=> int.Parse(x)).ToArray(); int maxNumber = 0; int maxNumberCount = 0; foreach(var number in numbers){ - if(Convert.ToInt32(number) < maxNumber){ + if(number < maxNumber){ continue; } - if(Convert.ToInt32(number) == maxNumber){ + if(number == maxNumber){ maxNumberCount++; continue; } - if(Convert.ToInt32(number) > maxNumber){ - maxNumber = Convert.ToInt32(number); + if(number > maxNumber){ + maxNumber = number; maxNumberCount = 1; } } diff --git a/tasks/tasks.sln b/tasks/tasks.sln new file mode 100644 index 0000000..928dd2b --- /dev/null +++ b/tasks/tasks.sln @@ -0,0 +1,59 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.002.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "khalitova-am", "khalitova-am", "{CABA1E47-65E2-4BC9-9B9E-4B4A48CF3D92}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lab_2", "lab_2", "{1A52B567-2366-4E04-A355-5CE1E80D8793}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "worker-1", "khalitova-am\lab_2\worker-1\worker-1.csproj", "{24CC1B87-489A-41D4-8E89-C130855DABDC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "worker-2", "khalitova-am\lab_2\worker-2\worker-2.csproj", "{8CA9A132-88A8-4512-9E70-BD02D190B130}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "moiseev-vv", "moiseev-vv", "{21C16477-A6B3-4B84-8DB3-501EA6A8A91C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lab_2", "lab_2", "{23E063EE-98CE-4A16-8657-5C08875754F2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "worker-1", "moiseev-vv\lab_2\worker-1\worker-1.csproj", "{6ECAD440-DFC5-495B-9F32-85B974A997BD}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "worker-2", "moiseev-vv\lab_2\worker-2\worker-2.csproj", "{BFE36C43-8FBA-4D98-B164-DBC31ECB4A41}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {24CC1B87-489A-41D4-8E89-C130855DABDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {24CC1B87-489A-41D4-8E89-C130855DABDC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {24CC1B87-489A-41D4-8E89-C130855DABDC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {24CC1B87-489A-41D4-8E89-C130855DABDC}.Release|Any CPU.Build.0 = Release|Any CPU + {8CA9A132-88A8-4512-9E70-BD02D190B130}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8CA9A132-88A8-4512-9E70-BD02D190B130}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8CA9A132-88A8-4512-9E70-BD02D190B130}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8CA9A132-88A8-4512-9E70-BD02D190B130}.Release|Any CPU.Build.0 = Release|Any CPU + {6ECAD440-DFC5-495B-9F32-85B974A997BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6ECAD440-DFC5-495B-9F32-85B974A997BD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6ECAD440-DFC5-495B-9F32-85B974A997BD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6ECAD440-DFC5-495B-9F32-85B974A997BD}.Release|Any CPU.Build.0 = Release|Any CPU + {BFE36C43-8FBA-4D98-B164-DBC31ECB4A41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BFE36C43-8FBA-4D98-B164-DBC31ECB4A41}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BFE36C43-8FBA-4D98-B164-DBC31ECB4A41}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BFE36C43-8FBA-4D98-B164-DBC31ECB4A41}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {1A52B567-2366-4E04-A355-5CE1E80D8793} = {CABA1E47-65E2-4BC9-9B9E-4B4A48CF3D92} + {24CC1B87-489A-41D4-8E89-C130855DABDC} = {1A52B567-2366-4E04-A355-5CE1E80D8793} + {8CA9A132-88A8-4512-9E70-BD02D190B130} = {1A52B567-2366-4E04-A355-5CE1E80D8793} + {23E063EE-98CE-4A16-8657-5C08875754F2} = {21C16477-A6B3-4B84-8DB3-501EA6A8A91C} + {6ECAD440-DFC5-495B-9F32-85B974A997BD} = {23E063EE-98CE-4A16-8657-5C08875754F2} + {BFE36C43-8FBA-4D98-B164-DBC31ECB4A41} = {23E063EE-98CE-4A16-8657-5C08875754F2} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5D57BA72-7BD7-4EA2-8682-D44F2CC83FCD} + EndGlobalSection +EndGlobal