Explorar el Código

Version estable

ricardo valls hace 3 años
padre
commit
77bc66b596
Se han modificado 60 ficheros con 5719 adiciones y 0 borrados
  1. 25 0
      WorkerService1/WebApplication3/Clases/Constants.cs
  2. 13 0
      WorkerService1/WebApplication3/Clases/DatosPostAcuifero.cs
  3. 13 0
      WorkerService1/WebApplication3/Clases/DatosPostSimulacion.cs
  4. 20 0
      WorkerService1/WebApplication3/Clases/DatosPozoRecarga.cs
  5. 15 0
      WorkerService1/WebApplication3/Clases/Feature.cs
  6. 13 0
      WorkerService1/WebApplication3/Clases/Fichero.cs
  7. 16 0
      WorkerService1/WebApplication3/Clases/GeoJson.cs
  8. 14 0
      WorkerService1/WebApplication3/Clases/Geometry.cs
  9. 46 0
      WorkerService1/WebApplication3/Clases/Logger.cs
  10. 779 0
      WorkerService1/WebApplication3/Clases/Parser.cs
  11. 35 0
      WorkerService1/WebApplication3/Clases/PiezometerData.cs
  12. 131 0
      WorkerService1/WebApplication3/Clases/Proceso.cs
  13. 64 0
      WorkerService1/WebApplication3/Clases/QueueWorker.cs
  14. 13 0
      WorkerService1/WebApplication3/Clases/Rate.cs
  15. 28 0
      WorkerService1/WebApplication3/Clases/RechargeData.cs
  16. 13 0
      WorkerService1/WebApplication3/Clases/TimeSerie.cs
  17. 18 0
      WorkerService1/WebApplication3/Clases/TimeSerieInterno.cs
  18. 65 0
      WorkerService1/WebApplication3/Clases/Utilities.cs
  19. 63 0
      WorkerService1/WebApplication3/Clases/WellData.cs
  20. 66 0
      WorkerService1/WebApplication3/Clases/Worker.cs
  21. 56 0
      WorkerService1/WebApplication3/Clases/ZoneBalance.cs
  22. 59 0
      WorkerService1/WebApplication3/Clases/ZoneConnection.cs
  23. 79 0
      WorkerService1/WebApplication3/Clases/ZoneData.cs
  24. 283 0
      WorkerService1/WebApplication3/Controllers/AcuiferoController.cs
  25. 290 0
      WorkerService1/WebApplication3/Controllers/BalanceHidricoController.cs
  26. 156 0
      WorkerService1/WebApplication3/Controllers/PiezometerController.cs
  27. 151 0
      WorkerService1/WebApplication3/Controllers/PiezometriaController.cs
  28. 364 0
      WorkerService1/WebApplication3/Controllers/PozoController.cs
  29. 256 0
      WorkerService1/WebApplication3/Controllers/RecargasController.cs
  30. 173 0
      WorkerService1/WebApplication3/Controllers/ServiceQueueController.cs
  31. 312 0
      WorkerService1/WebApplication3/Controllers/ServicioController.cs
  32. 533 0
      WorkerService1/WebApplication3/Controllers/SimulacionController.cs
  33. 136 0
      WorkerService1/WebApplication3/Controllers/TsPiezometerController.cs
  34. 155 0
      WorkerService1/WebApplication3/Controllers/TsPozoController.cs
  35. 120 0
      WorkerService1/WebApplication3/Controllers/TsRecargaController.cs
  36. 17 0
      WorkerService1/WebApplication3/Models/Acuifero.cs
  37. 545 0
      WorkerService1/WebApplication3/Models/AquiferContext.cs
  38. 17 0
      WorkerService1/WebApplication3/Models/BalanceHidrico.cs
  39. 18 0
      WorkerService1/WebApplication3/Models/ConexionZonasIn.cs
  40. 18 0
      WorkerService1/WebApplication3/Models/ConexionZonasOut.cs
  41. 20 0
      WorkerService1/WebApplication3/Models/DatosBalanceIn.cs
  42. 20 0
      WorkerService1/WebApplication3/Models/DatosBalanceOut.cs
  43. 21 0
      WorkerService1/WebApplication3/Models/Piezometria.cs
  44. 20 0
      WorkerService1/WebApplication3/Models/Piezometro.cs
  45. 39 0
      WorkerService1/WebApplication3/Models/Pozo.cs
  46. 29 0
      WorkerService1/WebApplication3/Models/Recarga.cs
  47. 20 0
      WorkerService1/WebApplication3/Models/ServiceQueue.cs
  48. 18 0
      WorkerService1/WebApplication3/Models/Servicio.cs
  49. 15 0
      WorkerService1/WebApplication3/Models/Simulacion.cs
  50. 16 0
      WorkerService1/WebApplication3/Models/TSPiezometer.cs
  51. 31 0
      WorkerService1/WebApplication3/Models/TSPozo.cs
  52. 17 0
      WorkerService1/WebApplication3/Models/TSRecarga.cs
  53. 47 0
      WorkerService1/WebApplication3/Program.cs
  54. 68 0
      WorkerService1/WebApplication3/Startup.cs
  55. 95 0
      WorkerService1/WebApplication3/WebApplication3.csproj
  56. 9 0
      WorkerService1/WebApplication3/appsettings.Development.json
  57. 19 0
      WorkerService1/WebApplication3/appsettings.json
  58. 1 0
      WorkerService1/WebApplication3/install_service.bat
  59. 1 0
      WorkerService1/WebApplication3/uninstall_service.bat
  60. 25 0
      WorkerService1/WorkerService1.sln

+ 25 - 0
WorkerService1/WebApplication3/Clases/Constants.cs Ver fichero

@@ -0,0 +1,25 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+
6
+namespace WebApplication3.Clases
7
+{
8
+    public static class Constants
9
+    {
10
+        public const string PathZip = @"C:\Users\Admin\Desktop\";
11
+        public const string PathExtract = @"C:\Users\Admin\Desktop\TestExtract\";
12
+        public const string PathModflow = @"C:\Users\Admin\Downloads\MF2005.1_12\MF2005.1_12\bin\mf2005.exe";
13
+        public static readonly Dictionary<string, string> _recharge_geometry_colors = new()
14
+        {
15
+            { "1", "#003366" },
16
+            { "2", "#996699" },
17
+            { "3", "#CCFF33" },
18
+            { "4", "#00FF99" },
19
+            { "5", "#CC0000" },
20
+            { "6", "#FF6600" },
21
+            { "7", "#660099" },
22
+            { "8", "#266A2E" }
23
+        };
24
+    }
25
+}

+ 13 - 0
WorkerService1/WebApplication3/Clases/DatosPostAcuifero.cs Ver fichero

@@ -0,0 +1,13 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+
6
+namespace WebApplication3.Clases
7
+{
8
+    public class DatosPostAcuifero
9
+    {
10
+        public string Nombre { get; set; }
11
+        public Fichero Fichero { get; set; }
12
+    }
13
+}

+ 13 - 0
WorkerService1/WebApplication3/Clases/DatosPostSimulacion.cs Ver fichero

@@ -0,0 +1,13 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+
6
+namespace WebApplication3.Clases
7
+{
8
+    public class DatosPostSimulacion
9
+    {
10
+        public string Nombre { get; set; }
11
+        public Fichero Fichero { get; set; }
12
+    }
13
+}

+ 20 - 0
WorkerService1/WebApplication3/Clases/DatosPozoRecarga.cs Ver fichero

@@ -0,0 +1,20 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+
6
+namespace WebApplication3.Clases
7
+{
8
+    public class DatosPozoRecarga
9
+    {
10
+        public uint Id { get; set; }
11
+        public string Nombre { get; set; }
12
+        public uint? Acuifero { get; set; }
13
+        public uint? Simulacion { get; set; }
14
+        public string Minimo { get; set; }
15
+        public string Maximo { get; set; }
16
+        public string Latitud { get; set; }
17
+        public string Longitud { get; set; }
18
+        public TimeSerie[] Ts {get; set;}
19
+    }
20
+}

+ 15 - 0
WorkerService1/WebApplication3/Clases/Feature.cs Ver fichero

@@ -0,0 +1,15 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace WebApplication3.Clases
8
+{
9
+    public class Feature
10
+    {
11
+        public string Type { get; set; }
12
+        public string Properties { get; set; }
13
+        public Geometry Geometry { get; set; }
14
+    }
15
+}

+ 13 - 0
WorkerService1/WebApplication3/Clases/Fichero.cs Ver fichero

@@ -0,0 +1,13 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+
6
+namespace WebApplication3.Clases
7
+{
8
+    public class Fichero
9
+    {
10
+        public string Nombre { get; set; }
11
+        public string Base64 { get; set; }
12
+    }
13
+}

+ 16 - 0
WorkerService1/WebApplication3/Clases/GeoJson.cs Ver fichero

@@ -0,0 +1,16 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace WebApplication3.Clases
8
+{
9
+    public class GeoJson
10
+    {
11
+        public string Type { get; set; }
12
+        public string Creator { get; set; }
13
+        public Feature[] Features { get; set; }
14
+
15
+    }
16
+}

+ 14 - 0
WorkerService1/WebApplication3/Clases/Geometry.cs Ver fichero

@@ -0,0 +1,14 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace WebApplication3.Clases
8
+{
9
+    public class Geometry
10
+    {
11
+        public string Type { get; set; }
12
+        public List<List<float>> Coordinates { get; set; }
13
+    }
14
+}

+ 46 - 0
WorkerService1/WebApplication3/Clases/Logger.cs Ver fichero

@@ -0,0 +1,46 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using System.Diagnostics;
6
+using System.Net.Http;
7
+using System.IO;
8
+
9
+namespace WebApplication3.Clases
10
+{
11
+    class Logger
12
+    {
13
+        
14
+        private static readonly Logger _instancia = new Logger();
15
+        
16
+
17
+        private Logger()
18
+        {
19
+
20
+        }
21
+
22
+        public static Logger GetInstance() => _instancia;
23
+
24
+        public static void WriteLog(string message)
25
+        {
26
+            string path = @"C:\Users\Admin\Desktop\log.txt";
27
+
28
+            if (!File.Exists(path))
29
+            {
30
+                // Create a file to write to.
31
+                using (StreamWriter sw = File.CreateText(path))
32
+                {
33
+                    sw.WriteLine(DateTime.Now + " " + message);
34
+                }
35
+            }
36
+            else
37
+            {
38
+
39
+                using (StreamWriter sw = File.AppendText(path))
40
+                {
41
+                    sw.WriteLine(DateTime.Now + " " + message);
42
+                }
43
+            }
44
+        }
45
+    }
46
+}

+ 779 - 0
WorkerService1/WebApplication3/Clases/Parser.cs Ver fichero

@@ -0,0 +1,779 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using System.IO;
6
+using WebApplication3.Models;
7
+using System.Globalization;
8
+using Microsoft.VisualBasic.FileIO;
9
+
10
+namespace WebApplication3.Clases
11
+{
12
+    public class Parser
13
+    {
14
+        public WellData[] ParseWellData(string textFile)
15
+        {
16
+            if (File.Exists(textFile))
17
+            {
18
+                StreamReader file = new StreamReader(textFile);
19
+                //WellData[] wellData = null;
20
+                List<WellData> wellDataList = null;
21
+                
22
+                WellData wellData = null;
23
+                string ln;
24
+                int cont = 0;
25
+                int index = 0;
26
+                bool intervalSkipped = false;
27
+                int finalBloque = 0;
28
+                string[] values;
29
+
30
+
31
+                while ((ln = file.ReadLine()) != null)
32
+                {
33
+                    if (wellData == null)
34
+                    {
35
+                        //wellData = new WellData[int.Parse(ln)];
36
+                        wellDataList = new List<WellData>(int.Parse(ln));
37
+                        wellData = new WellData();
38
+                        cont++;
39
+                        continue;
40
+                    }
41
+
42
+                    if (!intervalSkipped)
43
+                    {
44
+                        switch (cont)
45
+                        {
46
+                            case 1:
47
+                                //wellData[index].ActiveFlag = (ln == "0") ? false : true;
48
+                                wellData.ActiveFlag = ln != "0";
49
+                                break;
50
+                            case 2:
51
+                                //wellData[index].WellName = ln;
52
+                                wellData.WellName = ln;
53
+                                break;
54
+                            case 3:
55
+                                //wellData[index].X = double.Parse(ln);
56
+                                wellData.X = ln;
57
+                                break;
58
+                            case 4:
59
+                                //wellData[index].Y = double.Parse(ln);
60
+                                wellData.Y = ln;
61
+                                break;
62
+                            case 5:
63
+                                //wellData[index].ZMin = ln;
64
+                                values = ln.Split(" ");
65
+                                wellData.ZMin = values[0].Replace(".", ",");
66
+                                break;
67
+                            case 6:
68
+                                //wellData[index].ZMax = ln;
69
+                                values = ln.Split(" ");
70
+                                wellData.ZMax = values[0].Replace(".", ",");
71
+                                break;
72
+                            case 7:
73
+                                //wellData[index].ScreenIntervals = int.Parse(ln);
74
+                                wellData.ScreenIntervals = int.Parse(ln);
75
+                                //cont += (wellData[index].ScreenIntervals * 2) - 1;
76
+                                intervalSkipped = true;
77
+                                //leemos tantas lineas hay como intervalos de pantalla (al ser 2 parametros por cada intervalo es nIntervalos * 2
78
+                                //for (int i = 0; i < wellData[index].ScreenIntervals * 2; i++)
79
+                                for (int i = 0; i < wellData.ScreenIntervals * 2; i++)
80
+                                {
81
+                                    file.ReadLine();
82
+                                    cont++;
83
+                                }
84
+
85
+                                break;
86
+                            default:
87
+                                break;
88
+                        }
89
+                    }
90
+                    else
91
+                    {
92
+                        //if (wellData[index].PumpPeriods == 0)
93
+                        if (wellData.PumpPeriods == 0)
94
+                        {
95
+                            //wellData[index].PumpPeriods = int.Parse(ln);
96
+                            wellData.PumpPeriods = int.Parse(ln);
97
+                            //se calcula en que linea termina el bloque del pozo
98
+                            //finalBloque = cont + wellData[index].PumpPeriods + 1;
99
+                            finalBloque = cont + 1 + wellData.PumpPeriods * 3;
100
+                        }
101
+                        else
102
+                        {
103
+                            TimeSerieInterno ts = new TimeSerieInterno();
104
+                            string aux = "";
105
+                            //Rate rate = new Rate();
106
+                            ts.Hora = ln;
107
+                            //rate.StartTime = float.Parse(ln.Replace('.', ','));
108
+
109
+                            ln = file.ReadLine();
110
+                            cont++;
111
+                            
112
+                            if(cont == finalBloque - 1)
113
+                            {
114
+                                aux = ln;
115
+                            }
116
+
117
+                            ln = file.ReadLine();
118
+                            cont++;
119
+                            //Separamos la cadena por " " 
120
+                            //TODO -> igual es un \t
121
+                            string[] exploded = ln.Split(" ");
122
+                            //Solo nos interesa el primer valor
123
+                            string value = exploded[0].Replace('.', ',');
124
+                            ts.Valor = value;
125
+                            ts.Info = ln.Replace(exploded[0] + ' ', "");
126
+                            //rate.Value = double.Parse(value);
127
+                            //wellData[index].Rates.Add(rate);
128
+                            wellData.Rates.Add(ts);
129
+
130
+                            if(aux != "")
131
+                            {
132
+                                ts = new TimeSerieInterno();
133
+                                ts.Hora = aux;
134
+                                ts.Valor = value;
135
+                                ts.Info = ln.Replace(exploded[0] + ' ', "");
136
+                                wellData.Rates.Add(ts);
137
+                            }
138
+                        }
139
+                    }
140
+
141
+                    cont++;
142
+
143
+                    //hemos llegado al final del primer bloque de pozo, preparamos para el siguiente
144
+                    if (finalBloque == cont)
145
+                    {
146
+                        intervalSkipped = false;
147
+                        index++;
148
+                        wellDataList.Add(wellData);
149
+                        wellData = new WellData();
150
+                        cont = 1;
151
+                    }
152
+
153
+                }
154
+                file.Close();
155
+
156
+                return wellDataList.ToArray();
157
+            }
158
+
159
+            return null;
160
+        }
161
+
162
+        public RechargeData[] ParseRechargeData(string textFile,out string recharge_geometry)
163
+        {
164
+            List<RechargeData> recharges = new List<RechargeData>();
165
+            RechargeData rechargeData = null;
166
+            TimeSerieInterno timeSerie;
167
+            string rechargeProperty="";
168
+            recharge_geometry = "";
169
+
170
+            if (File.Exists(textFile))
171
+            {
172
+                Console.WriteLine("File exist");
173
+                string text = File.ReadAllText(textFile);
174
+                string[] data = text.Split("\r\n\r\n");
175
+
176
+                int layers = int.Parse(data[0][0].ToString());
177
+                int blankLinePerBlock = layers + 1;
178
+                int rechargeBlockInex = blankLinePerBlock * 2;
179
+
180
+                Console.WriteLine(data[rechargeBlockInex]);
181
+                string[] explode = data[rechargeBlockInex].Split("\r\n");
182
+
183
+                for(int i = 3; i < explode.Length; i++)
184
+                {
185
+                    string[] values = explode[i].Split(" ", StringSplitOptions.RemoveEmptyEntries);
186
+
187
+                    //Si hay cambio de propiedad se crea otro RechargeData
188
+                    if(rechargeProperty != values[0])
189
+                    {
190
+                        if(rechargeProperty != "")
191
+                        {
192
+                            recharges.Add(rechargeData);
193
+                        }
194
+
195
+                        rechargeData = new RechargeData();
196
+                        rechargeData.Nombre = "Recarga_" + values[0];
197
+                        rechargeProperty = values[0];
198
+                    }
199
+
200
+                    timeSerie = new TimeSerieInterno();
201
+                    timeSerie.Hora = values[2];
202
+                    timeSerie.Valor = values[1];
203
+                    timeSerie.Info = values[4] + " " + values[5];
204
+
205
+                    rechargeData.Rates.Add(timeSerie);
206
+                    
207
+                    //se anyade el ultimo registro de tiempo ya que solo nos quedamos con la primera marca de tiempo de cada linea
208
+                    if(i == explode.Length - 1)
209
+                    {
210
+                        timeSerie = new TimeSerieInterno();
211
+                        timeSerie.Hora = values[3];
212
+                        timeSerie.Valor = values[1];
213
+                        timeSerie.Info = values[4] + " " + values[5];
214
+                        rechargeData.Rates.Add(timeSerie);
215
+                    }
216
+                }
217
+                recharge_geometry = data[rechargeBlockInex + layers];
218
+
219
+                //Se anyade la ultima instancia de rechargeData ya que no se produce cambio en la ultima iteracion del bucle
220
+                recharges.Add(rechargeData);
221
+
222
+                return recharges.ToArray();
223
+            }
224
+            else
225
+            {
226
+                Console.WriteLine("File does not exist");
227
+            }
228
+
229
+            return null;
230
+        }
231
+
232
+        public List<string> ParseInFile(string textFile)
233
+        {
234
+            Console.WriteLine("File exist");
235
+            string text = File.ReadAllText(textFile);
236
+
237
+            List<string> lines = new();
238
+            List<string> aux = new();
239
+
240
+            //Introducimos todas las lineas
241
+            aux.AddRange(text.Split("\r\n").ToList());
242
+
243
+            //Se eliminan las referencias a ficheros que no son validos para el modelo
244
+
245
+            aux.RemoveAll(x => x.Contains("WHS") || x.Contains("NDC") || x.Contains("CLB") || x == "");
246
+
247
+            foreach (string row in aux)
248
+            {
249
+                string[] rowSplit = row.Split(" ", StringSplitOptions.RemoveEmptyEntries);
250
+                Console.WriteLine(rowSplit);
251
+
252
+                if (rowSplit[0] == "LIST" && int.Parse(rowSplit[1]) < 10)
253
+                {
254
+                    rowSplit[1] = "12";
255
+                }
256
+
257
+                //Se tiene que parsear la 3a parte del string porque contiene la ruta absoluta del ordenador donde se han originado los ficheros
258
+                List<string> ficheroSplit = rowSplit[2].Split("\\").ToList();
259
+                rowSplit[2] = ficheroSplit.Last();
260
+
261
+                lines.Add(rowSplit[0] + " " + rowSplit[1] + " " + rowSplit[2]);
262
+            }
263
+            return lines;
264
+
265
+        }
266
+
267
+        public ZoneBalance[] ParseZonesBalance(string textFile)
268
+        {
269
+
270
+            List<ZoneBalance> zonesOutput = new List<ZoneBalance>();
271
+                
272
+            string text = File.ReadAllText(textFile);
273
+            string[] data = text.Split(" test                                                                            \r\n \r\n", StringSplitOptions.RemoveEmptyEntries);
274
+
275
+            List<string> data_aux = data[1].Split("\r\n").ToList();
276
+            string zones = data_aux.Find(x => x.Contains("zones"));
277
+            int index = data_aux.IndexOf(zones);
278
+            string[] zone_names = data_aux[index + 1].Split("    ", StringSplitOptions.RemoveEmptyEntries);
279
+            int zonesConectionPerZone = zone_names.Length - 1;
280
+            Logger logger = Logger.GetInstance();
281
+
282
+
283
+            for (int z = 2; z < data.Length; z++)
284
+            {
285
+                List<string> balanceData = data[z].Split("\r\n", StringSplitOptions.RemoveEmptyEntries).ToList();
286
+                ZoneBalance zoneBalance = new ZoneBalance();
287
+
288
+
289
+
290
+                string storage, constantHead, drains, recharge, total, percentDisparity;
291
+                string auxFind, auxSplit, zoneConnectionLine;
292
+                string[] split;
293
+
294
+                split = balanceData[0].Trim().Split(" ", StringSplitOptions.RemoveEmptyEntries);
295
+                zoneBalance.Zone = split[4];
296
+                zoneBalance.StressPeriod = int.Parse(split[12]);
297
+
298
+
299
+                #region IN
300
+                //buscamos el indice en el cual empieza el bloque de los datos de salida
301
+                auxFind = balanceData.Find(x => x.Contains("IN:"));
302
+                index = balanceData.IndexOf(auxFind);
303
+
304
+                //el primer dado del bloque se encuentra 2 indices despues del obtenido
305
+                index += 2;
306
+
307
+                auxSplit = balanceData[index].Split("STORAGE =")[1];
308
+                storage = auxSplit;
309
+                index++;
310
+
311
+                auxSplit = balanceData[index].Split("CONSTANT HEAD =")[1].Trim();
312
+                constantHead = auxSplit;
313
+                index++;
314
+
315
+                auxSplit = balanceData[index].Split("DRAINS =")[1].Trim();
316
+                drains = auxSplit;
317
+                index++;
318
+
319
+                auxSplit = balanceData[index].Split("RECHARGE =")[1].Trim();
320
+                recharge = auxSplit;
321
+                index++;
322
+
323
+                //Zone connections 
324
+                for (int i = index; i < index + zonesConectionPerZone; i++)
325
+                {
326
+                    zoneConnectionLine = balanceData[i].Trim();
327
+                    split = zoneConnectionLine.Split("to");
328
+
329
+                    ZoneConnection zoneConnection = new ZoneConnection();
330
+                    zoneConnection.From = split[0].Split("Zone")[1].Trim();
331
+                    zoneConnection.To = split[1].Split("=")[0].Trim();
332
+                    zoneConnection.Value = split[1].Split("=")[1].Trim();
333
+
334
+                    zoneBalance.In.ZoneConnections.Add(zoneConnection);
335
+                }
336
+
337
+                //Para el total hay que buscar el indice porque al haber fluctuacion entre zonas no podemos saber el indice fijo de la linea donde se encuentra de forma directa
338
+                auxFind = balanceData.Find(x => x.Contains("Total IN"));
339
+                index = balanceData.IndexOf(auxFind);
340
+                auxSplit = balanceData[index].Split("Total IN =")[1].Trim();
341
+                total = auxSplit;
342
+
343
+                zoneBalance.In.Storage = storage;
344
+                zoneBalance.In.ConstantHead = constantHead;
345
+                zoneBalance.In.Drains = drains;
346
+                zoneBalance.In.Recharge = recharge;
347
+                zoneBalance.In.Total = total;
348
+                #endregion
349
+
350
+                #region OUT
351
+                //buscamos el indice en el cual empieza el bloque de los datos de salida
352
+                auxFind = balanceData.Find(x => x.Contains("OUT:"));
353
+                index = balanceData.IndexOf(auxFind);
354
+
355
+                //el primer dado del bloque se encuentra 2 indices despues del obtenido
356
+                index += 2;
357
+
358
+                auxSplit = balanceData[index].Split("STORAGE =")[1];
359
+                storage = auxSplit;
360
+                index++;
361
+
362
+                auxSplit = balanceData[index].Split("CONSTANT HEAD =")[1].Trim();
363
+                constantHead = auxSplit;
364
+                index++;
365
+
366
+                auxSplit = balanceData[index].Split("DRAINS =")[1].Trim();
367
+                drains = auxSplit;
368
+                index++;
369
+
370
+                auxSplit = balanceData[index].Split("RECHARGE =")[1].Trim();
371
+                recharge = auxSplit;
372
+                index++;
373
+
374
+                //Zone connections
375
+                for (int i = index; i < index + zonesConectionPerZone; i++)
376
+                {
377
+                    zoneConnectionLine = balanceData[i].Trim();
378
+                    split = zoneConnectionLine.Split("to");
379
+
380
+                    ZoneConnection zoneConnection = new ZoneConnection();
381
+                    zoneConnection.From = split[0].Split("Zone")[1].Trim();
382
+                    zoneConnection.To = split[1].Split("=")[0].Trim();
383
+                    zoneConnection.Value = split[1].Split("=")[1].Trim();
384
+
385
+                    zoneBalance.Out.ZoneConnections.Add(zoneConnection);
386
+                }
387
+
388
+                //Para el total hay que buscar el indice porque al haber fluctuacion entre zonas no podemos saber el indice fijo de la linea donde se encuentra de forma directa
389
+                auxFind = balanceData.Find(x => x.Contains("Total OUT"));
390
+                index = balanceData.IndexOf(auxFind);
391
+                auxSplit = balanceData[index].Split("Total OUT =")[1].Trim();
392
+                total = auxSplit;
393
+
394
+                zoneBalance.Out.Storage = storage;
395
+                zoneBalance.Out.ConstantHead = constantHead;
396
+                zoneBalance.Out.Drains = drains;
397
+                zoneBalance.Out.Recharge = recharge;
398
+                zoneBalance.Out.Total = total;
399
+                #endregion
400
+
401
+                auxFind = balanceData.Find(x => x.Contains("IN - OUT"));
402
+                index = balanceData.IndexOf(auxFind);
403
+
404
+                auxSplit = balanceData[index].Split("IN - OUT = ")[1].Trim();
405
+                total = auxSplit;
406
+
407
+                auxFind = balanceData.Find(x => x.Contains("Percent Discrepancy = "));
408
+                index = balanceData.IndexOf(auxFind);
409
+                auxSplit = balanceData[index].Split("Percent Discrepancy = ")[1].Trim();
410
+                percentDisparity = auxSplit;
411
+
412
+                zoneBalance.TotalInOut = total;
413
+                zoneBalance.PercentDiscrepancy = percentDisparity;
414
+
415
+                zonesOutput.Add(zoneBalance);
416
+            }
417
+            return zonesOutput.ToArray();
418
+        }
419
+
420
+        public ZoneBalance[] ParseWholeModelBalance(string textfile)
421
+        {
422
+            
423
+            string text = File.ReadAllText(textfile);
424
+            string[] data = text.Split(" DRAWDOWN WILL BE SAVED ON UNIT  151 AT END OF TIME STEP   10, STRESS PERIOD", StringSplitOptions.RemoveEmptyEntries);
425
+
426
+            List<ZoneBalance> zoneBalances = new List<ZoneBalance>();
427
+
428
+
429
+            for (int i = 1; i < data.Length; i++)
430
+            {
431
+                ZoneBalance cummulative = new ZoneBalance();
432
+                ZoneBalance current = new ZoneBalance();
433
+
434
+                cummulative.Zone = "Zone 0";
435
+                cummulative.StressPeriod = i;
436
+                cummulative.Type = 1;
437
+
438
+                current.Zone = "Zone 0";
439
+                current.StressPeriod = i;
440
+                current.Type = 2;
441
+
442
+
443
+                List<string> data_aux = data[i].Split("\r\n").ToList();
444
+                string[] split = data_aux[2].Split("STRESS PERIOD");
445
+
446
+
447
+                #region IN
448
+                split = data_aux[10].Split("STORAGE =", StringSplitOptions.RemoveEmptyEntries);
449
+                cummulative.In.Storage = split[1].Trim();
450
+                current.In.Storage = split[2].Trim();
451
+
452
+                split = data_aux[11].Split("CONSTANT HEAD =", StringSplitOptions.RemoveEmptyEntries);
453
+                cummulative.In.ConstantHead = split[1].Trim();
454
+                current.In.ConstantHead = split[2].Trim();
455
+
456
+                split = data_aux[12].Split("DRAINS =", StringSplitOptions.RemoveEmptyEntries);
457
+                cummulative.In.Drains = split[1].Trim();
458
+                current.In.Drains = split[2].Trim();
459
+
460
+                split = data_aux[13].Split("RECHARGE =", StringSplitOptions.RemoveEmptyEntries);
461
+                cummulative.In.Recharge = split[1].Trim();
462
+                current.In.Recharge = split[2].Trim();
463
+
464
+                split = data_aux[15].Split("TOTAL IN =", StringSplitOptions.RemoveEmptyEntries);
465
+                cummulative.In.Total = split[1].Trim();
466
+                current.In.Total = split[2].Trim();
467
+                #endregion
468
+
469
+                #region OUT
470
+                split = data_aux[19].Split("STORAGE =", StringSplitOptions.RemoveEmptyEntries);
471
+                cummulative.Out.Storage = split[1].Trim();
472
+                current.Out.Storage = split[2].Trim();
473
+
474
+                split = data_aux[20].Split("CONSTANT HEAD =", StringSplitOptions.RemoveEmptyEntries);
475
+                cummulative.Out.ConstantHead = split[1].Trim();
476
+                current.Out.ConstantHead = split[2].Trim();
477
+
478
+                split = data_aux[21].Split("DRAINS =", StringSplitOptions.RemoveEmptyEntries);
479
+                cummulative.Out.Drains = split[1].Trim();
480
+                current.Out.Drains = split[2].Trim();
481
+
482
+                split = data_aux[22].Split("RECHARGE =", StringSplitOptions.RemoveEmptyEntries);
483
+                cummulative.Out.Recharge = split[1].Trim();
484
+                current.Out.Recharge = split[2].Trim();
485
+
486
+                split = data_aux[24].Split("TOTAL OUT =", StringSplitOptions.RemoveEmptyEntries);
487
+                cummulative.Out.Total = split[1].Trim();
488
+                current.Out.Total = split[2].Trim();
489
+                #endregion
490
+
491
+                split = data_aux[26].Split("IN - OUT =", StringSplitOptions.RemoveEmptyEntries);
492
+                cummulative.TotalInOut = split[1].Trim();
493
+                current.TotalInOut = split[2].Trim();
494
+
495
+                split = data_aux[28].Split("PERCENT DISCREPANCY =", StringSplitOptions.RemoveEmptyEntries);
496
+                cummulative.PercentDiscrepancy = split[1].Trim();
497
+                current.PercentDiscrepancy = split[2].Trim();
498
+
499
+                zoneBalances.Add(cummulative);
500
+                zoneBalances.Add(current);
501
+            }
502
+
503
+            return zoneBalances.ToArray();
504
+        }
505
+
506
+        public List<Piezometria> ParseBinaryFile(string file, uint? simulacionId)
507
+        {
508
+            List<Piezometria> piezometria = new List<Piezometria>();
509
+            Logger.WriteLog("Parseando fichero binario");
510
+            if (File.Exists(file))
511
+            {
512
+                try
513
+                {
514
+                    using (FileStream fs = new FileStream(file, FileMode.Open))
515
+                    using (BinaryReader brr = new BinaryReader(fs))
516
+                    {
517
+                        Logger.WriteLog("Fichero existente y abierto");
518
+                        while (fs.Length != fs.Position) // This will throw an exception for non-seekable streams (stream.CanSeek == false), but filestreams are seekable so it's OK here
519
+                        {
520
+                            Piezometria p = new();
521
+                            p.IdSimulacion = simulacionId;
522
+
523
+                            int KSTP = brr.ReadInt32();
524
+                            int KPER = brr.ReadInt32();
525
+                            var PERTIM = brr.ReadSingle();
526
+                            var TOTIM = brr.ReadSingle();
527
+                            char[] auxDESC = brr.ReadChars(16);
528
+                            string DESC = new(auxDESC);
529
+                            int NCOL = brr.ReadInt32();
530
+                            int NROW = brr.ReadInt32();
531
+                            int ILAY = brr.ReadInt32();
532
+
533
+                            p.Layer = ILAY;
534
+                            p.StressPeriod = KPER;
535
+                            p.Rows = NROW;
536
+                            p.Columns = NCOL;
537
+
538
+                            List<float> values = new();
539
+                            for (int i = 0; i < NROW * NCOL; i++)
540
+                            {
541
+                                values.Add(brr.ReadSingle());
542
+                            }
543
+
544
+
545
+                            int c = 1;
546
+                            string original = "";
547
+                            string convertida = "";
548
+                            foreach (float v in values)
549
+                            {
550
+                                if (c < NCOL)
551
+                                {
552
+                                    original += v + "   ";
553
+
554
+                                    //Check for range + color conversion
555
+                                    //convertida += Constants.piezometry_conversion[v.ToString()] + ",";
556
+                                }
557
+                                else if (c == NCOL)
558
+                                {
559
+                                    //Add \n to the string
560
+                                    original += "\n";
561
+                                    //convertida += "\n";
562
+                                    c = 0;
563
+                                }
564
+                                c++;
565
+                            }
566
+                            p.Original = original;
567
+                            p.Convertida = convertida;
568
+
569
+                            piezometria.Add(p);
570
+                            
571
+                        }
572
+                    }
573
+                }catch(Exception ex)
574
+                {
575
+                    Logger.WriteLog(ex.Message);
576
+                    Logger.WriteLog(ex.InnerException.Message);
577
+                }
578
+            }
579
+            return piezometria;
580
+        }
581
+
582
+        public void GetGeolocalizationFromFile(string file,out string worldX,out string worldY)
583
+        {
584
+
585
+            string text = File.ReadAllText(file);
586
+
587
+            List<string> data = text.Split("\r\n").ToList();
588
+            //string geolocationData = data[2];
589
+            string geolocation_line = data.Find(x=> x.Contains("<Georeference"));
590
+
591
+            string[] geolocation_data = geolocation_line.Split(" ");
592
+            string[] world_origin_x = geolocation_data[1].Split("=");
593
+            string[] world_origin_y = geolocation_data[2].Split("=");
594
+
595
+            
596
+            worldX = world_origin_x[1].Replace("\"",string.Empty);
597
+            worldY = world_origin_y[1].Replace("\"",string.Empty);
598
+        }
599
+
600
+        public WellData[] parseWellCSV(string file)
601
+        {
602
+            List<WellData> wellsData = new();
603
+            WellData wellData = null;
604
+            using (TextFieldParser csvParser = new TextFieldParser(file))
605
+            {
606
+                csvParser.CommentTokens = new string[] { "#" };
607
+                csvParser.SetDelimiters(new string[] { "," });
608
+                csvParser.HasFieldsEnclosedInQuotes = true;
609
+
610
+                // Skip the row with the column names
611
+                csvParser.ReadLine();
612
+                string wellName = "";
613
+                string[] aux = Array.Empty<string>();
614
+                TimeSerieInterno tsInterno;
615
+                int pumpPeriods = 0;
616
+                while (!csvParser.EndOfData)
617
+                {
618
+                    // Read current line fields, pointer moves to the next line.
619
+                    string[] fields = csvParser.ReadFields();
620
+                    if (wellName != fields[0])
621
+                    {
622
+
623
+                        if (wellName == "")
624
+                        {
625
+                            aux = new string[fields.Length];
626
+                        }
627
+                        else
628
+                        {
629
+
630
+                            wellData.PumpPeriods = pumpPeriods;
631
+                            wellsData.Add(wellData);
632
+
633
+                            tsInterno = new();
634
+                            tsInterno.Hora = aux[11];
635
+                            tsInterno.Valor = aux[12];
636
+                            wellData.Rates.Add(tsInterno);
637
+                            pumpPeriods = 0;
638
+                        }
639
+
640
+                        wellData = new();
641
+                        wellData.WellName = fields[0];
642
+                        wellData.X = fields[1];
643
+                        wellData.Y = fields[2];
644
+                        wellData.Top = fields[5];
645
+                        wellData.Bot = fields[6];
646
+                        wellData.ZMin = fields[4];
647
+                        wellData.ZMax = fields[3];
648
+                        wellData.ScreenIntervals = 1;
649
+                        //wellData.ZMin = "";
650
+                        //wellData.ZMax = "";
651
+                        wellData.ActiveFlag = false;
652
+                        
653
+                        wellName = fields[0];
654
+                        
655
+                    }
656
+
657
+                    tsInterno = new ();
658
+                    tsInterno.Hora = fields[10];
659
+                    tsInterno.Valor = fields[12];
660
+
661
+                    wellData.Rates.Add(tsInterno);
662
+                    fields.CopyTo(aux, 0);
663
+                    pumpPeriods++;
664
+                }
665
+
666
+                wellData.PumpPeriods = pumpPeriods;
667
+
668
+                tsInterno = new();
669
+                tsInterno.Hora = aux[11];
670
+                tsInterno.Valor = aux[12];
671
+                wellData.Rates.Add(tsInterno);
672
+                wellsData.Add(wellData);
673
+            }
674
+
675
+            return wellsData.ToArray();
676
+        }
677
+
678
+        public RechargeData[] parseRechargeCSV(string file)
679
+        {
680
+            List<RechargeData> rechargeDatas = new();
681
+            RechargeData rechargeData = new();
682
+            TimeSerieInterno ts;
683
+            string[] aux = Array.Empty<string>();
684
+            using (TextFieldParser csvParser = new TextFieldParser(file))
685
+            {
686
+                csvParser.CommentTokens = new string[] { "#" };
687
+                csvParser.SetDelimiters(new string[] { "," });
688
+                csvParser.HasFieldsEnclosedInQuotes = true;
689
+
690
+                // Skip the row with the column names
691
+                csvParser.ReadLine();
692
+
693
+                while (!csvParser.EndOfData)
694
+                {
695
+                    // Read current line fields, pointer moves to the next line.
696
+                    string[] fields = csvParser.ReadFields();
697
+
698
+                    if(rechargeData.Nombre == null)
699
+                    {
700
+                        rechargeData.Nombre = fields[0];
701
+                        aux = new string[fields.Length];
702
+                    }
703
+
704
+                    ts = new();
705
+                    ts.Valor = fields[3];
706
+                    ts.Hora = fields[1];
707
+                    //ts.HoraEnd = fields[2];
708
+                    rechargeData.Rates.Add(ts);
709
+                    fields.CopyTo(aux, 0);
710
+                }
711
+
712
+                ts = new();
713
+                ts.Valor = aux[3];
714
+                ts.Hora = aux[2];
715
+                //ts.HoraEnd = fields[2];
716
+                rechargeData.Rates.Add(ts);
717
+                rechargeDatas.Add(rechargeData);
718
+            }
719
+
720
+
721
+            return rechargeDatas.ToArray();
722
+        }
723
+
724
+        public PiezometerData[] parsePiezometerCSV(string file)
725
+        {
726
+            List<PiezometerData> piezometerDatas = new();
727
+            PiezometerData piezometerData = null;
728
+            TimeSerieInterno ts;
729
+            string[] aux = Array.Empty<string>();
730
+            string piezometerName = "";
731
+            using (TextFieldParser csvParser = new TextFieldParser(file))
732
+            {
733
+                csvParser.CommentTokens = new string[] { "#" };
734
+                csvParser.SetDelimiters(new string[] { "," });
735
+                csvParser.HasFieldsEnclosedInQuotes = true;
736
+
737
+                // Skip the row with the column names
738
+                csvParser.ReadLine();
739
+
740
+                while (!csvParser.EndOfData)
741
+                {
742
+                    // Read current line fields, pointer moves to the next line.
743
+                    string[] fields = csvParser.ReadFields();
744
+
745
+                    if (piezometerName != fields[0])
746
+                    {
747
+                        if(piezometerName == "")
748
+                        {
749
+                            aux = new string[fields.Length];
750
+                        }else
751
+                        {
752
+
753
+                        }
754
+
755
+                        piezometerData = new();
756
+                        piezometerData.Name = fields[0];
757
+                        piezometerData.X = fields[1];
758
+                        piezometerData.Y = fields[2];
759
+                        piezometerData.Z = fields[3];
760
+                        piezometerData.Prof = fields[4];
761
+                        piezometerData.Screen_top = fields[5];
762
+                        piezometerData.Screen_bot = fields[6];
763
+                    }
764
+
765
+                    ts = new();
766
+                    ts.DateIn = fields[8];
767
+                    ts.Hora = fields[9];
768
+                    ts.Valor = fields[10];
769
+                    
770
+                    piezometerData.Rates.Add(ts);
771
+                    //fields.CopyTo(aux, 0);
772
+                }
773
+            }
774
+
775
+
776
+            return piezometerDatas.ToArray();
777
+        }
778
+    }
779
+}

