From 6fe40ea9e39ac5feb7113ade781c707816f204ba Mon Sep 17 00:00:00 2001 From: Rich Date: Mon, 18 Apr 2011 21:32:28 +0000 Subject: [PATCH] Moved DocPDF from Documents to new PDFs table --- .../Generated/DocumentPdf.cs | 509 +++++++ .../Generated/DocumentPdfs.cs | 327 +++++ PROMS/VEPROMS.CSLA.Library/Generated/Pdf.cs | 1170 +++++++++++++++++ .../VEPROMS.CSLA.Library/Generated/PdfInfo.cs | 471 +++++++ .../Generated/PdfInfoList.cs | 262 ++++ PROMS/Volian.Controls.Library/DSOTabPanel.cs | 2 +- .../Volian.Controls.Library/DisplayLibDocs.cs | 2 +- PROMS/Volian.Print.Library/PromsPrinter.cs | 7 +- 8 files changed, 2744 insertions(+), 6 deletions(-) create mode 100644 PROMS/VEPROMS.CSLA.Library/Generated/DocumentPdf.cs create mode 100644 PROMS/VEPROMS.CSLA.Library/Generated/DocumentPdfs.cs create mode 100644 PROMS/VEPROMS.CSLA.Library/Generated/Pdf.cs create mode 100644 PROMS/VEPROMS.CSLA.Library/Generated/PdfInfo.cs create mode 100644 PROMS/VEPROMS.CSLA.Library/Generated/PdfInfoList.cs diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/DocumentPdf.cs b/PROMS/VEPROMS.CSLA.Library/Generated/DocumentPdf.cs new file mode 100644 index 00000000..107b6ec7 --- /dev/null +++ b/PROMS/VEPROMS.CSLA.Library/Generated/DocumentPdf.cs @@ -0,0 +1,509 @@ +// ======================================================================== +// Copyright 2007 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; +using System.ComponentModel; +using System.Collections.Generic; +using Csla.Validation; +namespace VEPROMS.CSLA.Library +{ + /// + /// DocumentPdf Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + [TypeConverter(typeof(DocumentPdfConverter))] + public partial class DocumentPdf : BusinessBase, IVEHasBrokenRules + { + #region Log4Net + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #endregion + #region Business Methods + private string _ErrorMessage = string.Empty; + public string ErrorMessage + { + get { return _ErrorMessage; } + } + private int _DebugStatus; + /// + /// > 0 for Debug + /// + [System.ComponentModel.DataObjectField(true, true)] + public int DebugStatus + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("DebugStatus", true); + return _DebugStatus; + } + } + private int _TopRow; + [System.ComponentModel.DataObjectField(true, true)] + public int TopRow + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("TopRow", true); + return _TopRow; + } + } + private int _PageLength; + [System.ComponentModel.DataObjectField(true, true)] + public int PageLength + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("PageLength", true); + return _PageLength; + } + } + private int _LeftMargin; + [System.ComponentModel.DataObjectField(true, true)] + public int LeftMargin + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("LeftMargin", true); + return _LeftMargin; + } + } + private int _PageWidth; + [System.ComponentModel.DataObjectField(true, true)] + public int PageWidth + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("PageWidth", true); + return _PageWidth; + } + } + private double _PageCount; + /// + /// Count of whole and partial pages + /// + public double PageCount + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("PageCount", true); + return _PageCount; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty("PageCount", true); + if (_PageCount != value) + { + _PageCount = value; + PropertyHasChanged(); + } + } + } + private byte[] _DocPdf; + public byte[] DocPdf + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("DocPdf", true); + return _DocPdf; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty("DocPdf", true); + if (_DocPdf != value) + { + _DocPdf = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("DTS", true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty("DTS", true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("UserID", true); + return _UserID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty("UserID", true); + if (value == null) value = string.Empty; + if (_UserID != value) + { + _UserID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + // CSLATODO: Check DocumentPdf.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current DocumentPdf + protected override object GetIdValue() + { + return MyDocumentPdfUnique; // Absolutely Unique ID + } + // CSLATODO: Replace base DocumentPdf.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current DocumentPdf + //public override string ToString() + //{ + // return base.ToString(); + //} + public override bool IsDirty + { + get { return base.IsDirty; } + } + public bool IsDirtyList(List list) + { + return base.IsDirty; + } + public override bool IsValid + { + get { return (IsNew && !IsDirty) ? true : base.IsValid; } + } + public bool IsValidList(List list) + { + return (IsNew && !IsDirty) ? true : base.IsValid; + } + #endregion + #region ValidationRules + [NonSerialized] + private bool _CheckingBrokenRules = false; + public IVEHasBrokenRules HasBrokenRules + { + get + { + if (_CheckingBrokenRules) return null; + if (BrokenRulesCollection.Count > 0) return this; + try + { + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + return hasBrokenRules; + } + finally + { + _CheckingBrokenRules = false; + } + } + } + public BrokenRulesCollection BrokenRules + { + get + { + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + if (this.Equals(hasBrokenRules)) return BrokenRulesCollection; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + } + } + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UserID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); + // CSLATODO: Add other validation rules + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //CSLATODO: Who can read/write which fields + //AuthorizationRules.AllowRead(DebugStatus, ""); + //AuthorizationRules.AllowRead(TopRow, ""); + //AuthorizationRules.AllowRead(PageLength, ""); + //AuthorizationRules.AllowRead(LeftMargin, ""); + //AuthorizationRules.AllowRead(PageWidth, ""); + //AuthorizationRules.AllowRead(PageCount, ""); + //AuthorizationRules.AllowWrite(PageCount, ""); + //AuthorizationRules.AllowRead(DocPdf, ""); + //AuthorizationRules.AllowWrite(DocPdf, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowRead(UserID, ""); + //AuthorizationRules.AllowWrite(UserID, ""); + } + public static bool CanAddObject() + { + // CSLATODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // CSLATODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // CSLATODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // CSLATODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private static int _DocumentPdfUnique = 0; + private static int DocumentPdfUnique + { get { return ++_DocumentPdfUnique; } } + private int _MyDocumentPdfUnique = DocumentPdfUnique; + public int MyDocumentPdfUnique // Absolutely Unique ID - Editable FK + { get { return _MyDocumentPdfUnique; } } + internal static DocumentPdf New(int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth, double pageCount) + { + return new DocumentPdf(debugStatus, topRow, pageLength, leftMargin, pageWidth, pageCount); + } + internal static DocumentPdf Get(SafeDataReader dr) + { + return new DocumentPdf(dr); + } + public DocumentPdf() + { + MarkAsChild(); + + _DTS = _DocumentPdfExtension.DefaultDTS; + _UserID = _DocumentPdfExtension.DefaultUserID; + ValidationRules.CheckRules(); + } + private DocumentPdf(int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth, double pageCount) + { + MarkAsChild(); + // CSLATODO: Add any initialization & defaults + _DTS = _DocumentPdfExtension.DefaultDTS; + _UserID = _DocumentPdfExtension.DefaultUserID; + _DebugStatus = debugStatus; + _TopRow = topRow; + _PageLength = pageLength; + _LeftMargin = leftMargin; + _PageWidth = pageWidth; + _PageCount = pageCount; + ValidationRules.CheckRules(); + } + internal DocumentPdf(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + private void Fetch(SafeDataReader dr) + { + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentPdf.FetchDR", GetHashCode()); + try + { + _DebugStatus = dr.GetInt32("DebugStatus"); + _TopRow = dr.GetInt32("TopRow"); + _PageLength = dr.GetInt32("PageLength"); + _LeftMargin = dr.GetInt32("LeftMargin"); + _PageWidth = dr.GetInt32("PageWidth"); + _PageCount = dr.GetDouble("PageCount"); + _DocPdf = (byte[])dr.GetValue("DocPdf"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + } + catch (Exception ex) // FKItem Fetch + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentPdf.FetchDR", ex); + throw new DbCslaException("DocumentPdf.Fetch", ex); + } + MarkOld(); + } + internal void Insert(Document myDocument) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; + _LastChanged = Pdf.Add(cn, myDocument, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth, _PageCount, _DocPdf, _DTS, _UserID); + MarkOld(); + } + internal void Update(Document myDocument) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; + _LastChanged = Pdf.Update(cn, myDocument.DocID, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth, _PageCount, _DocPdf, _DTS, _UserID, ref _LastChanged); + MarkOld(); + } + internal void DeleteSelf(Document myDocument) + { + // if we're not dirty then don't update the database + if (!this.IsDirty) return; + // if we're new then don't update the database + if (this.IsNew) return; + SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; + Pdf.Remove(cn, myDocument.DocID, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth); + MarkNew(); + } + #endregion + // Standard Default Code + #region extension + DocumentPdfExtension _DocumentPdfExtension = new DocumentPdfExtension(); + [Serializable()] + partial class DocumentPdfExtension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUserID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Instance Authorization Rules + public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + // InstanceValidation Rules + public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class + #region Converter + internal class DocumentPdfConverter : ExpandableObjectConverter + { + public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) + { + if (destType == typeof(string) && value is DocumentPdf) + { + // Return the ToString value + return ((DocumentPdf)value).ToString(); + } + return base.ConvertTo(context, culture, value, destType); + } + } + #endregion +} // Namespace + + +//// The following is a sample Extension File. You can use it to create DocumentPdfExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace VEPROMS.CSLA.Library +//{ +// public partial class DocumentPdf +// { +// partial class DocumentPdfExtension : extensionBase +// { +// // CSLATODO: Override automatic defaults +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUserID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowInstanceRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddInstanceRule(/* Instance Validation Rule */); +// } +// } +// } +//} diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/DocumentPdfs.cs b/PROMS/VEPROMS.CSLA.Library/Generated/DocumentPdfs.cs new file mode 100644 index 00000000..5b5ddc48 --- /dev/null +++ b/PROMS/VEPROMS.CSLA.Library/Generated/DocumentPdfs.cs @@ -0,0 +1,327 @@ +// ======================================================================== +// Copyright 2007 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; +using System.ComponentModel; +using System.Collections.Generic; +using Csla.Validation; +namespace VEPROMS.CSLA.Library +{ + /// + /// DocumentPdfs Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + [TypeConverter(typeof(DocumentPdfsConverter))] + public partial class DocumentPdfs : BusinessListBase, ICustomTypeDescriptor, IVEHasBrokenRules + { + #region Log4Net + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #endregion + #region Business Methods + private string _ErrorMessage = string.Empty; + public string ErrorMessage + { + get { return _ErrorMessage; } + } + // One To Many + public DocumentPdf this[int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth] + { + get + { + foreach (DocumentPdf pdf in this) + if (pdf.DebugStatus == debugStatus && pdf.TopRow == topRow && pdf.PageLength == pageLength && pdf.LeftMargin == leftMargin && pdf.PageWidth == pageWidth) + return pdf; + return null; + } + } + public new System.Collections.Generic.IList Items + { + get { return base.Items; } + } + public DocumentPdf GetItem(int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth) + { + foreach (DocumentPdf pdf in this) + if (pdf.DebugStatus == debugStatus && pdf.TopRow == topRow && pdf.PageLength == pageLength && pdf.LeftMargin == leftMargin && pdf.PageWidth == pageWidth) + return pdf; + return null; + } + public DocumentPdf Add(int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth, double pageCount) // One to Many with unique fields + { + if (!Contains(debugStatus, topRow, pageLength, leftMargin, pageWidth)) + { + DocumentPdf pdf = DocumentPdf.New(debugStatus, topRow, pageLength, leftMargin, pageWidth, pageCount); + this.Add(pdf); + return pdf; + } + else + throw new InvalidOperationException("pdf already exists"); + } + public void Remove(int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth) + { + foreach (DocumentPdf pdf in this) + { + if (pdf.DebugStatus == debugStatus && pdf.TopRow == topRow && pdf.PageLength == pageLength && pdf.LeftMargin == leftMargin && pdf.PageWidth == pageWidth) + { + Remove(pdf); + break; + } + } + } + public bool Contains(int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth) + { + foreach (DocumentPdf pdf in this) + if (pdf.DebugStatus == debugStatus && pdf.TopRow == topRow && pdf.PageLength == pageLength && pdf.LeftMargin == leftMargin && pdf.PageWidth == pageWidth) + return true; + return false; + } + public bool ContainsDeleted(int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth) + { + foreach (DocumentPdf pdf in DeletedList) + if (pdf.DebugStatus == debugStatus && pdf.TopRow == topRow && pdf.PageLength == pageLength && pdf.LeftMargin == leftMargin && pdf.PageWidth == pageWidth) + return true; + return false; + } + public bool IsDirtyList(List list) + { + // any non-new deletions make us dirty + foreach (DocumentPdf item in DeletedList) + if (!item.IsNew) + return true; + // run through all the child objects + // and if any are dirty then then + // collection is dirty + foreach (DocumentPdf child in this) + if (child.IsDirtyList(list)) + return true; + return false; + } + public override bool IsValid + { + get { return IsValidList(new List()); } + } + public bool IsValidList(List list) + { + // run through all the child objects + // and if any are invalid then the + // collection is invalid + foreach (DocumentPdf child in this) + if (!child.IsValidList(list)) + { + //Console.WriteLine("Valid {0} Child {1} - {2}", child.IsValid, child.GetType().Name,child.ToString()); + return false; + } + return true; + } + #endregion + #region ValidationRules + public IVEHasBrokenRules HasBrokenRules + { + get + { + IVEHasBrokenRules hasBrokenRules = null; + foreach (DocumentPdf documentPdf in this) + if ((hasBrokenRules = documentPdf.HasBrokenRules) != null) return hasBrokenRules; + return hasBrokenRules; + } + } + public BrokenRulesCollection BrokenRules + { + get + { + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + } + } + #endregion + #region Factory Methods + internal static DocumentPdfs New() + { + return new DocumentPdfs(); + } + internal static DocumentPdfs Get(SafeDataReader dr) + { + return new DocumentPdfs(dr); + } + public static DocumentPdfs GetByDocID(int docID) + { + try + { + return DataPortal.Fetch(new DocIDCriteria(docID)); + } + catch (Exception ex) + { + throw new DbCslaException("Error on DocumentPdfs.GetByDocID", ex); + } + } + private DocumentPdfs() + { + MarkAsChild(); + } + internal DocumentPdfs(SafeDataReader dr) + { + MarkAsChild(); + Fetch(dr); + } + #endregion + #region Data Access Portal + // called to load data from the database + private void Fetch(SafeDataReader dr) + { + this.RaiseListChangedEvents = false; + while (dr.Read()) + this.Add(DocumentPdf.Get(dr)); + this.RaiseListChangedEvents = true; + } + [Serializable()] + private class DocIDCriteria + { + public DocIDCriteria(int docID) + { + _DocID = docID; + } + private int _DocID; + public int DocID + { + get { return _DocID; } + set { _DocID = value; } + } + } + private void DataPortal_Fetch(DocIDCriteria criteria) + { + this.RaiseListChangedEvents = false; + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] DocumentPdfs.DataPortal_FetchDocID", GetHashCode()); + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getPdfsByDocID"; + cm.Parameters.AddWithValue("@DocID", criteria.DocID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + while (dr.Read()) this.Add(new DocumentPdf(dr)); + } + } + } + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("DocumentPdfs.DataPortal_FetchDocID", ex); + throw new DbCslaException("DocumentPdfs.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + internal void Update(Document document) + { + this.RaiseListChangedEvents = false; + try + { + // update (thus deleting) any deleted child objects + foreach (DocumentPdf obj in DeletedList) + obj.DeleteSelf(document);// Deletes related record + // now that they are deleted, remove them from memory too + DeletedList.Clear(); + // add/update any current child objects + foreach (DocumentPdf obj in this) + { + if (obj.IsNew) + obj.Insert(document); + else + obj.Update(document); + } + } + finally + { + this.RaiseListChangedEvents = true; + } + } + #endregion + #region ICustomTypeDescriptor impl + public String GetClassName() + { return TypeDescriptor.GetClassName(this, true); } + public AttributeCollection GetAttributes() + { return TypeDescriptor.GetAttributes(this, true); } + public String GetComponentName() + { return TypeDescriptor.GetComponentName(this, true); } + public TypeConverter GetConverter() + { return TypeDescriptor.GetConverter(this, true); } + public EventDescriptor GetDefaultEvent() + { return TypeDescriptor.GetDefaultEvent(this, true); } + public PropertyDescriptor GetDefaultProperty() + { return TypeDescriptor.GetDefaultProperty(this, true); } + public object GetEditor(Type editorBaseType) + { return TypeDescriptor.GetEditor(this, editorBaseType, true); } + public EventDescriptorCollection GetEvents(Attribute[] attributes) + { return TypeDescriptor.GetEvents(this, attributes, true); } + public EventDescriptorCollection GetEvents() + { return TypeDescriptor.GetEvents(this, true); } + public object GetPropertyOwner(PropertyDescriptor pd) + { return this; } + /// + /// Called to get the properties of this type. Returns properties with certain + /// attributes. this restriction is not implemented here. + /// + /// + /// + public PropertyDescriptorCollection GetProperties(Attribute[] attributes) + { return GetProperties(); } + /// + /// Called to get the properties of this type. + /// + /// + public PropertyDescriptorCollection GetProperties() + { + // Create a collection object to hold property descriptors + PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null); + // Iterate the list + for (int i = 0; i < this.Items.Count; i++) + { + // Create a property descriptor for the item and add to the property descriptor collection + DocumentPdfsPropertyDescriptor pd = new DocumentPdfsPropertyDescriptor(this, i); + pds.Add(pd); + } + // return the property descriptor collection + return pds; + } + #endregion + } // Class + #region Property Descriptor + /// + /// Summary description for CollectionPropertyDescriptor. + /// + public partial class DocumentPdfsPropertyDescriptor : vlnListPropertyDescriptor + { + private DocumentPdf Item { get { return (DocumentPdf)_Item; } } + public DocumentPdfsPropertyDescriptor(DocumentPdfs collection, int index) : base(collection, index) { ;} + } + #endregion + #region Converter + internal class DocumentPdfsConverter : ExpandableObjectConverter + { + public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) + { + if (destType == typeof(string) && value is DocumentPdfs) + { + // Return department and department role separated by comma. + return ((DocumentPdfs)value).Items.Count.ToString() + " Pdfs"; + } + return base.ConvertTo(context, culture, value, destType); + } + } + #endregion +} // Namespace diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/Pdf.cs b/PROMS/VEPROMS.CSLA.Library/Generated/Pdf.cs new file mode 100644 index 00000000..bfa1bb5b --- /dev/null +++ b/PROMS/VEPROMS.CSLA.Library/Generated/Pdf.cs @@ -0,0 +1,1170 @@ +// ======================================================================== +// Copyright 2007 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; +using System.ComponentModel; +using System.Collections.Generic; +using Csla.Validation; +namespace VEPROMS.CSLA.Library +{ + /// + /// Pdf Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + [TypeConverter(typeof(PdfConverter))] + public partial class Pdf : BusinessBase, IDisposable, IVEHasBrokenRules + { + #region Log4Net + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #endregion + #region Refresh + private List _RefreshPdfs = new List(); + private void AddToRefreshList(List refreshPdfs) + { + if (IsDirty) + refreshPdfs.Add(this); + } + private void BuildRefreshList() + { + _RefreshPdfs = new List(); + AddToRefreshList(_RefreshPdfs); + } + private void ProcessRefreshList() + { + foreach (Pdf tmp in _RefreshPdfs) + { + PdfInfo.Refresh(tmp); + if (tmp._MyDocument != null) DocumentInfo.Refresh(tmp._MyDocument); + } + } + #endregion + #region Collection + private static List _CacheList = new List(); + protected static void AddToCache(Pdf pdf) + { + if (!_CacheList.Contains(pdf)) _CacheList.Add(pdf); // In AddToCache + } + protected static void RemoveFromCache(Pdf pdf) + { + while (_CacheList.Contains(pdf)) _CacheList.Remove(pdf); // In RemoveFromCache + } + private static Dictionary> _CacheByPrimaryKey = new Dictionary>(); + private static void ConvertListToDictionary() + { + while (_CacheList.Count > 0) // Move Pdf(s) from temporary _CacheList to _CacheByPrimaryKey + { + Pdf tmp = _CacheList[0]; // Get the first Pdf + string pKey = tmp.DocID.ToString() + "_" + tmp.DebugStatus.ToString() + "_" + tmp.TopRow.ToString() + "_" + tmp.PageLength.ToString() + "_" + tmp.LeftMargin.ToString() + "_" + tmp.PageWidth.ToString(); + if (!_CacheByPrimaryKey.ContainsKey(pKey)) + { + _CacheByPrimaryKey[pKey] = new List(); // Add new list for PrimaryKey + } + _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list + _CacheList.RemoveAt(0); // Remove the first Pdf + } + } + protected static Pdf GetCachedByPrimaryKey(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth) + { + ConvertListToDictionary(); + string key = docID.ToString() + "_" + debugStatus.ToString() + "_" + topRow.ToString() + "_" + pageLength.ToString() + "_" + leftMargin.ToString() + "_" + pageWidth.ToString(); + if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; + return null; + } + #endregion + #region Business Methods + private string _ErrorMessage = string.Empty; + public string ErrorMessage + { + get { return _ErrorMessage; } + } + private int _DocID; + [System.ComponentModel.DataObjectField(true, true)] + public int DocID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("DocID", true); + if (_MyDocument != null) _DocID = _MyDocument.DocID; + return _DocID; + } + } + private Document _MyDocument; + [System.ComponentModel.DataObjectField(true, true)] + public Document MyDocument + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("MyDocument", true); + if (_MyDocument == null && _DocID != 0) _MyDocument = Document.Get(_DocID); + return _MyDocument; + } + } + private int _DebugStatus; + /// + /// > 0 for Debug + /// + [System.ComponentModel.DataObjectField(true, true)] + public int DebugStatus + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("DebugStatus", true); + return _DebugStatus; + } + } + private int _TopRow; + [System.ComponentModel.DataObjectField(true, true)] + public int TopRow + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("TopRow", true); + return _TopRow; + } + } + private int _PageLength; + [System.ComponentModel.DataObjectField(true, true)] + public int PageLength + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("PageLength", true); + return _PageLength; + } + } + private int _LeftMargin; + [System.ComponentModel.DataObjectField(true, true)] + public int LeftMargin + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("LeftMargin", true); + return _LeftMargin; + } + } + private int _PageWidth; + [System.ComponentModel.DataObjectField(true, true)] + public int PageWidth + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("PageWidth", true); + return _PageWidth; + } + } + private double _PageCount; + /// + /// Count of whole and partial pages + /// + public double PageCount + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("PageCount", true); + return _PageCount; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty("PageCount", true); + if (_PageCount != value) + { + _PageCount = value; + PropertyHasChanged(); + } + } + } + private byte[] _DocPdf; + public byte[] DocPdf + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("DocPdf", true); + return _DocPdf; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty("DocPdf", true); + if (_DocPdf != value) + { + _DocPdf = value; + PropertyHasChanged(); + } + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("DTS", true); + return _DTS; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty("DTS", true); + if (_DTS != value) + { + _DTS = value; + PropertyHasChanged(); + } + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("UserID", true); + return _UserID; + } + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + set + { + CanWriteProperty("UserID", true); + if (value == null) value = string.Empty; + if (_UserID != value) + { + _UserID = value; + PropertyHasChanged(); + } + } + } + private byte[] _LastChanged = new byte[8];//timestamp + public override bool IsDirty + { + get + { + if ( base.IsDirty ) + return true; + return IsDirtyList(new List()); + } + } + public bool IsDirtyList(List list) + { + if (base.IsDirty || list.Contains(this)) + return base.IsDirty; + list.Add(this); + return base.IsDirty || (_MyDocument == null ? false : _MyDocument.IsDirtyList(list)); + } + public override bool IsValid + { + get { return IsValidList(new List()); } + } + public bool IsValidList(List list) + { + if(list.Contains(this)) + return (IsNew && !IsDirty) ? true : base.IsValid; + list.Add(this); + return ((IsNew && !IsDirty) ? true : base.IsValid) && (_MyDocument == null ? true : _MyDocument.IsValidList(list)); + } + // CSLATODO: Replace base Pdf.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current Pdf + //public override string ToString() + //{ + // return base.ToString(); + //} + // CSLATODO: Check Pdf.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current Pdf + protected override object GetIdValue() + { + return MyPdfUnique; // Absolutely Unique ID + } + #endregion + #region ValidationRules + [NonSerialized] + private bool _CheckingBrokenRules = false; + public IVEHasBrokenRules HasBrokenRules + { + get + { + if (_CheckingBrokenRules) return null; + if ((IsDirty || !IsNew) && BrokenRulesCollection.Count > 0) return this; + try + { + _CheckingBrokenRules = true; + IVEHasBrokenRules hasBrokenRules = null; + return hasBrokenRules; + } + finally + { + _CheckingBrokenRules = false; + } + } + } + public BrokenRulesCollection BrokenRules + { + get + { + IVEHasBrokenRules hasBrokenRules = HasBrokenRules; + if (this.Equals(hasBrokenRules)) return BrokenRulesCollection; + return (hasBrokenRules != null ? hasBrokenRules.BrokenRules : null); + } + } + protected override void AddBusinessRules() + { + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringRequired, "UserID"); + ValidationRules.AddRule( + Csla.Validation.CommonRules.StringMaxLength, + new Csla.Validation.CommonRules.MaxLengthRuleArgs("UserID", 100)); + //ValidationRules.AddDependantProperty("x", "y"); + _PdfExtension.AddValidationRules(ValidationRules); + // CSLATODO: Add other validation rules + } + protected override void AddInstanceBusinessRules() + { + _PdfExtension.AddInstanceValidationRules(ValidationRules); + // CSLATODO: Add other validation rules + } + // Sample data comparison validation rule + //private bool StartDateGTEndDate(object target, Csla.Validation.RuleArgs e) + //{ + // if (_started > _ended) + // { + // e.Description = "Start date can't be after end date"; + // return false; + // } + // else + // return true; + //} + #endregion + #region Authorization Rules + protected override void AddAuthorizationRules() + { + //CSLATODO: Who can read/write which fields + //AuthorizationRules.AllowRead(DocID, ""); + //AuthorizationRules.AllowRead(DebugStatus, ""); + //AuthorizationRules.AllowRead(TopRow, ""); + //AuthorizationRules.AllowRead(PageLength, ""); + //AuthorizationRules.AllowRead(LeftMargin, ""); + //AuthorizationRules.AllowRead(PageWidth, ""); + //AuthorizationRules.AllowRead(PageCount, ""); + //AuthorizationRules.AllowRead(DocPdf, ""); + //AuthorizationRules.AllowRead(DTS, ""); + //AuthorizationRules.AllowRead(UserID, ""); + //AuthorizationRules.AllowWrite(PageCount, ""); + //AuthorizationRules.AllowWrite(DocPdf, ""); + //AuthorizationRules.AllowWrite(DTS, ""); + //AuthorizationRules.AllowWrite(UserID, ""); + _PdfExtension.AddAuthorizationRules(AuthorizationRules); + } + protected override void AddInstanceAuthorizationRules() + { + //CSLATODO: Who can read/write which fields + _PdfExtension.AddInstanceAuthorizationRules(AuthorizationRules); + } + public static bool CanAddObject() + { + // CSLATODO: Can Add Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + public static bool CanGetObject() + { + // CSLATODO: CanGet Authorization + return true; + } + public static bool CanDeleteObject() + { + // CSLATODO: CanDelete Authorization + //bool result = false; + //if (Csla.ApplicationContext.User.IsInRole("ProjectManager"))result = true; + //if (Csla.ApplicationContext.User.IsInRole("Administrator"))result = true; + //return result; + return true; + } + public static bool CanEditObject() + { + // CSLATODO: CanEdit Authorization + //return Csla.ApplicationContext.User.IsInRole("ProjectManager"); + return true; + } + #endregion + #region Factory Methods + public int CurrentEditLevel + { get { return EditLevel; } } + private static int _PdfUnique = 0; + protected static int PdfUnique + { get { return ++_PdfUnique; } } + private int _MyPdfUnique = PdfUnique; + public int MyPdfUnique // Absolutely Unique ID - Editable + { get { return _MyPdfUnique; } } + protected Pdf() + {/* require use of factory methods */ + AddToCache(this); + } + public void Dispose() + { + RemoveFromDictionaries(); + } + private void RemoveFromDictionaries() + { + RemoveFromCache(this); + if (_CacheByPrimaryKey.ContainsKey(DocID.ToString() + "_" + DebugStatus.ToString() + "_" + TopRow.ToString() + "_" + PageLength.ToString() + "_" + LeftMargin.ToString() + "_" + PageWidth.ToString())) + { + List listPdf = _CacheByPrimaryKey[DocID.ToString() + "_" + DebugStatus.ToString() + "_" + TopRow.ToString() + "_" + PageLength.ToString() + "_" + LeftMargin.ToString() + "_" + PageWidth.ToString()]; // Get the list of items + while (listPdf.Contains(this)) listPdf.Remove(this); // Remove the item from the list + if (listPdf.Count == 0) //If there are no items left in the list + _CacheByPrimaryKey.Remove(DocID.ToString() + "_" + DebugStatus.ToString() + "_" + TopRow.ToString() + "_" + PageLength.ToString() + "_" + LeftMargin.ToString() + "_" + PageWidth.ToString()); // remove the list + } + } + public static Pdf New() + { + if (!CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Pdf"); + try + { + return DataPortal.Create(); + } + catch (Exception ex) + { + throw new DbCslaException("Error on Pdf.New", ex); + } + } + public static Pdf New(Document myDocument, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth, double pageCount) + { + Pdf tmp = Pdf.New(); + tmp._MyDocument = myDocument; + tmp._DebugStatus = debugStatus; + tmp._TopRow = topRow; + tmp._PageLength = pageLength; + tmp._LeftMargin = leftMargin; + tmp._PageWidth = pageWidth; + tmp.PageCount = pageCount; + return tmp; + } + public static Pdf New(Document myDocument, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth, double pageCount, byte[] docPdf, DateTime dts, string userID) + { + Pdf tmp = Pdf.New(); + tmp._MyDocument = myDocument; + tmp._DebugStatus = debugStatus; + tmp._TopRow = topRow; + tmp._PageLength = pageLength; + tmp._LeftMargin = leftMargin; + tmp._PageWidth = pageWidth; + tmp.PageCount = pageCount; + tmp.DocPdf = docPdf; + tmp.DTS = dts; + tmp.UserID = userID; + return tmp; + } + public static Pdf MakePdf(Document myDocument, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth, double pageCount, byte[] docPdf, DateTime dts, string userID) + { + Pdf tmp = Pdf.New(myDocument, debugStatus, topRow, pageLength, leftMargin, pageWidth, pageCount, docPdf, dts, userID); + if (tmp.IsSavable) + { + Pdf tmp2 = tmp; + tmp = tmp2.Save(); + tmp2.Dispose(); + } + else + { + Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules(); + tmp._ErrorMessage = "Failed Validation:"; + foreach (Csla.Validation.BrokenRule br in brc) + { + tmp._ErrorMessage += "\r\n\tFailure: " + br.RuleName; + } + } + return tmp; + } + public static Pdf New(Document myDocument, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth, double pageCount, byte[] docPdf) + { + Pdf tmp = Pdf.New(); + tmp._MyDocument = myDocument; + tmp._DebugStatus = debugStatus; + tmp._TopRow = topRow; + tmp._PageLength = pageLength; + tmp._LeftMargin = leftMargin; + tmp._PageWidth = pageWidth; + tmp.PageCount = pageCount; + tmp.DocPdf = docPdf; + return tmp; + } + public static Pdf MakePdf(Document myDocument, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth, double pageCount, byte[] docPdf) + { + Pdf tmp = Pdf.New(myDocument, debugStatus, topRow, pageLength, leftMargin, pageWidth, pageCount, docPdf); + if (tmp.IsSavable) + { + Pdf tmp2 = tmp; + tmp = tmp2.Save(); + tmp2.Dispose(); + } + else + { + Csla.Validation.BrokenRulesCollection brc = tmp.ValidationRules.GetBrokenRules(); + tmp._ErrorMessage = "Failed Validation:"; + foreach (Csla.Validation.BrokenRule br in brc) + { + tmp._ErrorMessage += "\r\n\tFailure: " + br.RuleName; + } + } + return tmp; + } + public static Pdf Get(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth) + { + if (!CanGetObject()) + throw new System.Security.SecurityException("User not authorized to view a Pdf"); + try + { + Pdf tmp = GetCachedByPrimaryKey(docID, debugStatus, topRow, pageLength, leftMargin, pageWidth); + if (tmp == null) + { + tmp = DataPortal.Fetch(new PKCriteria(docID, debugStatus, topRow, pageLength, leftMargin, pageWidth)); + AddToCache(tmp); + } + if (tmp.ErrorMessage == "No Record Found") + { + tmp.Dispose(); // Clean-up Pdf + tmp = null; + } + return tmp; + } + catch (Exception ex) + { + throw new DbCslaException("Error on Pdf.Get", ex); + } + } + public static Pdf Get(SafeDataReader dr) + { + if (dr.Read()) return new Pdf(dr); + return null; + } + internal Pdf(SafeDataReader dr) + { + ReadData(dr); + } + public static void Delete(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth) + { + if (!CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Pdf"); + try + { + DataPortal.Delete(new PKCriteria(docID, debugStatus, topRow, pageLength, leftMargin, pageWidth)); + } + catch (Exception ex) + { + throw new DbCslaException("Error on Pdf.Delete", ex); + } + } + public override Pdf Save() + { + if (IsDeleted && !CanDeleteObject()) + throw new System.Security.SecurityException("User not authorized to remove a Pdf"); + else if (IsNew && !CanAddObject()) + throw new System.Security.SecurityException("User not authorized to add a Pdf"); + else if (!CanEditObject()) + throw new System.Security.SecurityException("User not authorized to update a Pdf"); + try + { + BuildRefreshList(); + Pdf pdf = base.Save(); + RemoveFromDictionaries(); // if save is successful remove the previous Folder from the cache + AddToCache(pdf);//Refresh the item in AllList + ProcessRefreshList(); + return pdf; + } + catch (Exception ex) + { + throw new DbCslaException("Error on CSLA Save", ex); + } + } + #endregion + #region Data Access Portal + [Serializable()] + protected class PKCriteria + { + private int _DocID; + public int DocID + { get { return _DocID; } } + private int _DebugStatus; + public int DebugStatus + { get { return _DebugStatus; } } + private int _TopRow; + public int TopRow + { get { return _TopRow; } } + private int _PageLength; + public int PageLength + { get { return _PageLength; } } + private int _LeftMargin; + public int LeftMargin + { get { return _LeftMargin; } } + private int _PageWidth; + public int PageWidth + { get { return _PageWidth; } } + public PKCriteria(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth) + { + _DocID = docID; + _DebugStatus = debugStatus; + _TopRow = topRow; + _PageLength = pageLength; + _LeftMargin = leftMargin; + _PageWidth = pageWidth; + } + } + // CSLATODO: If Create needs to access DB - It should not be marked RunLocal + [RunLocal()] + private new void DataPortal_Create() + { + + // Database Defaults + _DTS = _PdfExtension.DefaultDTS; + _UserID = _PdfExtension.DefaultUserID; + // CSLATODO: Add any defaults that are necessary + ValidationRules.CheckRules(); + } + private void ReadData(SafeDataReader dr) + { + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Pdf.ReadData", GetHashCode()); + try + { + _DocID = dr.GetInt32("DocID"); + _DebugStatus = dr.GetInt32("DebugStatus"); + _TopRow = dr.GetInt32("TopRow"); + _PageLength = dr.GetInt32("PageLength"); + _LeftMargin = dr.GetInt32("LeftMargin"); + _PageWidth = dr.GetInt32("PageWidth"); + _PageCount = dr.GetDouble("PageCount"); + _DocPdf = (byte[])dr.GetValue("DocPdf"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + dr.GetBytes("LastChanged", 0, _LastChanged, 0, 8); + MarkOld(); + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("Pdf.ReadData", ex); + _ErrorMessage = ex.Message; + throw new DbCslaException("Pdf.ReadData", ex); + } + } + private void DataPortal_Fetch(PKCriteria criteria) + { + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Pdf.DataPortal_Fetch", GetHashCode()); + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + ApplicationContext.LocalContext["cn"] = cn; + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getPdf"; + cm.Parameters.AddWithValue("@DocID", criteria.DocID); + cm.Parameters.AddWithValue("@DebugStatus", criteria.DebugStatus); + cm.Parameters.AddWithValue("@TopRow", criteria.TopRow); + cm.Parameters.AddWithValue("@PageLength", criteria.PageLength); + cm.Parameters.AddWithValue("@LeftMargin", criteria.LeftMargin); + cm.Parameters.AddWithValue("@PageWidth", criteria.PageWidth); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + if (!dr.Read()) + { + _ErrorMessage = "No Record Found"; + return; + } + ReadData(dr); + } + } + // removing of item only needed for local data portal + if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) + ApplicationContext.LocalContext.Remove("cn"); + } + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("Pdf.DataPortal_Fetch", ex); + _ErrorMessage = ex.Message; + throw new DbCslaException("Pdf.DataPortal_Fetch", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Insert() + { + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + ApplicationContext.LocalContext["cn"] = cn; + SQLInsert(); + // removing of item only needed for local data portal + if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) + ApplicationContext.LocalContext.Remove("cn"); + } + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("Pdf.DataPortal_Insert", ex); + _ErrorMessage = ex.Message; + throw new DbCslaException("Pdf.DataPortal_Insert", ex); + } + finally + { + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Pdf.DataPortal_Insert", GetHashCode()); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + internal void SQLInsert() + { + if (!this.IsDirty) return; + try + { + if (_MyDocument != null) _MyDocument.Update(); + SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addPdf"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@DocID", DocID); + cm.Parameters.AddWithValue("@DebugStatus", _DebugStatus); + cm.Parameters.AddWithValue("@TopRow", _TopRow); + cm.Parameters.AddWithValue("@PageLength", _PageLength); + cm.Parameters.AddWithValue("@LeftMargin", _LeftMargin); + cm.Parameters.AddWithValue("@PageWidth", _PageWidth); + cm.Parameters.AddWithValue("@PageCount", _PageCount); + cm.Parameters.AddWithValue("@DocPdf", _DocPdf); + if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // CSLATODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + MarkOld(); + // update child objects + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Pdf.SQLInsert", GetHashCode()); + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("Pdf.SQLInsert", ex); + _ErrorMessage = ex.Message; + throw new DbCslaException("Pdf.SQLInsert", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Add(SqlConnection cn, Document myDocument, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth, double pageCount, byte[] docPdf, DateTime dts, string userID) + { + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Pdf.Add", 0); + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "addPdf"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@DocID", myDocument.DocID); + cm.Parameters.AddWithValue("@DebugStatus", debugStatus); + cm.Parameters.AddWithValue("@TopRow", topRow); + cm.Parameters.AddWithValue("@PageLength", pageLength); + cm.Parameters.AddWithValue("@LeftMargin", leftMargin); + cm.Parameters.AddWithValue("@PageWidth", pageWidth); + cm.Parameters.AddWithValue("@PageCount", pageCount); + cm.Parameters.AddWithValue("@DocPdf", docPdf); + if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // CSLATODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("Pdf.Add", ex); + throw new DbCslaException("Pdf.Add", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_Update() + { + if (!IsDirty) return; // If not dirty - nothing to do + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Pdf.DataPortal_Update", GetHashCode()); + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + ApplicationContext.LocalContext["cn"] = cn; + SQLUpdate(); + // removing of item only needed for local data portal + if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) + ApplicationContext.LocalContext.Remove("cn"); + } + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("Pdf.DataPortal_Update", ex); + _ErrorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; + } + } + [Transactional(TransactionalTypes.TransactionScope)] + internal void SQLUpdate() + { + if (!IsDirty) return; // If not dirty - nothing to do + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Pdf.SQLUpdate", GetHashCode()); + try + { + if (_MyDocument != null) _MyDocument.Update(); + SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; + if (base.IsDirty) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updatePdf"; + // All Fields including Calculated Fields + cm.Parameters.AddWithValue("@DocID", DocID); + cm.Parameters.AddWithValue("@DebugStatus", _DebugStatus); + cm.Parameters.AddWithValue("@TopRow", _TopRow); + cm.Parameters.AddWithValue("@PageLength", _PageLength); + cm.Parameters.AddWithValue("@LeftMargin", _LeftMargin); + cm.Parameters.AddWithValue("@PageWidth", _PageWidth); + cm.Parameters.AddWithValue("@PageCount", _PageCount); + cm.Parameters.AddWithValue("@DocPdf", _DocPdf); + if (_DTS.Year >= 1753 && _DTS.Year <= 9999) cm.Parameters.AddWithValue("@DTS", _DTS); + cm.Parameters.AddWithValue("@UserID", _UserID); + cm.Parameters.AddWithValue("@LastChanged", _LastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // CSLATODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + _LastChanged = (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + MarkOld(); + // use the open connection to update child objects + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("Pdf.SQLUpdate", ex); + _ErrorMessage = ex.Message; + if (!ex.Message.EndsWith("has been edited by another user.")) throw ex; + } + } + internal void Update() + { + if (!this.IsDirty) return; + if (base.IsDirty) + { + SqlConnection cn = (SqlConnection)ApplicationContext.LocalContext["cn"]; + if (IsNew) + _LastChanged = Pdf.Add(cn, _MyDocument, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth, _PageCount, _DocPdf, _DTS, _UserID); + else + _LastChanged = Pdf.Update(cn, _DocID, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth, _PageCount, _DocPdf, _DTS, _UserID, ref _LastChanged); + MarkOld(); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static byte[] Update(SqlConnection cn, int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth, double pageCount, byte[] docPdf, DateTime dts, string userID, ref byte[] lastChanged) + { + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Pdf.Update", 0); + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "updatePdf"; + // Input All Fields - Except Calculated Columns + cm.Parameters.AddWithValue("@DocID", docID); + cm.Parameters.AddWithValue("@DebugStatus", debugStatus); + cm.Parameters.AddWithValue("@TopRow", topRow); + cm.Parameters.AddWithValue("@PageLength", pageLength); + cm.Parameters.AddWithValue("@LeftMargin", leftMargin); + cm.Parameters.AddWithValue("@PageWidth", pageWidth); + cm.Parameters.AddWithValue("@PageCount", pageCount); + cm.Parameters.AddWithValue("@DocPdf", docPdf); + if (dts.Year >= 1753 && dts.Year <= 9999) cm.Parameters.AddWithValue("@DTS", dts); + cm.Parameters.AddWithValue("@UserID", userID); + cm.Parameters.AddWithValue("@LastChanged", lastChanged); + // Output Calculated Columns + SqlParameter param_LastChanged = new SqlParameter("@newLastChanged", SqlDbType.Timestamp); + param_LastChanged.Direction = ParameterDirection.Output; + cm.Parameters.Add(param_LastChanged); + // CSLATODO: Define any additional output parameters + cm.ExecuteNonQuery(); + // Save all values being returned from the Procedure + return (byte[])cm.Parameters["@newLastChanged"].Value; + } + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("Pdf.Update", ex); + throw new DbCslaException("Pdf.Update", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + protected override void DataPortal_DeleteSelf() + { + DataPortal_Delete(new PKCriteria(_DocID, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth)); + } + [Transactional(TransactionalTypes.TransactionScope)] + private void DataPortal_Delete(PKCriteria criteria) + { + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Pdf.DataPortal_Delete", GetHashCode()); + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deletePdf"; + cm.Parameters.AddWithValue("@DocID", criteria.DocID); + cm.Parameters.AddWithValue("@DebugStatus", criteria.DebugStatus); + cm.Parameters.AddWithValue("@TopRow", criteria.TopRow); + cm.Parameters.AddWithValue("@PageLength", criteria.PageLength); + cm.Parameters.AddWithValue("@LeftMargin", criteria.LeftMargin); + cm.Parameters.AddWithValue("@PageWidth", criteria.PageWidth); + cm.ExecuteNonQuery(); + } + } + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("Pdf.DataPortal_Delete", ex); + _ErrorMessage = ex.Message; + throw new DbCslaException("Pdf.DataPortal_Delete", ex); + } + } + [Transactional(TransactionalTypes.TransactionScope)] + public static void Remove(SqlConnection cn, int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth) + { + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Pdf.Remove", 0); + try + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "deletePdf"; + // Input PK Fields + cm.Parameters.AddWithValue("@DocID", docID); + cm.Parameters.AddWithValue("@DebugStatus", debugStatus); + cm.Parameters.AddWithValue("@TopRow", topRow); + cm.Parameters.AddWithValue("@PageLength", pageLength); + cm.Parameters.AddWithValue("@LeftMargin", leftMargin); + cm.Parameters.AddWithValue("@PageWidth", pageWidth); + // CSLATODO: Define any additional output parameters + cm.ExecuteNonQuery(); + } + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("Pdf.Remove", ex); + throw new DbCslaException("Pdf.Remove", ex); + } + } + #endregion + #region Exists + public static bool Exists(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth) + { + ExistsCommand result; + try + { + result = DataPortal.Execute(new ExistsCommand(docID, debugStatus, topRow, pageLength, leftMargin, pageWidth)); + return result.Exists; + } + catch (Exception ex) + { + throw new DbCslaException("Error on Pdf.Exists", ex); + } + } + [Serializable()] + private class ExistsCommand : CommandBase + { + private int _DocID; + private int _DebugStatus; + private int _TopRow; + private int _PageLength; + private int _LeftMargin; + private int _PageWidth; + private bool _exists; + public bool Exists + { + get { return _exists; } + } + public ExistsCommand(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth) + { + _DocID = docID; + _DebugStatus = debugStatus; + _TopRow = topRow; + _PageLength = pageLength; + _LeftMargin = leftMargin; + _PageWidth = pageWidth; + } + protected override void DataPortal_Execute() + { + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] Pdf.DataPortal_Execute", GetHashCode()); + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + cn.Open(); + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "existsPdf"; + cm.Parameters.AddWithValue("@DocID", _DocID); + cm.Parameters.AddWithValue("@DebugStatus", _DebugStatus); + cm.Parameters.AddWithValue("@TopRow", _TopRow); + cm.Parameters.AddWithValue("@PageLength", _PageLength); + cm.Parameters.AddWithValue("@LeftMargin", _LeftMargin); + cm.Parameters.AddWithValue("@PageWidth", _PageWidth); + int count = (int)cm.ExecuteScalar(); + _exists = (count > 0); + } + } + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("Pdf.DataPortal_Execute", ex); + throw new DbCslaException("Pdf.DataPortal_Execute", ex); + } + } + } + #endregion + // Standard Default Code + #region extension + PdfExtension _PdfExtension = new PdfExtension(); + [Serializable()] + partial class PdfExtension : extensionBase + { + } + [Serializable()] + class extensionBase + { + // Default Values + public virtual DateTime DefaultDTS + { + get { return DateTime.Now; } + } + public virtual string DefaultUserID + { + get { return Environment.UserName.ToUpper(); } + } + // Authorization Rules + public virtual void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Instance Authorization Rules + public virtual void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules) + { + // Needs to be overriden to add new authorization rules + } + // Validation Rules + public virtual void AddValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + // InstanceValidation Rules + public virtual void AddInstanceValidationRules(Csla.Validation.ValidationRules rules) + { + // Needs to be overriden to add new validation rules + } + } + #endregion + } // Class + #region Converter + internal class PdfConverter : ExpandableObjectConverter + { + public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) + { + if (destType == typeof(string) && value is Pdf) + { + // Return the ToString value + return ((Pdf)value).ToString(); + } + return base.ConvertTo(context, culture, value, destType); + } + } + #endregion +} // Namespace + + +//// The following is a sample Extension File. You can use it to create PdfExt.cs +//using System; +//using System.Collections.Generic; +//using System.Text; +//using Csla; + +//namespace VEPROMS.CSLA.Library +//{ +// public partial class Pdf +// { +// partial class PdfExtension : extensionBase +// { +// // CSLATODO: Override automatic defaults +// public virtual DateTime DefaultDTS +// { +// get { return DateTime.Now; } +// } +// public virtual string DefaultUserID +// { +// get { return Environment.UserName.ToUpper(); } +// } +// public new void AddAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowRead(Dbid, ""); +// } +// public new void AddInstanceAuthorizationRules(Csla.Security.AuthorizationRules rules) +// { +// //rules.AllowInstanceRead(Dbid, ""); +// } +// public new void AddValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddRule( +// Csla.Validation.CommonRules.StringMaxLength, +// new Csla.Validation.CommonRules.MaxLengthRuleArgs("Name", 100)); +// } +// public new void AddInstanceValidationRules(Csla.Validation.ValidationRules rules) +// { +// rules.AddInstanceRule(/* Instance Validation Rule */); +// } +// } +// } +//} diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/PdfInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/PdfInfo.cs new file mode 100644 index 00000000..4d9b357a --- /dev/null +++ b/PROMS/VEPROMS.CSLA.Library/Generated/PdfInfo.cs @@ -0,0 +1,471 @@ +// ======================================================================== +// Copyright 2007 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; +using System.ComponentModel; +using System.Collections.Generic; +namespace VEPROMS.CSLA.Library +{ + public delegate void PdfInfoEvent(object sender); + /// + /// PdfInfo Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + [TypeConverter(typeof(PdfInfoConverter))] + public partial class PdfInfo : ReadOnlyBase, IDisposable + { + public event PdfInfoEvent Changed; + private void OnChange() + { + if (Changed != null) Changed(this); + } + #region Log4Net + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #endregion + #region Collection + private static List _CacheList = new List(); + protected static void AddToCache(PdfInfo pdfInfo) + { + if (!_CacheList.Contains(pdfInfo)) _CacheList.Add(pdfInfo); // In AddToCache + } + protected static void RemoveFromCache(PdfInfo pdfInfo) + { + while (_CacheList.Contains(pdfInfo)) _CacheList.Remove(pdfInfo); // In RemoveFromCache + } + private static Dictionary> _CacheByPrimaryKey = new Dictionary>(); + private static void ConvertListToDictionary() + { + while (_CacheList.Count > 0) // Move PdfInfo(s) from temporary _CacheList to _CacheByPrimaryKey + { + PdfInfo tmp = _CacheList[0]; // Get the first PdfInfo + string pKey = tmp.DocID.ToString() + "_" + tmp.DebugStatus.ToString() + "_" + tmp.TopRow.ToString() + "_" + tmp.PageLength.ToString() + "_" + tmp.LeftMargin.ToString() + "_" + tmp.PageWidth.ToString(); + if (!_CacheByPrimaryKey.ContainsKey(pKey)) + { + _CacheByPrimaryKey[pKey] = new List(); // Add new list for PrimaryKey + } + _CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list + _CacheList.RemoveAt(0); // Remove the first PdfInfo + } + } + internal static void AddList(PdfInfoList lst) + { + foreach (PdfInfo item in lst) AddToCache(item); + } + protected static PdfInfo GetCachedByPrimaryKey(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth) + { + ConvertListToDictionary(); + string key = docID.ToString() + "_" + debugStatus.ToString() + "_" + topRow.ToString() + "_" + pageLength.ToString() + "_" + leftMargin.ToString() + "_" + pageWidth.ToString(); + if (_CacheByPrimaryKey.ContainsKey(key)) return _CacheByPrimaryKey[key][0]; + return null; + } + #endregion + #region Business Methods + private string _ErrorMessage = string.Empty; + public string ErrorMessage + { + get { return _ErrorMessage; } + } + protected Pdf _Editable; + private IVEHasBrokenRules HasBrokenRules + { + get + { + IVEHasBrokenRules hasBrokenRules = null; + if (_Editable != null) + hasBrokenRules = _Editable.HasBrokenRules; + return hasBrokenRules; + } + } + private int _DocID; + [System.ComponentModel.DataObjectField(true, true)] + public int DocID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("DocID", true); + if (_MyDocument != null) _DocID = _MyDocument.DocID; + return _DocID; + } + } + private DocumentInfo _MyDocument; + [System.ComponentModel.DataObjectField(true, true)] + public DocumentInfo MyDocument + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("MyDocument", true); + if (_MyDocument == null && _DocID != 0) _MyDocument = DocumentInfo.Get(_DocID); + return _MyDocument; + } + } + private int _DebugStatus; + /// + /// > 0 for Debug + /// + [System.ComponentModel.DataObjectField(true, true)] + public int DebugStatus + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("DebugStatus", true); + return _DebugStatus; + } + } + private int _TopRow; + [System.ComponentModel.DataObjectField(true, true)] + public int TopRow + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("TopRow", true); + return _TopRow; + } + } + private int _PageLength; + [System.ComponentModel.DataObjectField(true, true)] + public int PageLength + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("PageLength", true); + return _PageLength; + } + } + private int _LeftMargin; + [System.ComponentModel.DataObjectField(true, true)] + public int LeftMargin + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("LeftMargin", true); + return _LeftMargin; + } + } + private int _PageWidth; + [System.ComponentModel.DataObjectField(true, true)] + public int PageWidth + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("PageWidth", true); + return _PageWidth; + } + } + private double _PageCount; + /// + /// Count of whole and partial pages + /// + public double PageCount + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("PageCount", true); + return _PageCount; + } + } + private byte[] _DocPdf; + public byte[] DocPdf + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("DocPdf", true); + return _DocPdf; + } + } + private DateTime _DTS = new DateTime(); + public DateTime DTS + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("DTS", true); + return _DTS; + } + } + private string _UserID = string.Empty; + public string UserID + { + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + get + { + CanReadProperty("UserID", true); + return _UserID; + } + } + // CSLATODO: Replace base PdfInfo.ToString function as necessary + /// + /// Overrides Base ToString + /// + /// A string representation of current PdfInfo + //public override string ToString() + //{ + // return base.ToString(); + //} + // CSLATODO: Check PdfInfo.GetIdValue to assure that the ID returned is unique + /// + /// Overrides Base GetIdValue - Used internally by CSLA to determine equality + /// + /// A Unique ID for the current PdfInfo + protected override object GetIdValue() + { + return MyPdfInfoUnique; // Absolutely Unique ID + } + #endregion + #region Factory Methods + private static int _PdfInfoUnique = 0; + private static int PdfInfoUnique + { get { return ++_PdfInfoUnique; } } + private int _MyPdfInfoUnique = PdfInfoUnique; + public int MyPdfInfoUnique // Absolutely Unique ID - Info + { get { return _MyPdfInfoUnique; } } + protected PdfInfo() + {/* require use of factory methods */ + AddToCache(this); + } + public void Dispose() + { + RemoveFromCache(this); + if (!_CacheByPrimaryKey.ContainsKey(DocID.ToString() + "_" + DebugStatus.ToString() + "_" + TopRow.ToString() + "_" + PageLength.ToString() + "_" + LeftMargin.ToString() + "_" + PageWidth.ToString())) return; + List listPdfInfo = _CacheByPrimaryKey[DocID.ToString() + "_" + DebugStatus.ToString() + "_" + TopRow.ToString() + "_" + PageLength.ToString() + "_" + LeftMargin.ToString() + "_" + PageWidth.ToString()]; // Get the list of items + while (listPdfInfo.Contains(this)) listPdfInfo.Remove(this); // Remove the item from the list + if (listPdfInfo.Count == 0) // If there are no items left in the list + _CacheByPrimaryKey.Remove(DocID.ToString() + "_" + DebugStatus.ToString() + "_" + TopRow.ToString() + "_" + PageLength.ToString() + "_" + LeftMargin.ToString() + "_" + PageWidth.ToString()); // remove the list + } + public virtual Pdf Get() + { + return _Editable = Pdf.Get(_DocID, _DebugStatus, _TopRow, _PageLength, _LeftMargin, _PageWidth); + } + public static void Refresh(Pdf tmp) + { + string key = tmp.DocID.ToString() + "_" + tmp.DebugStatus.ToString() + "_" + tmp.TopRow.ToString() + "_" + tmp.PageLength.ToString() + "_" + tmp.LeftMargin.ToString() + "_" + tmp.PageWidth.ToString(); + ConvertListToDictionary(); + if (_CacheByPrimaryKey.ContainsKey(key)) + foreach (PdfInfo tmpInfo in _CacheByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); + } + protected virtual void RefreshFields(Pdf tmp) + { + _PageCount = tmp.PageCount; + _DocPdf = tmp.DocPdf; + _DTS = tmp.DTS; + _UserID = tmp.UserID; + _PdfInfoExtension.Refresh(this); +//RHM Removed 20090724 - Duplicates function of code above. +// - Dispose caused error when a new step was added. +// - Resequence of transitions did not work properly. +// if(_MyDocument != null) +// { +// _MyDocument.Dispose();// Dispose related value +// _MyDocument = null;// Reset related value +// } + OnChange();// raise an event + } + public static void Refresh(Document myDocument, DocumentPdf tmp) + { + string key = myDocument.DocID.ToString() + "_" + tmp.DebugStatus.ToString() + "_" + tmp.TopRow.ToString() + "_" + tmp.PageLength.ToString() + "_" + tmp.LeftMargin.ToString() + "_" + tmp.PageWidth.ToString(); + ConvertListToDictionary(); + if (_CacheByPrimaryKey.ContainsKey(key)) + foreach (PdfInfo tmpInfo in _CacheByPrimaryKey[key]) + tmpInfo.RefreshFields(tmp); + } + protected virtual void RefreshFields(DocumentPdf tmp) + { + _PageCount = tmp.PageCount; + _DocPdf = tmp.DocPdf; + _DTS = tmp.DTS; + _UserID = tmp.UserID; + _PdfInfoExtension.Refresh(this); +//RHM Removed 20090724 - Duplicates function of code above. +// - Dispose caused error when a new step was added. +// - Resequence of transitions did not work properly. +// if(_MyDocument != null) +// { +// _MyDocument.Dispose();// Dispose related value +// _MyDocument = null;// Reset related value +// } + OnChange();// raise an event + } + public static PdfInfo Get(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth) + { + //if (!CanGetObject()) + // throw new System.Security.SecurityException("User not authorized to view a Pdf"); + try + { + PdfInfo tmp = GetCachedByPrimaryKey(docID, debugStatus, topRow, pageLength, leftMargin, pageWidth); + if (tmp == null) + { + tmp = DataPortal.Fetch(new PKCriteria(docID, debugStatus, topRow, pageLength, leftMargin, pageWidth)); + AddToCache(tmp); + } + if (tmp.ErrorMessage == "No Record Found") + { + tmp.Dispose(); // Clean-up PdfInfo + tmp = null; + } + return tmp; + } + catch (Exception ex) + { + throw new DbCslaException("Error on PdfInfo.Get", ex); + } + } + #endregion + #region Data Access Portal + internal PdfInfo(SafeDataReader dr) + { + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PdfInfo.Constructor", GetHashCode()); + try + { + ReadData(dr); + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("PdfInfo.Constructor", ex); + throw new DbCslaException("PdfInfo.Constructor", ex); + } + } + [Serializable()] + protected class PKCriteria + { + private int _DocID; + public int DocID + { get { return _DocID; } } + private int _DebugStatus; + public int DebugStatus + { get { return _DebugStatus; } } + private int _TopRow; + public int TopRow + { get { return _TopRow; } } + private int _PageLength; + public int PageLength + { get { return _PageLength; } } + private int _LeftMargin; + public int LeftMargin + { get { return _LeftMargin; } } + private int _PageWidth; + public int PageWidth + { get { return _PageWidth; } } + public PKCriteria(int docID, int debugStatus, int topRow, int pageLength, int leftMargin, int pageWidth) + { + _DocID = docID; + _DebugStatus = debugStatus; + _TopRow = topRow; + _PageLength = pageLength; + _LeftMargin = leftMargin; + _PageWidth = pageWidth; + } + } + private void ReadData(SafeDataReader dr) + { + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PdfInfo.ReadData", GetHashCode()); + try + { + _DocID = dr.GetInt32("DocID"); + _DebugStatus = dr.GetInt32("DebugStatus"); + _TopRow = dr.GetInt32("TopRow"); + _PageLength = dr.GetInt32("PageLength"); + _LeftMargin = dr.GetInt32("LeftMargin"); + _PageWidth = dr.GetInt32("PageWidth"); + _PageCount = dr.GetDouble("PageCount"); + _DocPdf = (byte[])dr.GetValue("DocPdf"); + _DTS = dr.GetDateTime("DTS"); + _UserID = dr.GetString("UserID"); + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("PdfInfo.ReadData", ex); + _ErrorMessage = ex.Message; + throw new DbCslaException("PdfInfo.ReadData", ex); + } + } + private void DataPortal_Fetch(PKCriteria criteria) + { + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PdfInfo.DataPortal_Fetch", GetHashCode()); + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + ApplicationContext.LocalContext["cn"] = cn; + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getPdf"; + cm.Parameters.AddWithValue("@DocID", criteria.DocID); + cm.Parameters.AddWithValue("@DebugStatus", criteria.DebugStatus); + cm.Parameters.AddWithValue("@TopRow", criteria.TopRow); + cm.Parameters.AddWithValue("@PageLength", criteria.PageLength); + cm.Parameters.AddWithValue("@LeftMargin", criteria.LeftMargin); + cm.Parameters.AddWithValue("@PageWidth", criteria.PageWidth); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + if (!dr.Read()) + { + _ErrorMessage = "No Record Found"; + return; + } + ReadData(dr); + } + } + // removing of item only needed for local data portal + if (ApplicationContext.ExecutionLocation == ApplicationContext.ExecutionLocations.Client) + ApplicationContext.LocalContext.Remove("cn"); + } + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("PdfInfo.DataPortal_Fetch", ex); + _ErrorMessage = ex.Message; + throw new DbCslaException("PdfInfo.DataPortal_Fetch", ex); + } + } + #endregion + // Standard Refresh + #region extension + PdfInfoExtension _PdfInfoExtension = new PdfInfoExtension(); + [Serializable()] + partial class PdfInfoExtension : extensionBase { } + [Serializable()] + class extensionBase + { + // Default Refresh + public virtual void Refresh(PdfInfo tmp) { } + } + #endregion + } // Class + #region Converter + internal class PdfInfoConverter : ExpandableObjectConverter + { + public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) + { + if (destType == typeof(string) && value is PdfInfo) + { + // Return the ToString value + return ((PdfInfo)value).ToString(); + } + return base.ConvertTo(context, culture, value, destType); + } + } + #endregion +} // Namespace diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/PdfInfoList.cs b/PROMS/VEPROMS.CSLA.Library/Generated/PdfInfoList.cs new file mode 100644 index 00000000..75075528 --- /dev/null +++ b/PROMS/VEPROMS.CSLA.Library/Generated/PdfInfoList.cs @@ -0,0 +1,262 @@ +// ======================================================================== +// Copyright 2007 - Volian Enterprises, Inc. All rights reserved. +// Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE +// ------------------------------------------------------------------------ +// $Workfile: $ $Revision: $ +// $Author: $ $Date: $ +// +// $History: $ +// ======================================================================== + +using System; +using System.Data; +using System.Data.SqlClient; +using Csla; +using Csla.Data; +using System.Configuration; +using System.IO; +using System.ComponentModel; +using System.Collections.Generic; +namespace VEPROMS.CSLA.Library +{ + /// + /// PdfInfoList Generated by MyGeneration using the CSLA Object Mapping template + /// + [Serializable()] + [TypeConverter(typeof(PdfInfoListConverter))] + public partial class PdfInfoList : ReadOnlyListBase, ICustomTypeDescriptor, IDisposable + { + #region Log4Net + private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + #endregion + #region Business Methods + internal new IList Items + { get { return base.Items; } } + public void AddEvents() + { + foreach (PdfInfo tmp in this) + { + tmp.Changed += new PdfInfoEvent(tmp_Changed); + } + } + void tmp_Changed(object sender) + { + for (int i = 0; i < Count; i++) + { + if (base[i] == sender) + this.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, i)); + } + } + public void Dispose() + { + foreach (PdfInfo tmp in this) + { + tmp.Changed -= new PdfInfoEvent(tmp_Changed); + } + } + #endregion + #region Factory Methods + public static PdfInfoList _PdfInfoList = null; + /// + /// Return a list of all PdfInfo. + /// + public static PdfInfoList Get() + { + try + { + if (_PdfInfoList != null) + return _PdfInfoList; + PdfInfoList tmp = DataPortal.Fetch(); + PdfInfo.AddList(tmp); + tmp.AddEvents(); + _PdfInfoList = tmp; + return tmp; + } + catch (Exception ex) + { + throw new DbCslaException("Error on PdfInfoList.Get", ex); + } + } + /// + /// Reset the list of all PdfInfo. + /// + public static void Reset() + { + _PdfInfoList = null; + } + // CSLATODO: Add alternative gets - + //public static PdfInfoList Get() + //{ + // try + // { + // return DataPortal.Fetch(new FilteredCriteria()); + // } + // catch (Exception ex) + // { + // throw new DbCslaException("Error on PdfInfoList.Get", ex); + // } + //} + public static PdfInfoList GetByDocID(int docID) + { + try + { + PdfInfoList tmp = DataPortal.Fetch(new DocIDCriteria(docID)); + PdfInfo.AddList(tmp); + tmp.AddEvents(); + return tmp; + } + catch (Exception ex) + { + throw new DbCslaException("Error on PdfInfoList.GetByDocID", ex); + } + } + private PdfInfoList() + { /* require use of factory methods */ } + #endregion + #region Data Access Portal + private void DataPortal_Fetch() + { + this.RaiseListChangedEvents = false; + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PdfInfoList.DataPortal_Fetch", GetHashCode()); + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getPdfs"; + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new PdfInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("PdfInfoList.DataPortal_Fetch", ex); + throw new DbCslaException("PdfInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + [Serializable()] + private class DocIDCriteria + { + public DocIDCriteria(int docID) + { + _DocID = docID; + } + private int _DocID; + public int DocID + { + get { return _DocID; } + set { _DocID = value; } + } + } + private void DataPortal_Fetch(DocIDCriteria criteria) + { + this.RaiseListChangedEvents = false; + if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] PdfInfoList.DataPortal_FetchDocID", GetHashCode()); + try + { + using (SqlConnection cn = Database.VEPROMS_SqlConnection) + { + using (SqlCommand cm = cn.CreateCommand()) + { + cm.CommandType = CommandType.StoredProcedure; + cm.CommandText = "getPdfsByDocID"; + cm.Parameters.AddWithValue("@DocID", criteria.DocID); + using (SafeDataReader dr = new SafeDataReader(cm.ExecuteReader())) + { + IsReadOnly = false; + while (dr.Read()) this.Add(new PdfInfo(dr)); + IsReadOnly = true; + } + } + } + } + catch (Exception ex) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("PdfInfoList.DataPortal_FetchDocID", ex); + throw new DbCslaException("PdfInfoList.DataPortal_Fetch", ex); + } + this.RaiseListChangedEvents = true; + } + #endregion + #region ICustomTypeDescriptor impl + public String GetClassName() + { return TypeDescriptor.GetClassName(this, true); } + public AttributeCollection GetAttributes() + { return TypeDescriptor.GetAttributes(this, true); } + public String GetComponentName() + { return TypeDescriptor.GetComponentName(this, true); } + public TypeConverter GetConverter() + { return TypeDescriptor.GetConverter(this, true); } + public EventDescriptor GetDefaultEvent() + { return TypeDescriptor.GetDefaultEvent(this, true); } + public PropertyDescriptor GetDefaultProperty() + { return TypeDescriptor.GetDefaultProperty(this, true); } + public object GetEditor(Type editorBaseType) + { return TypeDescriptor.GetEditor(this, editorBaseType, true); } + public EventDescriptorCollection GetEvents(Attribute[] attributes) + { return TypeDescriptor.GetEvents(this, attributes, true); } + public EventDescriptorCollection GetEvents() + { return TypeDescriptor.GetEvents(this, true); } + public object GetPropertyOwner(PropertyDescriptor pd) + { return this; } + /// + /// Called to get the properties of this type. Returns properties with certain + /// attributes. this restriction is not implemented here. + /// + /// + /// + public PropertyDescriptorCollection GetProperties(Attribute[] attributes) + { return GetProperties(); } + /// + /// Called to get the properties of this type. + /// + /// + public PropertyDescriptorCollection GetProperties() + { + // Create a collection object to hold property descriptors + PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null); + // Iterate the list + for (int i = 0; i < this.Items.Count; i++) + { + // Create a property descriptor for the item and add to the property descriptor collection + PdfInfoListPropertyDescriptor pd = new PdfInfoListPropertyDescriptor(this, i); + pds.Add(pd); + } + // return the property descriptor collection + return pds; + } + #endregion + } // Class + #region Property Descriptor + /// + /// Summary description for CollectionPropertyDescriptor. + /// + public partial class PdfInfoListPropertyDescriptor : vlnListPropertyDescriptor + { + private PdfInfo Item { get { return (PdfInfo)_Item; } } + public PdfInfoListPropertyDescriptor(PdfInfoList collection, int index) : base(collection, index) { ;} + } + #endregion + #region Converter + internal class PdfInfoListConverter : ExpandableObjectConverter + { + public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType) + { + if (destType == typeof(string) && value is PdfInfoList) + { + // Return department and department role separated by comma. + return ((PdfInfoList)value).Items.Count.ToString() + " Pdfs"; + } + return base.ConvertTo(context, culture, value, destType); + } + } + #endregion +} // Namespace diff --git a/PROMS/Volian.Controls.Library/DSOTabPanel.cs b/PROMS/Volian.Controls.Library/DSOTabPanel.cs index 2418226b..e9cb636b 100644 --- a/PROMS/Volian.Controls.Library/DSOTabPanel.cs +++ b/PROMS/Volian.Controls.Library/DSOTabPanel.cs @@ -325,7 +325,7 @@ namespace Volian.Controls.Library } LBDocumentClass doc = new LBDocumentClass(_MyDSOFramer.ActiveDocument); MyDSOFile.FullName = GetReflectiveProperty(_MyDSOFramer.ActiveDocument, "FullName"); - MyDSOFile.SaveFile(doc.Length,doc.Ascii); + MyDSOFile.SaveFile(doc.Length,doc.Ascii,MyDisplayTabItem.MyItemInfo); } /// /// Before a document closes check to see if it's contents should be saved. diff --git a/PROMS/Volian.Controls.Library/DisplayLibDocs.cs b/PROMS/Volian.Controls.Library/DisplayLibDocs.cs index 11c9b153..7e439c60 100644 --- a/PROMS/Volian.Controls.Library/DisplayLibDocs.cs +++ b/PROMS/Volian.Controls.Library/DisplayLibDocs.cs @@ -227,7 +227,7 @@ namespace Volian.Controls.Library int nBytesRead = fs.Read(ByteArray, 0, (int)len); fs.Close(); string t1 = (title == null || title == "") ? null : title; - Document doc = Document.MakeDocument(t1, ByteArray, null, null, null); //, DateTime.Now, "Migration"); + Document doc = Document.MakeDocument(t1, ByteArray, null, null); //, DateTime.Now, "Migration"); return doc.DocID; } // for an io exception, keep trying diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index 225878f9..a155dba4 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -316,9 +316,9 @@ namespace Volian.Print.Library { readerWord = myPdfFile != null ? new PdfReader(myPdfFile) : null; OnStatusChanged("Get Section", PromsPrinterStatusType.GetSection); - if (mySection.MyContent.MyEntry.MyDocument.DocumentConfig.Printing_Length != 0) //.SectionConfig.Section_NumPages != "") - { - int sectPageCount = (int)(Math.Ceiling(mySection.MyContent.MyEntry.MyDocument.DocumentConfig.Printing_Length)); //decimal.Parse(mySection.MyContent.MyEntry.MyDocument.DocumentConfig.Printing_Length))); + int sectPageCount=0; + using(PdfInfo myPdf = PdfInfo.Get(mySection)) + sectPageCount = (int)(Math.Ceiling(myPdf.PageCount)); for (int ii = 0; ii < sectPageCount; ii++) { int pageNumber = 1 + ii; @@ -344,7 +344,6 @@ namespace Volian.Print.Library OnStatusChanged("After NewPage", PromsPrinterStatusType.NewPage); } - } } catch (Exception ex) {