Added partPrograms to job model
This commit is contained in:
@@ -589,6 +589,14 @@ namespace CMS_Client.Browser_Tools
|
||||
|
||||
if (jobOpenFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// Check if zip is valid
|
||||
var zipIsValid = ValidateZip(jobOpenFileDialog.FileName);
|
||||
if (zipIsValid != null)
|
||||
{
|
||||
e.SetReturnValue(JsonConvert.SerializeObject(zipIsValid));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(JOB_OPENING_PATH))
|
||||
Directory.CreateDirectory(JOB_OPENING_PATH);
|
||||
|
||||
@@ -652,10 +660,11 @@ namespace CMS_Client.Browser_Tools
|
||||
else
|
||||
{
|
||||
entry.ExtractToFile(JOB_OPENING_PATH + entry.Name, true);
|
||||
job.partPrograms.Add(new PPContainer(Path.GetFileName(entry.Name)));
|
||||
}
|
||||
}
|
||||
}
|
||||
jobPath = Path.GetFileName(jobOpenFileDialog.FileName);
|
||||
jobPath = jobOpenFileDialog.FileName;
|
||||
e.SetReturnValue(JsonConvert.SerializeObject(job));
|
||||
return;
|
||||
}
|
||||
@@ -670,6 +679,7 @@ namespace CMS_Client.Browser_Tools
|
||||
{
|
||||
// Get file path
|
||||
string filePath = e.Arguments[0].StringValue;
|
||||
|
||||
// Check if zip is valid
|
||||
var zipIsValid = ValidateZip(filePath);
|
||||
if (zipIsValid != null)
|
||||
@@ -733,32 +743,6 @@ namespace CMS_Client.Browser_Tools
|
||||
}
|
||||
}
|
||||
|
||||
public static ErrorContainer ValidateZip(string filePath)
|
||||
{
|
||||
ErrorContainer result = null;
|
||||
if (!System.IO.File.Exists(filePath))
|
||||
return new ErrorContainer("error_file_not_found");
|
||||
|
||||
try
|
||||
{
|
||||
using (var archive = ZipFile.OpenRead(filePath))
|
||||
{
|
||||
List<ZipArchiveEntry> files = archive.Entries.Where(x => x.FullName == JOB_MAIN_FILENAME || x.FullName == JOB_METADATA_FILENAME).ToList();
|
||||
|
||||
if(files.Count() < 2)
|
||||
return new ErrorContainer("error_job_not_valid");
|
||||
else
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
result = new ErrorContainer("error_file_not_found");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void updateJobMetadata(object sender, CfrV8HandlerExecuteEventArgs e)
|
||||
{
|
||||
MetadataToFile metafile = new MetadataToFile();
|
||||
@@ -877,7 +861,7 @@ namespace CMS_Client.Browser_Tools
|
||||
//Create Zip File
|
||||
ZipFile.CreateFromDirectory(JOB_OPENING_PATH, jobSaveFileDialog.FileName);
|
||||
|
||||
jobPath = Path.GetFileName(jobSaveFileDialog.FileName);
|
||||
jobPath = jobSaveFileDialog.FileName;
|
||||
job.name = jobPath;
|
||||
e.SetReturnValue(JsonConvert.SerializeObject(job));
|
||||
return;
|
||||
@@ -944,7 +928,15 @@ namespace CMS_Client.Browser_Tools
|
||||
System.IO.File.Delete(jobPath);
|
||||
|
||||
//Create Zip File
|
||||
ZipFile.CreateFromDirectory(JOB_OPENING_PATH, jobPath);
|
||||
try
|
||||
{
|
||||
ZipFile.CreateFromDirectory(JOB_OPENING_PATH, jobPath);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("error_save_file")));
|
||||
return;
|
||||
}
|
||||
|
||||
e.SetReturnValue(JsonConvert.SerializeObject(job));
|
||||
return;
|
||||
@@ -1020,7 +1012,7 @@ namespace CMS_Client.Browser_Tools
|
||||
//Check the extension
|
||||
if (!_validExtensions.Contains(Path.GetExtension(PPOpenFileDialog.FileName).ToLower()))
|
||||
{
|
||||
e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("extension_not_available")));
|
||||
e.SetReturnValue(JsonConvert.SerializeObject(new ErrorContainer("ext_not_available")));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1091,6 +1083,33 @@ namespace CMS_Client.Browser_Tools
|
||||
return base64img.Substring(base64img.IndexOf(";base64,") + ";base64,".Length);
|
||||
}
|
||||
|
||||
|
||||
private static ErrorContainer ValidateZip(string filePath)
|
||||
{
|
||||
ErrorContainer result = null;
|
||||
if (!System.IO.File.Exists(filePath))
|
||||
return new ErrorContainer("error_file_not_found");
|
||||
|
||||
try
|
||||
{
|
||||
using (var archive = ZipFile.OpenRead(filePath))
|
||||
{
|
||||
List<ZipArchiveEntry> files = archive.Entries.Where(x => x.FullName == JOB_MAIN_FILENAME || x.FullName == JOB_METADATA_FILENAME).ToList();
|
||||
|
||||
if (files.Count() < 2)
|
||||
return new ErrorContainer("error_job_not_valid");
|
||||
else
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
result = new ErrorContainer("error_job_not_valid");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion JOB_METHODS
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,13 @@ namespace CMS_Client.Browser_Tools.Models
|
||||
public string name;
|
||||
public DateTime lastEditTimestamp;
|
||||
public string isoMainProgram;
|
||||
public Metas metadata;
|
||||
public Metas metadata;
|
||||
public List<PPContainer> partPrograms;
|
||||
|
||||
public JobToStep()
|
||||
{
|
||||
metadata = new Metas();
|
||||
partPrograms = new List<PPContainer>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user