+ 35 - 0
WorkerService1/WebApplication3/Clases/PiezometerData.cs Ver fichero

@@ -0,0 +1,35 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using WebApplication3.Models;
6
+
7
+namespace WebApplication3.Clases
8
+{
9
+    public class PiezometerData
10
+    {
11
+        public string Name { get; set; }
12
+        public string X { get; set; }
13
+        public string Y { get; set; }
14
+        public string Z { get; set; }
15
+        public string Prof { get; set; }
16
+        public string Screen_top { get; set; }
17
+        public string Screen_bot { get; set; }
18
+        public List<TimeSerieInterno> Rates { get; set; }
19
+
20
+
21
+        public Piezometer ToPiezometer()
22
+        {
23
+            Piezometer piezometer = new();
24
+            piezometer.Name = this.Name;
25
+            piezometer.X = this.X;
26
+            piezometer.Y = this.Y;
27
+            piezometer.Z = this.Z;
28
+            piezometer.Prof = this.Prof;
29
+            piezometer.ScreenTop = this.Screen_top;
30
+            piezometer.ScreenBot = this.Screen_bot;
31
+
32
+            return piezometer;
33
+        }
34
+    }
35
+}

+ 131 - 0
WorkerService1/WebApplication3/Clases/Proceso.cs Ver fichero

@@ -0,0 +1,131 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using System.Diagnostics;
6
+using System.Net.Http;
7
+
8
+namespace WebApplication3.Clases
9
+{
10
+    class Proceso
11
+    {
12
+        private Process proceso;
13
+        private static readonly Proceso _instancia = new Proceso();
14
+        private bool _detected;
15
+        private bool _started;
16
+        private HttpClient client = new HttpClient();
17
+
18
+
19
+        private Proceso()
20
+        {
21
+            proceso = new Process();
22
+            //_proceso.StartInfo.WorkingDirectory = "C:\\Users\\Admin\\Downloads\\00_Aquifer_Supervision_0 3\\00_Aquifer_Supervision_0\\TRASLADADO SIN EJECUTAR\\";
23
+            //_proceso.StartInfo.FileName = "mf2005.exe";
24
+            //_proceso.StartInfo.Arguments = "AA.modflow.in";
25
+            _detected = false;
26
+            _started = false;
27
+        }
28
+
29
+        public static Proceso GetInstance() => _instancia;
30
+
31
+        public void setParametersModflow(string workingDirectory, string arguments)
32
+        {
33
+            proceso.StartInfo.WorkingDirectory = workingDirectory;
34
+            proceso.StartInfo.FileName = @"C:\Users\Admin\Downloads\MF2005.1_12\MF2005.1_12\bin\mf2005.exe";
35
+            proceso.StartInfo.Arguments = arguments;
36
+            proceso.StartInfo.UseShellExecute = true;
37
+
38
+        }
39
+
40
+        public void setParametersZoneBudget(string workingDirectory)
41
+        {
42
+            proceso.StartInfo.WorkingDirectory = workingDirectory;
43
+            proceso.StartInfo.FileName = @"C:\WRDAPP\Zonbud.3_01\Bin\zonbud.exe";
44
+            proceso.StartInfo.Arguments = "";
45
+            proceso.StartInfo.RedirectStandardInput = true;
46
+
47
+        }
48
+
49
+        public void setParametersPython(string workingDirectory,string headFile, int rows, int cols, int isolines)
50
+        {
51
+            proceso.StartInfo.WorkingDirectory = workingDirectory;
52
+            //proceso.StartInfo.FileName = @"C:\Users\Admin\AppData\Local\Programs\Python\Python39\python.exe";
53
+            proceso.StartInfo.FileName = "python";
54
+            var script = @"C:\Users\Admin\Desktop\test.py";
55
+            proceso.StartInfo.Arguments = script+" "+headFile+" "+rows+" "+cols+" "+isolines;
56
+            proceso.StartInfo.UseShellExecute = false;
57
+        }
58
+        public int GetPid()
59
+        {
60
+            return proceso.Id;
61
+        }
62
+
63
+        public bool HasExited()
64
+        {
65
+            return proceso.HasExited;
66
+        }
67
+
68
+        public void Kill()
69
+        {
70
+            proceso.Kill();
71
+        }
72
+
73
+
74
+        public void Start()
75
+        {
76
+            proceso.Start();
77
+            _started = true;
78
+        }
79
+
80
+        public void ExecuteZonebudget(string[] prompts)
81
+        {
82
+            proceso.StandardInput.WriteLine(prompts[0]);
83
+            proceso.StandardInput.WriteLine(prompts[1]);
84
+            proceso.StandardInput.WriteLine(prompts[2]);
85
+            proceso.StandardInput.WriteLine(prompts[3]);
86
+            proceso.StandardInput.WriteLine(prompts[4]);
87
+            proceso.WaitForExit();
88
+        }
89
+
90
+        public void ResetProcess()
91
+        {
92
+            proceso.StartInfo.WorkingDirectory = "";
93
+            proceso.StartInfo.FileName = "";
94
+            proceso.StartInfo.Arguments = "";
95
+            proceso.StartInfo.RedirectStandardInput = false;
96
+            proceso.StartInfo.UseShellExecute = false;
97
+            _detected = false;
98
+            _started = false;
99
+        }
100
+
101
+        public void WaitForExit()
102
+        {
103
+            proceso.WaitForExit();
104
+        }
105
+
106
+        public bool Started
107
+        {
108
+            get
109
+            {
110
+                return _started;
111
+            }
112
+            set
113
+            {
114
+                _started = value;
115
+            }
116
+        }
117
+
118
+        public bool Detected
119
+        {
120
+            get
121
+            {
122
+                return _detected;
123
+            }
124
+            set
125
+            {
126
+                _detected = value;
127
+            }
128
+        }
129
+        
130
+    }
131
+}

+ 64 - 0
WorkerService1/WebApplication3/Clases/QueueWorker.cs Ver fichero

@@ -0,0 +1,64 @@
1
+using System;
2
+using System.Threading;
3
+using System.Threading.Tasks;
4
+using Microsoft.Extensions.Hosting;
5
+using Microsoft.Extensions.Logging;
6
+using WebApplication3.Clases;
7
+using System.IO;
8
+using WebApplication3.Controllers;
9
+using WebApplication3.Models;
10
+
11
+namespace WebApplication3.Clases
12
+{
13
+    public class QueueWorker : BackgroundService
14
+    {
15
+        private readonly ILogger<QueueWorker> _logger;
16
+        private ServicioController servicioController;
17
+        private SimulacionController simulacionController; 
18
+        private ServiceQueueController serviceQueueController;
19
+
20
+        public QueueWorker(ILogger<QueueWorker> logger)
21
+        {
22
+            _logger = logger;
23
+
24
+            var aquiferContext = new AquiferContext();
25
+            servicioController = new ServicioController(aquiferContext);
26
+            simulacionController = new SimulacionController(aquiferContext);
27
+            serviceQueueController = new ServiceQueueController(aquiferContext);
28
+        }
29
+
30
+        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
31
+        {
32
+            while (!stoppingToken.IsCancellationRequested)
33
+            {
34
+                _logger.LogInformation("HEY QUEUE WORKER HERE", DateTimeOffset.Now);
35
+
36
+                var serviceRunning = await serviceQueueController.ServiceRunning();
37
+                _logger.LogInformation(serviceRunning.ToString(), DateTimeOffset.Now);
38
+
39
+                if (serviceRunning == false)
40
+                {
41
+                    _logger.LogInformation("NOTHING RUNNING", DateTimeOffset.Now);
42
+                    var nextInQueue = serviceQueueController.GetNextInQueue();
43
+                    if (nextInQueue != null)
44
+                    {
45
+                        _logger.LogInformation("RUNNING A SIM", DateTimeOffset.Now);
46
+                        _logger.LogInformation(nextInQueue.Id.ToString(), DateTimeOffset.Now);
47
+                        //Actualizamos el estado del item del servicio/simulacion a ejecutar
48
+                        //await serviceQueueController.SetCorriendo(nextInQueue.Id);
49
+                        //Se ejecuta la simulacion
50
+                        await simulacionController.SimulaAsync(nextInQueue);
51
+                        ////Se actualiza el estado del item ya que ha terminado su ejecucion
52
+                        //await serviceQueueController.SetTerminado(nextInQueue.Id);
53
+                    }
54
+                }
55
+                await Task.Delay(TimeSpan.FromMinutes(2), stoppingToken);
56
+            }
57
+        }
58
+
59
+        public void LogInfo(string msg)
60
+        {
61
+            _logger.LogInformation(msg);
62
+        }
63
+    }
64
+}

+ 13 - 0
WorkerService1/WebApplication3/Clases/Rate.cs Ver fichero

@@ -0,0 +1,13 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+
6
+namespace WebApplication3.Clases
7
+{
8
+    public class Rate
9
+    {
10
+        public decimal StartTime { get; set; }
11
+        public decimal Value { get; set; }
12
+    }
13
+}

+ 28 - 0
WorkerService1/WebApplication3/Clases/RechargeData.cs Ver fichero

@@ -0,0 +1,28 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using WebApplication3.Models;
6
+
7
+namespace WebApplication3.Clases
8
+{
9
+    public class RechargeData
10
+    {
11
+        public RechargeData()
12
+        {
13
+            Rates = new List<TimeSerieInterno>();
14
+        }
15
+        public string Nombre { get; set; }
16
+        public List<TimeSerieInterno> Rates { get; set; }
17
+
18
+        public Recarga ToRecarga(uint acuifero)
19
+        {
20
+            Recarga recarga = new Recarga();
21
+
22
+            recarga.IdAcuifero = acuifero;
23
+            recarga.Nombre = this.Nombre;
24
+
25
+            return recarga;
26
+        }
27
+    }
28
+}

+ 13 - 0
WorkerService1/WebApplication3/Clases/TimeSerie.cs Ver fichero

@@ -0,0 +1,13 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+
6
+namespace WebApplication3.Clases
7
+{
8
+    public class TimeSerie
9
+    {
10
+        public string Hora { get; set; }
11
+        public string Valor { get; set; }
12
+    }
13
+}

+ 18 - 0
WorkerService1/WebApplication3/Clases/TimeSerieInterno.cs Ver fichero

@@ -0,0 +1,18 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+
6
+namespace WebApplication3.Clases
7
+{
8
+    public class TimeSerieInterno
9
+    {
10
+        public string Hora { get; set; }
11
+        public string HoraEnd { get; set; }
12
+        public string Valor { get; set; }
13
+        public string ValorEnd { get; set; }
14
+        public string DateIn { get; set; }
15
+        public string DateEnd { get; set; }
16
+        public string Info { get; set; }
17
+    }
18
+}

+ 65 - 0
WorkerService1/WebApplication3/Clases/Utilities.cs Ver fichero

@@ -0,0 +1,65 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Drawing;
4
+using System.Drawing.Imaging;
5
+using System.Linq;
6
+using System.Threading.Tasks;
7
+
8
+namespace WebApplication3.Clases
9
+{
10
+    public static class Utilities
11
+    {
12
+        public static bool String2Png(string data)
13
+        {
14
+            Logger.WriteLog("im in");
15
+            bool result = true;
16
+            List<string> rows = data.Split("\r\n",StringSplitOptions.RemoveEmptyEntries).ToList<string>();
17
+            Logger.WriteLog("rows has a lenght of" + rows.Count);
18
+            List<string> cols = rows[0].Split(" ",StringSplitOptions.RemoveEmptyEntries).ToList<string>();
19
+            Logger.WriteLog("cols has a length of " + cols.Count);
20
+            int width = cols.Count;
21
+            int height = rows.Count;
22
+            int[,] integers = new int[height, width];
23
+            int stride = width * 4;
24
+
25
+            string[,] array2Db = new string[height, width];
26
+            for(int i= 0; i < height; i++)
27
+            {
28
+                string[] values = rows[i].Split(" ",StringSplitOptions.RemoveEmptyEntries);
29
+                for(int j= 0; j< width; j++)
30
+                {
31
+                    string hexColor = Constants._recharge_geometry_colors[values[j]];
32
+                    array2Db[i, j] = hexColor;
33
+                }
34
+            }
35
+
36
+            // Fill array with random values
37
+            Random random = new Random();
38
+            for (int x = 0; x < height; ++x)
39
+            {
40
+                for (int y = 0; y < width; ++y)
41
+                {
42
+                    var color = System.Drawing.ColorTranslator.FromHtml(array2Db[x, y]);
43
+                    byte[] bgra = new byte[] { color.B, color.G, color.R, color.A };
44
+                    integers[x, y] = BitConverter.ToInt32(bgra, 0);
45
+                }
46
+            }
47
+
48
+            Bitmap b;
49
+            unsafe
50
+            {
51
+                fixed (int* intPtr = &integers[0, 0])
52
+                {
53
+                    b = new Bitmap(width, height, stride, PixelFormat.Format32bppRgb, new IntPtr(intPtr));
54
+                }
55
+            }
56
+
57
+
58
+            using (b)
59
+            {
60
+                b.Save(@"C:\Users\Admin\Desktop\AAAA\green.png", ImageFormat.Png);
61
+            }
62
+            return result;
63
+        }
64
+    }
65
+}

