This commit is contained in:
Kathy Ruffing 2011-04-27 11:18:37 +00:00
parent 271c1ce923
commit d207a0eefa

View File

@ -294,7 +294,7 @@ namespace VEPROMS.CSLA.Library
_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;
@ -303,6 +303,28 @@ namespace VEPROMS.CSLA.Library
Byte[] buf = new byte[_MyFile.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;