Пример #1
0
        public Job(Character owner, JobRecord record)
        {
            Owner    = owner;
            Record   = record;
            Template = JobManager.Instance.GetJobTemplate(record.TemplateId);

            var level = ExperienceManager.Instance.GetJobLevel(Experience);

            LowerBoundExperience = ExperienceManager.Instance.GetJobLevelExperience(level);
            UpperBoundExperience = ExperienceManager.Instance.GetJobNextLevelExperience(level);
            Level = level;
        }
Пример #2
0
        private bool CheckRecordExists()
        {
            if (Record == null)
            {
                Record = new JobRecord()
                {
                    OwnerId = Owner.Id, TemplateId = Template.Id
                };
                IsNew = true;
            }

            return(IsNew);
        }
Пример #3
0
        private Job Activate(JobRecord record)
        {
            if (record == null)
            {
                return(null);
            }

            var job = new Job(record);

            job._tasksField.Loader(() => record.Tasks.Select(Activate));
            job._cloudVideoPartField.Loader(() => _contentManager.Get <CloudVideoPart>(record.CloudVideoPartId, VersionOptions.Latest));
            return(job);
        }
        public void CreateJob(string industry, object context)
        {
            if (String.IsNullOrEmpty(industry))
            {
                throw new ArgumentNullException("industry");
            }

            var record = new JobRecord
            {
                Industry        = industry,
                ContextDefinion = JsonConvert.SerializeObject(context)
            };

            _repository.Create(record);
            _repository.Flush();
        }
Пример #5
0
        public List <JobRecord> SelectAllJob()
        {
            List <JobRecord> records = new List <JobRecord>();

            SqlCommand command = new SqlCommand();

            command.CommandType = System.Data.CommandType.Text;
            command.CommandText = @"SELECT *
                                    FROM Jobs";

            try { command.Connection = getConnection(); }
            catch (Exception)
            {
                throw new DatabaseConnectionException();
            }

            SqlDataReader reader;

            try { reader = command.ExecuteReader(); }
            catch
            {
                throw new DatabaseCommandTextException();
            }

            try
            {
                while (reader.Read())
                {
                    JobRecord nextRecord = new JobRecord();
                    nextRecord.Id            = int.Parse(reader["id"].ToString());
                    nextRecord.WorkplaceName = reader["workplace_name"].ToString();
                    nextRecord.Job           = reader["job"].ToString();
                    nextRecord.Description   = reader["description"].ToString();

                    records.Add(nextRecord);
                }
            }
            catch (Exception)
            {
                throw new DatabaseParameterException();
            }
            return(records);
        }
Пример #6
0
        void ScheduleJob(JobRecord job)
        {
            try
            {
                IJobDetail jobDetail = JobBuilder.Create <JobWrapper>()
                                       .UsingJobData("index", job.Index)
                                       .WithIdentity(job.Assembly)
                                       .Build();

                var tb = TriggerBuilder.Create();

                tb.WithCronSchedule(job.JobParams.CronString);

                log.Info("  модуль {0}, cron string: {1}", job.Assembly, job.JobParams.CronString);
                context.Scheduler.ScheduleJob(jobDetail, tb.Build());
            }
            catch (FormatException ex)
            {
                log.Error("Работа " + job.Assembly + ": ошибка в cron string: " + ex.Message);
            }
        }
Пример #7
0
 public void StartNewsLetter()
 {
     try
     {
         var settings = NewsletterSettings.GetSettings();
         if (!settings.SendRecentlyAddedEmail)
         {
             return;
         }
         JobRecord.SetRunning(true, JobNames.RecentlyAddedEmail);
         StartNewsLetter(settings);
     }
     catch (Exception e)
     {
         Log.Error(e);
     }
     finally
     {
         JobRecord.Record(JobNames.RecentlyAddedEmail);
         JobRecord.SetRunning(false, JobNames.RecentlyAddedEmail);
     }
 }
