public async Task <ActionResult <Reports> > PostReports(IFormFile files, string title) { ReportFiles reportFiles = new ReportFiles(); Reports reports = new Reports(); using (var fileContentStream = new MemoryStream()) { if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } await files.CopyToAsync(fileContentStream); await System.IO.File.WriteAllBytesAsync(Path.Combine(folderPath, files.FileName), fileContentStream.ToArray()); } reportFiles.Id = Guid.NewGuid(); reportFiles.FileName = files.FileName; reportFiles.FilePath = Path.GetFullPath(folderPath + files.FileName); reportFiles.FileExt = Path.GetExtension(files.FileName); _context.ReportFiles.Add(reportFiles); await _context.SaveChangesAsync(); reports.Id = Guid.NewGuid(); reports.Title = title; reports.ReportFilesId = reportFiles.Id; _context.Reports.Add(reports); await _context.SaveChangesAsync(); return(CreatedAtAction("GetReports", new { id = reports.Id }, reports)); }
private void btnSave_Click(object sender, RoutedEventArgs e) { ReportFiles rep = new ReportFiles(); DataRowView paths = (System.Data.DataRowView)dataGrid1.Items[0]; rep.RealName = Convert.ToString(paths.Row.ItemArray[0]); }
private void buttonAttach_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); if (dlg.ShowDialog() == true) { foreach (string str in dlg.FileNames) { ReportFiles list = new ReportFiles(); list.RealName = str; list.TargetName = filename; dataGrid1.Items.Add(new { RealName = list.RealName, TargetName = list.TargetName }); string fileName = @"C:\Temp\" + filename + System.IO.Path.GetExtension(str).Trim();; if (File.Exists(fileName)) { continue; } else { try { File.Copy(str, fileName); } catch (Exception err) { MessageBox.Show(err.Message); return; } } } } }
/// <summary> /// Execute the task. /// </summary> /// <returns><c>true</c> if the task executed successfully; otherwise, <c>false</c>.</returns> public override bool Execute() { Serilog.Log.Logger = new LoggerConfiguration() .Enrich.WithProperty(MSBuildProperties.Subcategory, nameof(Codecov)) .WriteTo.MSBuild(this) .CreateLogger(); try { var reportFiles = ReportFiles.Select(e => new ReportFile(e.ItemSpec, File.ReadAllText(e.ItemSpec))); var coverage = new Coverage(reportFiles); var envVars = new EnviornmentVariables(this); var continuousIntegrationServer = ContinuousIntegrationServerFactory.Create(envVars); envVars.LoadEnviornmentVariables(continuousIntegrationServer); var versionControlSystem = VersionControlSystemFactory.Create(this, new Terminal.Terminal()); var sourceCode = new SourceCode(versionControlSystem); var yaml = new Yaml.Yaml(sourceCode); var repositories = RepositoryFactory.Create(versionControlSystem, continuousIntegrationServer); var url = new Url.Url(new Host(this, envVars), new Route(), new Query(this, repositories, continuousIntegrationServer, yaml, envVars)); var report = new Report(this, envVars, sourceCode, coverage); var upload = new Uploads(url, report, Features); var uploadFacade = new UploadFacade(continuousIntegrationServer, versionControlSystem, yaml, coverage, envVars, url, upload); uploadFacade.LogContinuousIntegrationAndVersionControlSystem(); ReportUrl = uploadFacade.UploadReports(); return(true); } catch (Exception exception) { Log.LogError("The Codecov MSBuild task failed."); Log.LogErrorFromException(exception, showStackTrace: true); return(false); } }
public async Task <ActionResult> DeleteFilesConfirmed(int id) { ReportFiles reportFiles = await db.ReportFiles.FindAsync(id); db.ReportFiles.Remove(reportFiles); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> DeleteFiles(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ReportFiles reportFiles = await db.ReportFiles.FindAsync(id); if (reportFiles == null) { return(HttpNotFound()); } return(View(reportFiles)); }
public override bool Execute() { //Debug.Fail("Attach debugger here."); // Attach debugger to MSBuild process here. m_log = Log; var reportFiles = ReportFiles.Split(';'); if (reportFiles.Length == 0) { return(true); // Shouldn't happen... } GenerateReports(reportFiles); // we don't want to fail if we displayed failing tests return(true); }
public void SendEmailMessage(int Id, ActivityTypeContants ActivityType, DocEmailContent DocEmailContentSettings, string AttachmentProcedureName) { if (DocEmailContentSettings != null) { if (DocEmailContentSettings.ProcEmailContent != null && DocEmailContentSettings.ProcEmailContent != "") { SqlParameter SqlParameterId = new SqlParameter("@Id", Id); IEnumerable <EmailContentViewModel> MailContent = db.Database.SqlQuery <EmailContentViewModel>("" + ConfigurationManager.AppSettings["DataBaseSchema"] + "." + DocEmailContentSettings.ProcEmailContent + " @Id", SqlParameterId); foreach (EmailContentViewModel item in MailContent) { if (DocEmailContentSettings.AttachmentTypes != null && DocEmailContentSettings.AttachmentTypes != "") { string[] AttachmentTypeArr = DocEmailContentSettings.AttachmentTypes.Split(','); for (int i = 0; i <= AttachmentTypeArr.Length - 1; i++) { if (item.FileNameList != "" && item.FileNameList != null) { item.FileNameList = item.FileNameList + ","; } if (AttachmentTypeArr[i].ToUpper() == "PDF") { item.FileNameList = item.FileNameList + ReportFiles.CreateFiles(AttachmentProcedureName, Id.ToString(), ReportFileTypeConstants.PDF, (string)System.Configuration.ConfigurationManager.AppSettings["CustomizePath"]); } else if (AttachmentTypeArr[i].ToUpper() == "EXCEL") { item.FileNameList = item.FileNameList + ReportFiles.CreateFiles(AttachmentProcedureName, Id.ToString(), ReportFileTypeConstants.Excel, (string)System.Configuration.ConfigurationManager.AppSettings["CustomizePath"]); } else if (AttachmentTypeArr[i].ToUpper() == "WORD") { item.FileNameList = item.FileNameList + ReportFiles.CreateFiles(AttachmentProcedureName, Id.ToString(), ReportFileTypeConstants.Word, (string)System.Configuration.ConfigurationManager.AppSettings["CustomizePath"]); } else { item.FileNameList = item.FileNameList + ReportFiles.CreateFiles(AttachmentProcedureName, Id.ToString(), ReportFileTypeConstants.PDF, (string)System.Configuration.ConfigurationManager.AppSettings["CustomizePath"]); } } item.EmailBody = item.EmailBody.Replace("DomainName", (string)System.Configuration.ConfigurationManager.AppSettings["CurrentDomain"]); } SendEmail.SendEmailMsg(item); } } } }
private void ProcessDirectory() { var files = new List <KeyValuePair <string, string> >(); // Process the list of files found in the directory. string[] fileEntries = Directory.GetFiles(FullName); foreach (string fileName in fileEntries) { var re = new FileInfo(fileName); ReportFiles.Add(new ReportFile(re)); } // Recurse into subdirectories of this directory. string[] subdirectoryEntries = Directory.GetDirectories(FullName); foreach (string subdirectory in subdirectoryEntries) { var subReportDirectory = new ReportDirectory(subdirectory); SubDirectories.Add(subReportDirectory); } }
public async Task <IActionResult> OnPostUpdateReportFault() { GetUserName(); Current_Displayed_Report = _context.VReportSummary.FirstOrDefault(r => r.ReportId == Report_To_Update.PkReportId); //--------------- Update Fault if FaultType is null ----------------------------// if (Current_Displayed_Report.FaultTypeId == null) { foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(Fault_To_Update)) { string name = descriptor.Name; object value = descriptor.GetValue(Fault_To_Update); Console.WriteLine($"{name} = {value}"); } var Updated_Fault = await _context.Fault.FirstOrDefaultAsync(f => f.PkFaultId == Fault_To_Update.PkFaultId); Updated_Fault.FkTechnologyId = Fault_To_Update.FkTechnologyId; Updated_Fault.FkPrimaryComponentTypeId = Fault_To_Update.FkPrimaryComponentTypeId; Updated_Fault.FkPrimaryComponentSubtypeId = Fault_To_Update.FkPrimaryComponentSubtypeId; Updated_Fault.FkFaultTypeId = Fault_To_Update.FkFaultTypeId; Updated_Fault.FkFaultSubtypeId = Fault_To_Update.FkFaultSubtypeId; Updated_Fault.FaultLocation = Fault_To_Update.FaultLocation; _context.Attach(Updated_Fault).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FaultExists(Fault_To_Update.PkFaultId)) { return(NotFound()); } else { throw; } } } //--------------- Update Fault if FaultType is null ----------------------------// //--------------- Update Report----------------------------// //foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(Report_To_Update)) //{ // string name = descriptor.Name; // object value = descriptor.GetValue(Report_To_Update); // Console.WriteLine($"{name} = {value}"); //} var Updated_Report = await _context.Report.FirstOrDefaultAsync(f => f.PkReportId == Report_To_Update.PkReportId); Updated_Report.FkReportTypeId = Report_To_Update.FkReportTypeId; Updated_Report.FkConditionId = Report_To_Update.FkConditionId; Updated_Report.ReportDate = Report_To_Update.ReportDate; Updated_Report.Observations = Report_To_Update.Observations; Updated_Report.Actions = Report_To_Update.Actions; Updated_Report.ExternalNotes = Report_To_Update.ExternalNotes; Updated_Report.NotificationNo = Report_To_Update.NotificationNo; Updated_Report.WorkOrderNo = Report_To_Update.WorkOrderNo; Updated_Report.AnalystNotes = Report_To_Update.AnalystNotes; Updated_Report.FkReportStageId = Report_To_Update.FkReportStageId; _context.Attach(Updated_Report).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReportExists(Report_To_Update.PkReportId)) { return(NotFound()); } else { throw; } } //--------------- Update Report----------------------------// //--------------- Upload Attachments----------------------------// var UploadFileList = HttpContext.Request.Form.Files; foreach (var file in UploadFileList) { ReportFiles New_ReportFile = new ReportFiles(); Console.WriteLine(file.FileName); New_ReportFile.FileName = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(file.FileName); New_ReportFile.FkReportId = Report_To_Update.PkReportId; New_ReportFile.UploadDate = DateTime.Now; New_ReportFile.UploadedBy = Current_User; _context.ReportFiles.Add(New_ReportFile); try { _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ReportFileExists(New_ReportFile.PkFilePathId)) { return(NotFound()); } else { throw; } } string save_path = $"wwwroot\\MachineAttach\\{New_ReportFile.FileName}"; //string save_path = $"c:\\MachineAttach\\{New_Machine_Train_File.FileName}"; using (var fileStream = new FileStream(save_path, FileMode.Create)) { file.CopyTo(fileStream); } } //--------------- Upload Attachments----------------------------// return(RedirectToPage("/ReviewReports", new { id = Report_To_Update.PkReportId })); }
/// <summary> /// When overridden in a derived class, executes the task. /// </summary> /// <returns> /// true if the task successfully executed; otherwise, false. /// </returns> public override bool Execute() { var reportFilePatterns = Array.Empty <string>(); var targetDirectory = TargetDirectory; var sourceDirectories = Array.Empty <string>(); string historyDirectory = HistoryDirectory; var reportTypes = Array.Empty <string>(); var plugins = Array.Empty <string>(); var assemblyFilters = Array.Empty <string>(); var classFilters = Array.Empty <string>(); var fileFilters = Array.Empty <string>(); string verbosityLevel = VerbosityLevel; string tag = Tag; var config = Config.Build(ProjectDirectory).GetSection(SectionName); string value = null; if (ReportFiles.Length > 0) { reportFilePatterns = ReportFiles.Select(r => r.ItemSpec).ToArray(); } else if (config.TryGetString("reports", out value)) { reportFilePatterns = value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); } else { reportFilePatterns = config .GetAll("report") .Select(x => x.RawValue) .Where(x => !string.IsNullOrEmpty(x)) .ToArray(); } if (reportFilePatterns.Length == 0) { Log.LogError($"{nameof(ReportFiles)} is required."); return(false); } if (string.IsNullOrEmpty(targetDirectory) && config.TryGetString("targetdir", out value)) { targetDirectory = value; } if (string.IsNullOrEmpty(targetDirectory)) { Log.LogError($"{nameof(TargetDirectory)} is required."); return(false); } if (SourceDirectories.Length > 0) { sourceDirectories = SourceDirectories.Select(r => r.ItemSpec).ToArray(); } else if (config.TryGetString("sourcedirs", out value)) { sourceDirectories = value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); } else { sourceDirectories = config .GetAll("sourcedir") .Select(x => x.RawValue) .Where(x => !string.IsNullOrEmpty(x)) .ToArray(); } if (string.IsNullOrEmpty(HistoryDirectory) && config.TryGetString("historydir", out value)) { historyDirectory = value; } if (ReportTypes.Length > 0) { reportTypes = ReportTypes.Select(r => r.ItemSpec).ToArray(); } else if (config.TryGetString("reporttypes", out value)) { reportTypes = value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); } else { reportTypes = config .GetAll("reporttype") .Select(x => x.RawValue) .Where(x => !string.IsNullOrEmpty(x)) .ToArray(); } if (Plugins.Length > 0) { plugins = Plugins.Select(r => r.ItemSpec).ToArray(); } else if (config.TryGetString("plugins", out value)) { plugins = value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); } else { plugins = config .GetAll("plugin") .Select(x => x.RawValue) .Where(x => !string.IsNullOrEmpty(x)) .ToArray(); } if (AssemblyFilters.Length > 0) { assemblyFilters = AssemblyFilters.Select(r => r.ItemSpec).ToArray(); } else if (Filters.Length > 0) { assemblyFilters = Filters.Select(r => r.ItemSpec).ToArray(); } else if (config.TryGetString("assemblyfilters", out value)) { assemblyFilters = value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); } else { assemblyFilters = config .GetAll("assemblyfilter") .Select(x => x.RawValue) .Where(x => !string.IsNullOrEmpty(x)) .ToArray(); } if (ClassFilters.Length > 0) { classFilters = ClassFilters.Select(r => r.ItemSpec).ToArray(); } else if (config.TryGetString("classfilters", out value)) { classFilters = value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); } else { classFilters = config .GetAll("classfilter") .Select(x => x.RawValue) .Where(x => !string.IsNullOrEmpty(x)) .ToArray(); } if (FileFilters.Length > 0) { fileFilters = FileFilters.Select(r => r.ItemSpec).ToArray(); } else if (config.TryGetString("filefilters", out value)) { fileFilters = value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); } else { fileFilters = config .GetAll("filefilter") .Select(x => x.RawValue) .Where(x => !string.IsNullOrEmpty(x)) .ToArray(); } if (string.IsNullOrEmpty(verbosityLevel) && config.TryGetString("verbosity", out value)) { verbosityLevel = value; } if (string.IsNullOrEmpty(tag) && config.TryGetString("tag", out value)) { tag = value; } var configuration = new ReportConfiguration( reportFilePatterns, targetDirectory, sourceDirectories, historyDirectory, reportTypes, plugins, assemblyFilters, classFilters, fileFilters, verbosityLevel, tag); return(new Generator().GenerateReport(configuration)); }