Exemplo n.º 1
0
        /// <summary>
        /// Load's a <see cref="ReportModel"></see> from File using the
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns><see cref="ReportModel"></see></returns>
        public static ReportModel LoadReportModel(string fileName)
        {
            if (String.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException("fileName");
            }
            XmlDocument doc = new XmlDocument();

            try {
                doc.Load(fileName);
            } catch (XmlException) {
                // TODO: display user-friendly message
                throw;
            } catch (IOException) {
                // TODO: display user-friendly message
                throw;
            }

            BaseItemLoader loader = new BaseItemLoader();
            object         root   = loader.Load(doc.DocumentElement);

            ReportModel model = root as ReportModel;

            if (model != null)
            {
                model.ReportSettings.FileName = fileName;
                FilePathConverter.AdjustReportName(model);
            }
            else
            {
                IllegalFileFormatException e = new IllegalFileFormatException();
                throw e;
            }
            return(model);
        }
Exemplo n.º 2
0
        static ReportModel LoadModel(XmlDocument doc)
        {
            BaseItemLoader loader = new BaseItemLoader();
            object         root   = loader.Load(doc.DocumentElement);

            var model = root as ReportModel;

            if (model == null)
            {
                throw new IllegalFileFormatException("ReportModel");
            }
            return(model);
        }
		private ReportModel LoadObjectFromXmlDocument(XmlElement elem)
		{
			Console.WriteLine("LoadObjectFromXmlDocumen)");
			//ReportSettings
			OpenedFile file =(OpenedFile) host.GetService(typeof(OpenedFile));
			BaseItemLoader baseItemLoader = new BaseItemLoader();
			XmlNodeList n =  elem.FirstChild.ChildNodes;
			XmlElement rse = (XmlElement) n[0];
			ReportModel model = ReportModel.Create();
			
			// manipulate reportSettings if Filename differs
			this.reportSettings = baseItemLoader.Load(rse) as ReportSettings;
			if (this.reportSettings.FileName.CompareTo(file.FileName) != 0) {
				System.Diagnostics.Trace.WriteLine("LoadObjectFromXmlDocument - filename changed" );
				this.reportSettings.FileName = file.FileName;
			}
			
			model.ReportSettings = this.reportSettings;
			
			host.Container.Add(this.reportSettings);
			
			//Move to SectionCollection
			XmlNodeList sectionList =  elem.LastChild.ChildNodes;
			
			foreach (XmlNode sectionNode in sectionList) {
				try {
					object o = this.Load(sectionNode as XmlElement,null);
					BaseSection section = o as BaseSection;
					ConvertAbsolut2RelativePath(section.Controls,this.reportSettings.FileName);
//					ConvertAbsolut2RelativePath(section,this.reportSettings.FileName);
					host.Container.Add(section);
				} catch (Exception e) {
					MessageService.ShowException(e);
				}
			}
			return model;
		}
Exemplo n.º 4
0
		/// <summary>
		/// Load's a <see cref="ReportModel"></see> from File using the
		/// </summary>
		/// <param name="fileName"></param>
		/// <returns><see cref="ReportModel"></see></returns>
		public static ReportModel LoadReportModel (string fileName) {
			if (String.IsNullOrEmpty(fileName)) {
				throw new ArgumentNullException("fileName");
			}
			XmlDocument doc = new XmlDocument();
			try {
				doc.Load(fileName);
			} catch (XmlException) {
				// TODO: display user-friendly message
				throw;
			} catch (IOException) {
				// TODO: display user-friendly message
				throw;
			}
			
			BaseItemLoader loader = new BaseItemLoader();
			object root = loader.Load(doc.DocumentElement);
			
			ReportModel model = root as ReportModel;
			if (model != null) {
				model.ReportSettings.FileName = fileName;
				FilePathConverter.AdjustReportName(model);
			} else {
					IllegalFileFormatException e = new IllegalFileFormatException();
				throw e;
			}
			return model;
		}
Exemplo n.º 5
0
		static ReportModel LoadModel(XmlDocument doc)
		{
			Console.WriteLine("ReportEngine:LoadModel");
			BaseItemLoader loader = new BaseItemLoader();
			object root = loader.Load(doc.DocumentElement);

			var model = root as ReportModel;
			if (model == null) {
				throw new IllegalFileFormatException("ReportModel");
			}
			return model;
		}