コード例 #1
0
        private void AskForJobs()
        {
            JobAction receivedAction = null;

            Sender.Connect(RemoteEp);

            do
            {
                var bytes = new byte[100000];
                try
                {
                    Sender.Receive(bytes);
                    receivedAction = (JobAction)SocketHelper.Deserialize(bytes);

                    if (!receivedAction.NoJobsLeft)
                    {
                        Console.WriteLine("I got a job");
                        receivedAction.Run();

                        Sender.Send(SocketHelper.Serialize(receivedAction));
                    }
                }
                catch (SocketException e)
                {
                    Console.WriteLine(e);
                    Sender.Shutdown(SocketShutdown.Both);
                    Sender.Close();
                }
            } while (receivedAction != null && !receivedAction.NoJobsLeft);
        }
コード例 #2
0
        public static object ModifyTaskEntity(this TaskOptions taskOptions, ISchedulerFactory schedulerFactory,
                                              JobAction action)
        {
            TaskOptions options = null;
            object      result  = null;

            switch (action)
            {
            case JobAction.除:
                for (var i = 0; i < _taskList.Count; i++)
                {
                    options = _taskList[i];
                    if (options.TaskName == taskOptions.TaskName && options.GroupName == taskOptions.GroupName)
                    {
                        _taskList.RemoveAt(i);
                    }
                }

                break;

            case JobAction.修改:
                options = _taskList
                          .FirstOrDefault(x => x.TaskName == taskOptions.TaskName && x.GroupName == taskOptions.GroupName);
                //移除以前的配置
                if (options != null)
                {
                    _taskList.Remove(options);
                }

                //生成任务并添加新配置
                result = taskOptions.AddJob(schedulerFactory).GetAwaiter().GetResult();
                break;

            case JobAction.暂停:
            case JobAction.开启:
            case JobAction.停止:
            case JobAction.立即执行:
                options = _taskList
                          .FirstOrDefault(x => x.TaskName == taskOptions.TaskName && x.GroupName == taskOptions.GroupName);
                if (action == JobAction.暂停)
                {
                    options.Status = (int)TriggerState.Paused;
                }
                else if (action == JobAction.停止)
                {
                    options.Status = (int)action;
                }
                else
                {
                    options.Status = (int)TriggerState.Normal;
                }
                break;
            }

            //生成配置文件
            FileQuartz.WriteJobConfig(_taskList);
            FileQuartz.WriteJobAction(action, taskOptions.TaskName, taskOptions.GroupName,
                                      "操作对象:" + JsonConvert.SerializeObject(taskOptions));
            return(result);
        }
コード例 #3
0
 public static void WriteJobAction(JobAction jobAction, string taskName, string groupName,
                                   string content = null)
 {
     content =
         $"{jobAction.ToString()} --  {DateTime.Now:yyyy-MM-dd HH:mm:ss}  --分组:{groupName},作业:{taskName},消息:{content ?? "OK"}\r\n";
     FileHelper.WriteFile(LogPath, "action.txt", content, true);
 }
コード例 #4
0
        private void TriggerRecurringJob(JobAction jobAction)
        {
            var recurringJobManager = this.GetRecurringJobManager(jobAction.Database);
            var recurringJobId      = jobAction.Action.Substring(jobAction.Action.IndexOf(RecurringJobTriggerPrefix) + RecurringJobTriggerPrefix.Length);

            recurringJobManager.Trigger(recurringJobId);
        }
コード例 #5
0
        /// <summary>
        /// Populate job action values.
        /// </summary>
        /// <param name="jobActionParams">Job action properties specified via PowerShell.</param>
        /// <param name="jobAction">JobAction object to be populated.</param>
        private void PopulateJobAction(PSJobActionParams jobActionParams, ref JobAction jobAction)
        {
            switch (jobActionParams.JobActionType)
            {
            case JobActionType.Http:
            case JobActionType.Https:
                jobAction.Type    = jobActionParams.JobActionType;
                jobAction.Request = this.GetHttpJobAction(jobActionParams.HttpJobAction);
                break;

            case JobActionType.StorageQueue:
                jobAction.Type         = JobActionType.StorageQueue;
                jobAction.QueueMessage = this.GetStorageQueue(jobActionParams.StorageJobAction);
                break;

            case JobActionType.ServiceBusQueue:
                jobAction.Type = JobActionType.ServiceBusQueue;
                jobAction.ServiceBusQueueMessage = this.GetServiceBusQueue(jobActionParams.ServiceBusAction);
                break;

            case JobActionType.ServiceBusTopic:
                jobAction.Type = JobActionType.ServiceBusTopic;
                jobAction.ServiceBusTopicMessage = this.GetServiceBusTopic(jobActionParams.ServiceBusAction);
                break;
            }
        }
