Esempio n. 1
0
 public void AddJobType(double frequence, double[] meanProcessTimes, int[] machineSequence)
 {
     JobTypes.Add(new JobType
     {
         Id                  = JobTypes.Count,
         Frequence           = frequence,
         MachineSequence     = machineSequence.ToList(),
         MeanProcessingTimes = meanProcessTimes.ToList()
     });
 }
Esempio n. 2
0
        internal bool RegisterJobType(JobType type)
        {
            if (JobTypes.Any(t => t.Name.ToLowerInvariant() == type.Name.ToLowerInvariant()))
            {
                Log log = new Log();
                log.Create(LogType.Error, "JobManager.RegisterType", "Register type failed!", $"Type with name '{type.Name}' already exists.", saveDetailsAsJson: true);
                return(false);
            }

            if (!JobTypes.Any(t => t.Id == type.Id))
            {
                JobTypes.Add(type);
            }

            return(true);
        }
Esempio n. 3
0
        public bool RegisterType(JobType type)
        {
            if (JobTypes.Any(t => t.Name.ToLowerInvariant() == type.Name.ToLowerInvariant()))
            {
                Log log = new Log();
                log.Create(LogType.Error, "JobManager.RegisterType", "Register type failed!", $"Type with name '{type.Name}' already exists.", saveDetailsAsJson: true);
                return(false);
            }

            var      assemblies = AppDomain.CurrentDomain.GetAssemblies();
            Assembly assembly   = assemblies.FirstOrDefault(a => a.GetName().Name == type.Assembly);

            if (assembly == null)
            {
                //log error "Assembly can not be found!"
                Log log = new Log();
                log.Create(LogType.Error, "JobManager.RegisterType", "Register type failed!", $"Assembly with name '{type.Assembly}' can not be found.", saveDetailsAsJson: true);
                return(false);
            }

            Type assemblyType = assembly.GetType(type.CompleteClassName);

            if (assemblyType == null)
            {
                Log log = new Log();
                log.Create(LogType.Error, "JobManager.RegisterType", "Register type failed!", $"Type with name '{type.CompleteClassName}' does not exist in assembly {assembly.FullName}.", saveDetailsAsJson: true);
                return(false);
            }

            var method = assemblyType.GetMethod(type.MethodName);

            if (method == null)
            {
                Log log = new Log();
                log.Create(LogType.Error, "JobManager.RegisterType", "Register type failed!", $"Method with name '{type.MethodName}' does not exist in assembly {assembly.FullName}.", saveDetailsAsJson: true);
                return(false);
            }


            if (!JobTypes.Any(t => t.Id == type.Id))
            {
                JobTypes.Add(type);
            }

            return(true);
        }