Updated code to save the DocAscii field.
This commit is contained in:
parent
88fcff5852
commit
24c892b008
@ -6,7 +6,6 @@ using Csla;
|
||||
using Csla.Data;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using EPocalipse.IFilter;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
@ -20,45 +19,23 @@ namespace VEPROMS.CSLA.Library
|
||||
return _LibTitle;
|
||||
}
|
||||
}
|
||||
public void UpdateDocAscii(string fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
DocAscii = null;
|
||||
// Opening the file directly gives a sharing violation.
|
||||
// Therefore, the file is copied and the copy is used and then deleted.
|
||||
FileInfo myFile = new FileInfo(fileName);
|
||||
FileInfo tempFile = new FileInfo(myFile.DirectoryName + "\\tmp_" + myFile.Name);
|
||||
myFile.CopyTo(tempFile.FullName); // Copy to the temporary file
|
||||
using (FilterReader reader = new FilterReader(tempFile.FullName)) // Open the IFilter Reader
|
||||
{
|
||||
DocAscii = FixString(reader.ReadToEnd()); // Read the ascii text
|
||||
reader.Close(); // Close the reader
|
||||
}
|
||||
tempFile.Delete();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Converting Document to ascii, error is {0}", ex.Message);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// FixString processes the string returned and changes any symbols (0xF0??) to normal characters
|
||||
/// </summary>
|
||||
/// <param name="str"></param>
|
||||
/// <returns></returns>
|
||||
private static string FixString(string str)
|
||||
{
|
||||
StringBuilder results = new StringBuilder();
|
||||
foreach (char c in str)
|
||||
{
|
||||
if ((c & 0xFF00) == 0xF000)
|
||||
results.Append((char)(c & 0xFF));
|
||||
else
|
||||
results.Append((char)(c));
|
||||
}
|
||||
return results.ToString();
|
||||
}
|
||||
//private static string FixString(string str)
|
||||
//{
|
||||
// StringBuilder results = new StringBuilder();
|
||||
// foreach (char c in str)
|
||||
// {
|
||||
// if ((c & 0xFF00) == 0xF000)
|
||||
// results.Append((char)(c & 0xFF));
|
||||
// else
|
||||
// results.Append((char)(c));
|
||||
// }
|
||||
// return results.ToString();
|
||||
//}
|
||||
}
|
||||
public partial class DocumentInfo
|
||||
{
|
||||
@ -304,7 +281,7 @@ namespace VEPROMS.CSLA.Library
|
||||
_MyFile = new FileInfo(value);
|
||||
}
|
||||
}
|
||||
public void SaveFile(float length)
|
||||
public void SaveFile(float length,string ascii)
|
||||
{
|
||||
// TODO: Add Try & Catch logic
|
||||
if (_MyDocument == null) return;
|
||||
@ -315,7 +292,8 @@ namespace VEPROMS.CSLA.Library
|
||||
fs.Close();
|
||||
doc.FileExtension = MyFile.Extension;
|
||||
doc.DocContent = buf;
|
||||
doc.UpdateDocAscii(_MyFile.FullName);
|
||||
doc.DocAscii = ascii;
|
||||
//doc.UpdateDocAscii(_MyFile.FullName);
|
||||
DocumentConfig cfg = new DocumentConfig(doc);
|
||||
cfg.Printing_Length = length;
|
||||
doc.Config = cfg.ToString();
|
||||
|
Loading…
x
Reference in New Issue
Block a user