コード例 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            User u = UserAction.opuser;

            if (u.ID <= 0)
            {
                Js.AlertAndGoback("对不起,您还没有登录,不能上传简历!");
            }


            HttpPostedFile file = Request.Files[0];

            string extName = Path.GetExtension(file.FileName).ToLower();
            int    size    = file.ContentLength;

            if (extName != ".doc" && extName != ".docx")
            {
                Js.AlertAndGoback("对不起,简历文件只允许上传微软Word格式(.doc|.docx)");
                return;
            }
            if (size > 500 * 1024)
            {
                Js.AlertAndGoback("对不起,简历大小请限制在500K以内!");
                return;
            }

            JobAction.SaveResume(file, u.ID);

            Js.AlertAndChangUrl("简历上传成功!", "/Dynamic/Job/ResumeBasic.aspx");
        }
コード例 #7
0
        /// <summary>
        /// Get scheduler job action details.
        /// </summary>
        /// <param name="jobAction">Job action.</param>
        /// <returns>PSJobActionDetail.</returns>
        internal static PSJobActionDetails GetSchedulerJobActionDetails(JobAction jobAction)
        {
            if (jobAction == null)
            {
                throw new ArgumentNullException(paramName: "jobAction");
            }

            switch (jobAction.Type)
            {
            case JobActionType.Http:
            case JobActionType.Https:
                return(Converter.GetSchedulerHttpJobActionDetails(jobAction.Type.Value, jobAction.Request));

            case JobActionType.StorageQueue:
                return(Converter.GetSchedulerStorageJobActionDetails(jobAction.Type.Value, jobAction.QueueMessage));

            case JobActionType.ServiceBusQueue:
                return(Converter.GetSchedulerServiceBusQueueJobActionDetails(jobAction.Type.Value, jobAction.ServiceBusQueueMessage));

            case JobActionType.ServiceBusTopic:
                return(Converter.GetSchedulerServiceBusTopicJobActionDetails(jobAction.Type.Value, jobAction.ServiceBusTopicMessage));

            default:
                return(null);
            }
        }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:LFNet.Common.Scheduler.JobCompletedEventArgs" /> class.
 /// </summary>
 /// <param name="jobName">Name of the job.</param>
 /// <param name="action">The action.</param>
 /// <param name="jobId">The job id.</param>
 /// <param name="started">The time the job run started.</param>
 /// <param name="finished">The time the job run ended.</param>
 /// <param name="result">The result of the job run.</param>
 /// <param name="status">The status of the job run.</param>
 public JobCompletedEventArgs(string jobName, JobAction action, string jobId, DateTime started, DateTime finished, string result, JobStatus status) : base(jobName, action, jobId)
 {
     this.Started  = started;
     this.Finished = finished;
     this.Result   = result;
     this.Status   = status;
 }
コード例 #9
0
    // Update is called once per frame
    void Update()
    {
        if (dic.Count > 0)
        {
            lock (dic)
            {
                int           count   = 0;
                List <string> delKeys = new List <string>();
                foreach (string key in dic.Keys)
                {
                    JobAction jobAction = dic[key];
                    StartCoroutine(doAction(jobAction));

                    delKeys.Add(key);
                    if (count++ >= MaxPerUpdate)
                    {
                        break;
                    }
                }

                foreach (string delKey in delKeys)
                {
                    dic2.Add(delKey, dic[delKey]);
                    dic.Remove(delKey);
                }
            }
        }
    }
コード例 #10
0
ファイル: TribeJob.cs プロジェクト: Rakjavik/EmergenceOfRak
 public TribeJob(JobTasks task, Thing target, Tribe tribe)
 {
     this.tribe    = tribe;
     this.task     = task;
     this.target   = target;
     actions       = JobAction.GetActionsForTask(task, this);
     currentAction = 0;
 }
コード例 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JobCompletedEventArgs"/> class.
 /// </summary>
 /// <param name="jobName">Name of the job.</param>
 /// <param name="action">The action.</param>
 /// <param name="jobId">The job id.</param>
 /// <param name="started">The time the job run started.</param>
 /// <param name="finished">The time the job run ended.</param>
 /// <param name="result">The result of the job run.</param>
 /// <param name="status">The status of the job run.</param>
 public JobCompletedEventArgs(string jobName, JobAction action, string jobId, DateTime started, DateTime finished, string result, JobStatus status)
     : base(jobName, action, jobId)
 {
     Started = started;
     Finished = finished;
     Result = result;
     Status = status;
 }
