public async Task <IActionResult> PutProjectLog([FromRoute] int id, [FromBody] ProjectLog projectLog) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != projectLog.ProjectLogId) { return(BadRequest()); } _context.Entry(projectLog).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProjectLogExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> EditLog(int id, [Bind("Id, DateMade, Log, ProjectId")] ProjectLog model) { if (id != model.Id) { return(NotFound()); } try { if (ModelState.IsValid) { _context.ProjectLog.Update(model); await _context.SaveChangesAsync(); return(Redirect("~/Projects/Details/" + model.ProjectId)); } } catch (DbUpdateConcurrencyException) { if (!ProjectLogExists(id)) { return(NotFound()); } else { throw; } } var EditingLog = await _context.ProjectLog .FirstOrDefaultAsync(p => p.ProjectId == id); return(View(EditingLog)); }
public static IEnumerable <object[]> statsData() { var allStats = new STATS[] { STATS.STRENGTH, STATS.INTELLIGENCE, STATS.CREATIVITY, STATS.FLUENCY }; var opString = "add"; foreach (var stat in allStats) { var initStats = new Stats(); var expectedStats = new Stats(); expectedStats.GetType().InvokeMember(stat.ToString().ToLower(), BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetProperty, Type.DefaultBinder, expectedStats, new object[] { 90 }); var project = new Project { projectType = PROJECT_TYPE.STAT, name = "test1", stats = new STATS[] { stat }, dominantStat = stat }; var projectLog = new ProjectLog { log = "test", project = project, timeSpend = 90, type = PROJECT_TYPE.STAT, }; yield return(new object[] { expectedStats, initStats, projectLog, opString }); } }
public static Model.ProjectLog GetLogItem(string ID) { ProjectLog product = Db.Sql(@"select * from ProjectLog where ID = @0").Parameters(ID) .QuerySingle <ProjectLog>(); return(product); }
public async Task SendLog(ProjectLog log) { string serializedLog = SerializeLog(log); await _producer.ProduceAsync(_topic, new Message <Null, string> { Value = serializedLog }); }
private ProjectLog SaveLog(string url, string str) { var p = ProjectInfo.FindByIP(url); var log = new ProjectLog { ProjectID = p.ID, }; var m = Regex.Match(str, @"^(\d{2}:\d{2}:\d{2}\.\d{3})\s+(\d+)\s([W|Y|N])\s+([^\s]+?)\s([\w\W]+)$"); var now = DateTime.Now; if (m.Success) { log.Time = now.Date.Add(TimeSpan.Parse(m.Groups[1].Value)).Ticks; log.ThreadID = m.Groups[2].Value.ToInt(); log.ThreadType = (ThreadType)Enum.Parse(typeof(ThreadType), m.Groups[3].Value); log.ThreadName = m.Groups[4].Value; log.Message = m.Groups[5].Value; } else { log.Time = now.Ticks; log.ThreadType = ThreadType.Y; log.ThreadName = "-"; log.Message = str; } log.Insert(); return(log); }
public ActionResult DeleteConfirmed(int id) { ProjectLog projectLog = db.ProjectLogs.Find(id); db.ProjectLogs.Remove(projectLog); db.SaveChanges(); return(RedirectToAction("Index")); }
public async void ProjectLogCheck <T>(int projId, T originalValue, T newValue, string field) { // needed the double check because of strings if (originalValue != null && newValue != null) { if (!EqualityComparer <T> .Default.Equals(originalValue, newValue)) { ProjectLog log = new ProjectLog { CreatedDate = DateTime.Now, FieldName = field, Id = _context.ProjectLogs.Max(l => l.Id) + 1, ModifiedDate = DateTime.Now, NewValue = newValue.ToString(), OriginalValue = originalValue.ToString(), ProjectId = projId, UserId = await _context.AppUsers.Where(u => u.ADName == User.Identity.Name).Select(u => u.Id).FirstOrDefaultAsync() }; await _context.ProjectLogs.AddAsync(log); await _context.SaveChangesAsync(); } } else if (originalValue == null && newValue != null) { ProjectLog log = new ProjectLog { CreatedDate = DateTime.Now, FieldName = field, Id = _context.ProjectLogs.Max(l => l.Id) + 1, ModifiedDate = DateTime.Now, NewValue = newValue.ToString(), OriginalValue = null, ProjectId = projId, UserId = await _context.AppUsers.Where(u => u.ADName == User.Identity.Name).Select(u => u.Id).FirstOrDefaultAsync() }; await _context.ProjectLogs.AddAsync(log); await _context.SaveChangesAsync(); } else if (newValue == null && originalValue != null) { ProjectLog log = new ProjectLog { CreatedDate = DateTime.Now, FieldName = field, Id = _context.ProjectLogs.Max(l => l.Id) + 1, ModifiedDate = DateTime.Now, NewValue = null, OriginalValue = originalValue.ToString(), ProjectId = projId, UserId = await _context.AppUsers.Where(u => u.ADName == User.Identity.Name).Select(u => u.Id).FirstOrDefaultAsync() }; await _context.ProjectLogs.AddAsync(log); await _context.SaveChangesAsync(); } }
private ProjectLog updateStatsFields(statsChange update, ProjectLog projectLog) { if (projectLog.project.projectType != PROJECT_TYPE.STAT) { projectLog.project.dominantStat = update(projectLog.project.dominantStat.Value); projectLog.project.stats = projectLog.project.stats.Select(o => update(o)).ToArray(); } return(projectLog); }
/// <summary> /// Método para fazer as validações da criação de um Log de Project /// </summary> /// <param name="projectLog">Log de Project a ser criado</param> /// <returns>Retorna true caso as validações sejam satisfeitas</returns> public static bool CreateProjectLogScopeIsValid(this ProjectLog projectLog) { return(AssertionConcern.IsSatisfiedBy ( AssertionConcern.AssertNotNull(projectLog, "O Log de Company não pode ser vazio"), AssertionConcern.AssertNotEmpty(projectLog.Description, "A descrição do log não pode ser nula"), AssertionConcern.AssertGuidIsNotEmpty(projectLog.ProjectLogId, "O ID do log não pode ser vazio") )); }
public string InsertLog(JObject report) { ProjectLog Projecto = report.ToObject <ProjectLog>(); if (ProjectLog.Insert(Projecto)) { } return("ok"); }
private async Task manageStatsAsync(Del op, Dictionary <STATS, int> wages, ProjectLog projectLog) { var stats = await _statsRepository.getByUserIdAsync(projectLog.userId); stats = calculateAndUpdateStats(op, stats, wages, projectLog); if (stats != null) { await _statsRepository.updateAsync(stats.id, stats); } }
private void AddProjectLog() { var prjLog = new ProjectLog() { UserId = _currUser.UserId, UserName = _currUser.Name, Log = Summary, ProjectId = _model.ProjectId }; _db.ProjectLogs.Add(prjLog); }
public ActionResult Edit([Bind(Include = "LogID,ManagerID,ProjectID")] ProjectLog projectLog) { if (ModelState.IsValid) { db.Entry(projectLog).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ManagerID = new SelectList(db.Managers, "ManagerID", "firstName", projectLog.ManagerID); ViewBag.ProjectID = new SelectList(db.Projects, "ID", "name", projectLog.ProjectID); return(View(projectLog)); }
public async Task <IActionResult> PostProjectLog([FromBody] ProjectLog projectLog) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.ProjectLog.Add(projectLog); await _context.SaveChangesAsync(); return(CreatedAtAction("GetProjectLog", new { id = projectLog.ProjectLogId }, projectLog)); }
public void Save(ProjectLog projectLog) { if (projectLog.ProjectLogId <= 0) { Insert(projectLog); } else { Update(projectLog); } context.SaveChanges(); }
public async Task <bool> AddLog(ProjectLog projectLog, List <string> errors) { try { _unitOfWork.ProjectLogs.Insert(projectLog); return(await _unitOfWork.CommitAsync() > 0); } catch (Exception ex) { errors.Add(ex.Message); return(false); } }
public async void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine, ExecutiveBuildDTO build) { // If log starts with Step and containts FROM we stop logging because there will be useless Docker logs // (also applied to "Removing intermediate container" and "Sending build context"). Skip checking empty strings if (outLine.Data != null && ((outLine.Data.StartsWith("Step") && outLine.Data.Contains("FROM")) || outLine.Data.StartsWith("Removing intermediate container") || outLine.Data.StartsWith("Sending build context"))) { areDockerLogs = true; startLogging = 2; } // We begin logging again after logs that starts with Step and contains RUN. Usually RUN starts process, which we need logs to take from // TODO: We can add checking 'contains' from list, that will have all starter commands like RUN, CMD, etc. else if (outLine.Data != null && (outLine.Data.StartsWith("Step") && outLine.Data.Contains("RUN"))) { areDockerLogs = false; // Add one specific string to divide different build steps var log = new ProjectLog() { Timestamp = DateTime.Now, Message = $">>> Here starts a new step", BuildHistoryId = build.BuildHistoryId, ProjectId = build.ProjectId }; await _kafkaProducer.SendLog(log); } // This function is needed to get rid of first two lines before actual logs of our process if (!areDockerLogs) { startLogging--; } if (!areDockerLogs && startLogging < 0) { var log = new ProjectLog() { Timestamp = DateTime.Now, Message = outLine.Data, BuildHistoryId = build.BuildHistoryId, ProjectId = build.ProjectId }; await _elk.IndexDocumentAsync(log); await _kafkaProducer.SendLog(log); } }
// GET: ProjectLog/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProjectLog projectLog = db.ProjectLogs.Find(id); if (projectLog == null) { return(HttpNotFound()); } return(View(projectLog)); }
public ProjectLog Create(CreateProjectLogCommand command) { var projectLog = new ProjectLog(command); _repository.Create(projectLog); projectLog.CreateProjectLog(projectLog); if (Commit()) { return(projectLog); } return(null); }
public JsonResult Edit(Project model) { if (ModelState.IsValid) { var currUser = CurrentUser; model.UserId = currUser.UserId; var log = new ProjectLog { UserId = currUser.UserId, UserName = currUser.Name, Log = "Status - " + model.Status }; _db.ProjectLogs.Add(log); if (model.IsNew) { var startMile = new Milestone { MilestoneType = MilestoneTypes.Start, Name = "Customer Request", ExpectedDate = model.StartDate, }; var endMile = new Milestone { MilestoneType = MilestoneTypes.End, Name = "Project Delivery", ExpectedDate = model.DueDate, }; model.Milestones.Add(startMile); model.Milestones.Add(endMile); model.ProjetLogs.Add(log); _db.Projects.Add(model); } else { foreach (var item in model.Requirements) { _db.Entry(item).State = System.Data.EntityState.Modified; } _db.Entry(model).State = System.Data.EntityState.Modified; log.ProjectId = model.ProjectId; } _db.SaveChanges(); } return(GetErrorMsgJSON()); }
// GET: ProjectLog/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProjectLog projectLog = db.ProjectLogs.Find(id); if (projectLog == null) { return(HttpNotFound()); } ViewBag.ManagerID = new SelectList(db.Managers, "ManagerID", "firstName", projectLog.ManagerID); ViewBag.ProjectID = new SelectList(db.Projects, "ID", "name", projectLog.ProjectID); return(View(projectLog)); }
private async Task manageEnergyAsync(Del op, Dictionary <STATS, int> wages, ProjectLog projectLog) { DailyEnergy dailyEnergy = await _dailyEnergyRepository.getByDateAndUserIdAsync(projectLog.dateCreated, projectLog.userId); if (dailyEnergy == null) { dailyEnergy = new DailyEnergy().init(); } dailyEnergy.userId = projectLog.userId; dailyEnergy.dateCreated = projectLog.dateCreated.Date; dailyEnergy = calculateAndUpdateEnergy(op, dailyEnergy, wages, projectLog); if (dailyEnergy != null) { await _dailyEnergyRepository.createOrUpdateAsync(dailyEnergy); } }
public ProjectLogDetailsForm(ProjectLog projectLog) { InitializeComponent(); UserName.Text = projectLog.User.Username; ProjectName.Text = projectLog.Project.Name; StartDate.Text = projectLog.StartDate.ToString(); EndDate.Text = projectLog.EndDate.ToString(); Description.Text = projectLog.Description; Description.ReadOnly = true; int x = screenshotPanel.Location.X + 10; int y = screenshotPanel.Location.Y + 10; foreach (var item in projectLog.Screenshots) { } }
public async Task <IActionResult> CreateProjectLog(int id, [Bind("Log, ProjectId")] ProjectLog model) { ModelState.Remove("Id"); ModelState.Remove("DateMade"); if (ModelState.IsValid) { model.DateMade = System.DateTime.Now; _context.ProjectLog.Add(model); await _context.SaveChangesAsync(); return(Redirect("~/Projects/Details/" + model.ProjectId)); } return(View()); }
public void CleanDatabase() { ProjectoTT.Clean(); Orcamentos.Clean(); Ficheiros.Clean(); ProjectLog.Clean(); PagamentosCliente.Clean(); Alojamento.Clean(); Diarias.Clean(); ServicoTT.Clean(); Voos.Clean(); ReportFornecedores.Clean(); }
public async Task <Unit> Handle(Command request, CancellationToken cancellationToken) { var project = new Project { // Id = request.Id, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, ProjectCode = request.ProjectCode, JobType = request.JobType, OrderNumber = request.OrderNumber, MaterialOrderNo = request.MaterialOrderNo, Status = request.Status, Address = request.Address, JobStartDate = request.JobStartDate, EstimatedCompletionDate = request.EstimatedCompletionDate, StartTime = request.StartTime, EndTime = request.EndTime, InvoiceNo = request.InvoiceNo, Remark = request.Remark }; _context.Projects.Add(project); var success = await _context.SaveChangesAsync() > 0; if (success) { var projectlog = new ProjectLog { // Id = request.Id, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, ProjectId = project.Id, Notes = "Project created at: " + project.CreatedAt }; _context.ProjectLogs.Add(projectlog); success = await _context.SaveChangesAsync() > 0; return(Unit.Value); } throw new Exception("Problem saving changes"); }
public void statsTest(Stats expectedStats, Stats initStats, ProjectLog projectLog, string opString) { var mockDatabaseCollections = Mock.Of <IDatabaseCollections>(); var mockLogger = Mock.Of <ILogger <ProjectLogService> >(); var mockStatsRepo = Mock.Of <IStatsRepository>(); var mockProjectRepo = Mock.Of <IProjectRepository>(); var mockDailyEnergyRepo = Mock.Of <IDailyEnergyRepository>(); var projectLogService = new ProjectLogService(mockDatabaseCollections, mockLogger, mockStatsRepo, mockProjectRepo, mockDailyEnergyRepo); MethodInfo dynMethod = projectLogService.GetType().GetMethod("calculateAndUpdateStats", BindingFlags.NonPublic | BindingFlags.Instance); var dynOp = projectLogService.GetType().GetMethod(opString, BindingFlags.Public | BindingFlags.Instance); var delType = projectLogService.GetType().GetNestedType("Del"); var op = Delegate.CreateDelegate(delType, projectLogService, dynOp); var wages = projectLog.getWages(); var newStats = (Stats)dynMethod.Invoke(projectLogService, new object[] { op, initStats, wages, projectLog }); expectedStats.ShouldDeepEqual(newStats); }
public async Task <Unit> Handle(Command request, CancellationToken cancellationToken) { var projectlog = new ProjectLog { // Id = request.Id, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, ProjectId = request.ProjectId, Notes = request.Notes }; _context.ProjectLogs.Add(projectlog); var success = await _context.SaveChangesAsync() > 0; if (success) { return(Unit.Value); } throw new Exception("Problem saving changes"); }
protected override bool UpgradeProject(IProjectStore projectStore, ConversionType initialVersion, ConversionType targetVersion) { if (targetVersion != ConversionType.BlendSdk4) { return(false); } foreach (IProjectItemData item in projectStore.GetItems("Reference")) { AssemblyName assemblyName = ProjectConverterBase.GetAssemblyName(item.Value); if (assemblyName == null || !this.IsOverqualifiedSdkAssembly(item, assemblyName)) { continue; } string path = projectStore.DocumentReference.Path; string updateItemMetadataAction = StringTable.UpdateItemMetadataAction; object[] value = new object[] { "Include", "Reference", item.Value, item.Value, assemblyName.Name }; ProjectLog.LogSuccess(path, updateItemMetadataAction, value); item.Value = assemblyName.Name; } return(true); }