Update the Progress Bar as the RO values are refreshed in Word
This commit is contained in:
@@ -17,6 +17,13 @@ using System.Diagnostics;
|
||||
|
||||
namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
public enum VolianStatusType
|
||||
{
|
||||
Initialize,
|
||||
Update,
|
||||
Complete
|
||||
}
|
||||
public delegate void VolianStatusChange(VolianStatusType type, int count, string text);
|
||||
public partial class Document
|
||||
{
|
||||
public string DocumentTitle
|
||||
@@ -363,7 +370,7 @@ namespace VEPROMS.CSLA.Library
|
||||
_MyFile = new FileInfo(value);
|
||||
}
|
||||
}
|
||||
public void SaveFile(float length, string ascii, ItemInfo myItemInfo, bool cvtLibDoc)
|
||||
public void SaveFile(float length, string ascii, ItemInfo myItemInfo, bool cvtLibDoc, VolianStatusChange statusChange)
|
||||
{
|
||||
// TODO: Add Try & Catch logic
|
||||
if (_MyDocument == null) return;
|
||||
@@ -405,7 +412,7 @@ namespace VEPROMS.CSLA.Library
|
||||
doc.DTS = _MyFile.LastWriteTimeUtc;
|
||||
doc = doc.Save();
|
||||
List<string> roids = new List<string>();
|
||||
string pdfTmp = MSWordToPDF.ToPDFReplaceROs(_MyDocument, roids, myItemInfo);
|
||||
string pdfTmp = MSWordToPDF.ToPDFReplaceROs(_MyDocument, roids, myItemInfo,statusChange);
|
||||
FileInfo pdfFile = new FileInfo(pdfTmp);
|
||||
fs = pdfFile.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
buf = new byte[pdfFile.Length];
|
||||
@@ -516,7 +523,7 @@ namespace VEPROMS.CSLA.Library
|
||||
List<string> roids = new List<string>();
|
||||
try
|
||||
{
|
||||
pdfTmp = MSWordToPDF.ToPDFReplaceROs(docInfo,roids,sect);
|
||||
pdfTmp = MSWordToPDF.ToPDFReplaceROs(docInfo,roids,sect,null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -548,13 +555,13 @@ namespace VEPROMS.CSLA.Library
|
||||
docInfo.RefreshConfig();
|
||||
return true;
|
||||
}
|
||||
public static string ToPDFReplaceROs(DocumentInfo doc,List<string> roids, ItemInfo sect)
|
||||
public static string ToPDFReplaceROs(DocumentInfo doc, List<string> roids, ItemInfo sect, VolianStatusChange statusChange)
|
||||
{
|
||||
//ItemInfo sect = doc.DocumentEntries[0].MyContent.ContentItems[0];
|
||||
return ToPDFReplaceROs(sect, false, roids);
|
||||
return ToPDFReplaceROs(sect, false, roids, statusChange);
|
||||
}
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
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, VolianStatusChange statusChange) //, System.Drawing.Color overrideColor, System.Windows.Forms.Form myForm)
|
||||
{
|
||||
string fileName = GetFileName(sect);
|
||||
// TODO: do we want to cache the word pdfs
|
||||
@@ -653,9 +660,14 @@ namespace VEPROMS.CSLA.Library
|
||||
selxy.WholeStory();
|
||||
selxy = FindXyPlot();
|
||||
}
|
||||
LBSelection sel = hasRos ? FindRO() : null;
|
||||
LBSelection sel = MyApp.Selection;
|
||||
sel.WholeStory();
|
||||
if(statusChange != null) statusChange(VolianStatusType.Initialize, sel.End, "Refreshing ROs");
|
||||
sel = hasRos ? FindRO() : null;
|
||||
int roCount = 0;
|
||||
while (sel != null)
|
||||
{
|
||||
if (statusChange != null) statusChange(VolianStatusType.Update, sel.Start, string.Format("{0} ROs Refreshed", ++roCount));
|
||||
string val = lookup.GetROValueByAccPagID(sel.Text, spPrefix, igPrefix);
|
||||
int? type = lookup.GetROTypeByAccPagID(sel.Text, spPrefix, igPrefix);
|
||||
// if type is null, then set type to zero so that InsertROValue will put in "RO Not Found" for the value
|
||||
@@ -753,6 +765,7 @@ namespace VEPROMS.CSLA.Library
|
||||
}
|
||||
sel = FindRO();
|
||||
}
|
||||
if (statusChange != null) statusChange(VolianStatusType.Update, 0, "Creating PDF");
|
||||
sel = MyApp.Selection;
|
||||
sel.WholeStory();
|
||||
//sel.Range.Font.Color = (LBWdColor)WordColor(PrintOverride.OverrideTextColor(System.Drawing.Color.Black));
|
||||
@@ -764,6 +777,7 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
CloseAppAfterWait();
|
||||
}
|
||||
if (statusChange != null) statusChange(VolianStatusType.Complete, 0, "");
|
||||
return fileName;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user