Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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 });
            }
        }
Exemplo n.º 4
0
        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
     });
 }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        public ActionResult DeleteConfirmed(int id)
        {
            ProjectLog projectLog = db.ProjectLogs.Find(id);

            db.ProjectLogs.Remove(projectLog);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 8
0
        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();
            }
        }
Exemplo n.º 9
0
 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);
 }
Exemplo n.º 10
0
 /// <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")
            ));
 }
Exemplo n.º 11
0
        public string InsertLog(JObject report)
        {
            ProjectLog Projecto = report.ToObject <ProjectLog>();

            if (ProjectLog.Insert(Projecto))
            {
            }

            return("ok");
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 14
0
 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));
 }
Exemplo n.º 15
0
        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));
        }
Exemplo n.º 16
0
        public void Save(ProjectLog projectLog)
        {
            if (projectLog.ProjectLogId <= 0)
            {
                Insert(projectLog);
            }
            else
            {
                Update(projectLog);
            }

            context.SaveChanges();
        }
Exemplo n.º 17
0
 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);
            }
        }
Exemplo n.º 19
0
        // 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));
        }
Exemplo n.º 20
0
        public ProjectLog Create(CreateProjectLogCommand command)
        {
            var projectLog = new ProjectLog(command);

            _repository.Create(projectLog);

            projectLog.CreateProjectLog(projectLog);

            if (Commit())
            {
                return(projectLog);
            }

            return(null);
        }
Exemplo n.º 21
0
        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());
        }
Exemplo n.º 22
0
        // 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));
        }
Exemplo n.º 23
0
        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);
            }
        }
Exemplo n.º 24
0
        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)
            {
            }
        }
Exemplo n.º 25
0
        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());
        }
Exemplo n.º 26
0
        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");
            }
Exemplo n.º 28
0
        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");
            }
Exemplo n.º 30
0
 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);
 }