コード例 #12
0
ファイル: TribeJob.cs プロジェクト: Rakjavik/EmergenceOfRak
 public TribeJob(JobTasks task, Thing.Thing_Types type, Tribe tribe)
 {
     this.tribe      = tribe;
     this.task       = task;
     this.targetType = type;
     actions         = JobAction.GetActionsForTask(task, this);
     currentAction   = 0;
 }
コード例 #13
0
        private void TriggerSqlCommand(JobAction jobAction)
        {
            using var connection = this.GetOpenConnection(jobAction.Database);

            var command = connection.CreateCommand();

            command.CommandText = jobAction.Action;
            command.ExecuteNonQuery();
        }
コード例 #14
0
        public void GenerateDelegateInvokeTest2()
        {
            JobAction a = null;

            CodeTimer.Time("Generate Delegate Create", CreateTimes, () => a = CreateDelegateAction());


            CodeTimer.Time("Generated Delegate InvokeTest", InvokeTimes, () => a(InvokeTimes));
        }
コード例 #15
0
        protected void LoadInfo()
        {
            id = WS.RequestLong("id");
            if (id < 0)
            {
                return;
            }

            DataEntities ent = new DataEntities();

            if (u.ID > 0)
            {
                ViewHistory his = new ViewHistory();
                try
                {
                    his = (from l in ent.ViewHistory where l.ItemID == id && l.UserID == u.ID && l.ModelID == 5 select l).First();
                }
                catch
                { }

                his.ViewTime = DateTime.Now;
                his.ModelID  = 5;
                his.ItemID   = id;
                his.UserID   = u.ID;

                if (his.ID <= 0)
                {
                    ent.AddToViewHistory(his);
                }
                ent.SaveChanges();
            }


            var j = (from l in ent.JobPost where l.ID == id select l).FirstOrDefault();
            var c = (from l in ent.JobCompany where l.ID == j.CompanyID select l).FirstOrDefault();

            Title       = j.Title;
            CompanyID   = c.ID;
            CompanyName = c.CompanyName;
            PostTime    = j.PostTime.ToDateTime().ToString("yyyy-MM-dd");
            Province    = JobAction.GetProviceName(j.Province.ToInt32());
            City        = JobAction.GetCityName(j.City.ToInt32());
            Exp         = JobAction.GetExpressionsName(j.Expressions.ToInt32());
            Salary      = JobAction.GetSalaryDegreeName(j.Salary.ToInt32());
            Edu         = j.GetPostEdu();          //JobAction.GetEduName(j.Edu.ToInt32());
            EmpCount    = j.GetPostEduAndNumber(); //j.EmployNumber == 0 ? "若干" : j.EmployNumber.ToS();
            Intro       = j.Intro;
            CompIntro   = c.Intro;

            JobAction.AddCityHot(j.City.ToInt32());

            RelaJobs = Functions.getpostlist("5",
                                             "0",
                                             string.Format("t.Title='{0}' and t.Id!={1}", j.Title, j.ID),
                                             "t.id desc",
                                             "<tr><td height=\"80\"style=\"border-bottom: 1px solid #eeeeee\"><table width=\"810\"align=\"center\"border=\"0\"cellspacing=\"0\"cellpadding=\"0\"><tr><td align=\"left\"><table width=\"680\"border=\"0\"cellspacing=\"0\"cellpadding=\"0\"align=\"left\"><tr><td align=\"left\"class=\"job_title\"><a href=\"Job.aspx?id={id}\">{title}</a></td></tr><tr><td align=\"left\"><table width=\"610\"border=\"0\"cellspacing=\"0\"cellpadding=\"0\"><tr><td align=\"left\"class=\"job_compangy\"><a href=\"Company.aspx?id={companyid}\">{companyname}</a></td><td align=\"left\"class=\"job_qt\">规模{employeecount}/学历{edu}/经验{expressions}</td><td align=\"left\"class=\"job_qt1\">月薪<span>{salary}</span></td></tr></table></td></tr></table></td><td width=\"100\"align=\"center\"style=\"line-height: 24px; color: #666666\"><input type=\"button\"onclick=\"post({id})\"value=\"一键投递\"style=\"background: url(/skin/job/img/td.gif) no-repeat; width: 60px;height: 22px; color: #FFFFFF; border: 0px;\"/><br/>{posttime}</td></tr></table></td></tr>");
        }
