public static Report LoadFromFile(string path, Repository repository)
{
Report result = null;
try
{
StreamReader sr = new StreamReader(path);
XmlSerializer serializer = new XmlSerializer(typeof(Report));
result = (Report)serializer.Deserialize(sr);
result.FilePath = path;
result.Repository = repository;
sr.Close();
result.LastModification = File.GetLastWriteTime(path);
result.LoadErrors = "";
foreach (ReportSource source in result.Sources)
{
source.Report = result;
source.LoadRepositoryMetaSources(repository);
}
result.InitReferences();
//Refresh enums
foreach (ReportSource source in result.Sources) source.RefreshEnumsOnDbConnection();
}
catch (Exception ex)
{
throw new Exception(string.Format("Unable to read the file '{0}'.\r\n{1}\r\n", path, ex.Message, ex.StackTrace));
}
return result;
}