Web app logon.

This commit is contained in:
Andy Howard
2024-06-04 16:16:05 +01:00
parent f5e0b925fb
commit 0c44e9ddd3
70 changed files with 2624 additions and 1331 deletions
@@ -154,7 +154,6 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Consoles
//----------------------------------------------------------------
// Log process definition.
SaLogger.Info("Running process: " + processDfn.ProcessName + "." + (processDfn.Params.Count > 0 ? " Params: " + processDfn.Params.Concat() : ""), true);
SbmProcessConsole_Notifier processNotifier = new SbmProcessConsole_Notifier();
//----------------------------------------------------------------
// Hapag-Lloyd EDI.
@@ -170,7 +169,6 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Consoles
configInterface.ImportNotifications = true;
configInterface.Automated = true;
SbmInterface_System_HapagLloyd_Import process = new SbmInterface_System_HapagLloyd_Import(configInterface);
process.ProcessNotifier = processNotifier;
process.RunProcess();
if (process.HasProcessError())
SaLogger.Warn(caption + " reported: " + process.GetProcessError(), true);
@@ -219,20 +217,4 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Consoles
//-------------------------------------------------------------------
}
//=======================================================================
/// <summary>
/// Process Notificer for Process Console.
/// </summary>
class SbmProcessConsole_Notifier : ISacsProcessNotifier
{
public void OnStartProcess()
{
}
public void OnEndProcess()
{
}
public void SetProgressInfo(List<string> progressInfo)
{
}
}
//=======================================================================
}
@@ -78,6 +78,10 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
{
this.config = config;
interfaceObj = InterfaceConsole.GetInterfaceById(config.InterfaceId);
// Events.
base.OnProcessStarting += SbmInterfaceProcess_OnProcessStarting;
base.OnProgressInfoUpdated += SbmInterfaceProcess_OnProgressInfoUpdated;
base.OnProcessCompleted += SbmInterfaceProcess_OnProcessCompleted;
}
protected override void Dispose(bool disposing)
{
@@ -132,16 +136,19 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
//-------------------------------------------------------------------
// P r o c e s s i n g E v e n t s
//-------------------------------------------------------------------
protected override void OnProcessStarting()
private void SbmInterfaceProcess_OnProcessStarting(object sender, ProcessStartingEventArgs e)
{
base.OnProcessStarting();
if (config.InterfaceProcessCreation == InterfaceProcessCreation.OnStartProcessing)
OpenInterfaceProcess();
}
protected override void OnProcessEnding()
private void SbmInterfaceProcess_OnProgressInfoUpdated(object sender, ProgressInfoUpdatedEventArgs e)
{
}
private void SbmInterfaceProcess_OnProcessCompleted(object sender, ProcessCompletedEventArgs e)
{
CloseInterfaceProcess();
base.OnProcessEnding();
}
//-------------------------------------------------------------------
@@ -176,13 +183,13 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
{
// Process has not completed.
interfaceProcess.Status = SaStatus.Cancelled;
if (HasProcessError()) LogInterfaceProcessMessage(GetProcessError(), SaMessageLevel.Error);
if (HasErrorMessage()) LogInterfaceProcessMessage(GetErrorMessage(), SaMessageLevel.Error);
if (IsInterrupted) LogInterfaceProcessMessage("Processing cancelled by user", SaMessageLevel.Warning);
}
if (InterfaceConsole.StoreInterfaceProcess(interfaceProcess, DbUpdateInfo))
{ }
else if (!HasProcessError())
SetProcessError("Failed to store interface process: " + InterfaceConsole.ErrorStateMessage);
else if (!HasErrorMessage())
AddErrorMessage("Failed to store interface process: " + InterfaceConsole.ErrorStateMessage);
// Clean-up.
interfaceProcess.Dispose();
@@ -229,7 +236,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
// Store interface data item.
if (!InterfaceConsole.StoreInterfaceDataItem(interfaceDataItem, DbUpdateInfo))
SetProcessError("Failed to save Interface data item" + (!StringUtil.IsEmpty(itemCaption) ? " for " + itemCaption : "") + " - " + InterfaceConsole.ErrorStateMessage);
AddErrorMessage("Failed to save Interface data item" + (!StringUtil.IsEmpty(itemCaption) ? " for " + itemCaption : "") + " - " + InterfaceConsole.ErrorStateMessage);
return OK;
}
@@ -29,7 +29,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
// Configuration.
public new class Config : SbmInterfaceProcess.Config
{
public Config (ISbmUserContext userContext) : base(userContext)
public Config(ISbmUserContext userContext) : base(userContext)
{
ItemType = Sbm.ItemType.Commodity;
ProcessType = ProcessType.ExportData;
@@ -117,12 +117,12 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
//-------------------------------------------------------------------
// Construction.
public SbmInterfaceProcess_Commodity_Export (Config config) : base(config)
public SbmInterfaceProcess_Commodity_Export(Config config) : base(config)
{
this.config = config;
interfaceOptions = SbmSystem.GetCodesOfType(UserContext, Sbm.SystemCode.InterfaceOption);
}
protected override void Dispose (bool disposing)
protected override void Dispose(bool disposing)
{
if (disposing)
{
@@ -159,7 +159,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
//-------------------------------------------------------------------
// Utilities.
private void CalculateItemCount ()
private void CalculateItemCount()
{
if (Params.CommodityCountTotal >= 0 || !OK) return;
Params.CommodityCountTotal = CommodityMgr.GetCommodityCount(GetParams());
@@ -168,7 +168,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
//-------------------------------------------------------------------
// I n t e r f a c e P a r a m e t e r s
//-------------------------------------------------------------------
private bool PopulateInterfaceParams ()
private bool PopulateInterfaceParams()
{
interfaceParams = new InterfaceParams();
@@ -230,7 +230,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
int columnPos = StringUtil.ToInt(columnOption.Context);
SbmCommodity.Column eCol = (SbmCommodity.Column)optionValues_Column.GetTypeForCode(columnOption.Value);
if (columnPos <= previousColumnPos)
return SetProcessError("Out of sequence column found in configuration: '" + columnOption.Value + "' for column '" + columnOption.Context + "'");
return AddErrorMessage("Out of sequence column found in configuration: '" + columnOption.Value + "' for column '" + columnOption.Context + "'");
if (columnPos > 0 && columnPos <= kiMaxDataColumn)
{
ColumnDfn col = CommodityMgr.GetCommodityColumnDfn(eCol);
@@ -241,9 +241,9 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
interfaceParams.Columns.Add(columnNull);
interfaceParams.Columns[columnPos - 1] = col;
}
else return SetProcessError("Invalid field specified in configuration: '" + columnOption.Value + "' for column '" + columnOption.Context + "'");
else return AddErrorMessage("Invalid field specified in configuration: '" + columnOption.Value + "' for column '" + columnOption.Context + "'");
}
else return SetProcessError("Invalid column specified in configuration: '" + columnOption.Value + "'");
else return AddErrorMessage("Invalid column specified in configuration: '" + columnOption.Value + "'");
}
return true;
}
@@ -251,7 +251,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
//-------------------------------------------------------------------
// P r o c e s s i n g
//-------------------------------------------------------------------
protected override bool Run ()
protected override bool Run()
{
SetProgress("Preparing to export commodities.");
SaLogger.Info("Process: " + ProcessDescription);
@@ -265,17 +265,17 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
ExportCommodityData_Csv();
else if (interfaceParams.ExportMode == Sbm.FileInterface_Mode.MsExcel)
ExportCommodityData_Excel();
else return SetProcessError("Invalid Commodity export mode: " + interfaceParams.ExportMode.ToString());
else return AddErrorMessage("Invalid Commodity export mode: " + interfaceParams.ExportMode.ToString());
// Log statistics.
int commoditiesExported = GetStatistic(ProcessingStatistic.CommoditiesExported);
if (commoditiesExported > 0) LogInterfaceProcessMessage("Commodites exported: " + commoditiesExported.ToString());
return !HasProcessError();
return !HasErrorMessage();
}
//-------------------------------------------------------------------
protected override void ResetProcess ()
protected override void ResetProcess()
{
base.ResetProcess();
@@ -288,42 +288,42 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
}
//-------------------------------------------------------------------
protected override bool ValidateConfig ()
protected override bool ValidateConfig()
{
if (!base.ValidateConfig()) return false;
// Configuration:
if (!SysId.IsValid(config.InterfaceId)) return SetProcessError("Interface Id must be supplied.");
if (!config.ExportCommodities) return SetProcessError("No processing options selected.");
if (!SysId.IsValid(config.InterfaceId)) return AddErrorMessage("Interface Id must be supplied.");
if (!config.ExportCommodities) return AddErrorMessage("No processing options selected.");
// Processing parameters.
if (!PopulateInterfaceParams()) return false;
if (interfaceParams.ExportMode <= 0) return SetProcessError("Invalid export mode specified.");
if (interfaceParams.ExportMode <= 0) return AddErrorMessage("Invalid export mode specified.");
if (interfaceParams.ExportMode == Sbm.FileInterface_Mode.Csv && StringUtil.IsEmpty(interfaceParams.OutputFolder))
return SetProcessError("Output folder must be specified for 'CSV' mode.");
return AddErrorMessage("Output folder must be specified for 'CSV' mode.");
if (interfaceParams.FirstDataRow < 1 || interfaceParams.FirstDataRow > 100)
return SetProcessError("Invalid first data row (" + (interfaceParams.FirstDataRow) + ")");
return AddErrorMessage("Invalid first data row (" + (interfaceParams.FirstDataRow) + ")");
// Validate the output folder.
if (!StringUtil.IsEmpty(interfaceParams.OutputFolder) && !DirectoryUtil.DirectoryExists(interfaceParams.OutputFolder))
return SetProcessError("Invalid export folder specified - " + interfaceParams.OutputFolder);
return AddErrorMessage("Invalid export folder specified - " + interfaceParams.OutputFolder);
if (interfaceParams.Columns.Count < 1)
return SetProcessError("At least one data column must be specified");
return AddErrorMessage("At least one data column must be specified");
return OK;
}
//-------------------------------------------------------------------
/// <summary>Construct the commodity filter parameters.</summary>
public SbmCommodity.Params GetParams ()
public SbmCommodity.Params GetParams()
{
SbmCommodity.Params prmCommodity = config.CommodityParams ?? new SbmCommodity.Params();
prmCommodity.IncludedIds.AddRange(config.ItemIds);
return prmCommodity;
}
private DbResultSet ExecuteQuery ()
private DbResultSet ExecuteQuery()
{
if (!OK) return null;
@@ -333,12 +333,12 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
if (!queryColumns.HasId(SbmCommodity.Column.Id)) queryColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Id));
if (!queryColumns.HasId(SbmCommodity.Column.Code)) queryColumns.Add(CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Code));
// Query data.
SbmCommodity.Params prmCommodity =GetParams();
SbmCommodity.Params prmCommodity = GetParams();
DbResultSet resultSet = CommodityMgr.ExecuteCommodityQuery(queryColumns, prmCommodity);
if (resultSet == null) SetProcessError("Failed to query data - " + CommodityMgr.ErrorStateMessage);
if (resultSet == null) AddErrorMessage("Failed to query data - " + CommodityMgr.ErrorStateMessage);
return resultSet;
}
private DataValue GetDataValue (ColumnDfn column, NamedValue.Map values)
private DataValue GetDataValue(ColumnDfn column, NamedValue.Map values)
{
DataValue value = new DataValue();
SbmCommodity.Column columnId = (SbmCommodity.Column)column.Id;
@@ -362,7 +362,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
//-------------------------------------------------------------------
// E x p o r t T o C S V
//-------------------------------------------------------------------
private bool ExportCommodityData_Csv ()
private bool ExportCommodityData_Csv()
{
String fn = this.GetFn("ExportCommodityData_Csv");
if (!OK) return false;
@@ -374,10 +374,10 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
{
// Progress is refreshed every few rows.
Params.CommodityCountTotal = CommodityMgr.GetCommodityCount(GetParams());
int progressRefreshRows = (int)Math.Max(5,Params.CommodityCountTotal/(Params.CommodityCountTotal>1000?1000:100));
int progressRefreshRows = (int)Math.Max(5, Params.CommodityCountTotal / (Params.CommodityCountTotal > 1000 ? 1000 : 100));
// Open the output file.
String sFilename = FileUtil.FormatFilename("SaBusMgr_CommodityExport_" + DateUtil.Format(DateTime.Now,"yyyyMMddHHmmss") + ".csv");
String sFilename = FileUtil.FormatFilename("SaBusMgr_CommodityExport_" + DateUtil.Format(DateTime.Now, "yyyyMMddHHmmss") + ".csv");
String sOutputPath = interfaceParams.OutputFolder + FileUtil.GetPathDelim(interfaceParams.OutputFolder) + sFilename;
using (StreamWriter textWriter = new StreamWriter(sFilename, false))
{
@@ -390,8 +390,8 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
SetProgress(progressPrefix + "\nQuerying data");
using (DbResultSet resultSet = ExecuteQuery())
{
if (resultSet.HasErrorState()) return SetProcessError(resultSet.ErrorState.Message);
if (resultSet == null) return SetProcessError("Failed to query commodity data");
if (resultSet.HasErrorState()) return AddErrorMessage(resultSet.ErrorState.Message);
if (resultSet == null) return AddErrorMessage("Failed to query commodity data");
while (OK && resultSet != null && resultSet.NextRecord())
{
Params.ItemBeingExported++;
@@ -416,7 +416,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
catch (Exception exc)
{
SaLogger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc));
return SetProcessError(ExceptionUtil.GetErrorStateMessage(exc));
return AddErrorMessage(ExceptionUtil.GetErrorStateMessage(exc));
}
return OK;
}
@@ -424,7 +424,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
//-------------------------------------------------------------------
// E x p o r t T o E x c e l
//-------------------------------------------------------------------
private bool ExportCommodityData_Excel ()
private bool ExportCommodityData_Excel()
{
String fn = this.GetFn("ExportCommodityData_Excel");
if (!OK) return false;
@@ -438,14 +438,15 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
using (SaMsSpreadsheet spreadsheet = new SaMsSpreadsheet_POI())
{
spreadsheet.CreateWorkbook();
SaMsExcelStyleAttr attrSheet = new SaMsExcelStyleAttr();
attrSheet.FontAttr.Name = interfaceParams.Font_Name;
attrSheet.FontAttr.HeightInPoints = interfaceParams.Font_Size_Data;
spreadsheet.ApplyDefaultStyle(attrSheet);
spreadsheet.SetWorksheetCount(1);
OpenWorkSheet(spreadsheet, 1, "Commodities");
SaMsExcelItemAttr attrSheet = new SaMsExcelItemAttr();
attrSheet.FontName = interfaceParams.Font_Name;
attrSheet.FontSize = interfaceParams.Font_Size_Data;
spreadsheet.SetWorksheetAttr(attrSheet);
// Margins.
SaMsExcelPageSetup_Config cfgPageSetup = new SaMsExcelPageSetup_Config();
cfgPageSetup.Unit = SaExcelLogicalUnit.Cm;
@@ -462,14 +463,14 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
{
SetProgress(progressPrefix + "\nPopulating column headers");
SaMsExcelColumnHeading_Config cfgHeadings = new SaMsExcelColumnHeading_Config();
cfgHeadings.HeadingFontSize = interfaceParams.Font_Size_Header;
cfgHeadings.FirstHeadingRow = Params.FirstDataRow;
cfgHeadings.FontAttr.HeightInPoints = interfaceParams.Font_Size_Header;
cfgHeadings.FirstHeadingRowPos = Params.FirstDataRow;
int colPos_Code = interfaceParams.Columns.GetPosForId(SbmCommodity.Column.Code);
if (colPos_Code > 0)
Params.FreezeColumn = (uint)(colPos_Code + Params.FirstDataColumn);
cfgHeadings.FreezeColumn = Params.FreezeColumn;
cfgHeadings.FreezeColPos = Params.FreezeColumn;
if (interfaceParams.BackgroundColour_Header != -1)
cfgHeadings.InteriorColour = interfaceParams.BackgroundColour_Header;
cfgHeadings.ForegroundColourRGB = interfaceParams.BackgroundColour_Header;
spreadsheet.SetColumnHeadings(interfaceParams.Columns, cfgHeadings);
Params.FirstDataRow++;
}
@@ -488,28 +489,28 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
catch (Exception exc)
{
SaLogger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc));
return SetProcessError(ExceptionUtil.GetErrorStateMessage(exc));
return AddErrorMessage(ExceptionUtil.GetErrorStateMessage(exc));
}
return OK;
}
//-------------------------------------------------------------------
private bool ExportDataToExcel (SaMsSpreadsheet spreadsheet, String progressPrefix)
private bool ExportDataToExcel(SaMsSpreadsheet spreadsheet, String progressPrefix)
{
if (!OK) return false;
String dataName_Code = CommodityMgr.GetCommodityColumnDfn(SbmCommodity.Column.Code).DataName;
// Progress is refreshed every few rows.
Params.CommodityCountTotal = CommodityMgr.GetCommodityCount(GetParams());
int progressRefreshRows = (int)Math.Max(5,Params.CommodityCountTotal/(Params.CommodityCountTotal>1000?1000:100));
int progressRefreshRows = (int)Math.Max(5, Params.CommodityCountTotal / (Params.CommodityCountTotal > 1000 ? 1000 : 100));
// Query data.
SetProgress(progressPrefix + "\nQuerying data");
using (DbResultSet resultSet = ExecuteQuery())
{
if (resultSet.HasErrorState()) return SetProcessError(resultSet.ErrorState.Message);
if (resultSet == null) return SetProcessError("Failed to query commodity data");
if (resultSet.HasErrorState()) return AddErrorMessage(resultSet.ErrorState.Message);
if (resultSet == null) return AddErrorMessage("Failed to query commodity data");
while (OK && resultSet != null && resultSet.NextRecord())
{
Params.ItemBeingExported++;
@@ -544,50 +545,50 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
case SbmCommodity.Column.Id:
break;
case SbmCommodity.Column.Image:
{
// Retrieve the image path.
String sImagePath = GetDataValue(columnDfn, values).ToString();
// Configure image.
SaMsExcelImage_Config cfgImg = new SaMsExcelImage_Config();
cfgImg.ImagePath = CommodityMgr.GetActualImagePath(sImagePath);
cfgImg.ColPos = colPos;
cfgImg.RowPos = rowPos;
cfgImg.Unit = SaExcelLogicalUnit.Cm;
if (FileUtil.IsFile(cfgImg.ImagePath))
{
if (interfaceParams.DataRowHeightCm > 0)
cfgImg.TargetHeight = interfaceParams.DataRowHeightCm;
spreadsheet.InsertImage(cfgImg);
// Retrieve the image path.
String sImagePath = GetDataValue(columnDfn, values).ToString();
// Configure image.
SaMsExcelImage_Config cfgImg = new SaMsExcelImage_Config();
cfgImg.ImagePath = CommodityMgr.GetActualImagePath(sImagePath);
cfgImg.ColPos = colPos;
cfgImg.RowPos = rowPos;
cfgImg.Unit = SaExcelLogicalUnit.Cm;
if (FileUtil.IsFile(cfgImg.ImagePath))
{
if (interfaceParams.DataRowHeightCm > 0)
cfgImg.TargetHeight = interfaceParams.DataRowHeightCm;
spreadsheet.InsertImage(cfgImg);
}
break;
}
break;
}
case SbmCommodity.Column.BarcodeImage:
{
SaMsExcelImage_Config cfgImg = new SaMsExcelImage_Config();
cfgImg.ImagePath = CommodityMgr.GetBarcodeImagePath(commodityCode);
cfgImg.ColPos = colPos;
cfgImg.RowPos = rowPos;
cfgImg.Unit = SaExcelLogicalUnit.Cm;
if (FileUtil.IsFile(cfgImg.ImagePath))
{
if (interfaceParams.DataRowHeightCm > 0)
cfgImg.TargetHeight = interfaceParams.DataRowHeightCm;
spreadsheet.InsertImage(cfgImg);
SaMsExcelImage_Config cfgImg = new SaMsExcelImage_Config();
cfgImg.ImagePath = CommodityMgr.GetBarcodeImagePath(commodityCode);
cfgImg.ColPos = colPos;
cfgImg.RowPos = rowPos;
cfgImg.Unit = SaExcelLogicalUnit.Cm;
if (FileUtil.IsFile(cfgImg.ImagePath))
{
if (interfaceParams.DataRowHeightCm > 0)
cfgImg.TargetHeight = interfaceParams.DataRowHeightCm;
spreadsheet.InsertImage(cfgImg);
}
break;
}
break;
}
default:
{
cellValue = GetDataValue(columnDfn, values);
if (!columnDfn.ShowZeroValues && cellValue.IsNumeric() && cellValue.ToNumeric() == 0.0)
cellValue = new DataValue(); // Blank value.
break;
}
{
cellValue = GetDataValue(columnDfn, values);
if (!columnDfn.ShowZeroValues && cellValue.IsNumeric() && cellValue.ToNumeric() == 0.0)
cellValue = new DataValue(); // Blank value.
break;
}
}
cellValues.Add(cellValue);
}
// Populate values to spreadesheet row.
spreadsheet.SetRangeFormulas(new SaMsExcelRange(Params.FirstDataColumn, rowPos, (uint)(Params.FirstDataColumn + cellValues.Count - 1), rowPos), cellValues.ToObjectList());
spreadsheet.SetRangeValues(new SaMsExcelRange(Params.FirstDataColumn, rowPos, (uint)(Params.FirstDataColumn + cellValues.Count - 1), rowPos), cellValues);
IncrementStatistic(ProcessingStatistic.CommoditiesExported);
//if (Params.ItemBeingExported >= 10) break;
}
@@ -600,7 +601,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
// P r o g r e s s I n f o r m a t i o n
//-------------------------------------------------------------------
// Display progress information - redirected to dialog:
protected void SetProgress (String message)
protected void SetProgress(String message)
{
// Progress message:
List<String> progressMessages = new List<string>();
@@ -620,7 +621,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
//-------------------------------------------------------------------
// I n t e r f a c e I t e m O p t i o n s
//-------------------------------------------------------------------
public List<SaItemOptionDfn> GetInterfaceItemOptionDfns ()
public List<SaItemOptionDfn> GetInterfaceItemOptionDfns()
{
InitOptionDefinitions();
List<SaItemOptionDfn> interfaceOptionDfns = new List<SaItemOptionDfn>();
@@ -648,7 +649,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
}
//-------------------------------------------------------------------
private void InitOptionDefinitions ()
private void InitOptionDefinitions()
{
if (optionContexts_Value == null)
{
@@ -1019,7 +1020,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
}
}
}
private bool AddColumnValue (SbmCommodity.Column eCol, String sCode, String sDesc)
private bool AddColumnValue(SbmCommodity.Column eCol, String sCode, String sDesc)
{
return AddColumnValue(eCol, sCode, sDesc, null, null, null);
}
@@ -1073,7 +1074,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
Export_Commodities,
}
/// <summary>Configure processing options.</summary>
public static List<SaProcess_Base.GroupData> GetProcessingOptions (ISbmUserContext userContext, SaInterface interfaceObj)
public static List<SaProcess_Base.GroupData> GetProcessingOptions(ISbmUserContext userContext, SaInterface interfaceObj)
{
List<SaProcess_Base.GroupData> optionGroups = new List<SaProcess_Base.GroupData>();
@@ -1088,7 +1089,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Interfaces
//-------------------------------------------------------------------
/// <summary>Process interface using selected options.</summary>
public static SbmInterfaceProcess ConfigureProcess (ISbmUserContext userContext, SaInterface interfaceObj, SaProcess_Base.GroupData processGroup)
public static SbmInterfaceProcess ConfigureProcess(ISbmUserContext userContext, SaInterface interfaceObj, SaProcess_Base.GroupData processGroup)
{
if (processGroup.OptionGroup.Type == (int)InterfaceProcessGroup.Export)
{
@@ -81,7 +81,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
catch (Exception exc)
{
SaLogger.Warn(fn + " " + exc.GetType().Name + ": " + exc.Message, true);
return SetProcessError("Unable to connect to FTP host");
return AddErrorMessage("Unable to connect to FTP host");
}
finally
{
@@ -38,7 +38,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
}
public new class Config : SaProcess.Config
{
protected Config(ISbmUserContext userContext) : base()
protected Config(ISbmUserContext userContext) : base(userContext.DbUpdateInfo)
{
UserContext = userContext;
}
@@ -221,7 +221,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
// ToDo Save Folder...
String saveFolder = ""; //GetOption_SaveFolder();
if (OK && !StringUtil.IsEmpty(saveFolder) && !DirectoryUtil.DirectoryExists(saveFolder))
SetProcessError("Invalid output folder specified.");
AddErrorMessage("Invalid output folder specified.");
// Perform export.
if (OK)
@@ -248,11 +248,11 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
if (!OK) return false;
// Validate environment.
if (CommodityMgr == null) return SetProcessError("Unable to initialise commodity manager");
if (ProcessMgr == null) return SetProcessError("Unable to initialise process manager");
if (ReferenceDataConsole == null) return SetProcessError("Reference data console not available");
if (CommodityMgr == null) return AddErrorMessage("Unable to initialise commodity manager");
if (ProcessMgr == null) return AddErrorMessage("Unable to initialise process manager");
if (ReferenceDataConsole == null) return AddErrorMessage("Reference data console not available");
if (config.DataFormat != DataFormatType.Excel) return SetProcessError("Only Excel export format supported.");
if (config.DataFormat != DataFormatType.Excel) return AddErrorMessage("Only Excel export format supported.");
// Data field columns.
Params.IncludeCol_MaterialCost = StringUtil.ToBool(GetProcessingOptionValue(OptionName_Flag, optionContexts_Flag.GetCodeForType(ProcessOptionFlag.IncludeCol_MaterialCost)));
@@ -293,14 +293,14 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
// Headings.
SetProgressInfo(progressPrefix + " - Populating headings");
SaMsExcelColumnHeading_Config configHeadings = new SaMsExcelColumnHeading_Config();
configHeadings.HeadingFontSize = 10;
configHeadings.FirstHeadingRow = 1;
configHeadings.InteriorColour = ColorTranslator.ToOle(ExcelColumnHeadingColor);
configHeadings.FontAttr.HeightInPoints = 10;
configHeadings.FirstHeadingRowPos = 1;
configHeadings.ForegroundColourRGB = ExcelColumnHeadingColor.ToArgb();
configHeadings.BorderWeight = SaXlBorderWeight.Thin;
configHeadings.FreezeColumn = (uint)(displayColumns.GetPosForId(SbmCommodity.Column.Code) + 1);
configHeadings.FreezeColPos = (uint)(displayColumns.GetPosForId(SbmCommodity.Column.Code) + 1);
spreadsheet.SetColumnHeadings(displayColumns, configHeadings);
Params.HomeColumn = configHeadings.FreezeColumn + 1;
Params.HomeColumn = configHeadings.FreezeColPos + 1;
Params.HomeRow = Params.FirstDataRow;
ExportCommoditiesToExcel(spreadsheet);
@@ -315,7 +315,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
catch (Exception exc)
{
SaLogger.Error(fn + " " + ExceptionUtil.GetLogMessage(exc));
return SetProcessError(exc.GetType().Name + " exporting data to Excel.");
return AddErrorMessage(exc.GetType().Name + " exporting data to Excel.");
}
return OK;
@@ -625,8 +625,8 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
using (DbResultSet resultSet = CommodityMgr.ExecuteCommodityQuery(queryColumns, config.CommodityParams))
{
if (resultSet.HasErrorState()) return SetProcessError(resultSet.ErrorState.Message);
if (resultSet == null) return SetProcessError("Failed to query commodity data");
if (resultSet.HasErrorState()) return AddErrorMessage(resultSet.ErrorState.Message);
if (resultSet == null) return AddErrorMessage("Failed to query commodity data");
while (OK && resultSet != null && resultSet.NextRecord())
{
if (++commodityCount % progressRefreshRows == 0 || commodityCount == 1)
@@ -670,7 +670,7 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
for (int columnIdx = 0; columnIdx < displayColumns.Count; columnIdx++)
{
ColumnDfn column = displayColumns[columnIdx];
SaMsExcelItemAttr attrCell = new SaMsExcelItemAttr();
SaMsExcelStyleAttr attrCell = new SaMsExcelStyleAttr();
bool cellAttributesPopulated = false;
// Intercept specific values.
@@ -687,8 +687,8 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
if (SacsSystem.GetStatusForCode(statusCode) != SaStatus.Current)
{
value = new DataValue("X");
attrCell.Bold = true;
attrCell.FontColourIndex = SaXlColourIndex.Red;
attrCell.FontAttr.Bold = true;
attrCell.FontAttr.ColourIndex = SaXlColourIndex.Red;
cellAttributesPopulated = true;
}
}
@@ -705,8 +705,8 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
value = new DataValue(availableStock);
if (availableStock < -0.001m)
{
attrCell.Bold = true;
attrCell.FontColourIndex = SaXlColourIndex.Red; //38; // Pale red (pink).
attrCell.FontAttr.Bold = true;
attrCell.FontAttr.ColourIndex = SaXlColourIndex.Red; //38; // Pale red (pink).
cellAttributesPopulated = true;
}
}
@@ -744,9 +744,9 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
decimal imminentAvailablePropReorder = (imminentAvailable * 100.0m) / reorderLevel;
value = new DataValue(imminentAvailablePropReorder);
if (imminentAvailablePropReorder < ReorderPercRed)
attrCell.InteriorColourIndex = SaXlColourIndex.Rose;
attrCell.ForegroundColourIndex = SaXlColourIndex.Rose;
else if (imminentAvailablePropReorder < ReorderPercGreen)
attrCell.InteriorColourIndex = SaXlColourIndex.Tan;
attrCell.ForegroundColourIndex = SaXlColourIndex.Tan;
cellAttributesPopulated = true;
}
}
@@ -771,9 +771,9 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
decimal percSoldVsBudget = salesProjPeriod > 0.0m ? stockSoldPeriod / salesProjPeriod * 100.0m : 0.0m;
value = new DataValue(stockSoldPeriod);
if (percSoldVsBudget < BudgetPercRed)
attrCell.InteriorColourIndex = SaXlColourIndex.Rose;
attrCell.ForegroundColourIndex = SaXlColourIndex.Rose;
else if (percSoldVsBudget < BudgetPercGreen)
attrCell.InteriorColourIndex = SaXlColourIndex.Tan;
attrCell.ForegroundColourIndex = SaXlColourIndex.Tan;
cellAttributesPopulated = true;
}
}
@@ -803,9 +803,9 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
// Check month end stock level against reorder level.
if (projSales.EndOfMonth < 0.0m)
attrCell.InteriorColourIndex = SaXlColourIndex.Rose;
attrCell.ForegroundColourIndex = SaXlColourIndex.Rose;
else if (reorderLevel > 0.0m && projSales.EndOfMonth <= reorderLevel)
attrCell.InteriorColourIndex = SaXlColourIndex.Tan;
attrCell.ForegroundColourIndex = SaXlColourIndex.Tan;
cellAttributesPopulated = true;
}
}
@@ -837,16 +837,16 @@ namespace Sarand.BusinessMgr.Net.Core.Procs.Procs
cellValues.Add(value);
// Populate the cell's attributes.
if (attrCell.InteriorColourIndex != SaXlColourIndex.NotSpecified)
if (attrCell.ForegroundColourIndex != SaXlColourIndex.NotSpecified)
{
attrCell.InteriorPattern = SaXlPattern.Solid;
attrCell.InteriorPatternColourIndex = SaXlColourIndex.Automatic;
attrCell.ForegroundColourIndex = SaXlColourIndex.Automatic;
cellAttributesPopulated = true;
}
if (cellAttributesPopulated)
spreadsheet.SetRangeAttr(new SaMsExcelRange(Params.FirstDataColumn + (uint)columnIdx, iRow), attrCell);
}
spreadsheet.SetRangeFormulas(new SaMsExcelRange(Params.FirstDataColumn, iRow, Params.FirstDataColumn + (uint)cellValues.Count - 1, iRow), cellValues.ToObjectList());
spreadsheet.SetRangeValues(new SaMsExcelRange(Params.FirstDataColumn, iRow, Params.FirstDataColumn + (uint)cellValues.Count - 1, iRow), cellValues);
IncrementStatistic(ProcessingStatistic.CommoditiesExported);
}
}