internal static void Serialize <T>(IEnumerable <T> list, string name = null)
 {
     if (string.IsNullOrWhiteSpace(name))
     {
         name = typeof(T).Name;
     }
     Directory.CreateDirectory($@"{ConversionBaseHelper.XmlOutputLocation}\{name}\");
     JAMSXmlSerializer.WriteXml(list, $@"{ConversionBaseHelper.XmlOutputLocation}\{name}\{name}.xml");
 }
Exemplo n.º 2
0
        public override void Convert()
        {
            // ServiceModuleDictionary = CreateServiceModuleDto();
            PopulateJobConditionsDictionary();

            var convertedJobs = new Dictionary <string, List <MVPSI.JAMS.Job> >();

            foreach (var job in Source)
            {
                try
                {
                    Log.Logger.Information($"Converting {job.JobName}");

                    var newJob = GetInstance();

                    ConvertJobDetails(job, newJob);
                    ConvertJobConditions(job, newJob);
                    AddJobSteps(job, newJob);

                    if (JobConversionHelper.GenerateExceptions(newJob, convertedJobs, job.JobUID))
                    {
                        continue;
                    }

                    var jobCategoryName = JobConversionHelper.JobFolderName[job.JobUID]?.CategoryName;

                    if (convertedJobs.TryGetValue(jobCategoryName ?? "", out var jobForFolder))
                    {
                        jobForFolder.Add(newJob);
                    }
                    else
                    {
                        convertedJobs.Add(jobCategoryName ?? "", new List <MVPSI.JAMS.Job> {
                            newJob
                        });
                    }
                }
                catch (Exception ex)
                {
                    Log.Logger.Error(ex, ex.Message);
                    throw;
                }
            }

            SerializerHelper.Serialize(_connectionStoreDictionary.Values, "ConnectionStores");

            foreach (var convertedJob in convertedJobs)
            {
                JobConversionHelper.CreateDummyJobExportXml(convertedJob);

                JAMSXmlSerializer.WriteXml(convertedJob.Value,
                                           $@"{ConversionBaseHelper.XmlOutputLocation}\Jobs\{convertedJob.Key}\2_run_second-{convertedJob.Key}.xml");
            }
        }