This commit is contained in:
parent
271c1ce923
commit
d207a0eefa
@ -273,7 +273,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
_MyFile = new FileInfo(string.Format(@"{0}\tmp_{1}{2}{3}", VlnSettings.TemporaryFolder, MyDocument.DocID, Unique, MyDocument.FileExtension));
|
||||
FileStream fs = _MyFile.Create();
|
||||
if(MyDocument.DocContent != null)fs.Write(MyDocument.DocContent, 0, MyDocument.DocContent.Length);
|
||||
if (MyDocument.DocContent != null) fs.Write(MyDocument.DocContent, 0, MyDocument.DocContent.Length);
|
||||
fs.Close();
|
||||
_MyFile.CreationTime = _MyDocument.DTS;
|
||||
_MyFile.LastWriteTime = _MyDocument.DTS;
|
||||
@ -290,19 +290,41 @@ namespace VEPROMS.CSLA.Library
|
||||
get { return _MyFile.FullName; }
|
||||
set
|
||||
{
|
||||
if(FullName != value)
|
||||
if (FullName != value)
|
||||
_MyFile = new FileInfo(value);
|
||||
}
|
||||
}
|
||||
public void SaveFile(float length,string ascii,ItemInfo myItemInfo)
|
||||
public void SaveFile(float length, string ascii, ItemInfo myItemInfo, bool cvtLibDoc)
|
||||
{
|
||||
// TODO: Add Try & Catch logic
|
||||
if (_MyDocument == null) return;
|
||||
Document doc = _MyDocument.Get();
|
||||
FileStream fs = _MyFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
Byte[] buf = new byte[_MyFile.Length];
|
||||
fs.Read(buf,0,buf.Length);
|
||||
fs.Read(buf, 0, buf.Length);
|
||||
fs.Close();
|
||||
|
||||
// Handle if this is a libdoc & the user wanted to convert to a non-library document.
|
||||
if (cvtLibDoc)
|
||||
{
|
||||
// if just one usage (this one), then just convert this to a non-library document. If there is more
|
||||
// than one usage, make a copy so that the rest of the usages still point to the library document.
|
||||
if (doc.DocumentEntryCount == 1)
|
||||
doc.LibTitle = null;
|
||||
else
|
||||
{
|
||||
// make new document with 'no' libtitle. Then link this to the item/content via the entry.
|
||||
// the data gets set below.
|
||||
Document tdoc = Document.MakeDocument(null, null, null, null);
|
||||
_MyDocument = DocumentInfo.Get(doc.DocID);
|
||||
doc = tdoc;
|
||||
using (Entry ent = myItemInfo.MyContent.MyEntry.Get())
|
||||
{
|
||||
ent.MyDocument = tdoc;
|
||||
ent.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
doc.FileExtension = MyFile.Extension;
|
||||
doc.DocContent = buf;
|
||||
doc.DocAscii = ascii;
|
||||
@ -313,7 +335,7 @@ namespace VEPROMS.CSLA.Library
|
||||
doc.DTS = _MyFile.LastWriteTime;
|
||||
doc = doc.Save();
|
||||
List<string> roids = new List<string>();
|
||||
string pdfTmp = MSWordToPDF.ToPDFReplaceROs(_MyDocument,roids,myItemInfo);
|
||||
string pdfTmp = MSWordToPDF.ToPDFReplaceROs(_MyDocument, roids, myItemInfo);
|
||||
FileInfo pdfFile = new FileInfo(pdfTmp);
|
||||
fs = pdfFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
buf = new byte[pdfFile.Length];
|
||||
@ -322,8 +344,8 @@ namespace VEPROMS.CSLA.Library
|
||||
pdfFile.Delete();
|
||||
Pdf.DeleteAll(doc.DocID); // clear the PDF table for DocID first
|
||||
DocStyle myDocStyle = myItemInfo.ActiveSection.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)) { ;}
|
||||
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.Save();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user