+ 63 - 0
WorkerService1/WebApplication3/Clases/WellData.cs Ver fichero

@@ -0,0 +1,63 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using WebApplication3.Models;
6
+
7
+namespace WebApplication3.Clases
8
+{
9
+    //public struct TextRates
10
+    //{
11
+    //    string init;
12
+    //    string finish;
13
+    //    string rate;
14
+    //}
15
+    public class WellData
16
+    {
17
+        public WellData()
18
+        {
19
+            Rates = new List<TimeSerieInterno>();
20
+            //StringRates = new List<TextRates>();
21
+        }
22
+
23
+        public bool ActiveFlag { get; set; }
24
+        public string WellName { get; set; }
25
+        public string X { get; set; }
26
+        public string Y { get; set; }
27
+        public string ZMin { get; set; }
28
+        public string ZMax { get; set; }
29
+        public int ScreenIntervals { get; set; }
30
+        public string Bot { get; set; }
31
+        public string Top { get; set; }
32
+        public int PumpPeriods { get; set; }
33
+        public List<TimeSerieInterno> Rates { get; set; }
34
+        
35
+
36
+
37
+        public Pozo ToPozo(uint acuifero)
38
+        {
39
+            Pozo p = new Pozo();
40
+
41
+            p.IdAquifero = acuifero;
42
+            p.IdSimulacion = null;
43
+            p.Longitud = this.X;
44
+            p.Latitud = this.Y;
45
+            //p.Maximo = float.Parse(this.ZMax);
46
+            p.Maximo = "0";
47
+            //p.Minimo = float.Parse(this.ZMin);
48
+            p.Minimo = "0";
49
+            p.Nombre = this.WellName;
50
+            return p;
51
+        }
52
+
53
+        public WellData Copy()
54
+        {
55
+            WellData wellData = new WellData();
56
+            wellData.ActiveFlag = this.ActiveFlag;
57
+            wellData.Bot = this.Bot;
58
+            wellData.PumpPeriods = this.PumpPeriods;
59
+            wellData.Rates = this.Rates;
60
+            return wellData;
61
+        }
62
+    }
63
+}

+ 66 - 0
WorkerService1/WebApplication3/Clases/Worker.cs Ver fichero

@@ -0,0 +1,66 @@
1
+using System;
2
+using System.Threading;
3
+using System.Threading.Tasks;
4
+using Microsoft.Extensions.Hosting;
5
+using Microsoft.Extensions.Logging;
6
+using WebApplication3.Clases;
7
+using System.IO;
8
+using WebApplication3.Controllers;
9
+using WebApplication3.Models;
10
+
11
+namespace WebApplication3.Clases
12
+{
13
+    public class Worker : BackgroundService
14
+    {
15
+        private readonly ILogger<Worker> _logger;
16
+        private ServicioController servicioController;
17
+        private ServiceQueueController serviceQueueController;
18
+
19
+        public Worker(ILogger<Worker> logger)
20
+        {
21
+            _logger = logger;
22
+
23
+            var aquiferContext = new AquiferContext();
24
+            servicioController = new ServicioController(aquiferContext);
25
+            serviceQueueController = new ServiceQueueController(aquiferContext);
26
+        }
27
+
28
+        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
29
+        {
30
+            
31
+            Proceso proceso = Proceso.GetInstance();
32
+
33
+            while (!stoppingToken.IsCancellationRequested)
34
+            {
35
+                
36
+                try
37
+                {
38
+                    //logger.LogInformation("Process is started: "+proceso.Started+" and has exited "+proceso.HasExited()+" at: "+ DateTimeOffset.Now);
39
+                    //_logger.LogInformation("STATE OF PID: "+proceso.GetPid().ToString()+"is "+proceso.HasExited());
40
+                    if (proceso.Started && proceso.HasExited())
41
+                    {
42
+                        proceso.Started = false;
43
+                        proceso.Detected = true;
44
+
45
+                        int terminado = await servicioController.setTerminado(proceso.GetPid());
46
+                        
47
+                        if( terminado > 0)
48
+                        {
49
+                            _logger.LogInformation("Process " + proceso.GetPid() + " has terminated", DateTimeOffset.Now);
50
+                        }
51
+
52
+                    }
53
+                } catch (Exception ex)
54
+                {
55
+                    _logger.LogInformation(ex.Message, DateTimeOffset.Now);
56
+                }
57
+                await Task.Delay(1000, stoppingToken);
58
+            }
59
+        }
60
+
61
+        public void LogInfo(string msg)
62
+        {
63
+            _logger.LogInformation(msg);
64
+        }
65
+    }
66
+}

+ 56 - 0
WorkerService1/WebApplication3/Clases/ZoneBalance.cs Ver fichero

@@ -0,0 +1,56 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using WebApplication3.Models;
6
+
7
+namespace WebApplication3.Clases
8
+{
9
+    public class ZoneBalance
10
+    {
11
+        public uint Id { get; set; }
12
+        public string Zone { get; set; }
13
+        public int StressPeriod { get; set; }
14
+        public ZoneData In { get; set; }
15
+        public ZoneData Out { get; set; }
16
+        public string TotalInOut { get; set; }
17
+        public string PercentDiscrepancy { get; set; }
18
+
19
+        /* 0-> Balance normal con conexion a otras zonas
20
+         * 1-> Balance acumulativo de la Zona 0
21
+         * 2-> Balance del periodo de stress concreto de la Zona 0
22
+        */
23
+        public int Type { get; set; }
24
+
25
+        public ZoneBalance()
26
+        {
27
+            In = new ZoneData();
28
+            Out = new ZoneData();
29
+        }
30
+
31
+        public ZoneBalance(BalanceHidrico bh)
32
+        {
33
+            Zone = bh.Zona;
34
+            StressPeriod = (int)bh.StressPeriod;
35
+            TotalInOut = bh.TotalZona;
36
+            Id = bh.Id;
37
+            //PercentDiscrepancy = bh.PercentDiscrepancy;
38
+        }
39
+
40
+        public void SetInOutData(ZoneData dataIn, ZoneData dataOut)
41
+        {
42
+            In = dataIn;
43
+            Out = dataOut;
44
+        }
45
+
46
+        public BalanceHidrico ToBalanceHidrico(uint? simulacionId)
47
+        {
48
+            BalanceHidrico bh = new BalanceHidrico();
49
+            bh.StressPeriod = this.StressPeriod;
50
+            bh.TotalZona = this.TotalInOut;
51
+            bh.Zona = this.Zone;
52
+            bh.IdSimulacion = simulacionId;
53
+            return bh;
54
+        }
55
+    }
56
+}

+ 59 - 0
WorkerService1/WebApplication3/Clases/ZoneConnection.cs Ver fichero

@@ -0,0 +1,59 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using WebApplication3.Models;
6
+
7
+namespace WebApplication3.Clases
8
+{
9
+    public class ZoneConnection
10
+    {
11
+        public uint Id { get; set; }
12
+        public string From { get; set; }
13
+        public string To { get; set; }
14
+        public string Value { get; set; }
15
+
16
+        public ZoneConnection()
17
+        {
18
+
19
+        }
20
+        public ZoneConnection(ConexionZonasIn connectionIn)
21
+        {
22
+            Id = connectionIn.Id;
23
+            From = connectionIn.From;
24
+            To = connectionIn.To;
25
+            Value = connectionIn.Value;
26
+        }
27
+
28
+        public ZoneConnection(ConexionZonasOut connectionOut)
29
+        {
30
+            Id = connectionOut.Id;
31
+            From = connectionOut.From;
32
+            To = connectionOut.To;
33
+            Value = connectionOut.Value;
34
+        }
35
+
36
+        public ConexionZonasIn ToConexionIn(uint? idBalanceIn)
37
+        {
38
+            ConexionZonasIn conexionIn = new ConexionZonasIn();
39
+            conexionIn.From = this.From;
40
+            conexionIn.To = this.To;
41
+            conexionIn.Value = this.Value;
42
+            conexionIn.IdDatosBalanceIn = idBalanceIn;
43
+
44
+            return conexionIn;
45
+        }
46
+
47
+        public ConexionZonasOut ToConexionOut(uint? idBalanceOut)
48
+        {
49
+            ConexionZonasOut conexionOut = new ConexionZonasOut();
50
+            conexionOut.From = this.From;
51
+            conexionOut.To = this.To;
52
+            conexionOut.Value = this.Value;
53
+            conexionOut.IdDatosBalanceOut = idBalanceOut;
54
+
55
+            return conexionOut;
56
+        }
57
+
58
+    }
59
+}

+ 79 - 0
WorkerService1/WebApplication3/Clases/ZoneData.cs Ver fichero

@@ -0,0 +1,79 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using WebApplication3.Models;
6
+
7
+namespace WebApplication3.Clases
8
+{
9
+    public class ZoneData
10
+    {
11
+        public uint Id { get; set; }
12
+        public string Storage { get; set; }
13
+        public string ConstantHead { get; set; }
14
+        public string Drains { get; set; }
15
+        public string Recharge { get; set; }
16
+        public string Total { get; set; }
17
+
18
+        public List<ZoneConnection> ZoneConnections { get; set; }
19
+
20
+        public ZoneData()
21
+        {
22
+            ZoneConnections = new List<ZoneConnection>();
23
+        }
24
+
25
+        public ZoneData(List<ZoneConnection> connections)
26
+        {
27
+            ZoneConnections = connections;
28
+        }
29
+
30
+        public ZoneData(DatosBalanceIn dataIn)
31
+        {
32
+            Id = dataIn.Id;
33
+            Storage = dataIn.Storage;
34
+            ConstantHead = dataIn.ConstantHead;
35
+            Drains = dataIn.Drains;
36
+            Recharge = dataIn.Recharge;
37
+            Total = dataIn.Total;
38
+            ZoneConnections = new List<ZoneConnection>();
39
+        }
40
+
41
+        public ZoneData(DatosBalanceOut dataIn)
42
+        {
43
+            Id = dataIn.Id;
44
+            Storage = dataIn.Storage;
45
+            ConstantHead = dataIn.ConstantHead;
46
+            Drains = dataIn.Drains;
47
+            Recharge = dataIn.Recharge;
48
+            Total = dataIn.Total;
49
+            ZoneConnections = new List<ZoneConnection>();
50
+        }
51
+
52
+        public DatosBalanceIn ToDatosBalanceIn(uint? idBalance)
53
+        {
54
+            DatosBalanceIn datosIn = new DatosBalanceIn();
55
+            datosIn.Storage = this.Storage;
56
+            datosIn.ConstantHead = this.ConstantHead;
57
+            datosIn.Drains = this.Drains;
58
+            datosIn.Recharge = this.Recharge;
59
+            datosIn.Total = this.Total;
60
+            datosIn.IdBalance = idBalance;
61
+
62
+            return datosIn;
63
+        }
64
+
65
+        public DatosBalanceOut ToDatosBalanceOut(uint? idBalance)
66
+        {
67
+            DatosBalanceOut datosOut = new DatosBalanceOut();
68
+            datosOut.Storage = this.Storage;
69
+            datosOut.ConstantHead = this.ConstantHead;
70
+            datosOut.Drains = this.Drains;
71
+            datosOut.Recharge = this.Recharge;
72
+            datosOut.Total = this.Total;
73
+            datosOut.IdBalance = idBalance;
74
+
75
+            return datosOut;
76
+        }
77
+
78
+    }
79
+}

+ 283 - 0
WorkerService1/WebApplication3/Controllers/AcuiferoController.cs Ver fichero