コード例 #16
0
        protected void BindDropItems()
        {
            DataEntities ent = new DataEntities();

            #region  绑定省
            var provinces = from l in ent.Province select l;

            foreach (var pro in provinces)
            {
                ddl_Province.Items.Add(new ListItem(pro.province1, pro.ID.ToS()));
                ddl_ProvinceHome.Items.Add(new ListItem(pro.province1, pro.ID.ToS()));
                ddl_ProvinceWork.Items.Add(new ListItem(pro.province1, pro.ID.ToS()));
            }
            #endregion

            JobAction.BindCity(ddl_City, ddl_Province.SelectedValue.ToInt32());
            JobAction.BindCity(ddl_CityHome, ddl_Province.SelectedValue.ToInt32());
            JobAction.BindCity(ddl_CityWork, ddl_Province.SelectedValue.ToInt32());

            ddl_Marriage.Bind(JobAction.Marrage);
            ddl_CardType.Bind(JobAction.CardType);
            ddl_Nation.Bind(JobAction.Nation);
            ddl_Political.Bind(JobAction.Political);
            ent.Dispose();

            //绑定工作经历编辑区域

            JobAction.BindIndustry(ddl_exp_Post);
            ddl_exp_StartTime_Year.BindNumbers(1970, 2012);
            ddl_exp_StartTime_Month.BindNumbers(1, 12);
            ddl_exp_LeftTime_Year.BindNumbers(1970, 2012);
            ddl_exp_LeftTime_Month.BindNumbers(1, 12);

            //绑定教育经历
            JobAction.BindEduSpecialty(ddl_edu_Specialty);
            ddl_edu_Edu.Bind(JobAction.Edu);
            ddl_edu_StartTime_Year.BindNumbers(1970, 2012);
            ddl_edu_StartTime_Month.BindNumbers(1, 12);
            ddl_edu_LeftTime_Year.BindNumbers(1970, 2012);
            ddl_edu_LeftTime_Month.BindNumbers(1, 12);

            //培新经历
            ddl_train_StartTime_Year.BindNumbers(1970, 2012);
            ddl_train_StartTime_Month.BindNumbers(1, 12);
            ddl_train_LeftTime_Year.BindNumbers(1970, 2012);
            ddl_train_LeftTime_Month.BindNumbers(1, 12);

            //证书
            ddl_cer_gettime_Year.BindNumbers(1970, 2012);
            ddl_cer_gettime_Month.BindNumbers(1, 12);

            //语言
            ddl_language_type.Bind(JobAction.Languages);
            ddl_language_SpeakingAbility.Bind(JobAction.LanguageDegree);
            ddl_language_WritingAbility.Bind(JobAction.LanguageDegree);
        }
コード例 #17
0
ファイル: RunningJob.cs プロジェクト: agutak/Planager
 public RunningJob(JobAppointment jobAppointment, ILogger logger)
 {
     _jobAppointment = jobAppointment;
     _logger         = logger;
     Id               = jobAppointment.Id;
     Status           = JobStatus.Starting;
     _actionReference = jobAppointment.RepeatType == RepeatType.NoRepeat
         ? DoOnetimeWorkAsync
         : DoPeriodicWorkAsync;
 }
コード例 #18
0
 protected void BindDropItems()
 {
     //绑定教育经历
     JobAction.BindEduSpecialty(ddl_edu_Specialty);
     ddl_edu_Edu.Bind(JobAction.Edu);
     ddl_edu_StartTime_Year.BindNumbers(1970, 2012);
     ddl_edu_StartTime_Month.BindNumbers(1, 12);
     ddl_edu_LeftTime_Year.BindNumbers(1970, 2012);
     ddl_edu_LeftTime_Month.BindNumbers(1, 12);
 }