Пример #8
0
        public void CreateJob(string industry, object context, int priority)
        {
            if (String.IsNullOrEmpty(industry))
            {
                throw new ArgumentNullException("industry");
            }

            var record = new JobRecord
            {
                Industry        = industry,
                ContextDefinion = JsonConvert.SerializeObject(
                    context,
                    Formatting.None,
                    new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.Auto
                }),
                Priority = priority
            };

            _repository.Create(record);
            _repository.Flush();
        }
Пример #9
0
 public Job(JobRecord record)
 {
     Record = record;
 }
Пример #10
0
        protected override void OnStart(string[] args)
        {
#if DEBUG
            System.Diagnostics.Debugger.Launch();
#endif
            string rootPath = AppDomain.CurrentDomain.BaseDirectory;

            glContext = new GlobalContext(rootPath);
            rcProc    = new RemoteCommandProcessor(glContext);

            glContext.RemoteProcessor = rcProc;

            Directory.CreateDirectory(glContext.LogsDirFull);
            Directory.CreateDirectory(glContext.ReportsDirFull);
            Directory.CreateDirectory(glContext.RecordsDirFull);

            SetupLogger(glContext.LogsDirFull);


            log.Info("===================================");
            log.Info("Сервис запущен " + DateTime.Now.ToString(CultureInfo.CurrentCulture));
            context = new LocalContext();
            JobWrapper.ServiceContext = context;



            context.Scheduler = StdSchedulerFactory.GetDefaultScheduler();
            context.Recorder  = new DataRecorder(glContext.RecordsDirFull);

            context.Recorder.Record("ServiceOn", 0);

            try
            {
                log.Info("Загружаем расписание");
                context.Schedule = Schedule.Load(glContext.ScheduleFileFull);

                log.Info("Загружаем исполняющие модули");
                modulesLoader = new PluginLoader <IModule>((type, name) =>
                {
                    var jobs           = context.Schedule.Jobs.Where(p => p.Assembly == name);
                    List <IModule> res = new List <IModule>();
                    foreach (var job in jobs)
                    {
                        JobRecord rec = new JobRecord();
                        rec.Assembly  = name;
                        rec.JobParams = job;
                        rec.Index     = JobWrapper.Modules.Count;
                        rec.Module    = (BaseModule)Activator.CreateInstance(type);
                        res.Add(rec.Module);
                        rec.Module.Name = name;
                        JobWrapper.Modules[rec.Index] = rec;
                    }
                    return(res);
                });

                foreach (var rec in JobWrapper.Modules.Values)
                {
                    log.Info("Инициализируем " + rec.Assembly);
                    try
                    {
                        rec.Module.Init(rec.JobParams.Parameters, glContext);
                    }
                    catch (Exception e)
                    {
                        log.Error("Ошибка при инициализации: " + e.Message);
                    }
                }
                log.Info("------------------");
                log.Info("Назначаем работы");

                Thread.Sleep(10000);
                foreach (var job in JobWrapper.Modules.Values)
                {
                    ScheduleJob(job);
                }

                context.Scheduler.Start();
            }
            catch (Exception e)
            {
                log.Error(e);
            }

            /*
             * Schedule s = new Schedule();
             * s.Jobs.Add(new ScheduleJob()
             * {
             *  Assembly = "test.dll",Parameters =  new Dictionary<string, string>()
             *  {
             * {"param1","value1"},
             * {"param2","value2"},
             *  },
             *  PeriodMinutes = 2,
             *  StartType =  JobStartType.InTime
             *
             * });
             * s.Jobs.Add(new ScheduleJob()
             * {
             *  Assembly = "test.dll",
             *  Parameters = new Dictionary<string, string>()
             *  {
             * {"param1","value1"},
             * {"param2","value2"},
             *  },
             *  PeriodMinutes = 2,
             *  StartType = JobStartType.InTime
             *
             * });
             * s.Save(Path.Combine(rootPath,"test.json"));*/
        }
Пример #11
0
 public void AddRecord(JobRecord record)
 {
 }
Пример #12
0
        public void OnMessage(Message <byte[]> message)
        {
            JobRecord value = JobRecord.Parser.ParseFrom(message.GetMessageObject());

            MessageConsumer.Invoke(value);
        }