Merge remote-tracking branch 'CMS/develop' into develop
This commit is contained in:
@@ -36,7 +36,8 @@ namespace Active_Client.Browser_Tools
|
||||
|
||||
private MainForm mainForm;
|
||||
|
||||
private static readonly string[] _validExtensions = { "", ".txt", ".cnc", ".cn", ".cno", ".ini", ".mpf", ".spf", ".tap", ".anc", ".iso", /*".job", ".zip"*/ };
|
||||
private static readonly string[] _validExtensions = { "", ".json", ".rcp", ".tpl" };
|
||||
//private static readonly string[] _validExtensions = { "", ".txt", ".cnc", ".cn", ".cno", ".ini", ".mpf", ".spf", ".tap", ".anc", ".iso" };
|
||||
private static readonly string[] _validImages = { ".jpg", ".jpeg", ".png" };
|
||||
private static string jobPath = "";
|
||||
private static Dictionary<string, IntPtr> _editorOpened = new Dictionary<string, IntPtr>();
|
||||
|
||||
@@ -200,21 +200,21 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<Content Include="Config\Recipes\template.json">
|
||||
<None Include="Config\Recipes\template.tpl">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</None>
|
||||
<EmbeddedResource Include="Config\thermoProdConfigValidator.xsd">
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Recipes\Startup1.json">
|
||||
<None Include="Recipes\Startup1.rcp">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Recipes\Startup2.json">
|
||||
<None Include="Recipes\Startup2.rcp">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Recipes\testa.json">
|
||||
<None Include="Recipes\testa.rcp">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
@@ -221,8 +221,8 @@ namespace Thermo.Active.Model
|
||||
#endif
|
||||
public const string CONFIG_DIRECTORY = "Config\\";
|
||||
public const string RECIPE_DIRECTORY = "Recipes\\";
|
||||
public const string RECIPE_TEMPLATE_PATH = CONFIG_DIRECTORY + RECIPE_DIRECTORY + "template.json";
|
||||
public const string LIVE_RECIPE_PATH = TEMP_FOLDER + RECIPE_DIRECTORY + "current.json";
|
||||
public const string RECIPE_TEMPLATE_PATH = CONFIG_DIRECTORY + RECIPE_DIRECTORY + "template.tpl";
|
||||
public const string LIVE_RECIPE_PATH = TEMP_FOLDER + RECIPE_DIRECTORY + "current.rcp";
|
||||
public const string RESOURCE_DIRECTORY = @"Thermo.Active.Config.Config.";
|
||||
public const string SERVER_CONFIG_SCHEMA_PATH = RESOURCE_DIRECTORY + @"serverConfigValidator.xsd";
|
||||
public const string SERVER_CONFIG_PATH = CONFIG_DIRECTORY + "serverConfig.xml";
|
||||
|
||||
@@ -681,11 +681,11 @@ namespace Thermo.Active.NC
|
||||
public static bool LoadRecipe(string filePath)
|
||||
{
|
||||
bool answ = false;
|
||||
|
||||
// check file extension
|
||||
if (!filePath.EndsWith(".json"))
|
||||
// check file extension: accetta json / rcp / tpl
|
||||
if (!(filePath.EndsWith(".json") || filePath.EndsWith(".rcp") || filePath.EndsWith(".tpl")))
|
||||
{
|
||||
filePath += ".json";
|
||||
// default: ricetta!
|
||||
filePath += ".rcp";
|
||||
}
|
||||
string fileName = Path.GetFileName(filePath);
|
||||
|
||||
@@ -755,7 +755,7 @@ namespace Thermo.Active.NC
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Try to write live data to json persistence file
|
||||
/// Write live data to json persistence file
|
||||
/// </summary>
|
||||
public static bool SaveRecipeCurrent()
|
||||
{
|
||||
@@ -779,6 +779,45 @@ namespace Thermo.Active.NC
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Write image data for recipe
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
/// <param name="fileData"></param>
|
||||
/// <returns></returns>
|
||||
public static bool SaveRecipeImage(string filePath, byte[] fileData)
|
||||
{
|
||||
bool imageUploaded = false;
|
||||
try
|
||||
{
|
||||
// save live!
|
||||
var dir = Path.GetDirectoryName(RECIPE_DIRECTORY);
|
||||
if (!Directory.Exists(dir))
|
||||
{
|
||||
Directory.CreateDirectory(dir);
|
||||
}
|
||||
|
||||
// Delete previous image
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
|
||||
if (!Path.IsPathRooted(filePath))
|
||||
{
|
||||
// aggiungo base path!
|
||||
filePath = RECIPE_DIRECTORY + filePath;
|
||||
}
|
||||
|
||||
// Save NEW image
|
||||
File.WriteAllBytes(filePath, fileData);
|
||||
imageUploaded = true;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
return imageUploaded;
|
||||
}
|
||||
/// <summary>
|
||||
/// Try to save live recipe as NEW template
|
||||
/// </summary>
|
||||
public static bool SaveRecipeTemplate()
|
||||
@@ -798,23 +837,29 @@ namespace Thermo.Active.NC
|
||||
try
|
||||
{
|
||||
answ = true;
|
||||
string fileName = Path.GetFileName(filePath);
|
||||
if (!fileName.EndsWith(".json"))
|
||||
// check file extension: accetta json / rcp / tpl
|
||||
if (!(filePath.EndsWith(".json") || filePath.EndsWith(".rcp") || filePath.EndsWith(".tpl")))
|
||||
{
|
||||
fileName += ".json";
|
||||
filePath += ".json";
|
||||
// default: ricetta!
|
||||
filePath += ".rcp";
|
||||
}
|
||||
string fileName = Path.GetFileName(filePath);
|
||||
|
||||
// fix name!
|
||||
currRecipe.RecipeName = fileName;
|
||||
// serialize
|
||||
string rawData = JsonConvert.SerializeObject(currRecipe);
|
||||
// save live!
|
||||
File.WriteAllText(LIVE_RECIPE_PATH, rawData);
|
||||
// check filePath...
|
||||
if (!filePath.Contains(RECIPE_DIRECTORY) && filePath != RECIPE_TEMPLATE_PATH)
|
||||
// verifica path
|
||||
if (!Path.IsPathRooted(filePath))
|
||||
{
|
||||
// aggiungo base path!
|
||||
filePath = RECIPE_DIRECTORY + filePath;
|
||||
// controllo se ha path della recipe directory
|
||||
if (!filePath.Contains(RECIPE_DIRECTORY) && filePath != RECIPE_TEMPLATE_PATH)
|
||||
{
|
||||
// aggiungo base path!
|
||||
filePath = RECIPE_DIRECTORY + filePath;
|
||||
}
|
||||
}
|
||||
// save!
|
||||
File.WriteAllText(filePath, rawData);
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
using CMS_CORE_Library.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
using Thermo.Active.Config;
|
||||
using Thermo.Active.Model.DTOModels.ThRecipe;
|
||||
@@ -402,6 +407,33 @@ namespace Thermo.Active.Controllers.WebApi
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[Route("uploadImage"), HttpPost]
|
||||
public async Task<IHttpActionResult> UpdloadImage()
|
||||
{
|
||||
bool imageUploaded = false;
|
||||
|
||||
if (!Request.Content.IsMimeMultipartContent())
|
||||
{
|
||||
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
|
||||
}
|
||||
|
||||
List<FormItem> formItems = await MultipartHandler.ManageMultiPartFileAsync(Request);
|
||||
|
||||
foreach (FormItem item in formItems)
|
||||
{
|
||||
if (item.IsAFile)
|
||||
{
|
||||
if (item.ParameterName == "image" || item.MediaType.StartsWith("image/"))
|
||||
{
|
||||
string filePath = item.FileName;
|
||||
imageUploaded = NcFileAdapter.SaveRecipeImage(item.FileName, item.Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Do actual recipe parameters FileSave
|
||||
@@ -421,6 +453,7 @@ namespace Thermo.Active.Controllers.WebApi
|
||||
ThermoActiveLogger.LogError($"Recipe | SaveCurrentRecipeParams exception | {exc}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// write current recipe to PLC
|
||||
/// </summary>
|
||||
|
||||
@@ -12,7 +12,7 @@ function DoLog($txt2log)
|
||||
}
|
||||
|
||||
|
||||
DoLog("-------------------------------- START script --------------------------------")
|
||||
Write-Output "-------------------------------- START script --------------------------------" | Out-File c:\tmp\Script.log
|
||||
$StopWatch = New-Object System.Diagnostics.Stopwatch
|
||||
$StopWatch.Start()
|
||||
|
||||
@@ -34,6 +34,9 @@ DoLog("START npm run build ")
|
||||
npm run build | Out-File c:\tmp\Script.log -Append
|
||||
DoLog("END npm run build ")
|
||||
|
||||
# torno in folder base
|
||||
cd ..
|
||||
|
||||
$StopWatch.Stop()
|
||||
$StopWatch.Elapsed | Out-File c:\tmp\Script.log -Append
|
||||
DoLog("-------------------------------- END script --------------------------------")
|
||||
DoLog("-------------------------------- END script --------------------------------")
|
||||
@@ -27,8 +27,7 @@ function DoLog($txt2log)
|
||||
Write-Output "$(Get-TimeStamp) $txt2log" | Out-File c:\tmp\Script.log -Append
|
||||
}
|
||||
|
||||
|
||||
DoLog("-------------------------------- START script --------------------------------")
|
||||
Write-Output "-------------------------------- START script --------------------------------" | Out-File c:\tmp\Script.log
|
||||
$StopWatch = New-Object System.Diagnostics.Stopwatch
|
||||
$StopWatch.Start()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user