private Task GenerateOnceTask(MetaTask metaTask, DateTime?beginTime, DateTime endTime, string prevTaskIds) { int?taskExId = null; if (metaTask.TaskExtensionType != TaskExtensionType.None) { var taskEx = ChineseAbs.ABSManagement.Models.TaskExtension.Create(metaTask.TaskExtensionType); taskEx = m_dbAdapter.Task.NewTaskExtension(taskEx); taskExId = taskEx.TaskExtensionId; } var task = new Task(); task.MetaTaskId = metaTask.Id; task.ProjectId = metaTask.ProjectId; task.Description = metaTask.Name; task.StartTime = beginTime; task.EndTime = endTime; task.TaskExtensionId = taskExId; task.PreTaskIds = prevTaskIds; task.TaskDetail = metaTask.Detail; task.TaskTarget = metaTask.Target; task.TaskStatus = (DateTime.Today <= task.EndTime) ? TaskStatus.Waitting : TaskStatus.Overdue; return(task); }
static M() { // Interfaces Object = MetaObject.Instance; Cachable = MetaCachable.Instance; Deletable = MetaDeletable.Instance; Enumeration = MetaEnumeration.Instance; UniquelyIdentifiable = MetaUniquelyIdentifiable.Instance; Version = MetaVersion.Instance; Versioned = MetaVersioned.Instance; Printable = MetaPrintable.Instance; Localised = MetaLocalised.Instance; AccessControlledObject = MetaAccessControlledObject.Instance; DelegatedAccessControlledObject = MetaDelegatedAccessControlledObject.Instance; SecurityTokenOwner = MetaSecurityTokenOwner.Instance; ObjectState = MetaObjectState.Instance; Task = MetaTask.Instance; Transitional = MetaTransitional.Instance; TransitionalVersion = MetaTransitionalVersion.Instance; User = MetaUser.Instance; WorkItem = MetaWorkItem.Instance; // Classes Employment = MetaEmployment.Instance; Organisation = MetaOrganisation.Instance; Person = MetaPerson.Instance; Settings = MetaSettings.Instance; Singleton = MetaSingleton.Instance; Counter = MetaCounter.Instance; Media = MetaMedia.Instance; MediaContent = MetaMediaContent.Instance; PrintDocument = MetaPrintDocument.Instance; Template = MetaTemplate.Instance; TemplateType = MetaTemplateType.Instance; PreparedExtent = MetaPreparedExtent.Instance; PreparedFetch = MetaPreparedFetch.Instance; Country = MetaCountry.Instance; Currency = MetaCurrency.Instance; Language = MetaLanguage.Instance; Locale = MetaLocale.Instance; LocalisedText = MetaLocalisedText.Instance; AccessControl = MetaAccessControl.Instance; Login = MetaLogin.Instance; Permission = MetaPermission.Instance; Role = MetaRole.Instance; SecurityToken = MetaSecurityToken.Instance; AutomatedAgent = MetaAutomatedAgent.Instance; EmailMessage = MetaEmailMessage.Instance; Notification = MetaNotification.Instance; NotificationList = MetaNotificationList.Instance; TaskAssignment = MetaTaskAssignment.Instance; TaskList = MetaTaskList.Instance; UserGroup = MetaUserGroup.Instance; }
public MetaTask[] RegisterTasks(IBrokerModule thisModule) { MetaTask t = new MetaTask() { intervalType = IntervalType.isolatedThread, ModuleName = thisModule.UniqueName, NameAndDescription = "Host for BSON service (BSON over TCP)" }; return(new MetaTask[] { t }); }
private void GenerateTasks(MetaTask metaTask, List <DateTime> beginTimeList, List <DateTime> endTimeList) { var prevMetaTaskIds = CommUtils.Split(metaTask.PreMetaTaskIds).Select(x => int.Parse(x)); var prevTasks = m_dbAdapter.Task.GetTasksByMetaTaskId(prevMetaTaskIds); var prevTasksKeys = prevTasks.Keys.ToList(); if (prevTasks != null && prevTasks.Count != 0) { CommUtils.Assert(prevTasksKeys.Any(x => prevTasks[x].Count == endTimeList.Count && endTimeList.Count != 0), "前置工作的数量[{0}]与要生成的工作数量[{1}]不匹配", prevTasks.Count, endTimeList.Count); } var tasks = new List <Task>(); if (beginTimeList.Count != 0) { CommUtils.Assert(beginTimeList.Count == endTimeList.Count && endTimeList.Count != 0, "当前工作[{0}]的开始时间数量[{1}]与截止时间数量[{1}]不匹配,请重新核对后再试", metaTask.Name, beginTimeList.Count, endTimeList.Count); } for (int i = 0; i < endTimeList.Count; i++) { DateTime?beginTime = null; if (beginTimeList.Count != 0) { beginTime = beginTimeList[i]; } var endTime = endTimeList[i]; var prevTaskIds = string.Empty; if (prevTasks != null && prevTasks.Count != 0) { var prevTaskIdsStr = new List <string>(); foreach (var prevTasksId in prevTasks.Keys) { var prevTask = prevTasks[prevTasksId][i]; CommUtils.Assert(prevTask.EndTime.Value <= endTime, "工作[{0}][{1}]的截止时间不能小于前置工作[{2}][{3}]的截止时间", metaTask.Name, endTime, prevTask.Description, prevTask.EndTime.Value.ToString("yyyy-MM-dd")); prevTaskIdsStr.Add(prevTask.TaskId.ToString()); } prevTaskIds = CommUtils.Join(prevTaskIdsStr); } var task = GenerateOnceTask(metaTask, beginTime, endTime, prevTaskIds); tasks.Add(task); } tasks.ForEach(x => m_dbAdapter.Task.NewTask(x)); }
public ActionResult CreateMetaTask(string projectGuid, string metaTaskName, string guidAsStartTime, string guidAsEndTime, string prevMetaTaskText, string taskExtensionType, string detail, string target) { return(ActionUtils.Json(() => { ValidateUtils.Name(metaTaskName, "工作名称"); CommUtils.Assert(detail == null ? true : detail.Length <= 500, "工作描述不能超过500个字符数"); CommUtils.Assert(target == null ? true : target.Length <= 500, "工作目标不能超过500个字符数"); CommUtils.AssertHasContent(guidAsEndTime, "请先设置截止时间"); var startTimeSeries = string.IsNullOrWhiteSpace(guidAsStartTime) ? null : m_dbAdapter.TimeSeries.GetByGuid(guidAsStartTime); var endTimeSeries = m_dbAdapter.TimeSeries.GetByGuid(guidAsEndTime); var timeListCount = CheckStartAndEndTimeCount(startTimeSeries, endTimeSeries); var extensionType = CommUtils.ParseEnum <TaskExtensionType>(taskExtensionType); var project = m_dbAdapter.Project.GetProjectByGuid(projectGuid); var prevMetaTaskGuidList = CommUtils.Split(prevMetaTaskText).ToList(); var prevMetaTask = m_dbAdapter.MetaTask.GetMetaTaskByGuids(prevMetaTaskGuidList); var prevMetaTaskIds = prevMetaTask.ConvertAll(x => x.Id.ToString()).ToList(); CheckPrevMetaTaskGenerateCount(timeListCount, prevMetaTask); var metaTask = new MetaTask(); metaTask.ProjectId = project.ProjectId; metaTask.Name = metaTaskName; if (startTimeSeries == null) { metaTask.StartTimeSeriesId = null; } else { metaTask.StartTimeSeriesId = startTimeSeries.Id; } metaTask.EndTimeSeriesId = endTimeSeries.Id; metaTask.PreMetaTaskIds = CommUtils.Join(prevMetaTaskIds); metaTask.TaskExtensionType = extensionType; metaTask.Detail = detail; metaTask.Target = target; var newMetaTask = m_dbAdapter.MetaTask.New(metaTask); return ActionUtils.Success(newMetaTask.Guid); })); }
public void RegisterTempTask(MetaTask mst, IBrokerModule module) { QueueTask t = new QueueTask() { ModuleName = mst.ModuleName, //Description = mst.NameAndDescription, ChannelName = mst.ChannelName, Anteroom = mst.ChannelName == null ? null : MessageChannels.GetAnteroom(mst.ChannelName), Parameters = null, intervalType = mst.intervalType, intervalValue = mst.intervalValue, NameAndDescription = mst.NameAndDescription }; if (t.Anteroom != null) { t.Anteroom.ChannelStatsIn = Statistics.InitialiseModel(new BrokerStat("chan_in", mst.ChannelName)); t.Anteroom.ChannelStatsOut = Statistics.InitialiseModel(new BrokerStat("chan_out", mst.ChannelName)); //t.Anteroom.ChannelStatistic = Statistics.InitialiseModel(new BrokerStat("channel", mst.ChannelName)); } //ModMod module = Modules.GetByName(t.ModuleName); //if (module == null) // throw new Exception("required qmodule not found."); TaskScheduler.PlanItemEntryPoint ep = TaskEntry; if (t.intervalType == IntervalType.isolatedThread) { ep = IsolatedTaskEntry; } t.JobEntry = ep; t.Module = module; t.Temp = true; Tasks.Add(t); UpdatePlan(); }
public void RegisterTempTask(MetaTask mst, IBrokerModule module) { if (module == null) { module = Modules.GetInstanceByName(mst.ModuleName); if (module == null) throw new Exception("RegisterTempTask: required module not found: " + mst.ModuleName); } QueueTask t = new QueueTask() { ModuleName = mst.ModuleName, //Description = mst.NameAndDescription, ChannelName = mst.ChannelName, Anteroom = mst.ChannelName == null ? null : MessageChannels.GetAnteroom(mst.ChannelName), Parameters = null, intervalType = mst.intervalType, intervalValue = mst.intervalValue, NameAndDescription = mst.NameAndDescription }; if (t.Anteroom != null && t.Anteroom.ChannelStatsIn == null) { t.Anteroom.ChannelStatsIn = Statistics.InitialiseModel(new BrokerStat("chan_in", mst.ChannelName)); t.Anteroom.ChannelStatsOut = Statistics.InitialiseModel(new BrokerStat("chan_out", mst.ChannelName)); //t.Anteroom.ChannelStatistic = Statistics.InitialiseModel(new BrokerStat("channel", mst.ChannelName)); } if (module.Role == ExecutionType.Consumer) { MessageChannels.AssignMessageTypeToChannel(t.ChannelName, ((IModConsumer)module.MI).AcceptsModel, t.ModuleName); } //ModMod module = Modules.GetByName(t.ModuleName); //if (module == null) // throw new Exception("required qmodule not found."); TaskScheduler.PlanItemEntryPoint ep = TaskEntry; if (t.intervalType == IntervalType.isolatedThread) { ep = IsolatedTaskEntry; } t.JobEntry = ep; t.Module = module; t.Temporary = true; //if (module.Role == ExecutionType.Consumer) //{ // if (!typeof(IModConsumer).IsAssignableFrom(module.MI.GetType())) // { // throw new Exception("Consumer module required a consumer interface"); // } // if (t.ChannelName == null) // { // throw new Exception("Consumer module required a channel"); // } // else // { // if (t.Anteroom.ChannelStatsIn == null && t.Anteroom.ChannelStatsIn == null)// first task for this channel? // { // // monitoring put operation // t.Anteroom.ChannelStatsIn = Statistics.InitialiseModel(new BrokerStat("chan_in", t.ChannelName)); // t.Anteroom.ChannelStatsOut = Statistics.InitialiseModel(new BrokerStat("chan_out", t.ChannelName)); // // set selector // TaskQueue.TQItemSelector selector = ((IModConsumer)module.MI).ConfigureSelector(); // // channel -> model(MType) // MessageChannels.AssignMessageTypeToChannel(t.ChannelName, ((IModConsumer)module.MI).AcceptsModel, t.ModuleName); // MessageChannel channel = MessageChannels.GetInstanceByName(t.ChannelName); // channel.consumerSelector = selector; // } // } //} Tasks.Add(t); UpdatePlan(); }
public MetaTask[] RegisterTasks(IBrokerModule thisModule) { MetaTask t = new MetaTask() { intervalType = IntervalType.isolatedThread, ModuleName = thisModule.UniqueName, NameAndDescription = "Host for BSON service (BSON over TCP)" }; return new MetaTask[] { t }; }
/// <summary> /// Static method to generate an example configuration as file or string /// </summary> /// <param name="file">File name of the demo configuration</param> /// <param name="type">Task type of the demo configuration</param> /// <param name="asFile">If true a file will be generated, otherwise a string returned</param> private static string CreateDemoFile(string file, TaskType type, bool asFile) { Task t = new Task(); t.TaskName = "Demo-Task"; t.Description = "This is a demo Task with several sub-tasks of the type " + type.ToString(); t.Type = type; SubTask tb = null; SubTask t1, t2, t3; if (type == TaskType.DeleteFile) { tb = new DeleteFileTask(); } else if (type == TaskType.DeleteRegKey) { tb = new DeleteRegKeyTask(); } else if (type == TaskType.StartProgram) { tb = new StartProgramTask(); } else if (type == TaskType.WriteLog) { tb = new WriteLogTask(); } else if (type == TaskType.ControlService) { tb = new ControlServiceTask(); } else if (type == TaskType.KillProcess) { tb = new KillProcessTask(); } else if (type == TaskType.MetaTask) { tb = new MetaTask(); } t1 = tb.GetDemoFile(1); t2 = tb.GetDemoFile(2); t3 = tb.GetDemoFile(3); t3.UseParameter = true; t3.MainValue = "PARAM_NAME_1"; t3.Description = t3.Description + ". This Sub-Tasks uses a value of a global Parameter (passed as flag -p|--param) with the parameter name PARAM_NAME_1"; t.Items.Add(t1); t.Items.Add(t2); t.Items.Add(t3); if (asFile == true) { t.Serialize(file); return(""); } else { try { MemoryStream ms = t.SerializeAsStream(); StreamReader sr = new StreamReader(ms); string output = sr.ReadToEnd(); ms.Close(); ms.Dispose(); return(output); } catch (Exception e) { System.Console.WriteLine("Error while loading demo file as string\n" + e.Message); return(""); } } }