コード例 #19
0
        protected void LoadInfo()
        {
            User u = UserAction.opuser;

            if (u.ID < 0)
            {
                Js.AlertAndChangUrl("您还没有登录,请登录或注册后进入简历管理!", "/");
            }
            DataEntities  ent = new DataEntities();
            JobResumeInfo r   = new JobResumeInfo();

            try
            {
                r = (from l in ent.JobResumeInfo where l.UserID == u.ID select l).First();
            }
            catch
            {
                r.UserID       = u.ID;
                r.IsResumeOpen = true;
                r.Image        = "/u/ResumeFace/0.jpg";
                r.Title        = u.UserName + "的简历";

                ent.AddToJobResumeInfo(r);
                ent.SaveChanges();
            }

            var file = u.DefaultResumeFile();

            if (u.ID > 0)
            {
                file_resume = string.Format("<a href='{0}' target='_blank'>{1}</a>", file.FilePath, file.FileName);
            }
            else
            {
                file_resume = "还没有上传简历";
            }

            txt_ChineseName.Text = r.ChineseName;
            txt_Sex.Text         = r.IsMale == true?"男":"女";

            txt_LivePlace.Text = JobAction.GetProviceName(r.Province.ToInt32()) + "-" + JobAction.GetCityName(r.City.ToInt32());


            txt_Mobile.Text = r.Mobile;
            txt_Email.Text  = r.Email;

            txt_WorkPlace.Text = JobAction.GetCityName(r.WorkPlace.ToInt32());


            txt_Birth.Text = r.Birthday.ToDateTime().ToString("yyyy年MM月dd日");

            ResumeOpen = r.IsResumeOpen == true ? "简历完全开放" : "简历关闭";
            Image      = r.Image;
        }
コード例 #20
0
    public void Visualize(Vector2 position, Color color, float delay)
    {
        icon.color = color;
        rectTransform.localPosition = position;
        JobAction jobAction = (float timeStamp, bool isComplete) =>
        {
            isVisualize = true;
        };

        JobSystem.ScheduleUntil(jobAction, delay);
    }
コード例 #21
0
    public static void startJob(Delegate d, float time, object[] args)
    {
        JobAction jobAction = new JobAction();

        jobAction.d      = d;
        jobAction.time   = time;
        jobAction.args   = args;
        jobAction.cancel = false;
        lock (dic) {
            dic.Add(defaultKey(), jobAction);
        }
    }
コード例 #22
0
    IEnumerator doAction(JobAction jobAction)
    {
        yield return(new WaitForSeconds(jobAction.time));

        if (!jobAction.cancel)
        {
            jobAction.d.DynamicInvoke(jobAction.args);
        }
        lock (dic){
            dic2.Remove(jobAction.key);
        }
    }
コード例 #23
0
        /// <summary>
        /// 记录任务运行结果
        /// </summary>
        /// <param name="jobId">任务Id</param>
        /// <param name="jobAction">任务执行动作</param>
        /// <param name="blresultTag">任务执行结果表示,true成功,false失败,初始执行为true</param>
        /// <param name="msg">任务记录描述</param>
        public void RecordRun(string jobId, JobAction jobAction, bool blresultTag = true, string msg = "")
        {
            DateTime    addTime = DateTime.Now;
            TaskManager job     = _repository.GetSingle(jobId);

            if (job == null)
            {
                _taskJobsLogService.Insert(new TaskJobsLog
                {
                    Id          = GuidUtils.CreateNo(),
                    CreatorTime = DateTime.Now,
                    TaskId      = jobId,
                    TaskName    = "",
                    JobAction   = jobAction.ToString(),
                    Status      = false,
                    Description = $"未能找到定时任务:{jobId}"
                });
                return;
            }
            string resultStr = string.Empty, strDesc = string.Empty;

            if (!blresultTag)
            {
                job.ErrorCount++;
                job.LastErrorTime = addTime;
                strDesc           = $"异常," + msg;
            }
            else
            {
                strDesc = $"正常," + msg;
            }
            if (jobAction == JobAction.开始)
            {
                job.RunCount++;
                job.LastRunTime = addTime;

                CronExpression cronExpression = new CronExpression(job.Cron);
                job.NextRunTime = cronExpression.GetNextValidTimeAfter(addTime).ToDateTime();
            }
            _repository.Update(job, jobId);

            _taskJobsLogService.Insert(new TaskJobsLog
            {
                Id          = GuidUtils.CreateNo(),
                CreatorTime = DateTime.Now,
                TaskId      = job.Id,
                TaskName    = job.TaskName,
                JobAction   = jobAction.ToString(),
                Status      = blresultTag,
                Description = strDesc
            });
        }
コード例 #24
0
ファイル: DatabaseJobAdapter.cs プロジェクト: ynzenu/Blog
        private void AddLogEntry(JobAction action, string messageAmendment = null)
        {
            var entry = new AuditLogEntry
            {
                PluginId = PluginId,
                Action   = action,
                Message  = messageAmendment == null ?
                           Reason :
                           string.Format("{0}<br />{1}", Reason, messageAmendment)
            };
            var store = typeof(AuditLogEntry).GetStore();

            store.Save(entry);
        }
