public async Task <ActionResult <TaskSetting> > PostEmployee([FromForm] TaskSetting appTask) { if (appTask == null) { return(BadRequest()); } _context.TaskSettings.Add(appTask); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTaskSettings", new { id = appTask.Id }, appTask)); }
public async Task <IActionResult> PutTaskPriority([FromForm] TaskSetting appTask) { if (null == appTask) { return(BadRequest()); } _context.TaskSettings.Update(appTask); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTaskSettings", new { id = appTask.Id }, appTask)); }
public TaskSetting GetTaskById(int id) { TaskSetting xTask = null; bool bResult = m_TaskMap.TryGetValue(id, out xTask); if (!bResult) { return(null); } return(xTask); }
/// <summary> /// Создать задание /// </summary> /// <param name="document"></param> /// <param name="kindId"></param> /// <param name="performers"></param> /// <param name="end"></param> /// <param name="taskName"></param> /// <param name="taskContent"></param> /// <returns></returns> public Task CreateTask(Document document, Guid kindId, List <StaffEmployee> performers, DateTime end, string taskName, string taskContent) { ITaskService TaskService = context.ObjectContext.GetService <ITaskService>(); ITaskListService TaskListService = context.ObjectContext.GetService <ITaskListService>(); IStaffService StaffService = context.ObjectContext.GetService <IStaffService>(); KindsCardKind kind = context.ObjectContext.GetObject <KindsCardKind>(kindId); Task task = TaskService.CreateTask(kind); try { TaskService.InitializeDefaults(task); task.MainInfo.Name = taskName; task.Description = taskName; task.MainInfo.Author = StaffService.GetCurrentEmployee(); task.MainInfo.StartDate = DateTime.Now; task.MainInfo.EndDate = end; task.MainInfo.Content = taskContent; //myTask.Preset.Completion.ReportRequired = false; foreach (StaffEmployee performer in performers) { TaskService.AddSelectedPerformer(task.MainInfo, performer); } TaskSetting taskSettings = TaskService.GetKindSettings(kind); //добавляем ссылку на родительскую карточку TaskService.AddLinkOnParentCard(task, taskSettings, document); //добавляем ссылку на задание в карточку TaskListService.AddTask(document.MainInfo.Tasks, task, document); //создаем и сохраняем новый список заданий TaskList newTaskList = TaskListService.CreateTaskList(); context.ObjectContext.SaveObject <TaskList>(newTaskList); //записываем в задание task.MainInfo.ChildTaskList = newTaskList; context.ObjectContext.SaveObject(task); context.ObjectContext.SaveObject(document); } catch (Exception ex) { throw new Exception("Во время создания задания произошла ошибка", ex); } return(task); }
static void Main(string[] args) { try { var setting = new TaskSetting(); ScriptEngines.AddReferencedAssembly("ZyGames.Test.dll"); ScriptEngines.Initialize(); Console.WriteLine("==============================="); Console.WriteLine("Stress Test"); Console.WriteLine("Option:"); Console.WriteLine("\tPress \"Esc\" is exits!"); Console.WriteLine("==============================="); Console.WriteLine("Press any key start run"); if (Console.ReadKey().Key == ConsoleKey.Escape) { return; } Console.WriteLine("Running..."); //ThreadCaseWork<CaseStep> testCase = new ThreadCaseWork<CaseStep>(); while (true) { string result = ThreadManager.RunTest(setting); //string result = testCase.RunTest(setting); Console.WriteLine(result); TraceLog.ReleaseWrite(result); Console.WriteLine("Press any key to continue."); if (Console.ReadKey().Key == ConsoleKey.Escape) { break; } Console.WriteLine("Running..."); } } catch (Exception ex) { Console.WriteLine(ex.Message); TraceLog.WriteError("Main error:{0}", ex); Console.ReadKey(); } }
int GetMissionCompleteExp() { MissionInfo info = missionConfig.GetMissionInfoByMissionId(dataManager.missionId); if (info == null) { return(10); } TaskSetting task = taskConifg.GetTaskById(info.QuestId); if (task != null) { foreach (var reward in task.Rewards) { if (reward.ItemID == 10001) { return((int)reward.Value); } } } return(10); }
static void Main(string[] args) { try { var setting = new TaskSetting(); ScriptEngines.AddReferencedAssembly("ZyGames.Test.dll"); ScriptEngines.Initialize(); Console.WriteLine("==============================="); Console.WriteLine("Stress Test"); Console.WriteLine("Option:"); Console.WriteLine("\tPress \"Esc\" is exits!"); Console.WriteLine("==============================="); Console.WriteLine("Press any key start run"); if (Console.ReadKey().Key == ConsoleKey.Escape) { return; } Console.WriteLine("Running..."); while (true) { string result = ThreadManager.RunTest(setting); Console.WriteLine(result); TraceLog.ReleaseWrite(result); Console.WriteLine("Press any key to continue."); if (Console.ReadKey().Key == ConsoleKey.Escape) { break; } Console.WriteLine("Running..."); } } catch (Exception ex) { Console.WriteLine(ex.Message); TraceLog.WriteError("Main error:{0}", ex); Console.ReadKey(); } }
public bool SaveData() { if (!ValidateData()) { return(false); } var settings = new AdvantShop.Core.Scheduler.TaskSettings(); var item = new TaskSetting(); //html item.Enabled = chbEnabledHtml.Checked; item.JobType = typeof(GenerateHtmlMapJob).ToString(); item.TimeInterval = txtTimeIntervalHtml.Text.TryParseInt(); item.TimeType = (TimeIntervalType)Enum.Parse(typeof(TimeIntervalType), ddlTypeHtml.SelectedValue, true); if (item.TimeType == TimeIntervalType.Days) { item.TimeHours = txtHoursHtml.Text.TryParseInt(); item.TimeMinutes = txtMinutesHtml.Text.TryParseInt(); } settings.Add(item); //xml item = new TaskSetting(); item.Enabled = chbEnabledXml.Checked; item.JobType = typeof(GenerateXmlMapJob).ToString(); item.TimeInterval = txtTimeIntervalXml.Text.TryParseInt(); item.TimeType = (TimeIntervalType)Enum.Parse(typeof(TimeIntervalType), ddlTypeXml.SelectedValue, true); if (item.TimeType == TimeIntervalType.Days) { item.TimeHours = txtHoursXml.Text.TryParseInt(); item.TimeMinutes = txtMinutesXml.Text.TryParseInt(); } settings.Add(item); //yandex item = new TaskSetting(); item.Enabled = chbEnabledYandex.Checked; item.JobType = typeof(GenerateYandexMarketJob).ToString(); item.TimeInterval = txtTimeIntervalYandex.Text.TryParseInt(); item.TimeType = (TimeIntervalType)Enum.Parse(typeof(TimeIntervalType), ddlTypeYandex.SelectedValue, true); if (item.TimeType == TimeIntervalType.Days) { item.TimeHours = txtHoursYandex.Text.TryParseInt(); item.TimeMinutes = txtMinutesYandex.Text.TryParseInt(); } settings.Add(item); //googlebase item = new TaskSetting(); item.Enabled = chbEnabledGoogleBase.Checked; item.JobType = typeof(GenerateGoogleBaseJob).ToString(); item.TimeInterval = txtTimeIntervalGoogleBase.Text.TryParseInt(); item.TimeType = (TimeIntervalType)Enum.Parse(typeof(TimeIntervalType), ddlTypeGoogleBase.SelectedValue, true); if (item.TimeType == TimeIntervalType.Days) { item.TimeHours = txtHoursGoogleBase.Text.TryParseInt(); item.TimeMinutes = txtMinutesGoogleBase.Text.TryParseInt(); } settings.Add(item); AdvantShop.Core.Scheduler.TaskSettings.Settings = settings; TaskManager.TaskManagerInstance().ManagedTask(settings); LoadData(); return(true); }
public void ConvertTaskSettingXml2Bin() { taskSettingStorage.Tasksettings.Clear(); string targetPath = Application.dataPath + "/Config/Tasks"; DirectoryInfo originDirInfo = new DirectoryInfo(targetPath); System.IO.FileInfo[] files = (originDirInfo.GetFiles("*.xml", SearchOption.AllDirectories)); foreach (FileInfo file in files) { SecurityParser xmlDoc = new SecurityParser(); StreamReader reader = file.OpenText(); xmlDoc.LoadXml(reader.ReadToEnd()); reader.Close(); SecurityElement rootProject = xmlDoc.ToXml().SearchForChildByTag("Quest"); TaskSetting taskSetting = new TaskSetting(); taskSetting.TaskId = Convert.ToUInt32(rootProject.Attribute("Id")); taskSetting.QuestType = Convert.ToUInt32(rootProject.Attribute("QuestType")); taskSetting.Difficulty = Convert.ToUInt32(rootProject.Attribute("Difficulty")); taskSetting.IsRepeat = Convert.ToUInt32(rootProject.Attribute("IsRepeat")); taskSetting.CanDisplay = Convert.ToUInt32(rootProject.Attribute("CanDisplay")); taskSetting.IsValidity = Convert.ToUInt32(rootProject.Attribute("IsValidity")); taskSetting.Description = (rootProject.Attribute("Description")); ArrayList nodeList = rootProject.Children; foreach (SecurityElement xe in nodeList) { if (xe.Tag == "Rewards") { ArrayList rewardList = xe.Children; foreach (SecurityElement xeReward in rewardList) { if (xeReward.Tag == "Reward") { Reward reward = new Reward(); reward.ItemID = Convert.ToUInt32(xeReward.Attribute("ItemId")); reward.Value = Convert.ToSingle(xeReward.Attribute("Value")); taskSetting.Rewards.Add(reward); } } } else if (xe.Tag == "CommitRequirements") { ArrayList rewardList = xe.Children; foreach (SecurityElement xeReward in rewardList) { if (xeReward.Tag == "Requirement") { Requirement requirement = new Requirement(); requirement.Type = Convert.ToUInt32(xeReward.Attribute("Type")); requirement.Value = Convert.ToSingle(xeReward.Attribute("Value")); taskSetting.CommitRequirements.Add(requirement); } } } else if (xe.Tag == "RecieveRequirements") { ArrayList rewardList = xe.Children; foreach (SecurityElement xeReward in rewardList) { if (xeReward.Tag == "Requirement") { Requirement requirement = new Requirement(); requirement.Type = Convert.ToUInt32(xeReward.Attribute("Type")); requirement.Value = Convert.ToSingle(xeReward.Attribute("Value")); taskSetting.RecieveRequirements.Add(requirement); } } } } taskSettingStorage.Tasksettings.Add(taskSetting); } string accountPath = Application.dataPath + "/StreamingAssets/Tasks.bytes"; try { FileStream fs = File.Open(accountPath, FileMode.Create, FileAccess.Write); using (MemoryStream ms = new MemoryStream()) { BinaryWriter bw = new BinaryWriter(fs); taskSettingStorage.WriteTo(ms); ms.Position = 0; bw.Write((int)ms.Length); bw.Write(ms.GetBuffer(), 0, (int)ms.Length); bw.Close(); } fs.Close(); fs.Dispose(); Debug.Log("SaveAccountFile:" + accountPath + ", OK!"); } catch (Exception e) { Debug.Log("SaveAccountFile:" + e.ToString() + accountPath); } }
private void sendTasks(String Performer) { try { //сохраняем карточку if (!SaveCard()) { UIService.ShowError("Сохранение не удалось. Выполните сохранение вручную"); return; } //this.Context.SaveObject(this.Document); Guid TaskKindID = new Guid("0F6C537B-9D75-43EC-9D91-B29C5F1B7C4D"); //айди типа задания на исполнение KindsCardKind kind = Context.GetObject <KindsCardKind>(TaskKindID); DocsVision.BackOffice.ObjectModel.Task oTask = this.TaskService.CreateTask(kind); TaskService.InitializeDefaults(oTask); //заполняем данные задания oTask.MainInfo.Author = this.StaffService.GetCurrentEmployee(); //текущий сотрудник //содержание задания oTask.MainInfo.Content = "Документ пришел Вам на исполнение/ознакомление"; oTask.MainInfo.StartDate = DateTime.Now; oTask.MainInfo.OnControl = false; oTask.MainInfo.Name = "Задание по бухгалтерскому документу " + this.Document.MainInfo.Name; oTask.Description = "Задание по бухгалтерскому документу " + this.Document.MainInfo.Name; //определяем важность oTask.MainInfo.Priority = TaskPriority.Normal; BaseCardSectionRow contractRow = (BaseCardSectionRow)this.Document.GetSection(new System.Guid("3997861D-4FF5-496A-B8A2-D16617DE91D7"))[0]; if (contractRow["ContractEnd"] != null) { oTask.MainInfo.EndDate = Convert.ToDateTime(contractRow["ContractEnd"]); } //добавляем исполнителя StaffEmployee oPerf = Context.GetObject <StaffEmployee>(new System.Guid(Performer));; TaskService.AddSelectedPerformer(oTask.MainInfo, oPerf); TaskSetting oTaskSetting = TaskService.GetKindSettings(kind); //добавляем ссылку на родительскую карточку TaskService.AddLinkOnParentCard(oTask, oTaskSetting, this.Document); //добавляем ссылку на задание в карточку TaskListService.AddTask(this.Document.MainInfo.Tasks, oTask, this.Document); //создаем и сохраняем новый список заданий TaskList newTaskList = TaskListService.CreateTaskList(); Context.SaveObject <DocsVision.BackOffice.ObjectModel.TaskList>(newTaskList); //записываем в задание oTask.MainInfo.ChildTaskList = newTaskList; Context.SaveObject <DocsVision.BackOffice.ObjectModel.Task>(oTask); Context.SaveObject <DocsVision.BackOffice.ObjectModel.Document>(this.Document); //MessageBox.Show("Документ готов, запускаем"); //запускаем задание на исполнение string oErrMessageForStart; bool CanStart = TaskService.ValidateForBegin(oTask, out oErrMessageForStart); if (CanStart) { //MessageBox.Show("Can start"); TaskService.StartTask(oTask); //MessageBox.Show("Изменяется состояние задания"); StatesState oStartedState = StateService.GetStates(Context.GetObject <KindsCardKind>(TaskKindID)).FirstOrDefault(br => br.DefaultName == "Started"); oTask.SystemInfo.State = oStartedState; UIService.ShowMessage("Документ успешно отправлен пользователю " + oPerf.ToString(), "Отправка задания"); } else { UIService.ShowMessage(oErrMessageForStart, "Ошибка отправки задания"); } Context.SaveObject <DocsVision.BackOffice.ObjectModel.Task>(oTask); } catch (System.Exception ex) { UIService.ShowError(ex); } }