Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Init report file if empty #421

Open
wants to merge 1 commit into
base: reports
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ public double AutoDetectFileContent(FileName fileName, System.IO.Stream fileCont

public IViewContent CreateContentForFile(OpenedFile file)
{
if (file.IsDirty) {
bool hasContent = false;
using (var sr = new StreamReader(file.OpenRead()))
{
string line;
while (!hasContent && (line = sr.ReadLine()) != null)
if (line.Length != 0)
hasContent = true;
}
if (!hasContent) {

var reportModel = ReportModelFactory.Create();

Expand All @@ -55,6 +63,7 @@ public IViewContent CreateContentForFile(OpenedFile file)
doc.LoadXml(xml.ToString());
var ar = XmlToArray(doc);
file.SetData(ar);
file.MakeDirty();
}

var viewCmd = new CreateDesignerCommand(file);
Expand Down