diff --git a/Client/Browser_Tools/BrowserJSObject.cs b/Client/Browser_Tools/BrowserJSObject.cs
index dcaeba59..7b8c2d91 100644
--- a/Client/Browser_Tools/BrowserJSObject.cs
+++ b/Client/Browser_Tools/BrowserJSObject.cs
@@ -462,7 +462,7 @@ namespace CMS_Client.Browser_Tools
form.Add(new ByteArrayContent(filecontent), "file", fileName);
if (imagecontent != null)
form.Add(new ByteArrayContent(imagecontent), "image", imageName);
-
+ // Add reps to the form-data
form.Add(new StringContent(reps.ToString()), "reps");
//Send them
diff --git a/Client/Client.csproj b/Client/Client.csproj
index e9b071e2..e3ca8c54 100644
--- a/Client/Client.csproj
+++ b/Client/Client.csproj
@@ -127,8 +127,8 @@
..\packages\Microsoft.WindowsAPICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.ShellExtensions.dll
-
- ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll
+
+ ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll
diff --git a/Client/packages.config b/Client/packages.config
index 0f72ee8a..1639f044 100644
--- a/Client/packages.config
+++ b/Client/packages.config
@@ -3,5 +3,5 @@
-
+
\ No newline at end of file
diff --git a/Step.Config/Config/headsConfigValidator.xsd b/Step.Config/Config/headsConfigValidator.xsd
index 0588b2da..a360acc8 100644
--- a/Step.Config/Config/headsConfigValidator.xsd
+++ b/Step.Config/Config/headsConfigValidator.xsd
@@ -4,7 +4,7 @@
-
+
diff --git a/Step.Config/Config/macrosConfig.xml b/Step.Config/Config/macrosConfig.xml
new file mode 100644
index 00000000..e8022fdb
--- /dev/null
+++ b/Step.Config/Config/macrosConfig.xml
@@ -0,0 +1,6 @@
+
+
+ Macro 1
+ Macro 2
+ Macro 3
+
\ No newline at end of file
diff --git a/Step.Config/Config/macrosConfigValidator.xsd b/Step.Config/Config/macrosConfigValidator.xsd
new file mode 100644
index 00000000..af4c9e00
--- /dev/null
+++ b/Step.Config/Config/macrosConfigValidator.xsd
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Step.Config/ServerConfig.cs b/Step.Config/ServerConfig.cs
index 59c1cc79..7b0610fc 100644
--- a/Step.Config/ServerConfig.cs
+++ b/Step.Config/ServerConfig.cs
@@ -32,5 +32,7 @@ namespace Step.Config
public static AreasConfigModel MaintenanceConfig;
public static AreasConfigModel UtilitiesConfig;
public static AreasConfigModel ScadaConfig;
+
+ public static List MacrosConfig;
}
}
diff --git a/Step.Config/ServerConfigController.cs b/Step.Config/ServerConfigController.cs
index aee27570..91bbd3eb 100644
--- a/Step.Config/ServerConfigController.cs
+++ b/Step.Config/ServerConfigController.cs
@@ -28,6 +28,7 @@ namespace Step.Config
ReadAlarmsConfig();
ReadHeadsConfig();
ReadToolManagerConfig();
+ ReadMacros();
}
catch (System.Xml.XmlException ex)
{
@@ -385,6 +386,18 @@ namespace Step.Config
.FirstOrDefault();
}
+ public static void ReadMacros()
+ {
+ XDocument xmlConfigFile = GetXmlHandlerWithValidator(MACROS_CONFIG_SCHEMA_PATH, MACROS_CONFIG_PATH);
+
+ // Read config from XML file
+ MacrosConfig = xmlConfigFile
+ .Descendants("macros")
+ .Elements()
+ .Select(x => x.Value)
+ .ToList();
+ }
+
#endregion Read config from file from configuration
}
}
\ No newline at end of file
diff --git a/Step.Config/Step.Config.csproj b/Step.Config/Step.Config.csproj
index 257e2a89..e9622439 100644
--- a/Step.Config/Step.Config.csproj
+++ b/Step.Config/Step.Config.csproj
@@ -42,6 +42,10 @@
+
+ Designer
+ PreserveNewest
+
@@ -115,5 +119,10 @@
Designer
+
+
+ Designer
+
+
\ No newline at end of file
diff --git a/Step.Core/Step.Core.csproj b/Step.Core/Step.Core.csproj
index 42cc5b5e..fd61eed3 100644
--- a/Step.Core/Step.Core.csproj
+++ b/Step.Core/Step.Core.csproj
@@ -87,6 +87,7 @@
+
diff --git a/Step.Core/app.config b/Step.Core/app.config
new file mode 100644
index 00000000..b65ec51d
--- /dev/null
+++ b/Step.Core/app.config
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Step.Database/App.config b/Step.Database/App.config
index 37bd4d82..218f15ca 100644
--- a/Step.Database/App.config
+++ b/Step.Database/App.config
@@ -5,7 +5,7 @@
-
+
diff --git a/Step.Model/Constants.cs b/Step.Model/Constants.cs
index 9eb665f6..fc68621a 100644
--- a/Step.Model/Constants.cs
+++ b/Step.Model/Constants.cs
@@ -10,8 +10,13 @@ namespace Step.Model
public static readonly string[] VALID_IMAGE_EXTENSIONS = { ".jpg", ".jpeg", ".png" };
public const double EPSILON = 0.001;
public static string QUEUE_FILE_NAME = "pp";
+ public const string JOB_MAIN_FILENAME = "main.cnc";
+ public const string JOB_METADATA_FILENAME = "metadata.json";
+
+ public static String JOB_OPENING_PATH = BASE_PATH + "TempJob\\";
+
+
-
public enum ROLE_IDS
{
CMS_SERVICE_ONLY = 1,
@@ -140,6 +145,9 @@ namespace Step.Model
public const string TOOL_MANAGER_CONFIG_SCHEMA_PATH = RESOURCE_DIRECTORY + "toolManagerConfigValidator.xsd";
public const string TOOL_MANAGER_CONFIG_PATH = CONFIG_DIRECTORY + "toolManagerConfig.xml";
+ public const string MACROS_CONFIG_SCHEMA_PATH = RESOURCE_DIRECTORY + "macrosConfigValidator.xsd";
+ public const string MACROS_CONFIG_PATH = CONFIG_DIRECTORY + "macrosConfig.xml";
+
public static string WEBSITE_DIRECTORY = Path.Combine(BASE_PATH, "..", "wwwroot");
public static string LANGUAGE_PACK_DIRECTORY = BASE_PATH + "\\languages\\";
public static string LANGUAGE_SCHEMA_PATH = BASE_PATH + "\\LanguageValidator.xsd";
diff --git a/Step.Model/DTOModels/JobModels/DTOGenericParamModel.cs b/Step.Model/DTOModels/JobModels/DTOGenericParamModel.cs
new file mode 100644
index 00000000..7bc3f4ec
--- /dev/null
+++ b/Step.Model/DTOModels/JobModels/DTOGenericParamModel.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Step.Model.DTOModels.JobModels
+{
+ public class DTOGenericParamModel
+ {
+ public List Images;
+ public string Description;
+ public TimeSpan ExecutionTime;
+
+ public DTOGenericParamModel()
+ {
+ Images = new List();
+ }
+ }
+}
diff --git a/Step.Model/DTOModels/JobModels/DTOImageParamModel.cs b/Step.Model/DTOModels/JobModels/DTOImageParamModel.cs
new file mode 100644
index 00000000..25524b03
--- /dev/null
+++ b/Step.Model/DTOModels/JobModels/DTOImageParamModel.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Step.Model.DTOModels.JobModels
+{
+ public class DTOImageParamModel
+ {
+ public string Name;
+ public string Base64;
+ }
+}
diff --git a/Step.Model/DTOModels/JobModels/DTOJobCustomParamModel.cs b/Step.Model/DTOModels/JobModels/DTOJobCustomParamModel.cs
new file mode 100644
index 00000000..e6ba277f
--- /dev/null
+++ b/Step.Model/DTOModels/JobModels/DTOJobCustomParamModel.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Step.Model.DTOModels.JobModels
+{
+ public class DTOJobCustomParamModel
+ {
+ public string Name;
+ public string Type;
+ public List SelectionList;
+ public int Value;
+
+ public DTOJobCustomParamModel()
+ {
+ SelectionList = new List();
+ }
+ }
+}
diff --git a/Step.Model/DTOModels/JobModels/DTOJobModel.cs b/Step.Model/DTOModels/JobModels/DTOJobModel.cs
new file mode 100644
index 00000000..c885fb21
--- /dev/null
+++ b/Step.Model/DTOModels/JobModels/DTOJobModel.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Step.Model.DTOModels.JobModels
+{
+ public class DTOJobModel
+ {
+ public string Name;
+ public DateTime LastEditTimestamp;
+ public string IsoMainProgram;
+ public DTOMetadataModel Metadata;
+
+ public DTOJobModel()
+ {
+ Metadata = new DTOMetadataModel();
+ }
+ }
+}
diff --git a/Step.Model/DTOModels/JobModels/DTOMetadataFieldsModel.cs b/Step.Model/DTOModels/JobModels/DTOMetadataFieldsModel.cs
new file mode 100644
index 00000000..248b3ffc
--- /dev/null
+++ b/Step.Model/DTOModels/JobModels/DTOMetadataFieldsModel.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Step.Model.DTOModels.JobModels
+{
+ public class DTOMetadataFieldsModel
+ {
+ public string Description;
+ public TimeSpan ExecutionTime;
+ public List Tools;
+ public List Customs;
+
+ public DTOMetadataFieldsModel()
+ {
+ Tools = new List();
+ Customs = new List();
+ }
+ }
+}
diff --git a/Step.Model/DTOModels/JobModels/DTOMetadataModel.cs b/Step.Model/DTOModels/JobModels/DTOMetadataModel.cs
new file mode 100644
index 00000000..7a0db8a7
--- /dev/null
+++ b/Step.Model/DTOModels/JobModels/DTOMetadataModel.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Step.Model.DTOModels.JobModels
+{
+ public class DTOMetadataModel
+ {
+ public DTOGenericParamModel Generics;
+ public List Tools;
+ public List Customs;
+
+ public DTOMetadataModel()
+ {
+ Generics = new DTOGenericParamModel();
+ Tools = new List();
+ Customs = new List();
+ }
+ }
+}
diff --git a/Step.Model/Step.Model.csproj b/Step.Model/Step.Model.csproj
index 7f1db5d4..22be59aa 100644
--- a/Step.Model/Step.Model.csproj
+++ b/Step.Model/Step.Model.csproj
@@ -94,7 +94,13 @@
+
+
+
+
+
+
diff --git a/Step.NC/NcHandler.cs b/Step.NC/NcHandler.cs
index 04180c34..f4b00e3e 100644
--- a/Step.NC/NcHandler.cs
+++ b/Step.NC/NcHandler.cs
@@ -379,10 +379,11 @@ namespace Step.NC
{
itemId = itemId - 1;
- // Update queue running index
+ var a = QueueRunningIndexes[processId];
+ // Update queue running index after move an item
if (itemId < QueueRunningIndexes[processId] && newIndex >= QueueRunningIndexes[processId])
QueueRunningIndexes[processId] -= 1;
- if (newIndex <= QueueRunningIndexes[processId] && itemId > QueueRunningIndexes[processId])
+ if (newIndex < QueueRunningIndexes[processId] && itemId > QueueRunningIndexes[processId])
QueueRunningIndexes[processId] += 1;
queue = new List();
diff --git a/Step.NC/Step.NC.csproj b/Step.NC/Step.NC.csproj
index eec04cd2..e2277c8a 100644
--- a/Step.NC/Step.NC.csproj
+++ b/Step.NC/Step.NC.csproj
@@ -51,6 +51,7 @@
+
Always
diff --git a/Step.NC/app.config b/Step.NC/app.config
new file mode 100644
index 00000000..b65ec51d
--- /dev/null
+++ b/Step.NC/app.config
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Step.Utils/Step.Utils.csproj b/Step.Utils/Step.Utils.csproj
index 84b9729d..0a022247 100644
--- a/Step.Utils/Step.Utils.csproj
+++ b/Step.Utils/Step.Utils.csproj
@@ -35,11 +35,16 @@
..\packages\MySql.Data.6.10.4\lib\net452\MySql.Data.dll
+
+ ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll
+
..\packages\NLog.4.4.12\lib\net45\NLog.dll
+
+
diff --git a/Step.Utils/packages.config b/Step.Utils/packages.config
index 9e8a4d68..34a77645 100644
--- a/Step.Utils/packages.config
+++ b/Step.Utils/packages.config
@@ -1,5 +1,6 @@
+
\ No newline at end of file
diff --git a/Step.Utils/supportFunctions.cs b/Step.Utils/supportFunctions.cs
index 75f55ab5..281ef922 100644
--- a/Step.Utils/supportFunctions.cs
+++ b/Step.Utils/supportFunctions.cs
@@ -1,6 +1,10 @@
-using System.Collections.Generic;
+using Newtonsoft.Json;
+using Step.Model.DTOModels.JobModels;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.IO.Compression;
using System.Linq;
-using System.Reflection;
using static Step.Model.Constants;
namespace Step.Utils
@@ -101,7 +105,7 @@ namespace Step.Utils
}
}
}
-
+
public static int GetNextId(IEnumerable objIds)
{
if (objIds.Count() == 0)
@@ -121,6 +125,86 @@ namespace Step.Utils
else
return 1;
}
- }
+ public static DTOJobModel UnpackJobAndReadMetadata(string path)
+ {
+ DTOJobModel job = new DTOJobModel();
+ // Check if job exists
+ if (!File.Exists(path))
+ return null;
+
+ EmptyFolder(path);
+
+ string fileName = Path.GetFileName(path);
+
+ using (ZipArchive zipExtractor = ZipFile.OpenRead(fileName))
+ {
+ // Setup main job fields
+ job.Name = Path.GetFileName(fileName);
+ job.LastEditTimestamp = new FileInfo(fileName).LastAccessTime;
+
+ foreach (ZipArchiveEntry entry in zipExtractor.Entries)
+ {
+ // Get main program content
+ if (entry.Name.Equals(JOB_MAIN_FILENAME, StringComparison.OrdinalIgnoreCase))
+ {
+ using (var reader = new StreamReader(entry.Open()))
+ job.IsoMainProgram = (reader.ReadToEnd());
+ }
+
+ // Read images
+ else if (VALID_IMAGE_EXTENSIONS.Contains(Path.GetExtension(entry.Name).ToLower()))
+ {
+ var bytes = default(byte[]);
+ entry.ExtractToFile(JOB_OPENING_PATH + entry.Name, true);
+ using (var memstream = new MemoryStream())
+ {
+ entry.Open().CopyTo(memstream);
+ bytes = memstream.ToArray();
+ job.Metadata.Generics.Images.Add(new DTOImageParamModel()
+ {
+ Name = Path.GetFileNameWithoutExtension(entry.Name),
+ Base64 = "data:image/" + Path.GetExtension(entry.Name).ToLower().TrimStart('.') + ";base64," + Convert.ToBase64String(bytes)
+ });
+ }
+ }
+ // Read metadata
+ else if (entry.Name.Equals(JOB_METADATA_FILENAME, StringComparison.OrdinalIgnoreCase))
+ {
+ DTOMetadataFieldsModel metasFromFile = new DTOMetadataFieldsModel();
+
+ using (var reader = new StreamReader(entry.Open()))
+ {
+ metasFromFile = JsonConvert.DeserializeObject(reader.ReadToEnd());
+ if (metasFromFile == null)
+ {
+ return null;
+ }
+ else
+ {
+ job.Metadata.Generics.Description = metasFromFile.Description;
+ job.Metadata.Generics.ExecutionTime = metasFromFile.ExecutionTime;
+ job.Metadata.Tools = metasFromFile.Tools;
+ job.Metadata.Customs = metasFromFile.Customs;
+ }
+ }
+ }
+ // Consider other file as part program
+ else
+ entry.ExtractToFile(JOB_OPENING_PATH + entry.Name, true);
+ }
+
+ return job;
+ }
+ }
+
+ public static void EmptyFolder(string path)
+ {
+ DirectoryInfo di = new DirectoryInfo(path);
+ foreach (FileInfo file in di.GetFiles())
+ file.Delete();
+ foreach (DirectoryInfo dir in di.GetDirectories())
+ dir.Delete(true);
+ }
+ }
}
\ No newline at end of file
diff --git a/Step/App.config b/Step/App.config
index feb9879a..e9068b4f 100644
--- a/Step/App.config
+++ b/Step/App.config
@@ -22,7 +22,7 @@
-
+
diff --git a/Step/Controllers/WebApi/NcFileController.cs b/Step/Controllers/WebApi/NcFileController.cs
index e96cba39..9f56d018 100644
--- a/Step/Controllers/WebApi/NcFileController.cs
+++ b/Step/Controllers/WebApi/NcFileController.cs
@@ -291,6 +291,12 @@ namespace Step.Controllers.WebApi
}
}
+ [Route("macros")]
+ public IHttpActionResult GetMacros()
+ {
+ return Ok(MacrosConfig);
+ }
+
public class MoveItems
{
public int ObjectId;
diff --git a/Step/Step.csproj b/Step/Step.csproj
index da17de68..420cb0cf 100644
--- a/Step/Step.csproj
+++ b/Step/Step.csproj
@@ -97,8 +97,8 @@
..\packages\Microsoft.Owin.StaticFiles.3.1.0\lib\net45\Microsoft.Owin.StaticFiles.dll
-
- ..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll
+
+ ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll
..\packages\Owin.1.0\lib\net40\Owin.dll
diff --git a/Step/packages.config b/Step/packages.config
index da3e9a1b..df6ee823 100644
--- a/Step/packages.config
+++ b/Step/packages.config
@@ -27,7 +27,7 @@
-
+