コード例 #25
0
ファイル: RoundRobinScheduler.cs プロジェクト: maxcriser/3sem
 private void createExecutionThread()
 {
     executionThread = new Thread(() =>
     {
         while (actionQueue.Count != 0)
         {
             JobAction action = actionQueue.Dequeue();
             CurrentJob       = action.RelatedJob;
             CurrentJobChanged();
             Thread.Sleep(action.ExecutionTime);
         }
         executionThread = null;
         JobsEnded();
     });
 }
コード例 #26
0
ファイル: MainActivity.cs プロジェクト: rakansu/ThePathfinder
    private void OnVisualize()
    {
        if (!GridBoard.current.IsPathSet())
        {
            return;
        }
        pathDrawer.Reset();
        List <Coord> path            = GetPath(GridBoard.current.GetPointACoord(), GridBoard.current.GetPointBCoord(), mapGrid, true);
        JobAction    scheduledAction = (float timeStamp, bool isCompleted) =>
        {
            pathDrawer.DrawPath(path);
        };

        JobSystem.ScheduleUntil(scheduledAction, AppSystem.path_delay);
    }
コード例 #27
0
        internal static string ToSerializedValue(this JobAction value)
        {
            switch (value)
            {
            case JobAction.None:
                return("none");

            case JobAction.Disable:
                return("disable");

            case JobAction.Terminate:
                return("terminate");
            }
            return(null);
        }
コード例 #28
0
        /// <summary>
        /// Get JobAction instance.
        /// </summary>
        /// <param name="jobParams">Job properties specified via PowerShell.</param>
        /// <returns>JobActio instance.</returns>
        private JobAction GetJobAction(PSJobParams jobParams)
        {
            var jobAction = new JobAction();

            this.PopulateJobAction(jobParams.JobAction, ref jobAction);

            // Populate error job action.
            if (jobParams.JobErrorAction != null)
            {
                var jobErrorAction = new JobErrorAction();
                this.PopulateJobErrorAction(jobParams.JobErrorAction, ref jobErrorAction);
                jobAction.ErrorAction = jobErrorAction;
            }

            return(jobAction);
        }
コード例 #29
0
        private async Task <AjaxResponse> ModifyTaskEntity(TaskOptions taskOptions, JobAction action)
        {
            AjaxResponse result = new AjaxResponse();

            switch (action)
            {
            case JobAction.除:
                await _task.Delete(taskOptions.Id);

                break;

            case JobAction.修改:
                await _task.Edit(taskOptions);

                //生成任务并添加新配置
                await AddSchedulerJob(taskOptions);

                break;

            case JobAction.暂停:
            case JobAction.开启:
            case JobAction.停止:
            case JobAction.立即执行:
                TaskOptions options = await _task.GetTaskById(taskOptions.Id);

                if (action == JobAction.暂停)
                {
                    options.Status = (int)TriggerState.Paused;
                }
                else if (action == JobAction.停止)
                {
                    options.Status = (int)action;
                }
                else
                {
                    options.Status = (int)TriggerState.Normal;
                }

                await _task.Edit(options);

                break;
            }
            //生成配置文件
            _ = _log.WriteLog($"[{action}]任务:{taskOptions.GroupName}--[taskOptions.TaskName],操作对象:{JsonConvert.SerializeObject(taskOptions)}");
            return(result);
        }
コード例 #30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="action"></param>
        /// <returns></returns>
        public async Task AutoRun(DateTime dt, JobAction action, string name = "")
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                name = Guid.NewGuid().ToString();
            }
            string            group       = "_group";
            var               jobname     = "job_" + name;
            var               triggername = "trigger_" + name;
            Task <IJobDetail> task1       = Task.Run <IJobDetail>(() => CreateJob <DynamicTask>(jobname, jobname + group, new Dictionary <string, object>
            {
                { "jobaction", action }
            }));
            Task <ITrigger> task2 = Task.Run <ITrigger>(() => CreateTrigger(triggername, triggername + group, dt, jobname, jobname + group));

            Task.WaitAll(task1, task2);
            await Run(task1.Result, task2.Result);
        }
コード例 #31
0
    public static void startJob(string key, VoidAction d, float time)
    {
        lock (dic) {
            if (dic.ContainsKey(key))
            {
                dic.Remove(key);
            }
            else if (dic2.ContainsKey(key))
            {
                dic2[key].cancel = true;
                dic2.Remove(key);
            }
            JobAction jobAction = new JobAction();
            jobAction.key    = key;
            jobAction.d      = d;
            jobAction.time   = time;
            jobAction.cancel = false;

            dic.Add(key, jobAction);
        }
    }
