BusinessMgr 3.0.0.1

This commit is contained in:
Andy Howard
2025-02-08 16:41:25 +00:00
parent 1692179120
commit c84980672b
101 changed files with 1397 additions and 907 deletions
@@ -364,14 +364,14 @@ namespace Sarand.Net.Standard.Proc.Excel
{
for (uint colPos = Math.Max(1, colPosStart); colPos <= values.Count; colPos++)
SetCellFormula(colPos, rowPos, values[(int)(colPos - 1)]);
return !HasErrorState();
return OK;
}
/// <summary>Set cell values across a row - override if more efficient method available.</summary>
public virtual bool SetRowValues(uint colPosStart, uint rowPos, List<DataValue> values)
{
for (uint colPos = Math.Max(1, colPosStart); colPos <= values.Count; colPos++)
SetCellValue(colPos, rowPos, values[(int)(colPos - 1)]);
return !HasErrorState();
return OK;
}
/// <summary>
@@ -391,7 +391,7 @@ namespace Sarand.Net.Standard.Proc.Excel
SetCellFormula(colPos, rowPos, values[valueIdx++]);
}
}
return !HasErrorState();
return OK;
}
/// <summary>
/// Set cell values across a range of cells - override if more efficient logic available.
@@ -410,7 +410,7 @@ namespace Sarand.Net.Standard.Proc.Excel
SetCellValue(colPos, rowPos, values[valueIdx++]);
}
}
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -531,7 +531,7 @@ namespace Sarand.Net.Standard.Proc.Excel
AutoFitRows(rangeHeadings);
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -136,7 +136,7 @@ namespace Sarand.Net.Standard.Proc.Excel
else return SetErrorState("Failed to open document: " + workbook.WorkbookArchive.ErrorStateMessage);
}
catch (Exception exc) { SetErrorState(ExceptionUtil.GetErrorStateMessage(exc)); }
return !HasErrorState();
return OK;
}
public bool OpenWorkbook(byte[] workbookData)
{
@@ -150,7 +150,7 @@ namespace Sarand.Net.Standard.Proc.Excel
}
}
catch (Exception exc) { SetErrorState(ExceptionUtil.GetErrorStateMessage(exc)); }
return !HasErrorState();
return OK;
}
public bool OpenWorkbook(Stream workbookStream)
{
@@ -170,7 +170,7 @@ namespace Sarand.Net.Standard.Proc.Excel
else return SetErrorState("Failed to open document: " + workbook.WorkbookArchive.ErrorStateMessage);
}
catch (Exception exc) { SetErrorState(ExceptionUtil.GetErrorStateMessage(exc)); }
return !HasErrorState();
return OK;
}
private bool ExtractWorkbookElementsFromArchive()
{
@@ -212,7 +212,7 @@ namespace Sarand.Net.Standard.Proc.Excel
}
}
catch (Exception exc) { SetErrorState(ExceptionUtil.GetErrorStateMessage(exc)); }
return !HasErrorState();
return OK;
}
public override bool CleanseWorkbook()
{
@@ -227,7 +227,7 @@ namespace Sarand.Net.Standard.Proc.Excel
return SetErrorState("Unsupported file format: " + ((XlFileFormat)fileFormat).ToString());
if (!IsWorkbookValid()) SetErrorState(Msg_WorkbookNotOpen);
SetErrorState("Saving workbook not supported");
return !HasErrorState();
return OK;
}
public override bool CloseWorkbook()
{
@@ -247,7 +247,7 @@ namespace Sarand.Net.Standard.Proc.Excel
catch (Exception exc) { SetErrorState(ExceptionUtil.GetErrorStateMessage(exc)); }
workbook = null;
}
return !HasErrorState();
return OK;
}
/// <summary>Extract the document as a byte array.</summary>
@@ -350,7 +350,7 @@ namespace Sarand.Net.Standard.Proc.Excel
if (worksheet.WorksheetDoc == null) return SetErrorState("Unable to load worksheet " + worksheetPos.ToString());
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -408,7 +408,7 @@ namespace Sarand.Net.Standard.Proc.Excel
if (worksheet.WorksheetDoc == null) return SetErrorState("Unable to load worksheet " + worksheetPos.ToString());
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -430,7 +430,7 @@ namespace Sarand.Net.Standard.Proc.Excel
worksheet = null;
}
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -138,7 +138,7 @@ namespace Sarand.Net.Standard.Proc.Excel
// ToDo Save OpenXML Excel document.
return !HasErrorState();
return OK;
}
public override bool CloseWorkbook()
{
@@ -155,7 +155,7 @@ namespace Sarand.Net.Standard.Proc.Excel
}
catch (Exception exc) { SaLogger.Warn(exc.GetType().Name + ".CloseWorkbook " + ExceptionUtil.GetErrorStateMessage(exc)); }
workbook = null;
return !HasErrorState();
return OK;
}
/// <summary>Extract the document as a byte array.</summary>
@@ -196,7 +196,7 @@ namespace Sarand.Net.Standard.Proc.Excel
OpenWorksheet(1);
}
else SetErrorState("SetWorksheetCount - Requested number of worksheets (" + worksheetCount.ToString() + ") must be between 1 and 10");
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -345,7 +345,7 @@ namespace Sarand.Net.Standard.Proc.Excel
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
worksheet = null;
activeWorksheetPos = 0;
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -371,7 +371,7 @@ namespace Sarand.Net.Standard.Proc.Excel
// ToDo OpenXml SetWorksheetAttr
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -494,7 +494,7 @@ namespace Sarand.Net.Standard.Proc.Excel
*/
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
public override bool SetPageBreak(uint colPos, uint rowPos)
{
@@ -511,7 +511,7 @@ namespace Sarand.Net.Standard.Proc.Excel
*/
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -564,7 +564,7 @@ namespace Sarand.Net.Standard.Proc.Excel
// ToDo OpenXML SetColWidth.
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -609,7 +609,7 @@ namespace Sarand.Net.Standard.Proc.Excel
// ToDo OpenXML SetRowHeight.
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -658,7 +658,7 @@ namespace Sarand.Net.Standard.Proc.Excel
// ToDo OpenXML SetRangeAttr.
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
private bool SetRangeAttr(Range oRange, SaMsExcelStyleAttr attr)
{
@@ -668,7 +668,7 @@ namespace Sarand.Net.Standard.Proc.Excel
// ToDo OpenXML SetRangeAttr.
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -684,7 +684,7 @@ namespace Sarand.Net.Standard.Proc.Excel
// ToDo OpenXML InsertImage.
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -696,7 +696,7 @@ namespace Sarand.Net.Standard.Proc.Excel
// ToDo OpenXML FreezePanes.
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -708,7 +708,7 @@ namespace Sarand.Net.Standard.Proc.Excel
// ToDo OpenXML AutoFit.
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -720,7 +720,7 @@ namespace Sarand.Net.Standard.Proc.Excel
// ToDo OpenXML SelectRange.
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -95,7 +95,7 @@ namespace Sarand.Net.Standard.Proc.Excel
}
}
catch (Exception exc) { SetErrorState(ExceptionUtil.GetErrorStateMessage(exc)); }
return !HasErrorState();
return OK;
}
public bool OpenWorkbook(byte[] workbookData)
{
@@ -109,7 +109,7 @@ namespace Sarand.Net.Standard.Proc.Excel
}
}
catch (Exception exc) { SetErrorState(ExceptionUtil.GetErrorStateMessage(exc)); }
return !HasErrorState();
return OK;
}
public bool OpenWorkbook(Stream workbookStream)
{
@@ -131,7 +131,7 @@ namespace Sarand.Net.Standard.Proc.Excel
}
}
catch (Exception exc) { SetErrorState(ExceptionUtil.GetErrorStateMessage(exc)); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -152,7 +152,7 @@ namespace Sarand.Net.Standard.Proc.Excel
}
}
catch (Exception exc) { SetErrorState(SysUtil.Fn + " " + ExceptionUtil.GetErrorStateMessage(exc)); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -181,7 +181,7 @@ namespace Sarand.Net.Standard.Proc.Excel
}
catch (Exception exc) { SetErrorState(ExceptionUtil.GetErrorStateMessage(exc)); }
}
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -192,7 +192,7 @@ namespace Sarand.Net.Standard.Proc.Excel
// Clear workbook.
if (workbook != null)
workbook = null;
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -253,7 +253,7 @@ namespace Sarand.Net.Standard.Proc.Excel
OpenWorksheet(1);
}
else SetErrorState(SysUtil.Fn + " - Requested number of worksheets (" + worksheetCount.ToString() + ") must be between 1 and 10");
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -367,7 +367,7 @@ namespace Sarand.Net.Standard.Proc.Excel
worksheet = workbook.GetSheetAt(worksheetIdx);
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -393,7 +393,7 @@ namespace Sarand.Net.Standard.Proc.Excel
SetErrorState("Worksheet not found.");
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -405,7 +405,7 @@ namespace Sarand.Net.Standard.Proc.Excel
return SetErrorState(Msg_WorkbookNotOpen);
if (worksheet != null)
worksheet = null;
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -550,7 +550,7 @@ namespace Sarand.Net.Standard.Proc.Excel
}
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -572,7 +572,7 @@ namespace Sarand.Net.Standard.Proc.Excel
{
HandleException(SysUtil.Fn, exc);
}
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -616,7 +616,7 @@ namespace Sarand.Net.Standard.Proc.Excel
worksheet.SetColumnWidth((int)(colPos - 1), (int)Math.Ceiling(widthPixels * 256 / DEFAULT_CHARACTER_WIDTH));
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -681,7 +681,7 @@ namespace Sarand.Net.Standard.Proc.Excel
row.Height = (short)height;
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -875,7 +875,7 @@ namespace Sarand.Net.Standard.Proc.Excel
SetRangeAttr(range, attr);
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
public override bool SetCellValue(uint colPos, uint rowPos, DataValue value, SaMsExcelStyleAttr attr)
@@ -889,7 +889,7 @@ namespace Sarand.Net.Standard.Proc.Excel
SetRangeAttr(range, attr);
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -963,7 +963,7 @@ namespace Sarand.Net.Standard.Proc.Excel
}
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
public override bool SetRowValues(uint colPosStart, uint rowPos, List<DataValue> values)
@@ -980,7 +980,7 @@ namespace Sarand.Net.Standard.Proc.Excel
}
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
@@ -1139,7 +1139,7 @@ namespace Sarand.Net.Standard.Proc.Excel
}
}
catch (Exception exc) { HandleException(SysUtil.Fn, exc); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
+3 -3
View File
@@ -41,7 +41,7 @@ namespace Sarand.Net.Standard.Proc.Xml
document = new XmlDocument();
if (!StringUtil.IsEmpty(rootElementName))
document.AppendElement(rootElementName);
return !HasErrorState();
return OK;
}
public bool LoadXml (String xml)
{
@@ -52,7 +52,7 @@ namespace Sarand.Net.Standard.Proc.Xml
document.LoadXml(xml);
}
catch (Exception exc) { SetErrorState(ExceptionUtil.GetErrorStateMessage(exc)); }
return !HasErrorState();
return OK;
}
public bool LoadXml (Stream xml)
{
@@ -64,7 +64,7 @@ namespace Sarand.Net.Standard.Proc.Xml
document.Load(xml);
}
catch (Exception exc) { SetErrorState(ExceptionUtil.GetErrorStateMessage(exc)); }
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------
+3 -3
View File
@@ -53,7 +53,7 @@ namespace Sarand.Net.Standard.Proc.Zip
SaLogger.Warn($"{SysUtil.Fn} {ExceptionUtil.GetLogMessage(exc)}");
return SetErrorState(ExceptionUtil.GetErrorStateMessage(exc));
}
return !HasErrorState();
return OK;
}
/// <summary>Open ZIP archive from data stream.</summary>
public bool OpenArchive (Stream stream, ZipArchiveMode mode = ZipArchiveMode.Read, bool leaveOpen = true, Encoding entryNameEncoding = null)
@@ -72,7 +72,7 @@ namespace Sarand.Net.Standard.Proc.Zip
SaLogger.Warn($"{SysUtil.Fn} {ExceptionUtil.GetLogMessage(exc)}");
return SetErrorState(ExceptionUtil.GetErrorStateMessage(exc));
}
return !HasErrorState();
return OK;
}
public bool IsArchiveOpen ()
{
@@ -92,7 +92,7 @@ namespace Sarand.Net.Standard.Proc.Zip
SaLogger.Warn($"{SysUtil.Fn} {ExceptionUtil.GetLogMessage(exc)}");
}
zipArchive = null;
return !HasErrorState();
return OK;
}
//-------------------------------------------------------------------