@@ -0,0 +1,283 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using Microsoft.AspNetCore.Http;
6
+using Microsoft.AspNetCore.Mvc;
7
+using Microsoft.EntityFrameworkCore;
8
+using WebApplication3.Models;
9
+using WebApplication3.Clases;
10
+using System.IO.Compression;
11
+using System.IO;
12
+
13
+
14
+namespace WebApplication3.Controllers
15
+{
16
+    [Route("api/[controller]")]
17
+    [ApiController]
18
+    public class AcuiferoController : ControllerBase
19
+    {
20
+        private readonly AquiferContext _context;
21
+        private PozoController pozoController;
22
+        private RecargasController recargaController;
23
+
24
+        public AcuiferoController(AquiferContext context)
25
+        {
26
+            _context = context;
27
+            pozoController = new PozoController(context);
28
+            recargaController = new RecargasController(context);
29
+
30
+        }
31
+
32
+        // GET: api/Acuifero
33
+        [HttpGet]
34
+        public async Task<ActionResult<IEnumerable<Acuifero>>> GetAcuiferos()
35
+        {
36
+            return await _context.Acuiferos.ToListAsync();
37
+        }
38
+
39
+        // GET: api/Acuifero/5
40
+        [HttpGet("{id}")]
41
+        public async Task<ActionResult<Acuifero>> GetAcuifero(uint id)
42
+        {
43
+            var acuifero = await _context.Acuiferos.FindAsync(id);
44
+
45
+            if (acuifero == null)
46
+            {
47
+                return NotFound();
48
+            }
49
+
50
+            return acuifero;
51
+        }
52
+
53
+        [HttpGet("GeoRecharge/{id}")]
54
+        public async Task<bool> GetRechargeColorMap(uint id)
55
+        {
56
+            Acuifero aquifer = await _context.Acuiferos.FindAsync(id);
57
+
58
+            return Utilities.String2Png(aquifer.RechargeGeometry);
59
+
60
+        }
61
+
62
+        // PUT: api/Acuifero/5
63
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
64
+        [HttpPut("{id}")]
65
+        public async Task<IActionResult> PutAcuifero(uint id, [FromBody] DatosPostAcuifero datos)
66
+        {
67
+
68
+            Acuifero acuifero = _context.Acuiferos.Find(id);
69
+            //string pathZip = @"C:\Users\Admin\Desktop\";
70
+            //string pathExtract = @"C:\Users\Admin\Desktop\TestExtract\";
71
+            string pozoFile, recargaFile;
72
+            List<string> files;
73
+
74
+            if (id != acuifero.Id)
75
+            {
76
+                return BadRequest();
77
+            }
78
+
79
+            try
80
+            {
81
+                //Se parsea el base 64 que nos llega
82
+                byte[] tempBytes = Convert.FromBase64String(datos.Fichero.Base64);
83
+                //Guardamos en disco el archivo obtenido del base 64
84
+                System.IO.File.WriteAllBytes(@"C:\Users\Admin\Desktop\" + datos.Fichero.Nombre, tempBytes);
85
+            }
86
+            catch (Exception ex)
87
+            {
88
+                return Problem(ex.Message);
89
+            }
90
+
91
+
92
+            //Guardamos en bbdd la actualizacion del nombre de fichero
93
+            acuifero.Fichero = datos.Fichero.Nombre;
94
+
95
+            _context.Entry(acuifero).State = EntityState.Modified;
96
+
97
+            try
98
+            {
99
+                await _context.SaveChangesAsync();
100
+                Pozo[] pozos = pozoController.GetPozosAcuiferoSimulacionInicial(acuifero.Id);
101
+                Recarga[] recargas = recargaController.GetRecargasAcuiferoSimulacionInicial(acuifero.Id);
102
+
103
+                foreach (Pozo p in pozos)
104
+                {
105
+                    await pozoController.DeletePozo(p.Id);
106
+                }
107
+
108
+                foreach (Recarga r in recargas)
109
+                {
110
+                    await recargaController.DeleteRecarga(r.Id);
111
+                }
112
+
113
+                //1- Descomprimimos el fichero zip
114
+                ZipFile.ExtractToDirectory(Constants.PathZip + datos.Fichero.Nombre, Constants.PathExtract, true);
115
+                //2- Obtenemos nombre de los ficheros de pozos y recargas 
116
+                files = Directory.GetFiles(Constants.PathExtract).ToList<string>();
117
+                pozoFile = files.Find(x => x.Contains(".VMW"));
118
+                recargaFile = files.Find(x => x.Contains(".VMP"));
119
+                //3- Parseamos pozos
120
+                if (System.IO.File.Exists(pozoFile))
121
+                {
122
+                    await pozoController.ParseoFichero(acuifero.Id, pozoFile);
123
+                }
124
+                //4- Parseamos recargas
125
+                if (System.IO.File.Exists(recargaFile))
126
+                {
127
+                    await recargaController.ParseoFichero(acuifero.Id, recargaFile);
128
+                }
129
+
130
+            }
131
+            catch (DbUpdateConcurrencyException)
132
+            {
133
+                if (!AcuiferoExists(id))
134
+                {
135
+                    return NotFound();
136
+                }
137
+                else
138
+                {
139
+                    throw;
140
+                }
141
+            }
142
+
143
+            return CreatedAtAction("GetAcuifero", new { id = acuifero.Id }, acuifero);
144
+        }
145
+
146
+        // POST: api/Acuifero
147
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
148
+        [HttpPost]
149
+        public async Task<ActionResult<Acuifero>> PostAcuifero([FromBody] DatosPostAcuifero datos)
150
+        {
151
+            Acuifero acuifero = new Acuifero();
152
+            acuifero.Nombre = datos.Nombre;
153
+            string pathZip = @"C:\Users\Admin\Desktop\";
154
+            string pathExtract = @"C:\Users\Admin\Desktop\TestExtract\";
155
+            string pozoFile, recargaFile;
156
+            List<string> files;
157
+            Parser parser = new();
158
+
159
+            try
160
+            {
161
+                byte[] tempBytes = Convert.FromBase64String(datos.Fichero.Base64);
162
+                System.IO.File.WriteAllBytes(pathZip + datos.Fichero.Nombre, tempBytes);
163
+
164
+            }
165
+            catch (Exception ex)
166
+            {
167
+                return Problem(ex.Message);
168
+            }
169
+
170
+            acuifero.Fichero = datos.Fichero.Nombre;
171
+
172
+            try
173
+            {
174
+
175
+                //Como se crea el acuifero, no tiene simulacion 0, por lo que se insertan los datos de los pozos y recargas
176
+                //1- Descomprimimos el fichero zip
177
+                ZipFile.ExtractToDirectory(pathZip + datos.Fichero.Nombre, pathExtract, true);
178
+                files = Directory.GetFiles(pathExtract).ToList<string>();
179
+                //1.2 - Obtencion de coordenadas de origen (en el mundo) del modelo
180
+                string geoFile = files.Find(x => x.Contains(".vmf"));
181
+                string world_origin_x, world_origin_y;
182
+
183
+                parser.GetGeolocalizationFromFile(geoFile, out world_origin_x, out world_origin_y);
184
+
185
+                acuifero.WorldOriginX = world_origin_x;
186
+                acuifero.WorldOriginY = world_origin_y;
187
+
188
+                _context.Acuiferos.Add(acuifero);
189
+                await _context.SaveChangesAsync();
190
+
191
+                //2- Obtenemos nombre de los ficheros de pozos y recargas 
192
+                pozoFile = files.Find(x => x.Contains(".VMW"));
193
+                recargaFile = files.Find(x => x.Contains(".VMP"));
194
+
195
+                //3- Parseamos pozos
196
+                if (System.IO.File.Exists(pozoFile))
197
+                {
198
+                    await pozoController.ParseoFichero(acuifero.Id, pozoFile);
199
+                }
200
+                //4- Parseamos recargas
201
+                if (System.IO.File.Exists(recargaFile))
202
+                {
203
+                    await recargaController.ParseoFichero(acuifero.Id, recargaFile);
204
+                }
205
+            }
206
+            catch (DbUpdateException)
207
+            {
208
+                if (AcuiferoExists(acuifero.Id))
209
+                {
210
+                    return Conflict();
211
+                }
212
+                else
213
+                {
214
+                    throw;
215
+                }
216
+            }
217
+
218
+            return CreatedAtAction("GetAcuifero", new { id = acuifero.Id }, acuifero);
219
+        }
220
+
221
+        // DELETE: api/Acuifero/5
222
+        [HttpDelete("{id}")]
223
+        public async Task<IActionResult> DeleteAcuifero(int id)
224
+        {
225
+            var acuifero = await _context.Acuiferos.FindAsync(id);
226
+            if (acuifero == null)
227
+            {
228
+                return NotFound();
229
+            }
230
+
231
+            _context.Acuiferos.Remove(acuifero);
232
+            await _context.SaveChangesAsync();
233
+
234
+            return NoContent();
235
+        }
236
+
237
+        private bool AcuiferoExists(uint id)
238
+        {
239
+            return _context.Acuiferos.Any(e => e.Id == id);
240
+        }
241
+
242
+        [NonAction]
243
+        public string GetFicheroZip(uint id)
244
+        {
245
+            var acuifero = _context.Acuiferos.Find(id);
246
+
247
+            if (acuifero != null)
248
+            {
249
+                return acuifero.Fichero;
250
+            }
251
+
252
+            return string.Empty;
253
+        }
254
+
255
+        [NonAction]
256
+        public async Task<IActionResult> SetRechargeGeometry(uint id, string recharge_geometry)
257
+        {
258
+            Acuifero aquifer = _context.Acuiferos.Find(id);
259
+
260
+            aquifer.RechargeGeometry = recharge_geometry;
261
+
262
+            _context.Entry(aquifer).State = EntityState.Modified;
263
+
264
+            try
265
+            {
266
+                await _context.SaveChangesAsync();
267
+            }
268
+            catch (DbUpdateConcurrencyException)
269
+            {
270
+                if (!AcuiferoExists(id))
271
+                {
272
+                    return NotFound();
273
+                }
274
+                else
275
+                {
276
+                    throw;
277
+                }
278
+            }
279
+
280
+            return CreatedAtAction("GetAcuifero", new { id = aquifer.Id }, aquifer);
281
+        }
282
+    }
283
+}

+ 290 - 0
WorkerService1/WebApplication3/Controllers/BalanceHidricoController.cs Ver fichero

@@ -0,0 +1,290 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using Microsoft.AspNetCore.Http;
6
+using Microsoft.AspNetCore.Mvc;
7
+using Microsoft.EntityFrameworkCore;
8
+using WebApplication3.Models;
9
+using WebApplication3.Clases;
10
+
11
+namespace WebApplication3.Controllers
12
+{
13
+    [Route("api/[controller]")]
14
+    [ApiController]
15
+    public class BalanceHidricoController : ControllerBase
16
+    {
17
+        private readonly AquiferContext _context;
18
+
19
+        public BalanceHidricoController(AquiferContext context)
20
+        {
21
+            _context = context;
22
+        }
23
+
24
+        // GET: api/BalanceHidrico
25
+        [HttpGet]
26
+        public async Task<ActionResult<IEnumerable<BalanceHidrico>>> GetBalances()
27
+        {
28
+            return await _context.BalancesHidricos.ToListAsync();
29
+        }
30
+
31
+        // GET: api/balance/5
32
+        [HttpGet("{idSimulacion}")]
33
+        public async Task<ActionResult<IEnumerable<ZoneBalance>>> GetBalance(uint idSimulacion)
34
+        {            
35
+            List<BalanceHidrico> dbBalances = await _context.BalancesHidricos.Where( x=> x.IdSimulacion == idSimulacion).ToListAsync<BalanceHidrico>();
36
+                       
37
+            List<ZoneBalance> balancesOutput = new List<ZoneBalance>();
38
+
39
+            foreach (BalanceHidrico bh in dbBalances)
40
+            {
41
+                DatosBalanceIn dataIn = _context.DatosBalanceIns.Where(x => x.IdBalance == bh.Id).First();
42
+                DatosBalanceOut dataOut = _context.DatosBalanceOuts.Where(x => x.IdBalance == bh.Id).First();
43
+
44
+                List<ConexionZonasIn> connectionsIn = _context.ConexionZonasIns.Where(x => x.IdDatosBalanceIn == dataIn.Id).ToList();
45
+                List<ConexionZonasOut> connectionsOut = _context.ConexionZonasOuts.Where(x => x.IdDatosBalanceOut == dataOut.Id).ToList();
46
+
47
+
48
+                ZoneBalance zb = new ZoneBalance(bh);
49
+                ZoneData dataBalanceIn = new ZoneData(dataIn);
50
+                ZoneData dataBalanceOut = new ZoneData(dataOut);
51
+
52
+                /*
53
+                 * TODO: Hacer la discretización por tipo de zona, AGREGAR EL CAMPO A LA TABLA DE LA BBDD Y GUARDARLO TAMBIEN, que no se quede solo en la IMPORTACIÓN (?)
54
+                 */
55
+                if (bh.Zona != "Zone 0")
56
+                {
57
+                    List<ZoneConnection> zoneConnectionsIn = new List<ZoneConnection>();
58
+                    connectionsIn.ForEach(x => zoneConnectionsIn.Add(new ZoneConnection(x)));
59
+                    dataBalanceIn.ZoneConnections = zoneConnectionsIn;
60
+
61
+                    List<ZoneConnection> zoneConnectionsOut = new List<ZoneConnection>();
62
+                    connectionsOut.ForEach(x => zoneConnectionsOut.Add(new ZoneConnection(x)));
63
+                    dataBalanceOut.ZoneConnections = zoneConnectionsOut;
64
+                }
65
+
66
+                zb.SetInOutData(dataBalanceIn, dataBalanceOut);
67
+                balancesOutput.Add(zb);
68
+
69
+            }
70
+
71
+            return balancesOutput;
72
+        }
73
+
74
+        [NonAction]
75
+        public BalanceHidrico GetBalanceById(uint id)
76
+        {
77
+            var balance = _context.BalancesHidricos.Find(id);
78
+
79
+            return balance;
80
+        }
81
+
82
+        [NonAction]
83
+        public DatosBalanceIn GetBalanceIn(uint id)
84
+        {
85
+            var balanceIn = _context.DatosBalanceIns.Find(id);
86
+
87
+            return balanceIn;
88
+        }
89
+
90
+        [NonAction]
91
+        public DatosBalanceOut GetBalanceOut(uint id)
92
+        {
93
+            var balanceOut = _context.DatosBalanceOuts.Find(id);
94
+
95
+            return balanceOut;
96
+        }
97
+
98
+        [NonAction]
99
+        public ConexionZonasIn GetConnectionIn(uint id)
100
+        {
101
+            var connectionIn = _context.ConexionZonasIns.Find(id);
102
+
103
+            return connectionIn;
104
+        }
105
+
106
+        [NonAction]
107
+        public ConexionZonasOut GetConnectionOut(uint id)
108
+        {
109
+            var connectionOut = _context.ConexionZonasOuts.Find(id);
110
+
111
+            return connectionOut;
112
+        }
113
+
114
+        // POST: api/TsPozo
115
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
116
+        [HttpPost]
117
+        public async Task<ActionResult<uint>> PostBalance(BalanceHidrico balance)
118
+        {
119
+            _context.BalancesHidricos.Add(balance);
120
+            try
121
+            {
122
+                await _context.SaveChangesAsync();
123
+            }
124
+            catch (DbUpdateException)
125
+            {
126
+                if (BalanceExist(balance.Id))
127
+                {
128
+                    return Conflict();
129
+                }
130
+                else
131
+                {
132
+                    throw;
133
+                }
134
+            }
135
+
136
+            return balance.Id;
137
+        }
138
+
139
+        [NonAction]
140
+        public async Task<ActionResult<uint>> PostBalanceIn(DatosBalanceIn balanceIn)
141
+        {
142
+            _context.DatosBalanceIns.Add(balanceIn);
143
+            try
144
+            {
145
+                await _context.SaveChangesAsync();
146
+            }
147
+            catch (DbUpdateException)
148
+            {
149
+                if (BalanceInExist(balanceIn.Id))
150
+                {
151
+                    return Conflict();
152
+                }
153
+                else
154
+                {
155
+                    throw;
156
+                }
157
+            }
158
+
159
+            return balanceIn.Id;
160
+        }
161
+
162
+        [NonAction]
163
+        public async Task<ActionResult<uint>> PostBalanceOut(DatosBalanceOut balanceOut)
164
+        {
165
+            _context.DatosBalanceOuts.Add(balanceOut);
166
+            try
167
+            {
168
+                await _context.SaveChangesAsync();
169
+            }
170
+            catch (DbUpdateException)
171
+            {
172
+                if (BalanceOutExist(balanceOut.Id))
173
+                {
174
+                    return Conflict();
175
+                }
176
+                else
177
+                {
178
+                    throw;
179
+                }
180
+            }
181
+
182
+            return balanceOut.Id;
183
+        }
184
+
185
+        [NonAction]
186
+        public async Task<ActionResult<ConexionZonasIn>> PostConnectionIn(ConexionZonasIn connectionIn)
187
+        {
188
+            _context.ConexionZonasIns.Add(connectionIn);
189
+            try
190
+            {
191
+                await _context.SaveChangesAsync();
192
+            }
193
+            catch (DbUpdateException)
194
+            {
195
+                if (ConnectionInExist(connectionIn.Id))
196
+                {
197
+                    return Conflict();
198
+                }
199
+                else
200
+                {
201
+                    throw;
202
+                }
203
+            }
204
+
205
+            return CreatedAtAction("GetConnectionIn", new { id = connectionIn.Id }, connectionIn);
206
+        }
207
+
208
+        [NonAction]
209
+        public async Task<ActionResult<bool>> PostMultipleConnectionIn(ConexionZonasIn[] connectionsIn)
210
+        {
211
+            _context.ConexionZonasIns.AddRange(connectionsIn);
212
+            try
213
+            {
214
+                await _context.SaveChangesAsync();
215
+            }
216
+            catch (DbUpdateException)
217
+            {
218
+                
219
+                throw;
220
+                
221
+            }
222
+
223
+            return true;
224
+        }
225
+
226
+        [NonAction]
227
+        public async Task<ActionResult<ConexionZonasOut>> PostConnectionOut(ConexionZonasOut connectionOut)
228
+        {
229
+            _context.ConexionZonasOuts.Add(connectionOut);
230
+            try
231
+            {
232
+                await _context.SaveChangesAsync();
233
+            }
234
+            catch (DbUpdateException)
235
+            {
236
+                if (ConnectionOutExist(connectionOut.Id))
237
+                {
238
+                    return Conflict();
239
+                }
240
+                else
241
+                {
242
+                    throw;
243
+                }
244
+            }
245
+
246
+            return CreatedAtAction("GetConnectionOut", new { id = connectionOut.Id }, connectionOut);
247
+        }
248
+
249
+        [NonAction]
250
+        public async Task<ActionResult<bool>> PostMultipleConnectionOut(ConexionZonasOut[] connectionsOut)
251
+        {
252
+            _context.ConexionZonasOuts.AddRange(connectionsOut);
253
+            try
254
+            {
255
+                await _context.SaveChangesAsync();
256
+            }
257
+            catch (DbUpdateException)
258
+            {
259
+                throw;
260
+            }
261
+
262
+            return true;
263
+        }
264
+
265
+        private bool BalanceExist(uint id)
266
+        {
267
+            return _context.BalancesHidricos.Any(e => e.Id == id);
268
+        }
269
+
270
+        private bool BalanceInExist(uint id)
271
+        {
272
+            return _context.DatosBalanceIns.Any(e => e.Id == id);
273
+        }
274
+
275
+        private bool BalanceOutExist(uint id)
276
+        {
277
+            return _context.DatosBalanceOuts.Any(e => e.Id == id);
278
+        }
279
+
280
+        private bool ConnectionInExist(uint id)
281
+        {
282
+            return _context.ConexionZonasIns.Any(e => e.Id == id);
283
+        }
284
+
285
+        private bool ConnectionOutExist(uint id)
286
+        {
287
+            return _context.ConexionZonasOuts.Any(e => e.Id == id);
288
+        }
289
+    }
290
+}

+ 156 - 0
WorkerService1/WebApplication3/Controllers/PiezometerController.cs Ver fichero

@@ -0,0 +1,156 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using Microsoft.AspNetCore.Http;
6
+using Microsoft.AspNetCore.Mvc;
7
+using Microsoft.EntityFrameworkCore;
8
+using WebApplication3.Models;
9
+using WebApplication3.Clases;
10
+
11
+namespace WebApplication3.Controllers
12
+{
13
+    [Route("api/[controller]")]
14
+    [ApiController]
15
+    public class PiezometerController : ControllerBase
16
+    {
17
+        private readonly AquiferContext _context;
18
+        private TsPiezometerController tsPiezometerController;
19
+        
20
+        
21
+        public PiezometerController(AquiferContext context)
22
+        {
23
+            _context = context;
24
+            tsPiezometerController = new TsPiezometerController(context);
25
+            
26
+        }
27
+
28
+        // GET: api/Piezometer
29
+        [HttpGet]
30
+        public async Task<ActionResult<IEnumerable<Piezometer>>> GetPiezmeters()
31
+        {
32
+            return await _context.Piezometers.ToListAsync();
33
+        }
34
+
35
+        // GET: api/Piezometer/5
36
+        [HttpGet("{id}")]
37
+        public async Task<ActionResult<Piezometer>> GetPiezometer(uint id)
38
+        {            
39
+            var piezometer = await _context.Piezometers.FindAsync(id);
40
+            
41
+            if (piezometer == null)
42
+            {
43
+                return NotFound();
44
+            }
45
+            
46
+            return piezometer;
47
+        }
48
+
49
+        [HttpPost("Import")]
50
+        public async Task<ActionResult<bool>> ImportPiezometersFromCSV(DatosPostSimulacion data)
51
+        {
52
+            Parser parser = new();
53
+            string file = Constants.PathExtract + data.Fichero.Nombre;
54
+            bool result = true;
55
+
56
+            //Saving the file into hard drive
57
+            try
58
+            {
59
+                byte[] tempBytes = Convert.FromBase64String(data.Fichero.Base64);
60
+                System.IO.File.WriteAllBytes(file, tempBytes);
61
+
62
+            }
63
+            catch (Exception ex)
64
+            {
65
+                return Problem(ex.Message);
66
+            }
67
+
68
+            //parsing the information from the file we've just saved
69
+            PiezometerData[] piezometers = parser.parsePiezometerCSV(file);
70
+
71
+            try
72
+            {
73
+
74
+
75
+                foreach (PiezometerData p in piezometers)
76
+                {
77
+                    Piezometer piezometer = p.ToPiezometer();
78
+                    await this.PostPiezometer(piezometer);
79
+
80
+                    foreach (TimeSerieInterno tsi in p.Rates)
81
+                    {
82
+                        TsPiezometer tsp = new();
83
+                        tsp.PiezometerId = piezometer.Id;
84
+                        tsp.Date = tsi.DateIn;
85
+                        tsp.Day = tsi.Hora;
86
+                        tsp.Quote = tsi.Valor;
87
+
88
+                        await tsPiezometerController.PostTsPiezometer(tsp);
89
+                    }
90
+                }
91
+            }
92
+            catch(Exception ex)
93
+            {
94
+                Logger.WriteLog("Error while importing piezometers");
95
+                Logger.WriteLog(ex.Message);
96
+                Logger.WriteLog(ex.InnerException.Message);
97
+            }
98
+
99
+            return result;
100
+        }
101
+
102
+        // POST: api/Piezometer
103
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
104
+        [NonAction]
105
+        public async Task<ActionResult<Piezometer>> PostPiezometer(Piezometer piezometer)
106
+        {
107
+            _context.Piezometers.Add(piezometer);
108
+            try
109
+            {
110
+                Logger.WriteLog("Guardar cambios async");
111
+                await _context.SaveChangesAsync();
112
+
113
+            }
114
+            catch (DbUpdateException ex)
115
+            {
116
+                if (PiezometerExists(piezometer.Id))
117
+                {
118
+                    return Conflict();
119
+                }
120
+                else
121
+                {
122
+                    Logger.WriteLog("FALLO AL GUARDAR PIEZOMETRO");
123
+                    Logger.WriteLog(ex.Message);
124
+                    Logger.WriteLog(ex.InnerException.Message);
125
+                    throw;
126
+                }
127
+            }
128
+
129
+
130
+            return CreatedAtAction("GetPiezometria", new { id = piezometer.Id }, piezometer);
131
+        }
132
+
133
+        // DELETE: api/Pozo/5
134
+        [HttpDelete("{id}")]
135
+        public async Task<IActionResult> DeletePiezometer(uint id)
136
+        {
137
+            var piezometer = await _context.Piezometers.FindAsync(id);
138
+            if (piezometer == null)
139
+            {
140
+                return NotFound();
141
+            }
142
+            
143
+            _context.Piezometers.Remove(piezometer);
144
+            await _context.SaveChangesAsync();
145
+
146
+            return NoContent();
147
+        }
148
+
149
+        private bool PiezometerExists(uint id)
150
+        {
151
+            return _context.Piezometers.Any(e => e.Id == id);
152
+        }
153
+
154
+        
155
+    }
156
+}

+ 151 - 0
WorkerService1/WebApplication3/Controllers/PiezometriaController.cs Ver fichero

@@ -0,0 +1,151 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using Microsoft.AspNetCore.Http;
6
+using Microsoft.AspNetCore.Mvc;
7
+using Microsoft.EntityFrameworkCore;
8
+using WebApplication3.Models;
9
+using WebApplication3.Clases;
10
+
11
+namespace WebApplication3.Controllers
12
+{
13
+    [Route("api/[controller]")]
14
+    [ApiController]
15
+    public class PiezometriaController : ControllerBase
16
+    {
17
+        private readonly AquiferContext _context;
18
+        private TsPozoController _tsPozoController;
19
+        
20
+        
21
+        public PiezometriaController(AquiferContext context)
22
+        {
23
+            _context = context;
24
+            _tsPozoController = new TsPozoController(context);
25
+            
26
+        }
27
+
28
+        // GET: api/Pozo
29
+        [HttpGet]
30
+        public async Task<ActionResult<IEnumerable<Piezometria>>> GetPozos()
31
+        {
32
+            return await _context.Piezometria.ToListAsync();
33
+        }
34
+
35
+        // GET: api/Pozo/5
36
+        [HttpGet("{id}")]
37
+        public async Task<ActionResult<Piezometria>> GetPozo(uint id)
38
+        {            
39
+            var piezometria = await _context.Piezometria.FindAsync(id);
40
+            
41
+            if (piezometria == null)
42
+            {
43
+                return NotFound();
44
+            }
45
+            
46
+            return piezometria;
47
+        }
48
+
49
+        // PUT: api/Pozo/5
50
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
51
+        //[HttpPut("{id}")]
52
+        //public async Task<IActionResult> PutPozo(uint id, [FromBody] DatosPozoRecarga datos)
53
+        //{
54
+        //    Pozo pozo = _context.Pozos.Find(id);
55
+
56
+        //    if (id != pozo.Id)
57
+        //    {
58
+        //        return BadRequest();
59
+        //    }
60
+
61
+        //    pozo.IdAquifero = (datos.Acuifero != null && pozo.IdAquifero != datos.Acuifero) ? datos.Acuifero : pozo.IdAquifero;
62
+        //    pozo.IdSimulacion = (datos.Simulacion != null && pozo.IdSimulacion != datos.Simulacion) ? datos.Simulacion : pozo.IdSimulacion;
63
+        //    pozo.Latitud = (datos.Latitud != null && pozo.Latitud != datos.Latitud) ? datos.Latitud : pozo.Latitud;
64
+        //    pozo.Longitud = (datos.Longitud != null && pozo.Longitud != datos.Longitud) ? datos.Longitud : pozo.Longitud;
65
+        //    pozo.Maximo = (datos.Maximo != null && pozo.Maximo != datos.Maximo) ? datos.Maximo : pozo.Maximo;
66
+        //    pozo.Nombre = (datos.Nombre != null && pozo.Nombre != datos.Nombre) ? datos.Nombre : pozo.Nombre;
67
+
68
+        //    _context.Entry(pozo).State = EntityState.Modified;
69
+
70
+        //    try
71
+        //    {
72
+        //        await _context.SaveChangesAsync();
73
+        //    }
74
+        //    catch (DbUpdateConcurrencyException)
75
+        //    {
76
+        //        if (!PiezometriaExists(id))
77
+        //        {
78
+        //            return NotFound();
79
+        //        }
80
+        //        else
81
+        //        {
82
+        //            throw;
83
+        //        }
84
+        //    }
85
+
86
+        //    return CreatedAtAction("GetPozo", new { id = pozo.Id }, pozo);
87
+        //}
88
+
89
+        // POST: api/Pozo
90
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
91
+        [HttpPost]
92
+        public async Task<ActionResult<Piezometria>> PostPiezometria(Piezometria piezometria)
93
+        {
94
+            Logger.WriteLog("Se procede a guardar piezometria");
95
+            _context.Piezometria.Add(piezometria);
96
+            try
97
+            {
98
+                Logger.WriteLog("Guardar cambios async");
99
+                await _context.SaveChangesAsync();
100
+
101
+            }
102
+            catch (DbUpdateException ex)
103
+            {
104
+                if (PiezometriaExists(piezometria.Id))
105
+                {
106
+                    return Conflict();
107
+                }
108
+                else
109
+                {
110
+                    Logger.WriteLog("FALLO AL GUARDAR PIEZOMETRIA");
111
+                    Logger.WriteLog(ex.Message);
112
+                    Logger.WriteLog(ex.InnerException.Message);
113
+                    throw;
114
+                }
115
+            }
116
+
117
+
118
+            return CreatedAtAction("GetPiezometria", new { id = piezometria.Id }, piezometria);
119
+        }
120
+
121
+        // DELETE: api/Pozo/5
122
+        [HttpDelete("{id}")]
123
+        public async Task<IActionResult> DeletePiezometria(uint id)
124
+        {
125
+            var piezometria = await _context.Piezometria.FindAsync(id);
126
+            if (piezometria == null)
127
+            {
128
+                return NotFound();
129
+            }
130
+            
131
+            _context.Piezometria.Remove(piezometria);
132
+            await _context.SaveChangesAsync();
133
+
134
+            return NoContent();
135
+        }
136
+
137
+        private bool PiezometriaExists(uint id)
138
+        {
139
+            return _context.Piezometria.Any(e => e.Id == id);
140
+        }
141
+
142
+        [NonAction]
143
+        public void getDimensions(uint idSimulacion, out int rows, out int cols)
144
+        {
145
+            Piezometria piezometria = _context.Piezometria.Where(x => x.IdSimulacion == idSimulacion).FirstOrDefault();
146
+            rows = piezometria.Rows;
147
+            cols = piezometria.Columns;
148
+        }
149
+
150
+    }
151
+}

+ 364 - 0
WorkerService1/WebApplication3/Controllers/PozoController.cs Ver fichero

@@ -0,0 +1,364 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using Microsoft.AspNetCore.Http;
6
+using Microsoft.AspNetCore.Mvc;
7
+using Microsoft.EntityFrameworkCore;
8
+using WebApplication3.Models;
9
+using WebApplication3.Clases;
10
+
11
+namespace WebApplication3.Controllers
12
+{
13
+    [Route("api/[controller]")]
14
+    [ApiController]
15
+    public class PozoController : ControllerBase
16
+    {
17
+        private readonly AquiferContext _context;
18
+        private TsPozoController _tsPozoController;
19
+        
20
+        
21
+        public PozoController(AquiferContext context)
22
+        {
23
+            _context = context;
24
+            _tsPozoController = new TsPozoController(context);
25
+            
26
+        }
27
+
28
+        // GET: api/Pozo
29
+        [HttpGet]
30
+        public async Task<ActionResult<IEnumerable<Pozo>>> GetPozos()
31
+        {
32
+            return await _context.Pozos.ToListAsync();
33
+        }
34
+
35
+        // GET: api/Pozo/5
36
+        [HttpGet("{id}")]
37
+        public async Task<ActionResult<DatosPozoRecarga>> GetPozo(uint id)
38
+        {            
39
+            var pozo = await _context.Pozos.FindAsync(id);
40
+            
41
+            if (pozo == null)
42
+            {
43
+                return NotFound();
44
+            }
45
+
46
+            DatosPozoRecarga datosPozo = new DatosPozoRecarga();
47
+            datosPozo.Id = pozo.Id;
48
+            datosPozo.Nombre = pozo.Nombre;
49
+            datosPozo.Latitud = pozo.Latitud;
50
+            datosPozo.Longitud = pozo.Longitud;
51
+            datosPozo.Maximo = pozo.Maximo;
52
+            datosPozo.Minimo = pozo.Minimo;
53
+            datosPozo.Simulacion = pozo.IdSimulacion;
54
+            datosPozo.Ts = _tsPozoController.GetTsPozo(pozo.Id);
55
+            
56
+
57
+            return datosPozo;
58
+        }
59
+
60
+        // PUT: api/Pozo/5
61
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
62
+        [HttpPut("{id}")]
63
+        public async Task<IActionResult> PutPozo(uint id, [FromBody] DatosPozoRecarga datos)
64
+        {
65
+            Pozo pozo = _context.Pozos.Find(id);
66
+
67
+            if (id != pozo.Id)
68
+            {
69
+                return BadRequest();
70
+            }
71
+
72
+            pozo.IdAquifero = (datos.Acuifero != null && pozo.IdAquifero != datos.Acuifero) ? datos.Acuifero : pozo.IdAquifero;
73
+            pozo.IdSimulacion = (datos.Simulacion != null && pozo.IdSimulacion != datos.Simulacion) ? datos.Simulacion : pozo.IdSimulacion;
74
+            pozo.Latitud = (datos.Latitud != null && pozo.Latitud != datos.Latitud) ? datos.Latitud : pozo.Latitud;
75
+            pozo.Longitud = (datos.Longitud != null && pozo.Longitud != datos.Longitud) ? datos.Longitud : pozo.Longitud;
76
+            pozo.Maximo = (datos.Maximo != null && pozo.Maximo != datos.Maximo) ? datos.Maximo : pozo.Maximo;
77
+            pozo.Nombre = (datos.Nombre != null && pozo.Nombre != datos.Nombre) ? datos.Nombre : pozo.Nombre;
78
+
79
+            _context.Entry(pozo).State = EntityState.Modified;
80
+
81
+            try
82
+            {
83
+                await _context.SaveChangesAsync();
84
+            }
85
+            catch (DbUpdateConcurrencyException)
86
+            {
87
+                if (!PozoExists(id))
88
+                {
89
+                    return NotFound();
90
+                }
91
+                else
92
+                {
93
+                    throw;
94
+                }
95
+            }
96
+
97
+            return CreatedAtAction("GetPozo", new { id = pozo.Id }, pozo);
98
+        }
99
+
100
+        // POST: api/Pozo
101
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
102
+        [HttpPost]
103
+        public async Task<ActionResult<Pozo>> PostPozo([FromBody] DatosPozoRecarga datos)
104
+        {
105
+            Pozo pozo = new Pozo();
106
+            
107
+
108
+            pozo.IdAquifero = datos.Acuifero;
109
+            pozo.IdSimulacion = datos.Simulacion;
110
+            pozo.Latitud = datos.Latitud;
111
+            pozo.Longitud = datos.Longitud;
112
+            pozo.Maximo = datos.Maximo;
113
+            pozo.Minimo = datos.Minimo;
114
+            pozo.Nombre = datos.Nombre;
115
+
116
+            _context.Pozos.Add(pozo);
117
+            try
118
+            {
119
+                await _context.SaveChangesAsync();
120
+
121
+                foreach (TimeSerie ts in datos.Ts)
122
+                {
123
+                    TsPozo tsPozo = new TsPozo();
124
+                    tsPozo.IdPozo = pozo.Id;
125
+                    tsPozo.MarcaTiempo = ts.Hora;
126
+                    tsPozo.Valor = ts.Valor;
127
+
128
+                    await _tsPozoController.PostTsPozo(tsPozo);
129
+                }
130
+
131
+            }
132
+            catch (DbUpdateException)
133
+            {
134
+                if (PozoExists(pozo.Id))
135
+                {
136
+                    return Conflict();
137
+                }
138
+                else
139
+                {
140
+                    throw;
141
+                }
142
+            }
143
+
144
+
145
+            return CreatedAtAction("GetPozo", new { id = pozo.Id }, pozo);
146
+        }
147
+
148
+        // DELETE: api/Pozo/5
149
+        [HttpDelete("{id}")]
150
+        public async Task<IActionResult> DeletePozo(uint id)
151
+        {
152
+            var pozo = await _context.Pozos.FindAsync(id);
153
+            if (pozo == null)
154
+            {
155
+                return NotFound();
156
+            }
157
+            await _tsPozoController.DeleteTsPozoFromPozo(id);
158
+            _context.Pozos.Remove(pozo);
159
+            await _context.SaveChangesAsync();
160
+
161
+            return NoContent();
162
+        }
163
+
164
+        private bool PozoExists(uint id)
165
+        {
166
+            return _context.Pozos.Any(e => e.Id == id);
167
+        }
168
+
169
+        //api/Pozo/parsea/1
170
+        [HttpPost("Parsea/{acuifero}")]
171
+        public async Task<ActionResult<IEnumerable<Pozo>>> ParseoFicheroPostman(uint acuifero)
172
+        {
173
+            
174
+            Parser wellParser = new Parser();
175
+            string file = @"C:\Users\Admin\Desktop\ASD\infoPozos.VMW";
176
+            WellData[] wells =  wellParser.ParseWellData(file);
177
+
178
+            foreach(WellData w in wells)
179
+            {
180
+                Pozo pozo = w.ToPozo(acuifero);
181
+                _context.Pozos.Add(pozo);
182
+
183
+                try
184
+                {
185
+                    await _context.SaveChangesAsync();
186
+
187
+                    foreach (TimeSerieInterno ts in w.Rates)
188
+                    {
189
+                        TsPozo tsPozo = new TsPozo();
190
+                        tsPozo.IdPozo = pozo.Id;
191
+                        tsPozo.MarcaTiempo = ts.Hora;
192
+                        tsPozo.Valor = ts.Valor;
193
+
194
+                        await _tsPozoController.PostTsPozo(tsPozo);
195
+                    }
196
+
197
+                }
198
+                catch (DbUpdateException)
199
+                {
200
+                    if (PozoExists(pozo.Id))
201
+                    {
202
+                        return Conflict();
203
+                    }
204
+                    else
205
+                    {
206
+                        throw;
207
+                    }
208
+                }
209
+            }
210
+
211
+            return await _context.Pozos.ToListAsync();
212
+        }
213
+
214
+        [NonAction]
215
+        public async Task<ActionResult<IEnumerable<Pozo>>> ParseoFichero(uint acuifero, string file)
216
+        {
217
+            var s = acuifero;
218
+            Parser wellParser = new Parser();
219
+            //string file = @"C:\Users\Admin\Desktop\ASD\infoPozos.VMW";
220
+            WellData[] wells = wellParser.ParseWellData(file);
221
+
222
+            foreach (WellData w in wells)
223
+            {
224
+                Pozo pozo = w.ToPozo(acuifero);
225
+                _context.Pozos.Add(pozo);
226
+
227
+                try
228
+                {
229
+                    await _context.SaveChangesAsync();
230
+
231
+                    foreach (TimeSerieInterno ts in w.Rates)
232
+                    {
233
+                        TsPozo tsPozo = new TsPozo();
234
+                        tsPozo.IdPozo = pozo.Id;
235
+                        tsPozo.MarcaTiempo = ts.Hora;
236
+                        tsPozo.Valor = ts.Valor;
237
+                        tsPozo.InfoComplementaria = ts.Info;
238
+
239
+                        await _tsPozoController.PostTsPozo(tsPozo);
240
+                    }
241
+
242
+                }
243
+                catch (DbUpdateException)
244
+                {
245
+                    if (PozoExists(pozo.Id))
246
+                    {
247
+                        return Conflict();
248
+                    }
249
+                    else
250
+                    {
251
+                        throw;
252
+                    }
253
+                }
254
+            }
255
+
256
+            return await _context.Pozos.ToListAsync();
257
+        }
258
+
259
+        [NonAction]
260
+        public async Task<ActionResult<IEnumerable<Pozo>>> PostMultipleWells(uint aquiferId,WellData[] wellDatas)
261
+        {
262
+            foreach (WellData w in wellDatas)
263
+            {
264
+                Pozo pozo = w.ToPozo(aquiferId);
265
+                _context.Pozos.Add(pozo);
266
+
267
+                try
268
+                {
269
+                    await _context.SaveChangesAsync();
270
+
271
+                    foreach (TimeSerieInterno ts in w.Rates)
272
+                    {
273
+                        TsPozo tsPozo = new TsPozo();
274
+                        tsPozo.IdPozo = pozo.Id;
275
+                        tsPozo.MarcaTiempo = ts.Hora;
276
+                        tsPozo.Valor = ts.Valor;
277
+                        tsPozo.InfoComplementaria = ts.Info;
278
+
279
+                        await _tsPozoController.PostTsPozo(tsPozo);
280
+                    }
281
+
282
+                }
283
+                catch (DbUpdateException)
284
+                {
285
+                    if (PozoExists(pozo.Id))
286
+                    {
287
+                        return Conflict();
288
+                    }
289
+                    else
290
+                    {
291
+                        throw;
292
+                    }
293
+                }
294
+            }
295
+
296
+            return await _context.Pozos.ToListAsync();
297
+        }
298
+
299
+        [NonAction]
300
+        public Pozo[] GetPozosAcuifero(uint acuiferoId)
301
+        {
302
+            return _context.Pozos.Where(x => x.IdAquifero == acuiferoId).ToArray<Pozo>();
303
+        }
304
+
305
+        [NonAction]
306
+        public Pozo[] GetPozosAcuiferoSimulacionInicial(uint acuiferoId)
307
+        {
308
+            return _context.Pozos.Where(x => x.IdAquifero == acuiferoId && x.IdSimulacion == null).ToArray<Pozo>();
309
+        }
310
+
311
+        [NonAction]
312
+        public async void SetPozosSimulacion(uint? acuiferoId, uint? simulacionId)
313
+        {
314
+            //Obtenemos los pozos del acuifero
315
+            Pozo[] pozos = _context.Pozos.Where(x => x.IdAquifero == acuiferoId).ToArray<Pozo>();
316
+
317
+            foreach(Pozo p in pozos)
318
+            {
319
+                Pozo pozo = p.Copy(simulacionId);
320
+
321
+                _context.Pozos.Add(pozo);
322
+            }
323
+            await _context.SaveChangesAsync();
324
+        }
325
+
326
+        [NonAction]
327
+        public List<Pozo> GetPozosSimulacion(uint? simulacionId)
328
+        {
329
+            List <Pozo> pozos = _context.Pozos.Where(x => x.IdSimulacion == simulacionId).ToList<Pozo>();
330
+
331
+            return pozos;
332
+        }
333
+
334
+        [NonAction]
335
+        public List<TsPozo> GetTsPozoFromPozo(uint? pozo)
336
+        {
337
+            List<TsPozo> tsPozos = _context.TsPozos.Where(x => x.IdPozo == pozo).ToList<TsPozo>();
338
+
339
+            return tsPozos;
340
+        }
341
+
342
+        [NonAction]
343
+        public async Task<bool> DeletePozoFromSim(uint? idSimulacion)
344
+        {
345
+            List<Pozo> pozos = _context.Pozos.Where(x => x.IdSimulacion == idSimulacion).ToList();
346
+            bool error = false;
347
+            try
348
+            {
349
+                foreach(Pozo p in pozos)
350
+                {
351
+                    await DeletePozo(p.Id);
352
+                }
353
+            } catch(Exception ex)
354
+            {
355
+                error = true;
356
+                Logger.WriteLog("Fail at deleting well from a simulation (simulationID: " + idSimulacion+")");
357
+                Logger.WriteLog(ex.Message);
358
+                Logger.WriteLog(ex.InnerException.Message);
359
+            }
360
+
361
+            return error;
362
+        }
363
+    }
364
+}

+ 256 - 0
WorkerService1/WebApplication3/Controllers/RecargasController.cs Ver fichero

@@ -0,0 +1,256 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using Microsoft.AspNetCore.Http;
6
+using Microsoft.AspNetCore.Mvc;
7
+using Microsoft.EntityFrameworkCore;
8
+using WebApplication3.Models;
9
+using WebApplication3.Clases;
10
+
11
+namespace WebApplication3.Controllers
12
+{
13
+    [Route("api/[controller]")]
14
+    [ApiController]
15
+    public class RecargasController : ControllerBase
16
+    {
17
+        private readonly AquiferContext _context;
18
+        private TsRecargaController tsRecargaController;
19
+        //private AcuiferoController aquiferController;
20
+
21
+        public RecargasController(AquiferContext context)
22
+        {
23
+            _context = context;
24
+            tsRecargaController = new TsRecargaController(context);
25
+            //aquiferController = new AcuiferoController(context);
26
+        }
27
+
28
+        // GET: api/Recargas
29
+        [HttpGet]
30
+        public async Task<ActionResult<IEnumerable<Recarga>>> GetRecargas()
31
+        {
32
+            return await _context.Recargas.ToListAsync();
33
+        }
34
+
35
+        // GET: api/Recargas/5
36
+        [HttpGet("{id}")]
37
+        public async Task<ActionResult<DatosPozoRecarga>> GetRecarga(uint id)
38
+        {
39
+            var recarga = await _context.Recargas.FindAsync(id);
40
+
41
+            if (recarga == null)
42
+            {
43
+                return NotFound();
44
+            }
45
+
46
+            DatosPozoRecarga datosRecarga = new DatosPozoRecarga();
47
+            datosRecarga.Id = recarga.Id;
48
+            datosRecarga.Nombre = recarga.Nombre;
49
+            datosRecarga.Latitud = recarga.Latitud;
50
+            datosRecarga.Longitud = recarga.Longitud;
51
+            datosRecarga.Simulacion = recarga.IdSimulacion;
52
+            datosRecarga.Ts = tsRecargaController.GetTsRecarga(id);
53
+
54
+
55
+            return datosRecarga;
56
+
57
+        }
58
+
59
+        // PUT: api/Recargas/5
60
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
61
+        [HttpPut("{id}")]
62
+        public async Task<IActionResult> PutRecarga(uint id, [FromBody] DatosPozoRecarga datos)
63
+        {
64
+            Recarga recarga = _context.Recargas.Find(id);
65
+
66
+            if (id != recarga.Id)
67
+            {
68
+                return BadRequest();
69
+            }
70
+
71
+            
72
+            recarga.IdSimulacion = (datos.Simulacion != null && recarga.IdSimulacion != datos.Simulacion) ? datos.Simulacion : recarga.IdSimulacion;
73
+            recarga.Latitud = (datos.Latitud != null && recarga.Latitud != datos.Latitud) ? datos.Latitud : recarga.Latitud;
74
+            recarga.Longitud = (datos.Longitud != null && recarga.Longitud != datos.Longitud) ? datos.Longitud : recarga.Longitud;
75
+            recarga.Nombre = (datos.Nombre != null && recarga.Nombre != datos.Nombre) ? datos.Nombre : recarga.Nombre;
76
+            
77
+
78
+            //Para editar los datos de la TimeSerie haria falta un identificador más
79
+
80
+            _context.Entry(recarga).State = EntityState.Modified;
81
+
82
+            try
83
+            {
84
+                await _context.SaveChangesAsync();
85
+            }
86
+            catch (DbUpdateConcurrencyException)
87
+            {
88
+                if (!RecargaExists((uint)id))
89
+                {
90
+                    return NotFound();
91
+                }
92
+                else
93
+                {
94
+                    throw;
95
+                }
96
+            }
97
+
98
+            return CreatedAtAction("GetRecarga", new { id = recarga.Id }, recarga);
99
+        }
100
+
101
+        // POST: api/Recargas
102
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
103
+        [HttpPost]
104
+        public async Task<ActionResult<Recarga>> PostRecarga([FromBody] DatosPozoRecarga datos)
105
+        {
106
+            Recarga recarga = new Recarga();
107
+            recarga.IdSimulacion = datos.Simulacion;
108
+            recarga.Nombre = datos.Nombre;
109
+            recarga.Latitud = datos.Latitud;
110
+            recarga.Longitud = datos.Longitud;
111
+            recarga.IdAcuifero = datos.Acuifero;
112
+
113
+            _context.Recargas.Add(recarga);
114
+            try
115
+            {
116
+                await _context.SaveChangesAsync();
117
+
118
+                foreach(TimeSerie ts in datos.Ts)
119
+                {
120
+                    TsRecarga tsRecarga = new TsRecarga();
121
+                    tsRecarga.IdRecarga = recarga.Id;
122
+                    tsRecarga.MarcaTiempo = ts.Hora;
123
+                    tsRecarga.Valor = ts.Valor;
124
+
125
+                    await tsRecargaController.PostTsRecarga(tsRecarga);
126
+                }
127
+            }
128
+            catch (DbUpdateException)
129
+            {
130
+                if (RecargaExists(recarga.Id))
131
+                { 
132
+                    return Conflict();
133
+                }
134
+                else
135
+                {
136
+                    throw;
137
+                }
138
+            }
139
+
140
+            return CreatedAtAction("GetRecarga", new { id = recarga.Id }, recarga);
141
+        }
142
+
143
+        // DELETE: api/Recargas/5
144
+        [HttpDelete("{id}")]
145
+        public async Task<IActionResult> DeleteRecarga(uint id)
146
+        {
147
+            var recarga = await _context.Recargas.FindAsync(id);
148
+            if (recarga == null)
149
+            {
150
+                return NotFound();
151
+            }
152
+
153
+            _context.Recargas.Remove(recarga);
154
+            await _context.SaveChangesAsync();
155
+
156
+            return NoContent();
157
+        }
158
+
159
+        private bool RecargaExists(uint id)
160
+        {
161
+            return _context.Recargas.Any(e => e.Id == id);
162
+        }
163
+
164
+        [NonAction]
165
+        public async void SetRecargasSimulacion(uint? acuiferoId, uint? simulacionId)
166
+        {
167
+            Recarga[] recargas = _context.Recargas.Where(x => x.IdAcuifero == acuiferoId).ToArray<Recarga>();
168
+
169
+            foreach (Recarga r in recargas)
170
+            {
171
+                Recarga recarga = r.Copy(simulacionId);
172
+                _context.Recargas.Add(recarga);
173
+
174
+            }
175
+            await _context.SaveChangesAsync();
176
+        }
177
+
178
+        [NonAction]
179
+        public List<Recarga> GetRecargasSimulacion(uint? simulacionId)
180
+        {
181
+            List<Recarga> recargas = _context.Recargas.Where(x => x.IdSimulacion == simulacionId).ToList<Recarga>();
182
+
183
+            return recargas;
184
+        }
185
+
186
+        [NonAction]
187
+        public Recarga[] GetRecargasAcuifero(uint acuiferoId)
188
+        {
189
+            return _context.Recargas.Where(x => x.IdAcuifero == acuiferoId).ToArray<Recarga>();
190
+        }
191
+
192
+        [NonAction]
193
+        public Recarga[] GetRecargasAcuiferoSimulacionInicial(uint acuiferoId)
194
+        {
195
+            return _context.Recargas.Where(x => x.IdAcuifero == acuiferoId && x.IdSimulacion == null).ToArray<Recarga>();
196
+        }
197
+
198
+        [NonAction]
199
+        public List<TsRecarga> GetTsRecargaFromRecaga(uint? recarga)
200
+        {
201
+            List<TsRecarga> tsRecarga = _context.TsRecargas.Where(x => x.IdRecarga == recarga).ToList<TsRecarga>();
202
+
203
+            return tsRecarga;
204
+        }
205
+
206
+        [NonAction]
207
+        public async Task<ActionResult<IEnumerable<Recarga>>> ParseoFichero(uint aquifer, string file)
208
+        {
209
+            Parser parser = new Parser();
210
+            //string file = @"C:\Users\Admin\Desktop\ASD\infoPozos.VMW";
211
+            RechargeData[] recharges = parser.ParseRechargeData(file, out string recharge_geometry);
212
+            //await aquiferController.SetRechargeGeometry(aquifer, recharge_geometry);
213
+            return await PostMultipleRecharges(aquifer,recharges);
214
+        }
215
+
216
+        [NonAction]
217
+        public async Task<ActionResult<IEnumerable<Recarga>>> PostMultipleRecharges(uint aquifer, RechargeData[] recharges)
218
+        {
219
+            foreach (RechargeData r in recharges)
220
+            {
221
+                Recarga recarga = r.ToRecarga(aquifer);
222
+                _context.Recargas.Add(recarga);
223
+
224
+                try
225
+                {
226
+                    await _context.SaveChangesAsync();
227
+
228
+                    foreach (TimeSerieInterno ts in r.Rates)
229
+                    {
230
+
231
+                        TsRecarga tsRecarga = new(); 
232
+                        tsRecarga.IdRecarga = recarga.Id;
233
+                        tsRecarga.MarcaTiempo = ts.Hora;
234
+                        tsRecarga.Valor = ts.Valor;
235
+
236
+                        await tsRecargaController.PostTsRecarga(tsRecarga);
237
+                    }
238
+
239
+                }
240
+                catch (DbUpdateException)
241
+                {
242
+                    if (RecargaExists(recarga.Id))
243
+                    {
244
+                        return Conflict();
245
+                    }
246
+                    else
247
+                    {
248
+                        throw;
249
+                    }
250
+                }
251
+            }
252
+
253
+            return await _context.Recargas.ToListAsync();
254
+        }
255
+    }
256
+}

+ 173 - 0
WorkerService1/WebApplication3/Controllers/ServiceQueueController.cs Ver fichero

@@ -0,0 +1,173 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using Microsoft.AspNetCore.Http;
6
+using Microsoft.AspNetCore.Mvc;
7
+using Microsoft.EntityFrameworkCore;
8
+using WebApplication3.Models;
9
+using WebApplication3.Clases;
10
+
11
+namespace WebApplication3.Controllers
12
+{
13
+    [Route("api/queue")]
14
+    [ApiController]
15
+    public class ServiceQueueController : ControllerBase
16
+    {
17
+        private readonly AquiferContext _context;
18
+        //private TsPozoController tsPozoController;
19
+        
20
+        
21
+        public ServiceQueueController(AquiferContext context)
22
+        {
23
+            _context = context;
24
+            //tsPozoController = new TsPozoController(context);
25
+            
26
+        }
27
+
28
+        // GET: api/Pozo
29
+        [HttpGet]
30
+        public async Task<ActionResult<IEnumerable<ServiceQueue>>> GetQueue()
31
+        {
32
+            return await _context.ServiceQueue.ToListAsync();
33
+        }
34
+
35
+        // GET: api/Pozo/5
36
+        [HttpGet("{id}")]
37
+        public async Task<ActionResult<ServiceQueue>> GetQueueItem(uint id)
38
+        {            
39
+            var queueItem = await _context.ServiceQueue.FindAsync(id);
40
+            
41
+            if (queueItem == null)
42
+            {
43
+                return NotFound();
44
+            }
45
+            
46
+            return queueItem;
47
+        }
48
+
49
+        [HttpGet("Running")]
50
+        public async Task<bool> ServiceRunning()
51
+        {
52
+            var queueItem = await _context.ServiceQueue.AnyAsync(x => x.Corriendo != 0);
53
+                
54
+            return queueItem;
55
+        }
56
+        
57
+        [HttpGet("Inqueue")]
58
+        public async Task<bool> AnyInQueue()
59
+        {
60
+            return await _context.ServiceQueue.AnyAsync(x => x.Terminado == 0 && x.Corriendo == 0 && x.Error == 0);
61
+        }
62
+
63
+        [HttpGet("Next")]
64
+        public ServiceQueue GetNextInQueue()
65
+        {
66
+            return _context.ServiceQueue.Where(x => x.Terminado == 0 && x.Corriendo == 0 && x.Error == 0).OrderBy(x=> x.Id).FirstOrDefault();
67
+        }
68
+
69
+        [HttpPost("Corriendo/{id}")]
70
+        public async Task<int> SetCorriendo(uint id)
71
+        {
72
+            var serviceQueueItem = await _context.ServiceQueue.FindAsync(id);
73
+
74
+            serviceQueueItem.Corriendo = 1;
75
+            serviceQueueItem.Inicio = DateTime.Now.ToString();
76
+
77
+            _context.Entry(serviceQueueItem).State = EntityState.Modified;
78
+
79
+            int result = 0;
80
+            try
81
+            {
82
+                result = await _context.SaveChangesAsync();
83
+            }
84
+            catch (DbUpdateConcurrencyException)
85
+            {
86
+
87
+            }
88
+
89
+            return result;
90
+        }
91
+
92
+        [NonAction]
93
+        public async Task<ActionResult<ServiceQueue>> SetTerminado(uint id)
94
+        {
95
+            var serviceQueueItem = await _context.ServiceQueue.FindAsync(id);
96
+
97
+            serviceQueueItem.Corriendo = 0;
98
+            serviceQueueItem.Terminado = 1;
99
+            serviceQueueItem.Fin = DateTime.Now.ToString();
100
+
101
+            _context.Entry(serviceQueueItem).State = EntityState.Modified;
102
+
103
+            try
104
+            {
105
+                await _context.SaveChangesAsync();
106
+            }
107
+            catch (DbUpdateConcurrencyException)
108
+            {
109
+                if (!ServiceQueueExists(id))
110
+                {
111
+                    return NotFound();
112
+                }
113
+                else
114
+                {
115
+                    throw;
116
+                }
117
+            }
118
+
119
+            return CreatedAtAction("GetQueueItem", new { id = serviceQueueItem.Id }, serviceQueueItem);
120
+        }
121
+
122
+
123
+        // POST: api/ServiceQueue
124
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
125
+        [HttpPost]
126
+        public async Task<ActionResult<ServiceQueue>> PostServiceQueue(ServiceQueue serviceQueue)
127
+        {
128
+
129
+            _context.ServiceQueue.Add(serviceQueue);
130
+            try
131
+            {
132
+                await _context.SaveChangesAsync();
133
+
134
+            }
135
+            catch (DbUpdateException)
136
+            {
137
+                if (ServiceQueueExists(serviceQueue.Id))
138
+                {
139
+                    return Conflict();
140
+                }
141
+                else
142
+                {
143
+                    throw;
144
+                }
145
+            }
146
+
147
+
148
+            return CreatedAtAction("GetQueueItem", new { id = serviceQueue.Id }, serviceQueue);
149
+        }
150
+
151
+        // DELETE: api/Pozo/5
152
+        [HttpDelete("{id}")]
153
+        public async Task<IActionResult> DeleteServiceQueue(uint id)
154
+        {
155
+            var serviceQueueItem = await _context.ServiceQueue.FindAsync(id);
156
+            if (serviceQueueItem == null)
157
+            {
158
+                return NotFound();
159
+            }
160
+            
161
+            _context.ServiceQueue.Remove(serviceQueueItem);
162
+            await _context.SaveChangesAsync();
163
+
164
+            return NoContent();
165
+        }
166
+
167
+        private bool ServiceQueueExists(uint id)
168
+        {
169
+            return _context.ServiceQueue.Any(e => e.Id == id);
170
+        }
171
+
172
+    }
173
+}

+ 312 - 0
WorkerService1/WebApplication3/Controllers/ServicioController.cs Ver fichero

@@ -0,0 +1,312 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using Microsoft.AspNetCore.Http;
6
+using Microsoft.AspNetCore.Mvc;
7
+using Microsoft.EntityFrameworkCore;
8
+using WebApplication3.Models;
9
+using WebApplication3.Clases;
10
+
11
+
12
+namespace WebApplication3.Controllers
13
+{
14
+    [Route("api/servicio")]
15
+    [ApiController]
16
+    public class ServicioController : ControllerBase
17
+    {
18
+        private readonly AquiferContext _context;
19
+
20
+        public ServicioController(AquiferContext context)
21
+        {
22
+            _context = context;
23
+        }
24
+
25
+        // GET: api/Servicio
26
+        [HttpGet]
27
+        public async Task<ActionResult<IEnumerable<Servicio>>> GetServicios()
28
+        {
29
+            return await _context.Servicios.ToListAsync();
30
+        }
31
+
32
+        // GET: api/Servicio/5
33
+        [HttpGet("{id}")]
34
+        public async Task<ActionResult<Servicio>> GetServicio(uint id)
35
+        {
36
+            var servicio = await _context.Servicios.FindAsync(id);
37
+
38
+            if (servicio == null)
39
+            {
40
+                return NotFound();
41
+            }
42
+
43
+            return servicio;
44
+        }
45
+
46
+        // PUT: api/Servicio/5
47
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
48
+        [HttpPut("{id}")]
49
+        public async Task<IActionResult> PutServicio(uint id, Servicio servicio)
50
+        {
51
+            if (id != servicio.Id)
52
+            {
53
+                return BadRequest();
54
+            }
55
+
56
+            _context.Entry(servicio).State = EntityState.Modified;
57
+
58
+            try
59
+            {
60
+                await _context.SaveChangesAsync();
61
+            }
62
+            catch (DbUpdateConcurrencyException)
63
+            {
64
+                if (!ServicioExists(id))
65
+                {
66
+                    return NotFound();
67
+                }
68
+                else
69
+                {
70
+                    throw;
71
+                }
72
+            }
73
+
74
+            return NoContent();
75
+        }
76
+
77
+        // POST: api/Servicio
78
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
79
+        [HttpPost]
80
+        public async Task<ActionResult<Servicio>> PostServicio(Servicio servicio)
81
+        {
82
+            servicio.Id = GetLastId()+1;
83
+            servicio.Terminado = 0;
84
+            _context.Servicios.Add(servicio);
85
+            try
86
+            {
87
+                await _context.SaveChangesAsync();
88
+
89
+            }
90
+            catch (DbUpdateException ex)
91
+            {
92
+                Logger.WriteLog(ex.InnerException.Message);
93
+            }
94
+
95
+            return CreatedAtAction("GetServicio", new { id = servicio.Id }, servicio);
96
+        }
97
+
98
+        // DELETE: api/Servicio/5
99
+        [HttpDelete("{id}")]
100
+        public async Task<IActionResult> DeleteServicio(uint id)
101
+        {
102
+            var servicio = await _context.Servicios.FindAsync(id);
103
+            if (servicio == null)
104
+            {
105
+                return NotFound();
106
+            }
107
+
108
+            _context.Servicios.Remove(servicio);
109
+            await _context.SaveChangesAsync();
110
+
111
+            return NoContent();
112
+        }
113
+
114
+        private bool ServicioExists(uint id)
115
+        {
116
+            return _context.Servicios.Any(e => e.Id == id);
117
+        }
118
+
119
+        // GET: api/Servicio/simula
120
+        [HttpGet("simularest")]
121
+        public Task<ActionResult<Servicio>> SimulaRest()
122
+        {
123
+            string respuesta = "";
124
+
125
+            Proceso proceso = Proceso.GetInstance();
126
+            proceso.setParametersModflow(@"C:\Users\Admin\Desktop\TestExtract\simulaicionsimulacion_test", "AA.modflow.in");
127
+            try
128
+            {
129
+                if (!proceso.Started)
130
+                {
131
+                    proceso.Start();
132
+                    respuesta = "Id: " + proceso.GetPid();
133
+                    Servicio s = new Servicio();
134
+                    s.Id = GetLastId() + 1;
135
+                    s.Pid = (uint)proceso.GetPid();
136
+                    s.Terminado = 0;
137
+                    return PostServicio(s);
138
+                }
139
+            }
140
+            catch (Exception ex)
141
+            {
142
+                respuesta = ex.Message;
143
+                throw;
144
+            }
145
+
146
+
147
+            return null;
148
+
149
+        }
150
+
151
+        [NonAction]
152
+        public async Task<ActionResult<Servicio>> SimulaModflow(string workingDirectory, string arguments)
153
+        {
154
+            string respuesta = "";
155
+
156
+            Proceso proceso = Proceso.GetInstance();
157
+            Logger logger = Logger.GetInstance();
158
+            proceso.ResetProcess();
159
+            proceso.setParametersModflow(workingDirectory, arguments);
160
+
161
+            try
162
+            {
163
+                if (!proceso.Started)
164
+                {
165
+                    proceso.Start();
166
+                    respuesta = "Id: " + proceso.GetPid();
167
+                    Servicio s = new Servicio();
168
+                    s.Id = GetLastId() + 1;
169
+                    s.Pid = (uint)proceso.GetPid();
170
+                    s.Terminado = 0;
171
+                    s.Inicio = DateTime.Now.ToString();
172
+                    s.Tipo = "MODFLOW";
173
+                    Logger.WriteLog("MODFLOW " + s.Pid);
174
+                    var postServicio = await PostServicio(s);
175
+                    proceso.WaitForExit();
176
+                    return postServicio;
177
+                }
178
+            }
179
+            catch (Exception ex)
180
+            {
181
+                respuesta = ex.Message;
182
+                throw;
183
+            }
184
+
185
+
186
+            return null;
187
+
188
+        }
189
+
190
+        [NonAction]
191
+        public async Task<ActionResult<Servicio>> SimulaZoneBudget(string workingDirectory, string budgetFile, string zoneFile)
192
+        {
193
+            string respuesta = "";
194
+            Logger logger = Logger.GetInstance();
195
+            Logger.WriteLog("working directory: " + workingDirectory + " | budgetFile: " + budgetFile + " | zoneFile: " + zoneFile);
196
+            Proceso proceso = Proceso.GetInstance();
197
+            proceso.ResetProcess();
198
+            proceso.setParametersZoneBudget(workingDirectory);
199
+
200
+            try
201
+            {
202
+                if (!proceso.Started)
203
+                {
204
+                    proceso.Start();
205
+                    respuesta = "Id: " + proceso.GetPid();
206
+                    Servicio s = new Servicio();
207
+                    s.Id = GetLastId() + 1;
208
+                    s.Pid = (uint)proceso.GetPid();
209
+                    s.Terminado = 0;
210
+                    s.Inicio = DateTime.Now.ToString();
211
+                    s.Tipo = "ZONEBUDGET";
212
+                    Logger.WriteLog("ZONEBUDGET "+s.Pid);
213
+                    var postServicio = await PostServicio(s);
214
+
215
+                    string[] prompts = { "outputZoneBudget.zblst", budgetFile, "test", zoneFile, "A" };
216
+
217
+                    proceso.ExecuteZonebudget(prompts);
218
+
219
+                    return postServicio;
220
+                }
221
+            }
222
+            catch (Exception ex)
223
+            {
224
+                respuesta = ex.Message;
225
+                throw;
226
+            }
227
+
228
+            return null;
229
+        }
230
+
231
+        [NonAction]
232
+        public async Task<ActionResult<Servicio>> GetIsolinesWithPython(string workingDirectory,string headFile, int rows, int cols)
233
+        {
234
+            Logger logger = Logger.GetInstance();
235
+            Proceso proceso = Proceso.GetInstance();
236
+            int isolines = 30;
237
+            proceso.ResetProcess();
238
+            proceso.setParametersPython(workingDirectory,headFile,rows,cols,isolines);
239
+            proceso.Start();
240
+            Servicio s = new Servicio();
241
+            s.Id = GetLastId() + 1;
242
+            s.Pid = (uint)proceso.GetPid();
243
+            s.Terminado = 0;
244
+            s.Inicio = DateTime.Now.ToString();
245
+            s.Tipo = "PYTHON";
246
+            var postServicio = await PostServicio (s); ;
247
+            proceso.WaitForExit();
248
+            return postServicio;
249
+        }
250
+
251
+        // GET: api/Servicio/stopped
252
+        [HttpGet("stopped")]
253
+        public bool HasStopped()
254
+        {
255
+            Proceso proceso = Proceso.GetInstance();
256
+            return proceso.HasExited();
257
+        }
258
+
259
+        // GET: api/Servicio/detected
260
+        [HttpGet("detected")]
261
+        public bool HasDetected()
262
+        {
263
+            Proceso proceso = Proceso.GetInstance();
264
+            return proceso.Detected;
265
+        }
266
+
267
+        [HttpGet("lastid")]
268
+        public uint GetLastId()
269
+        {
270
+            if(_context.Servicios.Count() == 0)
271
+            {
272
+                return 0;
273
+            }
274
+
275
+            Servicio last = _context.Servicios.OrderByDescending(s => s.Id).First();
276
+
277
+            if (last != null)
278
+            {
279
+                return last.Id;
280
+            }
281
+            else
282
+            {
283
+                return 0;
284
+            }
285
+        }
286
+
287
+        [NonAction]
288
+        public async Task<int> setTerminado(int pid)
289
+        {
290
+
291
+            Servicio servicio = _context.Servicios.FromSqlRaw("SELECT * FROM servicio WHERE pid = {0} ORDER BY id DESC", pid).First();
292
+
293
+            servicio.Terminado = 1;
294
+            servicio.Fin = DateTime.Now.ToString();
295
+            _context.Entry(servicio).State = EntityState.Modified;
296
+            int result = 0;
297
+            try
298
+            {
299
+                result = await _context.SaveChangesAsync();
300
+            }
301
+            catch (DbUpdateConcurrencyException)
302
+            {
303
+                
304
+            }
305
+
306
+            Logger.WriteLog("TERMINADO " + pid);
307
+
308
+            return result;
309
+
310
+        }
311
+    }
312
+}

+ 533 - 0
WorkerService1/WebApplication3/Controllers/SimulacionController.cs Ver fichero

@@ -0,0 +1,533 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using Microsoft.AspNetCore.Http;
6
+using Microsoft.AspNetCore.Mvc;
7
+using Microsoft.EntityFrameworkCore;
8
+using WebApplication3.Models;
9
+using WebApplication3.Clases;
10
+using System.IO;
11
+using System.IO.Compression;
12
+using System.Threading;
13
+using Newtonsoft.Json;
14
+
15
+namespace WebApplication3.Controllers
16
+{
17
+    [Route("api/[controller]")]
18
+    [ApiController]
19
+    public class SimulacionController : ControllerBase
20
+    {
21
+        
22
+        private readonly AquiferContext _context;
23
+        private PozoController pozoController;
24
+        private RecargasController recargasController;
25
+        private AcuiferoController acuiferoController;
26
+        private ServicioController serviceController;
27
+        private BalanceHidricoController balanceHidricoController;
28
+        private PiezometriaController piezometriaController;
29
+        private ServiceQueueController serviceQueueController;
30
+
31
+        public SimulacionController(AquiferContext context)
32
+        {
33
+            _context = context;
34
+            pozoController = new PozoController(context);
35
+            recargasController = new RecargasController(context);
36
+            acuiferoController = new AcuiferoController(context);
37
+            serviceController = new ServicioController(context);
38
+            balanceHidricoController = new BalanceHidricoController(context);
39
+            piezometriaController= new PiezometriaController(context);
40
+            serviceQueueController = new ServiceQueueController(context);
41
+        }
42
+
43
+        // GET: api/Simulacion
44
+        [HttpGet]
45
+        public async Task<ActionResult<IEnumerable<Simulacion>>> GetSimulaciones()
46
+        {
47
+            return await _context.Simulaciones.ToListAsync();
48
+        }
49
+
50
+        // GET: api/Simulacion/5
51
+        [HttpGet("{id}")]
52
+        public async Task<ActionResult<Simulacion>> GetSimulacion(uint id)
53
+        {
54
+            var simulacion = await _context.Simulaciones.FindAsync(id);
55
+
56
+            if (simulacion == null)
57
+            {
58
+                return NotFound();
59
+            }
60
+
61
+            return simulacion;
62
+        }
63
+
64
+        // POST: api/Simulacion
65
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
66
+        [HttpPost]
67
+        public async Task<ActionResult<Simulacion>> PostSimulacion(Simulacion simulacion)
68
+        {
69
+            _context.Simulaciones.Add(simulacion);
70
+            await _context.SaveChangesAsync();
71
+
72
+            //prepacion de los valores por defecto para la simulación
73
+            pozoController.SetPozosSimulacion(simulacion.IdAcuifero,simulacion.Id);
74
+            recargasController.SetRecargasSimulacion(simulacion.IdAcuifero, simulacion.Id);
75
+
76
+            return CreatedAtAction("GetSimulacion", new { id = simulacion.Id }, simulacion);
77
+        }
78
+
79
+        [HttpPost("Simula/{simulacionId}")]
80
+        public async Task<bool> QueueSim(uint simulacionId)
81
+        {
82
+            Simulacion simulacion = _context.Simulaciones.Find(simulacionId);
83
+
84
+            ServiceQueue serviceQueue = new ServiceQueue();
85
+            serviceQueue.IdSimulacion = simulacionId;
86
+            serviceQueue.IdAcuifero = simulacion.IdAcuifero;
87
+
88
+            await serviceQueueController.PostServiceQueue(serviceQueue);
89
+            
90
+            return true;
91
+        }
92
+
93
+        [HttpPut("UpdateSimWellData")]
94
+        public async Task<ActionResult<bool>> UpdateSimWellsFromCsv(uint simulationId, [FromBody] DatosPostSimulacion data)
95
+        {
96
+            bool result = true;
97
+            Parser parser = new();
98
+            Simulacion sim = _context.Simulaciones.Find(simulationId);
99
+            string file = Constants.PathExtract + data.Fichero.Nombre;
100
+
101
+            //1. Se eliminan los pozos con sus respectivas time series de la bbdd ya que se va a sobreescribir la informacion
102
+            await pozoController.DeletePozoFromSim(simulationId);
103
+            //2. Guardamos el fichero que nos viene en el body en formato base64
104
+            try
105
+            {
106
+                byte[] tempBytes = Convert.FromBase64String(data.Fichero.Base64);
107
+                System.IO.File.WriteAllBytes( file, tempBytes);
108
+
109
+            }
110
+            catch (Exception ex)
111
+            {
112
+                return Problem(ex.Message);
113
+            }
114
+
115
+            WellData[] wellDatas = parser.parseWellCSV(file);
116
+
117
+            await pozoController.PostMultipleWells((uint)sim.IdAcuifero,wellDatas);
118
+
119
+            return result;
120
+        }
121
+
122
+        [HttpPut]
123
+        public async Task<ActionResult<bool>> UpdateSimRechargesFromCsv(uint simulationId, [FromBody] DatosPostSimulacion data)
124
+        {
125
+            bool result = true;
126
+            Parser parser = new();
127
+            Simulacion sim = _context.Simulaciones.Find(simulationId);
128
+            string file = Constants.PathExtract + data.Fichero.Nombre;
129
+
130
+            //1. Se eliminan los pozos con sus respectivas time series de la bbdd ya que se va a sobreescribir la informacion
131
+            await pozoController.DeletePozoFromSim(simulationId);
132
+            //2. Guardamos el fichero que nos viene en el body en formato base64
133
+            try
134
+            {
135
+                byte[] tempBytes = Convert.FromBase64String(data.Fichero.Base64);
136
+                System.IO.File.WriteAllBytes(file, tempBytes);
137
+
138
+            }
139
+            catch (Exception ex)
140
+            {
141
+                return Problem(ex.Message);
142
+            }
143
+
144
+            RechargeData[] rechargeDatas = parser.parseRechargeCSV(file);
145
+
146
+            
147
+            await recargasController.PostMultipleRecharges((uint)sim.IdAcuifero, rechargeDatas);
148
+
149
+            return result;
150
+        }
151
+
152
+        // PUT: api/Simulacion/5
153
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754s
154
+        [HttpPut("{id}")]
155
+        public async Task<IActionResult> PutSimulacion(uint id, [FromBody] DatosPostSimulacion datos)
156
+        {
157
+            Simulacion simulacion = _context.Simulaciones.Find(id);
158
+
159
+            if (id != simulacion.Id)
160
+            {
161
+                return BadRequest();
162
+            }
163
+
164
+
165
+            simulacion.Nombre = (datos.Nombre != null && datos.Nombre != simulacion.Nombre) ? datos.Nombre : simulacion.Nombre;
166
+
167
+            _context.Entry(simulacion).State = EntityState.Modified;
168
+
169
+            try
170
+            {
171
+                await _context.SaveChangesAsync();
172
+            }
173
+            catch (DbUpdateConcurrencyException)
174
+            {
175
+                if (!SimulacionExists(id))
176
+                {
177
+                    return NotFound();
178
+                }
179
+                else
180
+                {
181
+                    throw;
182
+                }
183
+            }
184
+
185
+            return CreatedAtAction("GetSimulacion", new { id = simulacion.Id }, simulacion);
186
+        }
187
+
188
+        // DELETE: api/Simulacion/5
189
+        [HttpDelete("{id}")]
190
+        public async Task<IActionResult> DeleteSimulacion(uint id)
191
+        {
192
+            var simulacion = await _context.Simulaciones.FindAsync(id);
193
+            if (simulacion == null)
194
+            {
195
+                return NotFound();
196
+            }
197
+
198
+            _context.Simulaciones.Remove(simulacion);
199
+            await _context.SaveChangesAsync();
200
+
201
+            return NoContent();
202
+        }
203
+
204
+        [NonAction]
205
+        public async Task<bool> SimulaAsync(ServiceQueue serviceQueue)
206
+        {
207
+            Logger logger = Logger.GetInstance();
208
+            await serviceQueueController.SetCorriendo(serviceQueue.Id);
209
+
210
+            uint simulacionId = (uint)serviceQueue.IdSimulacion;
211
+            Simulacion simulacion = _context.Simulaciones.Find(simulacionId);
212
+
213
+            //Obtenemos el nombre de fichero original del acuifero
214
+            string zip = acuiferoController.GetFicheroZip((uint)simulacion.IdAcuifero);
215
+            Logger.WriteLog("estoy simulando");
216
+            if (zip != string.Empty)
217
+            {
218
+                Parser parser = new Parser();
219
+                string zip_name = "simulaicion" + simulacion.Nombre;
220
+                string zip_copy = zip_name + ".zip";
221
+                System.IO.File.Copy(Constants.PathZip + zip, Constants.PathZip + zip_copy, true);
222
+
223
+                string workingDirectory = Constants.PathExtract + zip_name + "\\";
224
+                //Descomprimimos copia para escribir en fichero
225
+                Directory.CreateDirectory(workingDirectory);
226
+                ZipFile.ExtractToDirectory(Constants.PathZip + zip_copy, workingDirectory, true);
227
+
228
+                //Obtenemos fichero de pozo y recargas
229
+                List<string> files = Directory.GetFiles(workingDirectory).ToList<string>();
230
+
231
+                string pozoFile = files.Find(x => x.Contains(".VMW"));
232
+                string recargaFile = files.Find(x => x.Contains(".VMP"));
233
+                string inFile = files.Find(x => x.Contains(".MODFLOW.IN") || x.Contains(".modflow.in"));
234
+                string zoneFile = files.Find(x => x.Contains(".ZBI") || x.Contains(".zbi"));
235
+
236
+                //3- Parseamos pozos
237
+                if (System.IO.File.Exists(pozoFile))
238
+                {
239
+                    List<WellData> infoPozosFichero = parser.ParseWellData(pozoFile).ToList<WellData>();
240
+                    List<Pozo> pozos = pozoController.GetPozosSimulacion(simulacionId);
241
+                    List<string> lines = new List<string>();
242
+
243
+                    //Por ahora asumimos que el fichero tiene la misma cantidad de pozos que en bbdd para esta simulacion
244
+                    string[] maxDefault = infoPozosFichero[0].ZMax.Split(" ");
245
+
246
+
247
+                    lines.Add(pozos.Count.ToString());
248
+                    foreach (Pozo p in pozos)
249
+                    {
250
+                        List<TsPozo> timeSeriesPozo = pozoController.GetTsPozoFromPozo(p.Id);
251
+                        lines.Add("0"); //Activo o inactivo
252
+                        lines.Add(p.Nombre);
253
+                        lines.Add(p.Latitud.ToString());
254
+                        lines.Add(p.Longitud.ToString());
255
+                        lines.Add(p.Minimo.ToString());
256
+                        maxDefault[0] = p.Maximo.ToString();
257
+                        string aux = String.Join(' ', maxDefault);
258
+                        lines.Add(aux); //Maximo
259
+                        lines.Add(infoPozosFichero[0].ScreenIntervals.ToString()); //screen intervals
260
+                        lines.Add(infoPozosFichero[0].Top);
261
+                        lines.Add(infoPozosFichero[0].Bot);
262
+                        lines.Add(timeSeriesPozo.Count.ToString());
263
+
264
+                        for (int i = 0; i < timeSeriesPozo.Count - 1; i++)
265
+                        {
266
+                            lines.Add(timeSeriesPozo[i].MarcaTiempo);
267
+                            lines.Add(timeSeriesPozo[i + 1].MarcaTiempo);
268
+                            lines.Add(timeSeriesPozo[i].Valor.ToString() + " " + timeSeriesPozo[i].InfoComplementaria);
269
+                        }
270
+                    }
271
+
272
+                    //System.IO.File.WriteAllLines(@"C:\Users\Admin\Desktop\Test.VMW", lines);
273
+                    System.IO.File.WriteAllLines(pozoFile, lines);
274
+
275
+                }
276
+
277
+
278
+                //4- Parseamos recargas
279
+                if (System.IO.File.Exists(recargaFile))
280
+                {
281
+                    List<Recarga> recargas = recargasController.GetRecargasSimulacion(simulacionId);
282
+
283
+                    string text = System.IO.File.ReadAllText(recargaFile);
284
+                    string[] data = text.Split("\r\n\r\n");
285
+
286
+                    int layers = int.Parse(data[0][0].ToString());
287
+                    int blankLinePerBlock = layers + 1;
288
+                    int rechargeBlockInex = blankLinePerBlock * 2;
289
+
290
+
291
+                    List<string> lines = new List<string>();
292
+
293
+                    //Hasta el bloque de recargas vamos poniendo el texto que le precede
294
+                    for (int i = 0; i < rechargeBlockInex; i++)
295
+                    {
296
+                        lines.AddRange(data[i].Split("\r\n").ToList());
297
+                        lines.Add("");
298
+                    }
299
+
300
+                    //Bloque recargas
301
+                    lines.Add(recargas.Count.ToString());
302
+
303
+                    int index = 1;
304
+                    foreach (Recarga r in recargas)
305
+                    {
306
+                        List<TsRecarga> tsRecarga = recargasController.GetTsRecargaFromRecaga(r.Id);
307
+                        lines.Add(index + " 1 Index 1");
308
+                        lines.Add("1 rchr entries");
309
+                        lines.Add(index + " " + tsRecarga[0].Valor + "               " + tsRecarga[0].MarcaTiempo + "               " + tsRecarga[1].MarcaTiempo + " " + tsRecarga[0].InfoComplementaria);
310
+
311
+                    }
312
+                    lines.Add("");
313
+
314
+                    //Hasta el final
315
+                    for (int i = rechargeBlockInex + 1; i < data.Length; i++)
316
+                    {
317
+                        lines.AddRange(data[i].Split("\r\n").ToList());
318
+                        //controlamos que en la ultima iteracion no introduzca un \r\n
319
+                        if (i < data.Length - 1)
320
+                        {
321
+                            lines.Add("");
322
+                        }
323
+                    }
324
+
325
+                    //System.IO.File.WriteAllLines(@"C:\Users\Admin\Desktop\TestRec.VMP", lines);
326
+                    System.IO.File.WriteAllLines(recargaFile, lines);
327
+
328
+
329
+                }
330
+
331
+                //5.Ejecutamos el modelo
332
+                //Primeramente, para ejecutar el modelo, hay que modificar el contenido del fichero con extension .in para que no de error al ejecutarse el modelo
333
+                if (System.IO.File.Exists(inFile))
334
+                {
335
+                    List<string> inFileLines = parser.ParseInFile(inFile);
336
+                    System.IO.File.WriteAllLines(inFile, inFileLines);
337
+                }
338
+                string inFileName = inFile.Split("\\").ToList().Last();
339
+
340
+                Logger.WriteLog("ejecuto modflow");
341
+                await serviceController.SimulaModflow(workingDirectory, inFileName);
342
+                Thread.Sleep(5000);
343
+                Logger.WriteLog("fin modflow");
344
+
345
+                //6.Ejecucion Zonebudget
346
+                //Seguidamente miramos el fichero de resultado de zonas (si existe)
347
+                if (zoneFile != null && System.IO.File.Exists(zoneFile))
348
+                {
349
+                    files = Directory.GetFiles(workingDirectory).ToList<string>();
350
+                    string budgetFile = files.Find(x => x.Contains(".BGT"));
351
+                    Logger.WriteLog("budgetFile" + budgetFile);
352
+
353
+                    await serviceController.SimulaZoneBudget(workingDirectory, budgetFile, zoneFile);
354
+                    Thread.Sleep(5000);
355
+                    Logger.WriteLog("fin zonebudget");
356
+
357
+                }
358
+
359
+
360
+                //7. Parseo de salidas
361
+                files = Directory.GetFiles(workingDirectory).ToList<string>();
362
+
363
+                string zoneResultsFile = files.Find(x => x.Contains(".zblst"));
364
+                string modelResultsFile = files.Find(x => x.Contains(".LST"));
365
+                string piezometryFile = files.Find(x => x.Contains(".HDS"));
366
+
367
+                //Parseo del fichero de balance hidrico por zonas
368
+
369
+                if (System.IO.File.Exists(zoneResultsFile))
370
+                {
371
+                    Logger.WriteLog("inicio balance zonas");
372
+                    ZoneBalance[] zoneBalance = parser.ParseZonesBalance(zoneResultsFile);
373
+
374
+                    //Se inserta el balance hidrico en bbdd
375
+                    foreach (ZoneBalance zone in zoneBalance)
376
+                    {
377
+                        //Obtenemos la respuestas de la creacion con el objeto
378
+                        var resultBalance = await balanceHidricoController.PostBalance(zone.ToBalanceHidrico(simulacionId));
379
+
380
+                        uint balanceId = resultBalance.Value;
381
+
382
+                        var dataIn = await balanceHidricoController.PostBalanceIn(zone.In.ToDatosBalanceIn(balanceId));
383
+
384
+                        uint balanceDataInId = dataIn.Value;
385
+
386
+                        List<ConexionZonasIn> conexionZonasIns = new List<ConexionZonasIn>();
387
+
388
+                        zone.In.ZoneConnections.ForEach(x => conexionZonasIns.Add(x.ToConexionIn(balanceDataInId)));
389
+
390
+                        await balanceHidricoController.PostMultipleConnectionIn(conexionZonasIns.ToArray());
391
+
392
+                        var dataOut = await balanceHidricoController.PostBalanceOut(zone.Out.ToDatosBalanceOut(balanceId));
393
+                        uint balanceDataOutId = dataOut.Value;
394
+
395
+                        List<ConexionZonasOut> conexionZonasOuts = new List<ConexionZonasOut>();
396
+
397
+                        zone.Out.ZoneConnections.ForEach(x => conexionZonasOuts.Add(x.ToConexionOut(balanceDataOutId)));
398
+
399
+                        await balanceHidricoController.PostMultipleConnectionOut(conexionZonasOuts.ToArray());
400
+                    }
401
+                    Logger.WriteLog("fin balance hidrico zonas");
402
+                }
403
+
404
+                //Parseo del fichero de resultados sobre el modelo entero
405
+                if (System.IO.File.Exists(modelResultsFile))
406
+                {
407
+                    Logger.WriteLog("inicio balance modelo entero");
408
+                    ZoneBalance[] modelBalance = parser.ParseWholeModelBalance(modelResultsFile);
409
+
410
+                    //insertamos en bbdd
411
+                    foreach (ZoneBalance zone in modelBalance)
412
+                    {
413
+                        var result = await balanceHidricoController.PostBalance(zone.ToBalanceHidrico(simulacionId));
414
+                        uint balanceId = result.Value;
415
+
416
+                        await balanceHidricoController.PostBalanceIn(zone.In.ToDatosBalanceIn(balanceId));
417
+                        await balanceHidricoController.PostBalanceOut(zone.Out.ToDatosBalanceOut(balanceId));
418
+                    }
419
+                    Logger.WriteLog("fin balance modelo entero");
420
+                }
421
+
422
+                //Parseo del fichero HDS para obtener el mapa de piezometria
423
+                if (System.IO.File.Exists(piezometryFile))
424
+                {
425
+                    Logger.WriteLog("inicio piezometria");
426
+                    List<Piezometria> piezometrias = parser.ParseBinaryFile(piezometryFile, simulacionId);
427
+
428
+                    foreach (Piezometria p in piezometrias)
429
+                    {
430
+                        await piezometriaController.PostPiezometria(p);
431
+                    }
432
+                    Logger.WriteLog("fin piezometria");
433
+                }
434
+                piezometriaController.getDimensions(simulacionId, out int rows, out int cols);
435
+
436
+                await serviceController.GetIsolinesWithPython(workingDirectory, piezometryFile, rows, cols);
437
+                Thread.Sleep(5000);
438
+
439
+                Byte[] bytes = System.IO.File.ReadAllBytes(workingDirectory + "test.png");
440
+                String base64Image = Convert.ToBase64String(bytes);
441
+
442
+
443
+                await SetIsolinesImage(simulacionId, base64Image);
444
+
445
+
446
+                await serviceQueueController.SetTerminado(serviceQueue.Id);
447
+                Logger.WriteLog("terminado");
448
+            }
449
+            return true;
450
+        }
451
+
452
+
453
+        [HttpGet("Geojson")]
454
+        public GeoJson GetGeoJson()
455
+        {
456
+            string allText = System.IO.File.ReadAllText(@"C:\Users\Admin\Desktop\AAAA\test_aa.geojson");
457
+            allText = allText.Replace("[[[","[[");
458
+            allText = allText.Replace("]]]", "]]");
459
+            GeoJson jsonObject = JsonConvert.DeserializeObject<GeoJson>(allText);
460
+            return jsonObject;
461
+        }
462
+        private bool SimulacionExists(uint id)
463
+        {
464
+            return _context.Simulaciones.Any(e => e.Id == id);
465
+        }
466
+
467
+        private async Task<IActionResult> SetIsolinesImage(uint simulacionId, string imageBase64)
468
+        {
469
+            var simulacion = _context.Simulaciones.Find(simulacionId);
470
+
471
+            if (simulacionId != simulacion.Id)
472
+            {
473
+                return BadRequest();
474
+            }
475
+
476
+
477
+            simulacion.IsolineImage = imageBase64;
478
+
479
+            _context.Entry(simulacion).State = EntityState.Modified;
480
+
481
+            try
482
+            {
483
+                await _context.SaveChangesAsync();
484
+            }
485
+            catch (DbUpdateConcurrencyException)
486
+            {
487
+                if (!SimulacionExists(simulacionId))
488
+                {
489
+                    return NotFound();
490
+                }
491
+                else
492
+                {
493
+                    throw;
494
+                }
495
+            }
496
+
497
+            return CreatedAtAction("GetSimulacion", new { id = simulacion.Id }, simulacion);
498
+        }
499
+
500
+        /*
501
+         * TEST ENDPOINTS
502
+         */
503
+        [HttpPost("Simula/Python/{simulacionId}")]
504
+        public async Task<bool> SimIsolinesWithPython(uint simulacionId)
505
+        {
506
+            string workingDirectory = @"C:\Users\Admin\Desktop\TestExtract\simulaicionsimulacion_test\";
507
+            string headFile = @"C:\Users\Admin\Desktop\TestExtract\simulaicionsimulacion_test\EJEMPLO_SOTIEL.HDS";
508
+
509
+            int rows, cols;
510
+            piezometriaController.getDimensions(simulacionId, out rows, out cols);
511
+            await serviceController.GetIsolinesWithPython(workingDirectory, headFile, rows, cols);
512
+            Thread.Sleep(3000);
513
+            return true;
514
+        }
515
+
516
+        [HttpGet("Piezometria")]
517
+        public async Task<ActionResult<IEnumerable<Simulacion>>> SimPiezometria()
518
+        {
519
+            Logger.WriteLog("inicio piezometria");
520
+            Parser parser = new Parser();
521
+            string piezometryFile = @"C:\Users\Admin\Desktop\TestExtract\simulaicionsimulacion_test\EJEMPLO_SOTIEL.HDS";
522
+            List<Piezometria> piezometrias = parser.ParseBinaryFile(piezometryFile, 4);
523
+            Logger.WriteLog("Fin parseo fichero binario");
524
+            Logger.WriteLog("Hay " + piezometrias.Count + " elementos de piezometria");
525
+            foreach (Piezometria p in piezometrias)
526
+            {
527
+                await piezometriaController.PostPiezometria(p);
528
+            }
529
+            Logger.WriteLog("fin piezometria");
530
+            return await GetSimulaciones();
531
+        }
532
+    }
533
+}

+ 136 - 0
WorkerService1/WebApplication3/Controllers/TsPiezometerController.cs Ver fichero

@@ -0,0 +1,136 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using Microsoft.AspNetCore.Http;
6
+using Microsoft.AspNetCore.Mvc;
7
+using Microsoft.EntityFrameworkCore;
8
+using WebApplication3.Models;
9
+using WebApplication3.Clases;
10
+
11
+namespace WebApplication3.Controllers
12
+{
13
+    [Route("api/[controller]")]
14
+    [ApiController]
15
+    public class TsPiezometerController: ControllerBase
16
+    {
17
+        private readonly AquiferContext _context;
18
+
19
+        public TsPiezometerController(AquiferContext context)
20
+        {
21
+            _context = context;
22
+        }
23
+
24
+        // GET: api/TsPiezometer
25
+        [HttpGet]
26
+        public async Task<ActionResult<IEnumerable<TsPiezometer>>> GetTsPiezometers()
27
+        {
28
+            return await _context.TsPiezometers.ToListAsync();
29
+        }
30
+
31
+        // GET: api/TsPiezometer/5
32
+        [HttpGet("{id}")]
33
+        //public async Task<ActionResult<TsPozo>> GetTsPozo(uint id)
34
+        public TimeSerie[] GetTsPiezometer(uint id)
35
+        {
36
+
37
+            //var tsPozo = await _context.TsPozos.FindAsync(id);
38
+            var tsPiezometers = _context.TsPiezometers.Where(x => x.PiezometerId == id);
39
+
40
+            List<TimeSerie> timeSeries = new List<TimeSerie>();
41
+            TimeSerie timeSerie = null;
42
+
43
+            if (tsPiezometers == null)
44
+            {
45
+                return null;
46
+            }
47
+
48
+            foreach(TsPiezometer tsp in tsPiezometers)
49
+            {
50
+                timeSerie = new TimeSerie();
51
+                timeSerie.Hora = tsp.Day;
52
+                timeSerie.Valor = tsp.Quote;
53
+                timeSeries.Add(timeSerie);
54
+            }
55
+
56
+            return timeSeries.ToArray();
57
+        }
58
+
59
+        // PUT: api/TsPiezometer/5
60
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
61
+        [HttpPut("{id}")]
62
+        public async Task<IActionResult> PutTsPiezometer(uint id, TsPozo tsPozo)
63
+        {
64
+            if (id != tsPozo.Id)
65
+            {
66
+                return BadRequest();
67
+            }
68
+
69
+            _context.Entry(tsPozo).State = EntityState.Modified;
70
+
71
+            try
72
+            {
73
+                await _context.SaveChangesAsync();
74
+            }
75
+            catch (DbUpdateConcurrencyException)
76
+            {
77
+                if (!TsPiezometerExists(id))
78
+                {
79
+                    return NotFound();
80
+                }
81
+                else
82
+                {
83
+                    throw;
84
+                }
85
+            }
86
+
87
+            return NoContent();
88
+        }
89
+
90
+        // POST: api/TsPiezometer
91
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
92
+        [HttpPost]
93
+        public async Task<ActionResult<TsPozo>> PostTsPiezometer(TsPiezometer tsPiezometer)
94
+        {
95
+            _context.TsPiezometers.Add(tsPiezometer);
96
+            try
97
+            {
98
+                await _context.SaveChangesAsync();
99
+            }
100
+            catch (DbUpdateException)
101
+            {
102
+                if (TsPiezometerExists(tsPiezometer.Id))
103
+                {
104
+                    return Conflict();
105
+                }
106
+                else
107
+                {
108
+                    throw;
109
+                }
110
+            }
111
+
112
+            return CreatedAtAction("GetTsPozo", new { id = tsPiezometer.Id }, tsPiezometer);
113
+        }
114
+
115
+        // DELETE: api/TsPozo/5
116
+        [HttpDelete("{id}")]
117
+        public async Task<IActionResult> DeleteTsPozo(int id)
118
+        {
119
+            var tsPozo = await _context.TsPozos.FindAsync(id);
120
+            if (tsPozo == null)
121
+            {
122
+                return NotFound();
123
+            }
124
+
125
+            _context.TsPozos.Remove(tsPozo);
126
+            await _context.SaveChangesAsync();
127
+
128
+            return NoContent();
129
+        }
130
+
131
+        private bool TsPiezometerExists(uint id)
132
+        {
133
+            return _context.TsPozos.Any(e => e.Id == id);
134
+        }
135
+    }
136
+}

+ 155 - 0
WorkerService1/WebApplication3/Controllers/TsPozoController.cs Ver fichero

@@ -0,0 +1,155 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using Microsoft.AspNetCore.Http;
6
+using Microsoft.AspNetCore.Mvc;
7
+using Microsoft.EntityFrameworkCore;
8
+using WebApplication3.Models;
9
+using WebApplication3.Clases;
10
+
11
+namespace WebApplication3.Controllers
12
+{
13
+    [Route("api/[controller]")]
14
+    [ApiController]
15
+    public class TsPozoController : ControllerBase
16
+    {
17
+        private readonly AquiferContext _context;
18
+
19
+        public TsPozoController(AquiferContext context)
20
+        {
21
+            _context = context;
22
+        }
23
+
24
+        // GET: api/TsPozo
25
+        [HttpGet]
26
+        public async Task<ActionResult<IEnumerable<TsPozo>>> GetTsPozos()
27
+        {
28
+            return await _context.TsPozos.ToListAsync();
29
+        }
30
+
31
+        // GET: api/TsPozo/5
32
+        [HttpGet("{id}")]
33
+        //public async Task<ActionResult<TsPozo>> GetTsPozo(uint id)
34
+        public TimeSerie[] GetTsPozo(uint id)
35
+        {
36
+
37
+            //var tsPozo = await _context.TsPozos.FindAsync(id);
38
+            var tsPozos = _context.TsPozos.Where(x => x.IdPozo == id);
39
+
40
+            List<TimeSerie> timeSeries = new List<TimeSerie>();
41
+            TimeSerie _timeSerie = null;
42
+
43
+            if (tsPozos == null)
44
+            {
45
+                return null;
46
+            }
47
+
48
+            foreach(TsPozo tsp in tsPozos)
49
+            {
50
+                _timeSerie = new TimeSerie();
51
+                _timeSerie.Hora = tsp.MarcaTiempo;
52
+                _timeSerie.Valor = tsp.Valor;
53
+                timeSeries.Add(_timeSerie);
54
+            }
55
+
56
+            return timeSeries.ToArray();
57
+        }
58
+
59
+        // PUT: api/TsPozo/5
60
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
61
+        [HttpPut("{id}")]
62
+        public async Task<IActionResult> PutTsPozo(uint id, TsPozo tsPozo)
63
+        {
64
+            if (id != tsPozo.Id)
65
+            {
66
+                return BadRequest();
67
+            }
68
+
69
+            _context.Entry(tsPozo).State = EntityState.Modified;
70
+
71
+            try
72
+            {
73
+                await _context.SaveChangesAsync();
74
+            }
75
+            catch (DbUpdateConcurrencyException)
76
+            {
77
+                if (!TsPozoExists(id))
78
+                {
79
+                    return NotFound();
80
+                }
81
+                else
82
+                {
83
+                    throw;
84
+                }
85
+            }
86
+
87
+            return NoContent();
88
+        }
89
+
90
+        // POST: api/TsPozo
91
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
92
+        [HttpPost]
93
+        public async Task<ActionResult<TsPozo>> PostTsPozo(TsPozo tsPozo)
94
+        {
95
+            _context.TsPozos.Add(tsPozo);
96
+            try
97
+            {
98
+                await _context.SaveChangesAsync();
99
+            }
100
+            catch (DbUpdateException)
101
+            {
102
+                if (TsPozoExists(tsPozo.Id))
103
+                {
104
+                    return Conflict();
105
+                }
106
+                else
107
+                {
108
+                    throw;
109
+                }
110
+            }
111
+
112
+            return CreatedAtAction("GetTsPozo", new { id = tsPozo.Id }, tsPozo);
113
+        }
114
+
115
+        // DELETE: api/TsPozo/5
116
+        [HttpDelete("{id}")]
117
+        public async Task<IActionResult> DeleteTsPozo(int id)
118
+        {
119
+            var tsPozo = await _context.TsPozos.FindAsync(id);
120
+            if (tsPozo == null)
121
+            {
122
+                return NotFound();
123
+            }
124
+
125
+            _context.TsPozos.Remove(tsPozo);
126
+            await _context.SaveChangesAsync();
127
+
128
+            return NoContent();
129
+        }
130
+
131
+        private bool TsPozoExists(uint id)
132
+        {
133
+            return _context.TsPozos.Any(e => e.Id == id);
134
+        }
135
+
136
+        [NonAction]
137
+        public async Task<IActionResult> DeleteTsPozoFromPozo(uint id)
138
+        {
139
+            List<TsPozo> tsPozos = _context.TsPozos.Where(x => x.IdPozo == id).ToList<TsPozo>();
140
+
141
+            if (tsPozos == null)
142
+            {
143
+                return NotFound();
144
+            }
145
+
146
+            tsPozos.ForEach( x =>
147
+                _context.TsPozos.Remove(x)
148
+            );
149
+            
150
+            await _context.SaveChangesAsync();
151
+
152
+            return NoContent();
153
+        }
154
+    }
155
+}

+ 120 - 0
WorkerService1/WebApplication3/Controllers/TsRecargaController.cs Ver fichero

@@ -0,0 +1,120 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using Microsoft.AspNetCore.Http;
6
+using Microsoft.AspNetCore.Mvc;
7
+using Microsoft.EntityFrameworkCore;
8
+using WebApplication3.Clases;
9
+using WebApplication3.Models;
10
+
11
+namespace WebApplication3.Controllers
12
+{
13
+    [Route("api/[controller]")]
14
+    [ApiController]
15
+    public class TsRecargaController : ControllerBase
16
+    {
17
+        private readonly AquiferContext _context;
18
+
19
+        public TsRecargaController(AquiferContext context)
20
+        {
21
+            _context = context;
22
+        }
23
+
24
+        // GET: api/TsRecarga
25
+        [HttpGet]
26
+        public async Task<ActionResult<IEnumerable<TsRecarga>>> GetTsRecargas()
27
+        {
28
+            return await _context.TsRecargas.ToListAsync();
29
+        }
30
+
31
+        // GET: api/TsRecarga/5
32
+        [HttpGet("{id}")]
33
+        public TimeSerie[] GetTsRecarga(uint id)
34
+        {
35
+            //var tsPozo = await _context.TsPozos.FindAsync(id);
36
+            var tsRecargas = _context.TsRecargas.Where(x => x.IdRecarga == id);
37
+
38
+            List<TimeSerie> timeSeries = new List<TimeSerie>();
39
+            TimeSerie _timeSerie = null;
40
+
41
+            if (tsRecargas == null)
42
+            {
43
+                return null;
44
+            }
45
+
46
+            foreach (TsRecarga tsr in tsRecargas)
47
+            {
48
+                _timeSerie = new TimeSerie();
49
+                _timeSerie.Hora = tsr.MarcaTiempo;
50
+                _timeSerie.Valor = tsr.Valor;
51
+                timeSeries.Add(_timeSerie);
52
+            }
53
+
54
+            return timeSeries.ToArray();
55
+        }
56
+
57
+        // PUT: api/TsRecarga/5
58
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
59
+        [HttpPut("{id}")]
60
+        public async Task<IActionResult> PutTsRecarga(int id, TsRecarga tsRecarga)
61
+        {
62
+            if (id != tsRecarga.Id)
63
+            {
64
+                return BadRequest();
65
+            }
66
+
67
+            _context.Entry(tsRecarga).State = EntityState.Modified;
68
+
69
+            try
70
+            {
71
+                await _context.SaveChangesAsync();
72
+            }
73
+            catch (DbUpdateConcurrencyException)
74
+            {
75
+                if (!TsRecargaExists(id))
76
+                {
77
+                    return NotFound();
78
+                }
79
+                else
80
+                {
81
+                    throw;
82
+                }
83
+            }
84
+
85
+            return NoContent();
86
+        }
87
+
88
+        // POST: api/TsRecarga
89
+        // To protect from overposting attacks, see https://go.microsoft.com/fwlink/?linkid=2123754
90
+        [HttpPost]
91
+        public async Task<ActionResult<TsRecarga>> PostTsRecarga(TsRecarga tsRecarga)
92
+        {
93
+            _context.TsRecargas.Add(tsRecarga);
94
+            await _context.SaveChangesAsync();
95
+
96
+            return CreatedAtAction("GetTsRecarga", new { id = tsRecarga.Id }, tsRecarga);
97
+        }
98
+
99
+        // DELETE: api/TsRecarga/5
100
+        [HttpDelete("{id}")]
101
+        public async Task<IActionResult> DeleteTsRecarga(int id)
102
+        {
103
+            var tsRecarga = await _context.TsRecargas.FindAsync(id);
104
+            if (tsRecarga == null)
105
+            {
106
+                return NotFound();
107
+            }
108
+
109
+            _context.TsRecargas.Remove(tsRecarga);
110
+            await _context.SaveChangesAsync();
111
+
112
+            return NoContent();
113
+        }
114
+
115
+        private bool TsRecargaExists(int id)
116
+        {
117
+            return _context.TsRecargas.Any(e => e.Id == id);
118
+        }
119
+    }
120
+}

+ 17 - 0
WorkerService1/WebApplication3/Models/Acuifero.cs Ver fichero

@@ -0,0 +1,17 @@
1
+using System;
2
+using System.Collections.Generic;
3
+
4
+#nullable disable
5
+
6
+namespace WebApplication3.Models
7
+{
8
+    public partial class Acuifero
9
+    {
10
+        public uint Id { get; set; }
11
+        public string Nombre { get; set; }
12
+        public string Fichero { get; set; }
13
+        public string WorldOriginX { get; set; }
14
+        public string WorldOriginY { get; set; }
15
+        public string RechargeGeometry { get; set; }
16
+    }
17
+}

+ 545 - 0
WorkerService1/WebApplication3/Models/AquiferContext.cs Ver fichero

@@ -0,0 +1,545 @@
1
+using System;
2
+using Microsoft.EntityFrameworkCore;
3
+using Microsoft.EntityFrameworkCore.Metadata;
4
+using Microsoft.Extensions.Configuration;
5
+
6
+#nullable disable
7
+
8
+namespace WebApplication3.Models
9
+{
10
+    public partial class AquiferContext : DbContext
11
+    {
12
+        public AquiferContext()
13
+        {
14
+        }
15
+
16
+        public AquiferContext(DbContextOptions<AquiferContext> options)
17
+            : base(options)
18
+        {
19
+        }
20
+
21
+        public virtual DbSet<Acuifero> Acuiferos { get; set; }
22
+        public virtual DbSet<Pozo> Pozos { get; set; }
23
+        public virtual DbSet<Recarga> Recargas { get; set; }
24
+        public virtual DbSet<Servicio> Servicios { get; set; }
25
+        public virtual DbSet<Simulacion> Simulaciones { get; set; }
26
+        public virtual DbSet<TsPozo> TsPozos { get; set; }
27
+        public virtual DbSet<TsRecarga> TsRecargas { get; set; }
28
+        public virtual DbSet<BalanceHidrico> BalancesHidricos { get; set; }
29
+        public virtual DbSet<DatosBalanceIn> DatosBalanceIns { get; set; }
30
+        public virtual DbSet<DatosBalanceOut> DatosBalanceOuts { get; set; }
31
+        public virtual DbSet<ConexionZonasIn> ConexionZonasIns { get; set; }
32
+        public virtual DbSet<ConexionZonasOut> ConexionZonasOuts { get; set; }
33
+        public virtual DbSet<Piezometria> Piezometria { get; set; }
34
+        public virtual DbSet<Piezometer> Piezometers { get; set; }
35
+        public virtual DbSet<TsPiezometer> TsPiezometers { get; set; }
36
+        public virtual DbSet<ServiceQueue> ServiceQueue { get; set; }
37
+
38
+
39
+        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
40
+        {
41
+            if (!optionsBuilder.IsConfigured)
42
+            {
43
+                IConfigurationRoot configuration = new ConfigurationBuilder()
44
+                                    .SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
45
+                                    .AddJsonFile("appsettings.json")
46
+                                    .Build();
47
+
48
+                optionsBuilder.UseMySql(configuration.GetConnectionString("AquiferDatabase"), Microsoft.EntityFrameworkCore.ServerVersion.Parse("5.7.24-mysql"));
49
+            }
50
+        }
51
+
52
+        protected override void OnModelCreating(ModelBuilder modelBuilder)
53
+        {
54
+            modelBuilder.HasCharSet("latin1")
55
+                .UseCollation("latin1_spanish_ci");
56
+
57
+            modelBuilder.Entity<Acuifero>(entity =>
58
+            {
59
+                entity.ToTable("acuifero");
60
+
61
+                entity.Property(e => e.Id)
62
+                    .HasColumnType("int(10) unsigned")
63
+                    .HasColumnName("id");
64
+
65
+                entity.Property(e => e.Fichero)
66
+                    .HasMaxLength(255)
67
+                    .HasColumnName("fichero");
68
+
69
+                entity.Property(e => e.Nombre)
70
+                    .IsRequired()
71
+                    .HasMaxLength(50)
72
+                    .HasColumnName("nombre")
73
+                    .HasDefaultValueSql("''");
74
+
75
+                entity.Property(e => e.WorldOriginX).HasColumnName("world_origin_x");
76
+                entity.Property(e => e.WorldOriginY).HasColumnName("world_origin_y");
77
+                entity.Property(e => e.RechargeGeometry).HasColumnName("recharge_geometry");
78
+
79
+
80
+
81
+                entity.HasKey(e => e.Id)
82
+                .HasName("id");
83
+            });
84
+
85
+            modelBuilder.Entity<Pozo>(entity =>
86
+            {
87
+                entity.ToTable("pozo");
88
+
89
+                entity.Property(e => e.Id)
90
+                    .HasColumnType("int(10) unsigned")
91
+                    .HasColumnName("id");
92
+
93
+                entity.Property(e => e.IdAquifero)
94
+                    .HasColumnType("int(10) unsigned")
95
+                    .HasColumnName("id_aquifero");
96
+
97
+                entity.Property(e => e.IdSimulacion)
98
+                    .HasColumnType("int(10) unsigned")
99
+                    .HasColumnName("id_simulacion");
100
+
101
+                entity.Property(e => e.Latitud).HasColumnName("latitud");
102
+
103
+                entity.Property(e => e.Longitud).HasColumnName("longitud");
104
+
105
+                entity.Property(e => e.Maximo).HasColumnName("maximo");
106
+
107
+                entity.Property(e => e.Minimo).HasColumnName("minimo");
108
+
109
+                entity.Property(e => e.Nombre)
110
+                    .HasMaxLength(50)
111
+                    .HasColumnName("nombre");
112
+
113
+                entity.Property(e => e.X)
114
+                    .HasMaxLength(50)
115
+                    .HasColumnName("x");   
116
+
117
+                entity.Property(e => e.Y)
118
+                    .HasMaxLength(50)
119
+                    .HasColumnName("y");
120
+
121
+                entity.Property(e => e.Z)
122
+                    .HasMaxLength(50)
123
+                    .HasColumnName("z");
124
+
125
+                entity.Property(e => e.Prof)
126
+                    .HasMaxLength(50)
127
+                    .HasColumnName("prof");
128
+
129
+                entity.Property(e => e.ScreenTop)
130
+                    .HasMaxLength(50)
131
+                    .HasColumnName("screen_top");
132
+
133
+                entity.Property(e => e.ScreenBot)
134
+                    .HasMaxLength(50)
135
+                    .HasColumnName("screen_bot");
136
+
137
+                entity.HasKey(e => e.Id)
138
+                .HasName("id");
139
+            });
140
+
141
+            modelBuilder.Entity<Recarga>(entity =>
142
+            {
143
+                entity.ToTable("recarga");
144
+
145
+                entity.Property(e => e.Id)
146
+                    .HasColumnType("int(10) unsigned")
147
+                    .HasColumnName("id");
148
+
149
+                entity.Property(e => e.IdSimulacion)
150
+                    .HasColumnType("int(10) unsigned")
151
+                    .HasColumnName("id_simulacion");
152
+
153
+                entity.Property(e => e.IdAcuifero)
154
+                .HasColumnType("int(10) unsigned")
155
+                .HasColumnName("id_acuifero");
156
+
157
+                entity.Property(e => e.Nombre)
158
+                    .HasMaxLength(50)
159
+                    .HasColumnName("nombre");
160
+
161
+                entity.Property(e => e.Latitud).HasColumnName("latitud");
162
+
163
+                entity.Property(e => e.Longitud).HasColumnName("longitud");
164
+
165
+                entity.HasKey(e => e.Id)
166
+                .HasName("id");
167
+            });
168
+
169
+            modelBuilder.Entity<Servicio>(entity =>
170
+            {
171
+                entity.ToTable("servicio");
172
+
173
+                entity.Property(e => e.Id)
174
+                    .HasColumnType("int(10) unsigned")
175
+                    .HasColumnName("id");
176
+
177
+                entity.Property(e => e.Pid)
178
+                    .HasColumnType("int(10) unsigned")
179
+                    .HasColumnName("pid");
180
+
181
+                entity.Property(e => e.Terminado)
182
+                    .HasColumnType("tinyint(1) unsigned")
183
+                    .HasColumnName("terminado");
184
+
185
+                entity.Property(e => e.Inicio).HasColumnName("inicio");
186
+
187
+                entity.Property(e => e.Fin).HasColumnName("fin");
188
+
189
+                entity.Property(e => e.Tipo).HasColumnName("tipo");
190
+
191
+                entity.HasKey(e => e.Id)
192
+                .HasName("id");
193
+            });
194
+
195
+            modelBuilder.Entity<ServiceQueue>(entity =>
196
+            {
197
+                entity.ToTable("service_queue");
198
+
199
+                entity.Property(e => e.Id)
200
+                    .HasColumnType("int(10) unsigned")
201
+                    .HasColumnName("id");
202
+
203
+                entity.Property(e => e.IdSimulacion)
204
+                    .HasColumnType("int(10) unsigned")
205
+                    .HasColumnName("id_simulacion");
206
+
207
+                entity.Property(e => e.IdAcuifero)
208
+                    .HasColumnType("int(10) unsigned")
209
+                    .HasColumnName("id_acuifero");
210
+
211
+                entity.Property(e => e.Terminado)
212
+                    .HasColumnType("tinyint(1) unsigned")
213
+                    .HasColumnName("terminado");
214
+
215
+                entity.Property(e => e.Error)
216
+                    .HasColumnType("tinyint(1) unsigned")
217
+                    .HasColumnName("error");
218
+
219
+                entity.Property(e => e.Corriendo)
220
+                    .HasColumnType("tinyint(1) unsigned")
221
+                    .HasColumnName("corriendo");
222
+
223
+                entity.Property(e => e.Inicio).HasColumnName("inicio");
224
+
225
+                entity.Property(e => e.Fin).HasColumnName("fin");
226
+
227
+
228
+                entity.HasKey(e => e.Id)
229
+                .HasName("id");
230
+            });
231
+
232
+
233
+            modelBuilder.Entity<Simulacion>(entity =>
234
+            {
235
+                entity.ToTable("simulacion");
236
+
237
+                entity.Property(e => e.Id)
238
+                    .HasColumnType("int(10) unsigned")
239
+                    .HasColumnName("id");
240
+
241
+                entity.Property(e => e.IdAcuifero)
242
+                    .HasColumnType("int(10) unsigned")
243
+                    .HasColumnName("id_acuifero");
244
+
245
+                entity.Property(e => e.Nombre)
246
+                    .HasMaxLength(255)
247
+                    .HasColumnName("nombre");
248
+                
249
+                entity.Property(e => e.IsolineImage)
250
+                    .HasMaxLength(255)
251
+                    .HasColumnName("isoline_image");
252
+
253
+                entity.HasKey(e => e.Id)
254
+                .HasName("id");
255
+            });
256
+
257
+            modelBuilder.Entity<TsPozo>(entity =>
258
+            {
259
+                entity.ToTable("ts_pozo");
260
+
261
+                entity.Property(e => e.Id)
262
+                    .HasColumnType("int(10) unsigned")
263
+                    .HasColumnName("id");
264
+
265
+                entity.Property(e => e.IdPozo)
266
+                    .HasColumnType("int(10) unsigned")
267
+                    .HasColumnName("id_pozo");
268
+
269
+                entity.Property(e => e.MarcaTiempo)
270
+                    .HasMaxLength(50)
271
+                    .HasColumnName("marca_tiempo");
272
+
273
+                entity.Property(e => e.MarcaTiempoEnd)
274
+                    .HasMaxLength(50)
275
+                    .HasColumnName("marca_tiempo_end");
276
+
277
+                entity.Property(e => e.InfoComplementaria)
278
+                    .HasMaxLength(255)
279
+                    .HasColumnName("info_complementaria");
280
+
281
+                entity.Property(e => e.Valor).HasColumnName("valor");
282
+
283
+                
284
+                entity.Property(e => e.DateIn).HasColumnName("date_in");
285
+                entity.Property(e => e.DateEnd).HasColumnName("date_end");
286
+
287
+                entity.HasKey(e => e.Id)
288
+                .HasName("id");
289
+            });
290
+
291
+            modelBuilder.Entity<TsRecarga>(entity =>
292
+            {
293
+                entity.ToTable("ts_recarga");
294
+
295
+                entity.Property(e => e.Id)
296
+                    .HasColumnType("int(10) unsigned")
297
+                    .HasColumnName("id");
298
+
299
+                entity.Property(e => e.IdRecarga)
300
+                    .HasColumnType("int(10) unsigned")
301
+                    .HasColumnName("id_recarga");
302
+
303
+                entity.Property(e => e.MarcaTiempo)
304
+                    .HasMaxLength(50)
305
+                    .HasColumnName("marca_tiempo");
306
+
307
+                entity.Property(e => e.MarcaTiempoEnd)
308
+                    .HasMaxLength(50)
309
+                    .HasColumnName("marca_tiempo_end");
310
+
311
+                entity.Property(e => e.InfoComplementaria)
312
+                    .HasMaxLength(255)
313
+                    .HasColumnName("info_complementaria");
314
+
315
+                entity.Property(e => e.Valor).HasColumnName("valor");
316
+
317
+
318
+                entity.HasKey(e => e.Id)
319
+                .HasName("id");
320
+            });
321
+
322
+            modelBuilder.Entity<BalanceHidrico>(entity =>
323
+            {
324
+                entity.ToTable("balance_hidrico");
325
+
326
+                entity.Property(e => e.Id)
327
+                    .HasColumnType("int(10) unsigned")
328
+                    .HasColumnName("id");
329
+
330
+                entity.Property(e => e.IdSimulacion)
331
+                    .HasColumnType("int(10) unsigned")
332
+                    .HasColumnName("id_simulacion");
333
+
334
+                entity.Property(e => e.StressPeriod).HasColumnName("stress_period");
335
+
336
+                entity.Property(e => e.Zona).HasColumnName("zona");
337
+
338
+                entity.Property(e => e.TotalZona).HasColumnName("total_zona");
339
+
340
+                entity.HasKey(e => e.Id)
341
+                .HasName("id");
342
+            });
343
+
344
+            modelBuilder.Entity<DatosBalanceIn>(entity =>
345
+            {
346
+                entity.ToTable("datos_balance_in");
347
+
348
+                entity.Property(e => e.Id)
349
+                    .HasColumnType("int(10) unsigned")
350
+                    .HasColumnName("id");
351
+
352
+                entity.Property(e => e.IdBalance)
353
+                    .HasColumnType("int(10) unsigned")
354
+                    .HasColumnName("id_balance_hidrico");
355
+
356
+                entity.Property(e => e.Storage).HasColumnName("storage");
357
+
358
+                entity.Property(e => e.Recharge).HasColumnName("recharge");
359
+
360
+                entity.Property(e => e.Drains).HasColumnName("drains");
361
+
362
+                entity.Property(e => e.ConstantHead).HasColumnName("constant_head");
363
+
364
+
365
+                entity.Property(e => e.Total).HasColumnName("total");
366
+
367
+                entity.HasKey(e => e.Id)
368
+                .HasName("id");
369
+            });
370
+
371
+            modelBuilder.Entity<DatosBalanceOut>(entity =>
372
+            {
373
+                entity.ToTable("datos_balance_out");
374
+
375
+                entity.Property(e => e.Id)
376
+                    .HasColumnType("int(10) unsigned")
377
+                    .HasColumnName("id");
378
+
379
+                entity.Property(e => e.IdBalance)
380
+                    .HasColumnType("int(10) unsigned")
381
+                    .HasColumnName("id_balance_hidrico");
382
+
383
+                entity.Property(e => e.Storage).HasColumnName("storage");
384
+
385
+                entity.Property(e => e.Recharge).HasColumnName("recharge");
386
+
387
+                entity.Property(e => e.Drains).HasColumnName("drains");
388
+
389
+                entity.Property(e => e.ConstantHead).HasColumnName("constant_head");
390
+
391
+
392
+                entity.Property(e => e.Total).HasColumnName("total");
393
+
394
+                entity.HasKey(e => e.Id)
395
+                .HasName("id");
396
+            });
397
+
398
+            modelBuilder.Entity<ConexionZonasIn>(entity =>
399
+            {
400
+                entity.ToTable("conexion_zonas_in");
401
+
402
+                entity.Property(e => e.Id)
403
+                    .HasColumnType("int(10) unsigned")
404
+                    .HasColumnName("id");
405
+
406
+                entity.Property(e => e.IdDatosBalanceIn)
407
+                    .HasColumnType("int(10) unsigned")
408
+                    .HasColumnName("id_balance_in");
409
+
410
+                entity.Property(e => e.From).HasColumnName("from");
411
+
412
+                entity.Property(e => e.To).HasColumnName("to");
413
+
414
+                entity.Property(e => e.Value).HasColumnName("value");
415
+
416
+                entity.HasKey(e => e.Id)
417
+                .HasName("id");
418
+            });
419
+
420
+            modelBuilder.Entity<ConexionZonasOut>(entity =>
421
+            {
422
+                entity.ToTable("conexion_zonas_out");
423
+
424
+                entity.Property(e => e.Id)
425
+                    .HasColumnType("int(10) unsigned")
426
+                    .HasColumnName("id");
427
+
428
+                entity.Property(e => e.IdDatosBalanceOut)
429
+                    .HasColumnType("int(10) unsigned")
430
+                    .HasColumnName("id_balance_out");
431
+
432
+                entity.Property(e => e.From).HasColumnName("from");
433
+
434
+                entity.Property(e => e.To).HasColumnName("to");
435
+
436
+                entity.Property(e => e.Value).HasColumnName("value");
437
+
438
+                entity.HasKey(e => e.Id)
439
+                .HasName("id");
440
+            });
441
+
442
+            modelBuilder.Entity<Piezometria>(entity =>
443
+            {
444
+                entity.ToTable("piezometria");
445
+
446
+                entity.Property(e => e.Id)
447
+                    .HasColumnType("int(10) unsigned")
448
+                    .HasColumnName("id");
449
+
450
+                entity.Property(e => e.IdSimulacion)
451
+                    .HasColumnType("int(10) unsigned")
452
+                    .HasColumnName("id_simulacion");
453
+
454
+                entity.Property(e => e.StressPeriod).HasColumnName("stress_period");
455
+
456
+                entity.Property(e => e.Layer).HasColumnName("layer");
457
+
458
+                entity.Property(e => e.Columns).HasColumnName("columns");
459
+                
460
+                entity.Property(e => e.Rows).HasColumnName("rows");
461
+
462
+                entity.Property(e => e.Original).HasColumnName("original");
463
+                
464
+                entity.Property(e => e.Convertida).HasColumnName("convertida");
465
+
466
+                entity.HasKey(e => e.Id)
467
+                .HasName("id");
468
+            });
469
+
470
+            modelBuilder.Entity<Piezometer>(entity =>
471
+            {
472
+                entity.ToTable("piezometer");
473
+
474
+                entity.Property(e => e.Id)
475
+                    .HasColumnType("int(10) unsigned")
476
+                    .HasColumnName("id");
477
+
478
+                entity.Property(e => e.Name)
479
+                    .HasMaxLength(50)
480
+                    .HasColumnName("nombre");
481
+
482
+                entity.Property(e => e.X)
483
+                    .HasMaxLength(50)
484
+                    .HasColumnName("x");
485
+
486
+                entity.Property(e => e.Y)
487
+                    .HasMaxLength(50)
488
+                    .HasColumnName("y");
489
+
490
+                entity.Property(e => e.Z)
491
+                    .HasMaxLength(50)
492
+                    .HasColumnName("z");
493
+
494
+                entity.Property(e => e.Prof)
495
+                    .HasMaxLength(50)
496
+                    .HasColumnName("prof");
497
+
498
+                entity.Property(e => e.ScreenTop)
499
+                    .HasMaxLength(50)
500
+                    .HasColumnName("screen_top");
501
+
502
+                entity.Property(e => e.ScreenBot)
503
+                    .HasMaxLength(50)
504
+                    .HasColumnName("screen_bot");
505
+
506
+
507
+                entity.HasKey(e => e.Id)
508
+                .HasName("id");
509
+            });
510
+
511
+            modelBuilder.Entity<TsPiezometer>(entity =>
512
+            {
513
+                entity.ToTable("ts_piezometer");
514
+
515
+                entity.Property(e => e.Id)
516
+                    .HasColumnType("int(10) unsigned")
517
+                    .HasColumnName("id");
518
+
519
+                entity.Property(e => e.PiezometerId)
520
+                    .HasColumnType("int(10) unsigned")
521
+                    .HasColumnName("piezometer_id");
522
+
523
+                entity.Property(e => e.Date)
524
+                    .HasMaxLength(50)
525
+                    .HasColumnName("date");
526
+
527
+                entity.Property(e => e.Day)
528
+                    .HasMaxLength(50)
529
+                    .HasColumnName("day");
530
+
531
+                entity.Property(e => e.Quote)
532
+                    .HasMaxLength(50)
533
+                    .HasColumnName("quote");
534
+
535
+
536
+                entity.HasKey(e => e.Id)
537
+                .HasName("id");
538
+            });
539
+
540
+            OnModelCreatingPartial(modelBuilder);
541
+        }
542
+
543
+        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
544
+    }
545
+}

+ 17 - 0
WorkerService1/WebApplication3/Models/BalanceHidrico.cs Ver fichero

@@ -0,0 +1,17 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using WebApplication3.Clases;
4
+
5
+#nullable disable
6
+
7
+namespace WebApplication3.Models
8
+{
9
+    public partial class BalanceHidrico
10
+    {
11
+        public uint Id { get; set; }
12
+        public uint? IdSimulacion { get; set; }
13
+        public string TotalZona { get; set; }
14
+        public string Zona { get; set; }
15
+        public int? StressPeriod { get; set; }
16
+    }
17
+}

+ 18 - 0
WorkerService1/WebApplication3/Models/ConexionZonasIn.cs Ver fichero

@@ -0,0 +1,18 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using WebApplication3.Clases;
4
+
5
+#nullable disable
6
+
7
+namespace WebApplication3.Models
8
+{
9
+    public partial class ConexionZonasIn
10
+    {
11
+        public uint Id { get; set; }
12
+        public uint? IdDatosBalanceIn { get; set; }
13
+        public string From { get; set; }
14
+        public string To { get; set; }
15
+        public string Value { get; set; }
16
+
17
+    }
18
+}

+ 18 - 0
WorkerService1/WebApplication3/Models/ConexionZonasOut.cs Ver fichero

@@ -0,0 +1,18 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using WebApplication3.Clases;
4
+
5
+#nullable disable
6
+
7
+namespace WebApplication3.Models
8
+{
9
+    public partial class ConexionZonasOut
10
+    {
11
+        public uint Id { get; set; }
12
+        public uint? IdDatosBalanceOut { get; set; }
13
+        public string From { get; set; }
14
+        public string To { get; set; }
15
+        public string Value { get; set; }
16
+
17
+    }
18
+}

+ 20 - 0
WorkerService1/WebApplication3/Models/DatosBalanceIn.cs Ver fichero

@@ -0,0 +1,20 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using WebApplication3.Clases;
4
+
5
+#nullable disable
6
+
7
+namespace WebApplication3.Models
8
+{
9
+    public partial class DatosBalanceIn
10
+    {
11
+        public uint Id { get; set; }
12
+        public uint? IdBalance { get; set; }
13
+        public string Storage { get; set; }
14
+        public string ConstantHead { get; set; }
15
+        public string Drains { get; set; }
16
+        public string Recharge { get; set; }
17
+        public string Total { get; set; }
18
+
19
+    }
20
+}

+ 20 - 0
WorkerService1/WebApplication3/Models/DatosBalanceOut.cs Ver fichero

@@ -0,0 +1,20 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using WebApplication3.Clases;
4
+
5
+#nullable disable
6
+
7
+namespace WebApplication3.Models
8
+{
9
+    public partial class DatosBalanceOut
10
+    {
11
+        public uint Id { get; set; }
12
+        public uint? IdBalance { get; set; }
13
+        public string Storage { get; set; }
14
+        public string ConstantHead { get; set; }
15
+        public string Drains { get; set; }
16
+        public string Recharge { get; set; }
17
+        public string Total { get; set; }
18
+
19
+    }
20
+}

+ 21 - 0
WorkerService1/WebApplication3/Models/Piezometria.cs Ver fichero

@@ -0,0 +1,21 @@
1
+using System;
2
+using System.Collections.Generic;
3
+
4
+#nullable disable
5
+
6
+namespace WebApplication3.Models
7
+{
8
+    public partial class Piezometria
9
+    {
10
+        public uint Id { get; set; }
11
+        public uint? IdSimulacion { get; set; }
12
+        public int StressPeriod{ get; set; }
13
+        public int Layer { get; set; }
14
+        public int Columns { get; set; }
15
+        public int Rows { get; set; }
16
+        public string Original { get; set; }
17
+        public string Convertida { get; set; }
18
+        
19
+
20
+    }
21
+}

+ 20 - 0
WorkerService1/WebApplication3/Models/Piezometro.cs Ver fichero

@@ -0,0 +1,20 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using WebApplication3.Clases;
4
+
5
+#nullable disable
6
+
7
+namespace WebApplication3.Models
8
+{
9
+    public partial class Piezometer
10
+    {
11
+        public uint Id { get; set; }
12
+        public string Name { get; set; }
13
+        public string X { get; set; }
14
+        public string Y { get; set; }
15
+        public string Z { get; set; }
16
+        public string Prof { get; set; }
17
+        public string ScreenTop { get; set; }
18
+        public string ScreenBot { get; set; }
19
+    }
20
+}

+ 39 - 0
WorkerService1/WebApplication3/Models/Pozo.cs Ver fichero

@@ -0,0 +1,39 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using WebApplication3.Clases;
4
+
5
+#nullable disable
6
+
7
+namespace WebApplication3.Models
8
+{
9
+    public partial class Pozo
10
+    {
11
+        public uint Id { get; set; }
12
+        public string Nombre { get; set; }
13
+        public uint? IdAquifero { get; set; }
14
+        public string Minimo { get; set; }
15
+        public string  Maximo { get; set; }
16
+        public string Latitud { get; set; }
17
+        public string Longitud { get; set; }
18
+        public uint? IdSimulacion { get; set; }
19
+        public string X { get; set; }
20
+        public string Y { get; set; }
21
+        public string Z { get; set; }
22
+        public string Prof { get; set; }
23
+        public string ScreenTop { get; set; }
24
+        public string ScreenBot { get; set; }
25
+
26
+        public Pozo Copy(uint? idSimulacion)
27
+        {
28
+            Pozo pozo = new Pozo();
29
+            pozo.IdAquifero = this.IdAquifero;
30
+            pozo.IdSimulacion = idSimulacion;
31
+            pozo.Latitud = this.Latitud;
32
+            pozo.Longitud = this.Longitud;
33
+            pozo.Maximo = this.Maximo;
34
+            pozo.Minimo = this.Minimo;
35
+            pozo.Nombre = this.Nombre;
36
+            return pozo;
37
+        }
38
+    }
39
+}

+ 29 - 0
WorkerService1/WebApplication3/Models/Recarga.cs Ver fichero

@@ -0,0 +1,29 @@
1
+using System;
2
+using System.Collections.Generic;
3
+
4
+#nullable disable
5
+
6
+namespace WebApplication3.Models
7
+{
8
+    public partial class Recarga
9
+    {
10
+        public uint Id { get; set; }
11
+        public string Nombre { get; set; }
12
+        public uint? IdSimulacion { get; set; }
13
+        public string Latitud { get; set; }
14
+        public string Longitud { get; set; }
15
+        public uint? IdAcuifero { get; set; }
16
+
17
+        public Recarga Copy(uint? simulacionId)
18
+        {
19
+            Recarga recarga = new Recarga();
20
+            recarga.Nombre = this.Nombre;
21
+            recarga.Latitud = this.Latitud;
22
+            recarga.Longitud = this.Longitud;
23
+            recarga.IdSimulacion = simulacionId;
24
+            recarga.IdAcuifero = this.IdAcuifero;
25
+
26
+            return recarga;
27
+        }
28
+    }
29
+}

+ 20 - 0
WorkerService1/WebApplication3/Models/ServiceQueue.cs Ver fichero

@@ -0,0 +1,20 @@
1
+using System;
2
+using System.Collections.Generic;
3
+
4
+#nullable disable
5
+
6
+namespace WebApplication3.Models
7
+{
8
+    public partial class ServiceQueue
9
+    {
10
+        public uint Id { get; set; }
11
+        public uint? IdSimulacion { get; set; }
12
+        public uint? IdAcuifero { get; set; }
13
+        public string Inicio { get; set; }
14
+        public string Fin { get; set; }
15
+        public byte Terminado { get; set; }
16
+        public byte Error { get; set; }
17
+        public byte Corriendo { get; set; }
18
+
19
+    }
20
+}

+ 18 - 0
WorkerService1/WebApplication3/Models/Servicio.cs Ver fichero

@@ -0,0 +1,18 @@
1
+using System;
2
+using System.Collections.Generic;
3
+
4
+#nullable disable
5
+
6
+namespace WebApplication3.Models
7
+{
8
+    public partial class Servicio
9
+    {
10
+        public uint Id { get; set; }
11
+        public uint? Pid { get; set; }
12
+        public byte Terminado { get; set; }
13
+        public string Inicio { get; set; }
14
+        public string Fin { get; set; }
15
+        public string Tipo { get; set; }
16
+        
17
+    }
18
+}

+ 15 - 0
WorkerService1/WebApplication3/Models/Simulacion.cs Ver fichero

@@ -0,0 +1,15 @@
1
+using System;
2
+using System.Collections.Generic;
3
+
4
+#nullable disable
5
+
6
+namespace WebApplication3.Models
7
+{
8
+    public partial class Simulacion
9
+    {
10
+        public uint Id { get; set; }
11
+        public uint? IdAcuifero { get; set; }
12
+        public string Nombre { get; set; }
13
+        public string IsolineImage { get; set; }
14
+    }
15
+}

+ 16 - 0
WorkerService1/WebApplication3/Models/TSPiezometer.cs Ver fichero

@@ -0,0 +1,16 @@
1
+using System;
2
+using System.Collections.Generic;
3
+
4
+#nullable disable
5
+
6
+namespace WebApplication3.Models
7
+{
8
+    public partial class TsPiezometer
9
+    {
10
+        public uint Id { get; set; }
11
+        public uint? PiezometerId { get; set; }
12
+        public string Date { get; set; }
13
+        public string Day { get; set; }
14
+        public string Quote { get; set; }
15
+    }
16
+}

+ 31 - 0
WorkerService1/WebApplication3/Models/TSPozo.cs Ver fichero

@@ -0,0 +1,31 @@
1
+using System;
2
+using System.Collections.Generic;
3
+
4
+#nullable disable
5
+
6
+namespace WebApplication3.Models
7
+{
8
+    public partial class TsPozo
9
+    {
10
+        public uint Id { get; set; }
11
+        public uint? IdPozo { get; set; }
12
+        public string MarcaTiempo { get; set; }
13
+        public string Valor { get; set; }
14
+        public string InfoComplementaria { get; set; }
15
+        public string DateIn { get; set; }
16
+        public string DateEnd { get; set; }
17
+        public string MarcaTiempoEnd { get; set; }
18
+
19
+        public TsPozo Copy(uint? pozoId)
20
+        {
21
+            TsPozo tsPozo = new TsPozo();
22
+            tsPozo.IdPozo = pozoId;
23
+            tsPozo.Valor = this.Valor;
24
+            tsPozo.MarcaTiempo = this.MarcaTiempo;
25
+            tsPozo.InfoComplementaria = this.InfoComplementaria;
26
+
27
+            return tsPozo;
28
+        }
29
+
30
+    }
31
+}

+ 17 - 0
WorkerService1/WebApplication3/Models/TSRecarga.cs Ver fichero

@@ -0,0 +1,17 @@
1
+using System;
2
+using System.Collections.Generic;
3
+
4
+#nullable disable
5
+
6
+namespace WebApplication3.Models
7
+{
8
+    public partial class TsRecarga
9
+    {
10
+        public uint Id { get; set; }
11
+        public uint? IdRecarga { get; set; }
12
+        public string MarcaTiempo { get; set; }
13
+        public string Valor { get; set; }
14
+        public string MarcaTiempoEnd { get; set; }
15
+        public string InfoComplementaria { get; set; }
16
+    }
17
+}

+ 47 - 0
WorkerService1/WebApplication3/Program.cs Ver fichero

@@ -0,0 +1,47 @@
1
+using Microsoft.AspNetCore.Hosting;
2
+using Microsoft.Extensions.Configuration;
3
+using Microsoft.Extensions.DependencyInjection;
4
+using Microsoft.Extensions.Hosting;
5
+using WebApplication3.Clases;
6
+using Microsoft.Extensions.Logging;
7
+using System;
8
+using System.Collections.Generic;
9
+using System.Linq;
10
+using System.Threading.Tasks;
11
+
12
+namespace WebApplication3
13
+{
14
+    public class Program
15
+    {
16
+        public static void Main( string[] args )
17
+        {
18
+            Proceso proceso = Proceso.GetInstance();
19
+            CreateHostBuilder( args ).Build().Run();
20
+        }
21
+
22
+        public static IHostBuilder CreateHostBuilder( string[] args ) =>
23
+            Host.CreateDefaultBuilder( args )
24
+                .ConfigureLogging(logging =>
25
+                {
26
+                    logging.ClearProviders();
27
+                    logging.AddConsole();
28
+                    logging.AddEventLog();
29
+                })
30
+                .ConfigureServices((hostBuilderContext, services) =>
31
+                {
32
+                    services.AddLogging();
33
+                    services.AddHostedService<Worker>();
34
+                    services.AddHostedService<QueueWorker>();
35
+                })
36
+                .ConfigureWebHostDefaults( webBuilder =>
37
+                {
38
+                    webBuilder.UseStartup<Startup>();
39
+
40
+                } ).ConfigureWebHost( config =>
41
+                {
42
+                    config.UseUrls( "http://*:5050" );
43
+
44
+                } ).UseWindowsService();
45
+
46
+    }
47
+}

+ 68 - 0
WorkerService1/WebApplication3/Startup.cs Ver fichero

@@ -0,0 +1,68 @@
1
+using Microsoft.AspNetCore.Builder;
2
+using Microsoft.AspNetCore.Hosting;
3
+using Microsoft.AspNetCore.HttpsPolicy;
4
+using Microsoft.AspNetCore.Mvc;
5
+using Microsoft.Extensions.Configuration;
6
+using Microsoft.Extensions.DependencyInjection;
7
+using Microsoft.Extensions.Hosting;
8
+using Microsoft.Extensions.Logging;
9
+using Microsoft.OpenApi.Models;
10
+using System;
11
+using System.Collections.Generic;
12
+using System.Linq;
13
+using System.Threading.Tasks;
14
+using Microsoft.EntityFrameworkCore;
15
+using WebApplication3.Models;
16
+
17
+
18
+namespace WebApplication3
19
+{
20
+    public class Startup
21
+    {
22
+        public Startup( IConfiguration configuration )
23
+        {
24
+            Configuration = configuration;
25
+        }
26
+
27
+        public IConfiguration Configuration
28
+        {
29
+            get;
30
+        }
31
+
32
+        // This method gets called by the runtime. Use this method to add services to the container.
33
+        public void ConfigureServices( IServiceCollection services )
34
+        {
35
+            services.AddDbContext<AquiferContext>(opt =>
36
+                       opt.UseMySql(Configuration.GetConnectionString("AquiferDatabase"), Microsoft.EntityFrameworkCore.ServerVersion.Parse("5.7.24-mysql"))
37
+            );
38
+
39
+            services.AddControllers();
40
+            services.AddSwaggerGen( c =>
41
+             {
42
+                 c.SwaggerDoc( "v1", new OpenApiInfo { Title = "WebApplication3", Version = "v1" } );
43
+             } );
44
+        }
45
+
46
+        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
47
+        public void Configure( IApplicationBuilder app, IWebHostEnvironment env )
48
+        {
49
+            if( env.IsDevelopment() )
50
+            {
51
+                app.UseDeveloperExceptionPage();
52
+            }
53
+            app.UseSwagger();
54
+            app.UseSwaggerUI( c => c.SwaggerEndpoint( "/swagger/v1/swagger.json", "WebApplication3 v1" ) );
55
+
56
+            app.UseHttpsRedirection();
57
+
58
+            app.UseRouting();
59
+
60
+            app.UseAuthorization();
61
+
62
+            app.UseEndpoints( endpoints =>
63
+             {
64
+                 endpoints.MapControllers();
65
+             } );
66
+        }
67
+    }
68
+}

+ 95 - 0
WorkerService1/WebApplication3/WebApplication3.csproj Ver fichero

@@ -0,0 +1,95 @@
1
+<Project Sdk="Microsoft.NET.Sdk.Web">
2
+
3
+  <PropertyGroup>
4
+    <TargetFramework>net5.0</TargetFramework>
5
+  </PropertyGroup>
6
+
7
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
8
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
9
+  </PropertyGroup>
10
+
11
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
12
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
13
+  </PropertyGroup>
14
+
15
+  <ItemGroup>
16
+    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.6" />
17
+    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.6" />
18
+    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.6">
19
+      <PrivateAssets>all</PrivateAssets>
20
+      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21
+    </PackageReference>
22
+    <PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
23
+    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
24
+    <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.0" />
25
+    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.4" />
26
+    <PackageReference Include="System.Drawing.Common" Version="6.0.0" />
27
+    <PackageReference Include="System.Net.Http" Version="4.3.4" />
28
+  </ItemGroup>
29
+
30
+	<ItemGroup>
31
+		<Compile Update="Acuifero.cs">
32
+			<CopyToOutputDirectory>Never</CopyToOutputDirectory>
33
+		</Compile>
34
+	</ItemGroup>
35
+	<ItemGroup>
36
+		<Compile Update="aquiferContext.cs">
37
+			<CopyToOutputDirectory>Never</CopyToOutputDirectory>
38
+		</Compile>
39
+	</ItemGroup>
40
+	<ItemGroup>
41
+		<Compile Update="Pozo.cs">
42
+			<CopyToOutputDirectory>Never</CopyToOutputDirectory>
43
+		</Compile>
44
+	</ItemGroup>
45
+	    <ItemGroup>
46
+	    <Compile Update="Recarga.cs">
47
+		    <CopyToOutputDirectory>Never</CopyToOutputDirectory>
48
+	    </Compile>
49
+    </ItemGroup>
50
+	<ItemGroup>
51
+		<Compile Update="Servicio.cs">
52
+			<CopyToOutputDirectory>Never</CopyToOutputDirectory>
53
+		</Compile>
54
+	</ItemGroup>
55
+    <ItemGroup>
56
+	    <Compile Update="ServicioController.cs">
57
+		    <CopyToOutputDirectory>Never</CopyToOutputDirectory>
58
+	    </Compile>
59
+    </ItemGroup>
60
+
61
+	<ItemGroup>
62
+		<Compile Update="AcuiferoController.cs">
63
+			<CopyToOutputDirectory>Never</CopyToOutputDirectory>
64
+		</Compile>
65
+	</ItemGroup>
66
+	<ItemGroup>
67
+		<Compile Update="PozoController.cs">
68
+			<CopyToOutputDirectory>Never</CopyToOutputDirectory>
69
+		</Compile>
70
+	</ItemGroup>
71
+	<ItemGroup>
72
+		<Compile Update="RecargasController.cs">
73
+			<CopyToOutputDirectory>Never</CopyToOutputDirectory>
74
+		</Compile>
75
+	</ItemGroup>
76
+	<ItemGroup>
77
+		<Compile Update="Proceso.cs">
78
+			<CopyToOutputDirectory>Never</CopyToOutputDirectory>
79
+		</Compile>
80
+	</ItemGroup>
81
+	<ItemGroup>
82
+		<Compile Update="Worker.cs">
83
+			<CopyToOutputDirectory>Never</CopyToOutputDirectory>
84
+		</Compile>
85
+	</ItemGroup>
86
+	<ItemGroup>
87
+    <None Update="install_service.bat">
88
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
89
+    </None>
90
+    <None Update="uninstall_service.bat">
91
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
92
+    </None>
93
+  </ItemGroup>
94
+
95
+</Project>

+ 9 - 0
WorkerService1/WebApplication3/appsettings.Development.json Ver fichero

@@ -0,0 +1,9 @@
1
+{
2
+  "Logging": {
3
+    "LogLevel": {
4
+      "Default": "Information",
5
+      "Microsoft": "Warning",
6
+      "Microsoft.Hosting.Lifetime": "Information"
7
+    }
8
+  }
9
+}

+ 19 - 0
WorkerService1/WebApplication3/appsettings.json Ver fichero

@@ -0,0 +1,19 @@
1
+{
2
+  "Logging": {
3
+    "LogLevel": {
4
+      "Default": "Information",
5
+      "Microsoft": "Warning",
6
+      "Microsoft.Hosting.Lifetime": "Information"
7
+    },
8
+    "EventLog": {
9
+      "LogLevel": {
10
+        "Default": "Information",
11
+        "Microsoft.Hosting.Lifetime": "Information"
12
+      }
13
+    }
14
+  },
15
+  "AllowedHosts": "*",
16
+  "ConnectionStrings": {
17
+    "AquiferDatabase": "Server=localhost;UserId=root;Password=;Database=aquifer"
18
+  }
19
+}

+ 1 - 0
WorkerService1/WebApplication3/install_service.bat Ver fichero

@@ -0,0 +1 @@
1
+sc create APIasWIN binPath="C:\Users\Admin\Desktop\WorkerService1\WebApplication3\bin\Release\net5.0\WebApplication3.exe"

+ 1 - 0
WorkerService1/WebApplication3/uninstall_service.bat Ver fichero

@@ -0,0 +1 @@
1
+SC DELETE APIasWIN

+ 25 - 0
WorkerService1/WorkerService1.sln Ver fichero

@@ -0,0 +1,25 @@
1
+
2
+Microsoft Visual Studio Solution File, Format Version 12.00
3
+# Visual Studio Version 16
4
+VisualStudioVersion = 16.0.31321.278
5
+MinimumVisualStudioVersion = 10.0.40219.1
6
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebApplication3", "WebApplication3\WebApplication3.csproj", "{A7670D78-7D36-4BB9-B213-94FF50B2CBBF}"
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
+		{A7670D78-7D36-4BB9-B213-94FF50B2CBBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15
+		{A7670D78-7D36-4BB9-B213-94FF50B2CBBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
16
+		{A7670D78-7D36-4BB9-B213-94FF50B2CBBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
17
+		{A7670D78-7D36-4BB9-B213-94FF50B2CBBF}.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 = {DC477209-B590-4B80-9B20-AFE209ECD286}
24
+	EndGlobalSection
25
+EndGlobal