コード例 #32
0
        /// <summary>
        /// Populate job action values.
        /// </summary>
        /// <param name="jobActionParams">Job action properties specified via PowerShell.</param>
        /// <param name="jobAction">JobAction object to be populated.</param>
        private void PopulateJobAction(PSJobActionParams jobActionParams, ref JobAction jobAction)
        {
            switch (jobActionParams.JobActionType)
            {
                case JobActionType.Http:
                case JobActionType.Https:
                    jobAction.Type = jobActionParams.JobActionType;
                    jobAction.Request = this.GetHttpJobAction(jobActionParams.HttpJobAction);
                    break;

                case JobActionType.StorageQueue:
                    jobAction.Type = JobActionType.StorageQueue;
                    jobAction.QueueMessage = this.GetStorageQueue(jobActionParams.StorageJobAction);
                    break;

                case JobActionType.ServiceBusQueue:
                    jobAction.Type = JobActionType.ServiceBusQueue;
                    jobAction.ServiceBusQueueMessage = this.GetServiceBusQueue(jobActionParams.ServiceBusAction);
                    break;

                case JobActionType.ServiceBusTopic:
                    jobAction.Type = JobActionType.ServiceBusTopic;
                    jobAction.ServiceBusTopicMessage = this.GetServiceBusTopic(jobActionParams.ServiceBusAction);
                    break;
            }
        }
コード例 #33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JobEventArgs"/> class.
 /// </summary>
 /// <param name="jobName">Name of the job.</param>
 /// <param name="action">The action.</param>
 /// <param name="jobId">The job id.</param>
 public JobEventArgs(string jobName, JobAction action, string jobId)
 {
     JobName = jobName;
     Action = action;
     JobId = jobId;
 }
コード例 #34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JobEventArgs"/> class.
 /// </summary>
 /// <param name="jobName">Name of the job.</param>
 /// <param name="action">The action.</param>
 public JobEventArgs(string jobName, JobAction action)
     : this(jobName, action, String.Empty)
 { }
コード例 #35
0
ファイル: Converter.cs プロジェクト: Azure/azure-powershell
        /// <summary>
        /// Get scheduler job action details.
        /// </summary>
        /// <param name="jobAction">Job action.</param>
        /// <returns>PSJobActionDetail.</returns>
        internal static PSJobActionDetails GetSchedulerJobActionDetails(JobAction jobAction)
        {
            if (jobAction == null)
            {
                throw new ArgumentNullException(paramName: "jobAction");
            }

            switch (jobAction.Type)
            {
                case JobActionType.Http:
                case JobActionType.Https:
                    return Converter.GetSchedulerHttpJobActionDetails(jobAction.Type.Value, jobAction.Request);

                case JobActionType.StorageQueue:
                    return Converter.GetSchedulerStorageJobActionDetails(jobAction.Type.Value, jobAction.QueueMessage);

                case JobActionType.ServiceBusQueue:
                    return Converter.GetSchedulerServiceBusQueueJobActionDetails(jobAction.Type.Value, jobAction.ServiceBusQueueMessage);

                case JobActionType.ServiceBusTopic:
                    return Converter.GetSchedulerServiceBusTopicJobActionDetails(jobAction.Type.Value, jobAction.ServiceBusTopicMessage);

                default:
                    return null;
            }
        }
コード例 #36
0
 private void AddLogEntry(JobAction action, string messageAmendment = null)
 {
     var entry = new AuditLogEntry
     {
         PluginId = PluginId,
         Action = action,
         Message = messageAmendment == null ?
                         Reason :
                         string.Format("{0}<br />{1}", Reason, messageAmendment)
     };
     var store = typeof(AuditLogEntry).GetStore();
     store.Save(entry);
 }
コード例 #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JobCompletedEventArgs"/> class.
 /// </summary>
 /// <param name="jobName">Name of the job.</param>
 /// <param name="action">The action.</param>
 /// <param name="started">The time the job run started.</param>
 /// <param name="finished">The time the job run ended.</param>
 /// <param name="result">The result of the job run.</param>
 /// <param name="status">The status of the job run.</param>
 public JobCompletedEventArgs(string jobName, JobAction action, DateTime started, DateTime finished, string result, JobStatus status)
     : this(jobName, action, String.Empty, started, finished, result, status)
 { }
