Beispiel #1
0
        public async Task <BaseResponseModel> CreateSnapshot(int id, int projectMetricId, ProjectMetric projectMetric = null)
        {
            BaseResponseModel response = new BaseResponseModel {
                Message = "Creating of a snapshot ended successfully. For more detailed result check project metric log."
            };

            try
            {
                projectMetric = projectMetric ?? await _projectMetricService.Load(projectMetricId, response);

                if (projectMetric != null)
                {
                    await _jazzService.CreateSnapshot(projectMetric);

                    await Database.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                response.Success = false;
                response.Message = "Creating of a snapshot was not successfull! Please try again later.";
                await _helperService.SaveErrorToDB(new AppErrorModel(e, message : "task - all projects", module : "ProjectService", function : "CreateSnapshots"));

                projectMetric.ProjectMetricLog.Add(new ProjectMetricLog($"Within processing of snapshot for project metric #{projectMetric.Id} occured and error!"));
            }

            return(response);
        }
Beispiel #2
0
        /// <summary>
        /// zkontroluje, za jak dlouho se ma sluzba znovu spustit
        /// </summary>
        /// <returns></returns>
        public async Task CreateSnapshots()
        {
            Console.WriteLine("{0} -> Start of metrics update.", DateTime.Now.GetDateTimeString());

            int countOfProjects = 0, countOfProjectMetrics = 0;

            foreach (var project in await _db.Project.ToListAsync())
            {
                foreach (var projectMetric in project.ProjectMetric)
                {
                    await _jazzService.CreateSnapshot(projectMetric);

                    await _db.SaveChangesAsync();

                    countOfProjectMetrics++;
                }

                countOfProjects++;
            }

            Console.WriteLine("{0} -> End of metrics update. {1} projects was updated, this was {2} project metrics!", DateTime.Now.GetDateTimeString(), countOfProjects, countOfProjectMetrics);
        }