Fix integrated file edito
Refactor file names in constants Fix fanuc upload images
This commit is contained in:
@@ -127,13 +127,14 @@ namespace Step.Controllers.WebApi
|
||||
if (item.ParameterName == "main")
|
||||
{
|
||||
File.WriteAllBytes(TEMP_PP_FOLDER + item.FileName, item.Data);
|
||||
mainPPName = item.FileName;
|
||||
programs.Add(item.FileName);
|
||||
|
||||
// Upload main program
|
||||
CmsError cmsError = ncFileHandler.UploadPartProgramAndActivate(TEMP_PP_FOLDER, item.FileName, out programData);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
mainPPName = Path.GetFileNameWithoutExtension(programData.Path);
|
||||
}
|
||||
else if (item.ParameterName == "file")
|
||||
{
|
||||
@@ -147,8 +148,21 @@ namespace Step.Controllers.WebApi
|
||||
}
|
||||
else if (item.ParameterName == "image")
|
||||
{
|
||||
// Delete duplicated images
|
||||
string[] imgFiles = Directory.GetFiles(PART_PRG_IMAGES);
|
||||
foreach (string f in imgFiles)
|
||||
{
|
||||
if (Path.GetFileNameWithoutExtension(f) == mainPPName)
|
||||
File.Delete(f);
|
||||
}
|
||||
|
||||
// Upload image
|
||||
File.WriteAllBytes(PART_PRG_IMAGES + Path.GetFileNameWithoutExtension(programData.Path) + Path.GetExtension(item.FileName), item.Data);
|
||||
File.WriteAllBytes(
|
||||
PART_PRG_IMAGES + // Path
|
||||
mainPPName + // Part program name
|
||||
Path.GetExtension(item.FileName), // Extension of the image
|
||||
item.Data);
|
||||
|
||||
imageUploaded = true;
|
||||
}
|
||||
}
|
||||
@@ -156,7 +170,7 @@ namespace Step.Controllers.WebApi
|
||||
|
||||
if (!imageUploaded)
|
||||
{
|
||||
mainPPName = Path.GetFileNameWithoutExtension(mainPPName);
|
||||
// Delete old images with the same name of the main program
|
||||
string[] imgFiles = Directory.GetFiles(PART_PRG_IMAGES);
|
||||
foreach (string f in imgFiles)
|
||||
{
|
||||
@@ -169,7 +183,7 @@ namespace Step.Controllers.WebApi
|
||||
if (NcConfig.NcVendor != NC_VENDOR.OSAI) {
|
||||
|
||||
List<string> lines = new List<string>();
|
||||
string outputFileName = NcConfig.SharedPath + "activePP.list";
|
||||
string outputFileName = NcConfig.SharedPath + PARTPRG_LIST_FILE;
|
||||
|
||||
foreach (string prog in programs)
|
||||
{
|
||||
@@ -196,7 +210,7 @@ namespace Step.Controllers.WebApi
|
||||
return Ok(true);
|
||||
else
|
||||
{
|
||||
string fileName = NcConfig.SharedPath + "activePP.list";
|
||||
string fileName = NcConfig.SharedPath + PARTPRG_LIST_FILE;
|
||||
int count = Directory.GetFiles(NcConfig.SharedPath).Length;
|
||||
|
||||
if (!File.Exists(fileName) && count == 0)
|
||||
@@ -250,12 +264,12 @@ namespace Step.Controllers.WebApi
|
||||
public IHttpActionResult BackupSharedFolder()
|
||||
{
|
||||
if (NcConfig.NcVendor == NC_VENDOR.OSAI)
|
||||
return Ok(true);
|
||||
return Ok(true);
|
||||
else
|
||||
{
|
||||
string newFolder = "C:\\Backup_" + new DirectoryInfo(NcConfig.SharedPath).Name + "\\" + DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss") + "\\";
|
||||
|
||||
File.Delete(NcConfig.SharedPath + "activePP.list");
|
||||
File.Delete(NcConfig.SharedPath + PARTPRG_LIST_FILE);
|
||||
Directory.CreateDirectory(newFolder);
|
||||
foreach (string filename in Directory.GetFiles(NcConfig.SharedPath))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user