コード例 #38
0
        /// <summary>
        /// Get JobAction instance.
        /// </summary>
        /// <param name="jobParams">Job properties specified via PowerShell.</param>
        /// <returns>JobActio instance.</returns>
        private JobAction GetJobAction(PSJobParams jobParams)
        {
            var jobAction = new JobAction();

            this.PopulateJobAction(jobParams.JobAction, ref jobAction);

            // Populate error job action.
            if (jobParams.JobErrorAction != null)
            {
                var jobErrorAction = new JobErrorAction();
                this.PopulateJobErrorAction(jobParams.JobErrorAction, ref jobErrorAction);
                jobAction.ErrorAction = jobErrorAction;
            }

            return jobAction;
        }
コード例 #39
0
        /// <summary>
        /// Get job action.
        /// </summary>
        /// <param name="updateJobActionParams">Job action properties specified via PowerShell.</param>
        /// <param name="existingJobAction">Job action properties from existing job.</param>
        /// <returns>JobAction object.</returns>
        private JobAction GetExistingJobAction(PSJobActionParams updateJobActionParams, JobAction existingJobAction)
        {
            if (updateJobActionParams != null)
            {
                if (existingJobAction != null &&
                    (existingJobAction.Type == updateJobActionParams.JobActionType ||
                    ((existingJobAction.Type == JobActionType.Http || existingJobAction.Type == JobActionType.Https) &&
                    (updateJobActionParams.JobActionType == JobActionType.Http || updateJobActionParams.JobActionType == JobActionType.Https))))
                {
                    switch (updateJobActionParams.JobActionType)
                    {
                        case JobActionType.Http:
                        case JobActionType.Https:
                            PSHttpJobActionParams httpJobAction = updateJobActionParams.HttpJobAction;
                            HttpRequest existinghHttpRequest = existingJobAction.Request;
                            if (httpJobAction.Uri != null)
                            {
                                existinghHttpRequest.Uri = httpJobAction.Uri.ToString();
                                existingJobAction.Type = updateJobActionParams.JobActionType;
                            }

                            existinghHttpRequest.Method = httpJobAction.RequestMethod.GetValueOrDefault(defaultValue: existinghHttpRequest.Method);
                            existinghHttpRequest.Body = httpJobAction.RequestBody.GetValueOrDefault(defaultValue: existinghHttpRequest.Body);
                            existinghHttpRequest.Headers = httpJobAction.RequestHeaders != null ? httpJobAction.RequestHeaders.ToDictionary() : existinghHttpRequest.Headers;
                            existinghHttpRequest.Authentication = this.GetExistingAuthentication(httpJobAction.RequestAuthentication, existinghHttpRequest.Authentication);
                            break;

                        case JobActionType.StorageQueue:
                            PSStorageJobActionParams storageJobAction = updateJobActionParams.StorageJobAction;
                            StorageQueueMessage existingStorageQueue = existingJobAction.QueueMessage;
                            storageJobAction.StorageAccount = storageJobAction.StorageAccount.GetValueOrDefault(defaultValue: existingStorageQueue.StorageAccount);
                            storageJobAction.StorageQueueMessage = storageJobAction.StorageQueueMessage.GetValueOrDefault(defaultValue: existingStorageQueue.Message);
                            storageJobAction.StorageQueueName = storageJobAction.StorageQueueName.GetValueOrDefault(defaultValue: existingStorageQueue.QueueName);
                            storageJobAction.StorageSasToken = storageJobAction.StorageSasToken.GetValueOrDefault(defaultValue: existingStorageQueue.SasToken);
                            break;

                        case JobActionType.ServiceBusQueue:
                            PSServiceBusParams serviceBusQueueParams = updateJobActionParams.ServiceBusAction;
                            ServiceBusQueueMessage existingServiceBusQueueMessage = existingJobAction.ServiceBusQueueMessage;
                            this.UpdateServiceBus(serviceBusQueueParams, existingServiceBusQueueMessage);
                            existingServiceBusQueueMessage.QueueName = serviceBusQueueParams.QueueName.GetValueOrDefault(defaultValue: existingServiceBusQueueMessage.QueueName);
                            break;

                        case JobActionType.ServiceBusTopic:
                            PSServiceBusParams serviceBusTopicParams = updateJobActionParams.ServiceBusAction;
                            ServiceBusTopicMessage existingServiceBusTopicMessage = existingJobAction.ServiceBusTopicMessage;
                            this.UpdateServiceBus(serviceBusTopicParams, existingServiceBusTopicMessage);
                            existingServiceBusTopicMessage.TopicPath = serviceBusTopicParams.TopicPath.GetValueOrDefault(defaultValue: existingServiceBusTopicMessage.TopicPath);
                            break;
                    }
                }
                else
                {
                    this.PopulateJobAction(updateJobActionParams, ref existingJobAction);
                }
            }

            return existingJobAction;
        }