Removed PDF info from Document and Document Config
Added DebugStatus to MSWordToPDF Class Removed PDF info from Document Config Moved PDF info from Documents to PDFs Table Added MSWordPageCount Property Delete PDFs when RO Value Changes in a related document
This commit is contained in:
parent
dd9bc9e0dc
commit
f4a3a969f4
@ -123,7 +123,7 @@ namespace VEPROMS
|
|||||||
Content cont = Content.Get(sectinfo.MyContent.ContentID);
|
Content cont = Content.Get(sectinfo.MyContent.ContentID);
|
||||||
|
|
||||||
Byte[] tstbyte = System.Text.Encoding.Default.GetBytes("");
|
Byte[] tstbyte = System.Text.Encoding.Default.GetBytes("");
|
||||||
Document doc = Document.MakeDocument(null, tstbyte, null, null, null); // tstbyte, null, null, null);
|
Document doc = Document.MakeDocument(null, tstbyte, null, null); // tstbyte, null, null, null);
|
||||||
Entry entry = cont.MyEntry;
|
Entry entry = cont.MyEntry;
|
||||||
entry.MyDocument = Document.Get(doc.DocID);
|
entry.MyDocument = Document.Get(doc.DocID);
|
||||||
cont.Save().Dispose();
|
cont.Save().Dispose();
|
||||||
@ -476,7 +476,7 @@ namespace VEPROMS
|
|||||||
{
|
{
|
||||||
// make new document with 'no' libtitle - use libtitle for the doc title. Then link this
|
// make new document with 'no' libtitle - use libtitle for the doc title. Then link this
|
||||||
// to the item...
|
// to the item...
|
||||||
Document doc = Document.MakeDocument(null, doclibinfo.DocContent, doclibinfo.DocAscii, doclibinfo.Config, doclibinfo.DocPdf);
|
Document doc = Document.MakeDocument(null, doclibinfo.DocContent, doclibinfo.DocAscii, doclibinfo.Config);
|
||||||
_SectionConfig.MySection.MyContent.MyEntry.MyDocument = doc;
|
_SectionConfig.MySection.MyContent.MyEntry.MyDocument = doc;
|
||||||
}
|
}
|
||||||
ppCmbxLibDoc.Items.Clear();
|
ppCmbxLibDoc.Items.Clear();
|
||||||
|
@ -132,7 +132,15 @@ namespace VEPROMS
|
|||||||
// When creating an XY Plot, a System.Drawing.Graphics is needed and it requires a form. Use the main
|
// When creating an XY Plot, a System.Drawing.Graphics is needed and it requires a form. Use the main
|
||||||
// form.
|
// form.
|
||||||
if (VlnSettings.DebugMode)
|
if (VlnSettings.DebugMode)
|
||||||
|
{
|
||||||
|
MSWordToPDF.DebugStatus = 1;
|
||||||
MSWordToPDF.OverrideColor = Color.Red;
|
MSWordToPDF.OverrideColor = Color.Red;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MSWordToPDF.DebugStatus = 0;
|
||||||
|
MSWordToPDF.OverrideColor = Color.Transparent;
|
||||||
|
}
|
||||||
MSWordToPDF.FormForPlotGraphics = this;
|
MSWordToPDF.FormForPlotGraphics = this;
|
||||||
|
|
||||||
// set the color of the ribbon
|
// set the color of the ribbon
|
||||||
|
@ -67,39 +67,40 @@ namespace VEPROMS.CSLA.Library
|
|||||||
OnPropertyChanged("LibDoc_Comment");
|
OnPropertyChanged("LibDoc_Comment");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[Category("Printing")]
|
// RHM 20110415 - These are now stored in the PDF table.
|
||||||
[DisplayName("Length")]
|
//[Category("Printing")]
|
||||||
[Description("Length of Document in Full and Partial Pages")]
|
//[DisplayName("Length")]
|
||||||
public float Printing_Length
|
//[Description("Length of Document in Full and Partial Pages")]
|
||||||
{
|
//public float Printing_Length
|
||||||
get
|
//{
|
||||||
{
|
// get
|
||||||
string s = _Xp["Printing", "Length"];// get the saved value
|
// {
|
||||||
|
// string s = _Xp["Printing", "Length"];// get the saved value
|
||||||
|
|
||||||
return float.Parse(s);
|
// return float.Parse(s);
|
||||||
}
|
// }
|
||||||
set
|
// set
|
||||||
{
|
// {
|
||||||
_Xp["Printing", "Length"] = string.Format("{0:0.0000}", value);
|
// _Xp["Printing", "Length"] = string.Format("{0:0.0000}", value);
|
||||||
OnPropertyChanged("Printing_Length");
|
// OnPropertyChanged("Printing_Length");
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
[Category("Printing")]
|
//[Category("Printing")]
|
||||||
[DisplayName("Color")]
|
//[DisplayName("Color")]
|
||||||
[Description("Color of Document Text")]
|
//[Description("Color of Document Text")]
|
||||||
public Color Printing_Color
|
//public Color Printing_Color
|
||||||
{
|
//{
|
||||||
get
|
// get
|
||||||
{
|
// {
|
||||||
string sColor = _Xp["Printing", "Color"];
|
// string sColor = _Xp["Printing", "Color"];
|
||||||
return ColorConfig.ColorFromString(sColor);
|
// return ColorConfig.ColorFromString(sColor);
|
||||||
}
|
// }
|
||||||
set
|
// set
|
||||||
{
|
// {
|
||||||
_Xp["Printing", "Color"] = value.ToString();
|
// _Xp["Printing", "Color"] = value.ToString();
|
||||||
OnPropertyChanged("Printing_Color");
|
// OnPropertyChanged("Printing_Color");
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
#endregion
|
#endregion
|
||||||
#region ToString
|
#region ToString
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
@ -294,7 +294,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
_MyFile = new FileInfo(value);
|
_MyFile = new FileInfo(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void SaveFile(float length,string ascii)
|
public void SaveFile(float length,string ascii,ItemInfo myItemInfo)
|
||||||
{
|
{
|
||||||
// TODO: Add Try & Catch logic
|
// TODO: Add Try & Catch logic
|
||||||
if (_MyDocument == null) return;
|
if (_MyDocument == null) return;
|
||||||
@ -308,21 +308,22 @@ namespace VEPROMS.CSLA.Library
|
|||||||
doc.DocAscii = ascii;
|
doc.DocAscii = ascii;
|
||||||
//doc.UpdateDocAscii(_MyFile.FullName);
|
//doc.UpdateDocAscii(_MyFile.FullName);
|
||||||
DocumentConfig cfg = new DocumentConfig(doc);
|
DocumentConfig cfg = new DocumentConfig(doc);
|
||||||
cfg.Printing_Length = length;
|
|
||||||
cfg.Printing_Color = MSWordToPDF.OverrideColor;
|
|
||||||
doc.Config = cfg.ToString();
|
doc.Config = cfg.ToString();
|
||||||
doc.UserID = Volian.Base.Library.VlnSettings.UserID;
|
doc.UserID = Volian.Base.Library.VlnSettings.UserID;
|
||||||
doc.DTS = _MyFile.LastWriteTime;
|
doc.DTS = _MyFile.LastWriteTime;
|
||||||
doc.Save();
|
doc = doc.Save();
|
||||||
List<string> roids = new List<string>();
|
List<string> roids = new List<string>();
|
||||||
string pdfTmp = MSWordToPDF.ToPDFReplaceROs(_MyDocument,roids);
|
string pdfTmp = MSWordToPDF.ToPDFReplaceROs(_MyDocument,roids,myItemInfo);
|
||||||
FileInfo pdfFile = new FileInfo(pdfTmp);
|
FileInfo pdfFile = new FileInfo(pdfTmp);
|
||||||
fs = pdfFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
fs = pdfFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||||
buf = new byte[pdfFile.Length];
|
buf = new byte[pdfFile.Length];
|
||||||
fs.Read(buf, 0, buf.Length);
|
fs.Read(buf, 0, buf.Length);
|
||||||
fs.Close();
|
fs.Close();
|
||||||
pdfFile.Delete();
|
pdfFile.Delete();
|
||||||
doc.DocPdf = buf;
|
Pdf.DeleteAll(doc.DocID); // clear the PDF table for DocID first
|
||||||
|
DocStyle myDocStyle = myItemInfo.MyActiveSection.MyDocStyle;
|
||||||
|
using (Pdf myPdf = Pdf.MakePdf(doc, MSWordToPDF.DebugStatus, (int) myDocStyle.Layout.TopRow, (int) myDocStyle.Layout.PageLength,
|
||||||
|
(int) myDocStyle.Layout.LeftMargin, (int) myDocStyle.Layout.PageWidth, (double)myItemInfo.MSWordPageCount, buf)) { ;}
|
||||||
doc.UpdateDRoUsages(roids);
|
doc.UpdateDRoUsages(roids);
|
||||||
doc.Save();
|
doc.Save();
|
||||||
}
|
}
|
||||||
@ -372,6 +373,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
return _MyApp;
|
return _MyApp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private static int _DebugStatus = 0;
|
||||||
|
public static int DebugStatus
|
||||||
|
{
|
||||||
|
get { return MSWordToPDF._DebugStatus; }
|
||||||
|
set { MSWordToPDF._DebugStatus = value; }
|
||||||
|
}
|
||||||
private static System.Drawing.Color _OverrideColor = System.Drawing.Color.Transparent;
|
private static System.Drawing.Color _OverrideColor = System.Drawing.Color.Transparent;
|
||||||
public static System.Drawing.Color OverrideColor
|
public static System.Drawing.Color OverrideColor
|
||||||
{
|
{
|
||||||
@ -387,31 +394,29 @@ namespace VEPROMS.CSLA.Library
|
|||||||
public static string GetDocPdf(SectionInfo sect, Color overrideColor)
|
public static string GetDocPdf(SectionInfo sect, Color overrideColor)
|
||||||
{
|
{
|
||||||
DocumentInfo mydoc = sect.MyContent.MyEntry.MyDocument;
|
DocumentInfo mydoc = sect.MyContent.MyEntry.MyDocument;
|
||||||
UpdateDocPdf(mydoc, overrideColor);
|
UpdateDocPdf(mydoc, overrideColor,sect);
|
||||||
string fileName = GetFileName(sect);
|
string fileName = GetFileName(sect);
|
||||||
FileInfo fi = new FileInfo(fileName);
|
FileInfo fi = new FileInfo(fileName);
|
||||||
FileStream fs = fi.Create();
|
FileStream fs = fi.Create();
|
||||||
if (mydoc.DocPdf!=null)fs.Write(mydoc.DocPdf, 0, mydoc.DocPdf.Length);
|
PdfInfo myPdf = PdfInfo.Get(sect);
|
||||||
|
if (myPdf != null && myPdf.DocPdf != null) fs.Write(myPdf.DocPdf, 0, myPdf.DocPdf.Length);
|
||||||
fs.Close();
|
fs.Close();
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool UpdateDocPdf(DocumentInfo mydoc, Color overrideColor)
|
public static bool UpdateDocPdf(DocumentInfo mydoc, Color overrideColor, ItemInfo sect)
|
||||||
{
|
{
|
||||||
if (mydoc.DocPdf == null || overrideColor.ToArgb() != mydoc.DocumentConfig.Printing_Color.ToArgb())
|
MSWordToPDF.OverrideColor = overrideColor;
|
||||||
{
|
PdfInfo myPdf = PdfInfo.Get(sect);
|
||||||
MSWordToPDF.OverrideColor = overrideColor;
|
|
||||||
return SetDocPdf(mydoc);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public static bool SetDocPdf(DocumentInfo docInfo)
|
public static bool SetDocPdf(DocumentInfo docInfo, ItemInfo sect)
|
||||||
{
|
{
|
||||||
string pdfTmp = null;
|
string pdfTmp = null;
|
||||||
List<string> roids = new List<string>();
|
List<string> roids = new List<string>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pdfTmp = MSWordToPDF.ToPDFReplaceROs(docInfo,roids);
|
pdfTmp = MSWordToPDF.ToPDFReplaceROs(docInfo,roids,sect);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -426,19 +431,18 @@ namespace VEPROMS.CSLA.Library
|
|||||||
pdfFile.Delete();
|
pdfFile.Delete();
|
||||||
using (Document doc = docInfo.Get())
|
using (Document doc = docInfo.Get())
|
||||||
{
|
{
|
||||||
DocumentConfig dc = new DocumentConfig(doc);
|
DocStyle myDocStyle = sect.MyActiveSection.MyDocStyle;
|
||||||
dc.Printing_Color = MSWordToPDF.OverrideColor;
|
using (Pdf myPdf = Pdf.MakePdf(doc, MSWordToPDF.DebugStatus, (int)myDocStyle.Layout.TopRow, (int)myDocStyle.Layout.PageLength,
|
||||||
doc.Config = dc.ToString();
|
(int)myDocStyle.Layout.LeftMargin, (int)myDocStyle.Layout.PageWidth, (double)sect.MSWordPageCount, buf)) { ;}
|
||||||
doc.DocPdf = buf;
|
|
||||||
doc.UpdateDRoUsages(roids);
|
doc.UpdateDRoUsages(roids);
|
||||||
doc.Save();
|
doc.Save();
|
||||||
}
|
}
|
||||||
docInfo.RefreshConfig();
|
docInfo.RefreshConfig();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public static string ToPDFReplaceROs(DocumentInfo doc,List<string> roids)
|
public static string ToPDFReplaceROs(DocumentInfo doc,List<string> roids, ItemInfo sect)
|
||||||
{
|
{
|
||||||
ItemInfo sect = doc.DocumentEntries[0].MyContent.ContentItems[0];
|
//ItemInfo sect = doc.DocumentEntries[0].MyContent.ContentItems[0];
|
||||||
return ToPDFReplaceROs(sect, false, roids);
|
return ToPDFReplaceROs(sect, false, roids);
|
||||||
}
|
}
|
||||||
public static string ToPDFReplaceROs(ItemInfo sect, bool openPdf, List<string> roids) //, System.Drawing.Color overrideColor, System.Windows.Forms.Form myForm)
|
public static string ToPDFReplaceROs(ItemInfo sect, bool openPdf, List<string> roids) //, System.Drawing.Color overrideColor, System.Windows.Forms.Form myForm)
|
||||||
@ -588,6 +592,7 @@ namespace VEPROMS.CSLA.Library
|
|||||||
sel.Range.Font.Color = (LBWdColor)WordColor(OverrideColor == System.Drawing.Color.Transparent ? System.Drawing.Color.Black : OverrideColor);
|
sel.Range.Font.Color = (LBWdColor)WordColor(OverrideColor == System.Drawing.Color.Transparent ? System.Drawing.Color.Black : OverrideColor);
|
||||||
sel.ParagraphFormat.LineSpacingRule = LBWdLineSpacing.wdLineSpaceExactly;
|
sel.ParagraphFormat.LineSpacingRule = LBWdLineSpacing.wdLineSpaceExactly;
|
||||||
sel.ParagraphFormat.LineSpacing = 12;
|
sel.ParagraphFormat.LineSpacing = 12;
|
||||||
|
sect.MSWordPageCount = myDoc.Length;
|
||||||
fileName = CreatePDF(fileName, openPdf);
|
fileName = CreatePDF(fileName, openPdf);
|
||||||
MyApp.ActiveDocument.Close(false);
|
MyApp.ActiveDocument.Close(false);
|
||||||
if (CloseWordWhenDone)
|
if (CloseWordWhenDone)
|
||||||
|
@ -297,6 +297,12 @@ namespace VEPROMS.CSLA.Library
|
|||||||
// return ii._ItemID == _ItemID;
|
// return ii._ItemID == _ItemID;
|
||||||
// return false;
|
// return false;
|
||||||
//}
|
//}
|
||||||
|
private float _MSWordPageCount = 0;
|
||||||
|
public float MSWordPageCount
|
||||||
|
{
|
||||||
|
get { return _MSWordPageCount; }
|
||||||
|
set { _MSWordPageCount = value; }
|
||||||
|
}
|
||||||
public event ItemInfoEvent OrdinalChanged;
|
public event ItemInfoEvent OrdinalChanged;
|
||||||
private void OnOrdinalChange()
|
private void OnOrdinalChange()
|
||||||
{
|
{
|
||||||
|
@ -247,14 +247,16 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
foreach (DROUsageInfo droUsg in affected)
|
foreach (DROUsageInfo droUsg in affected)
|
||||||
{
|
{
|
||||||
using (Document document = Document.Get(droUsg.DocID))
|
//using (Document document = Document.Get(droUsg.DocID))
|
||||||
{
|
//{
|
||||||
if (document.DocPdf != null)
|
Pdf.DeleteAll(droUsg.DocID);
|
||||||
{
|
// Delete PDFs
|
||||||
document.DocPdf = null;
|
//if (document.DocPdf != null)
|
||||||
document.Save();
|
//{
|
||||||
}
|
// document.DocPdf = null;
|
||||||
}
|
// document.Save();
|
||||||
|
//}
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user