 | ERPExportBaseExtraOptsWithUserSettingsFIELDSETTINGSTYPE, EXPORTSETTINGSTYPE, USERSETTINGSTYPE Class |
Export Base with custom Export Profile Field specific settings, custom Export Profile settings and User settings.
Export profile and field settings can be accessed from
GetExportSettings(CTExportProfile).
User settings can be accessed from
GetUserSettings.
Inheritance Hierarchy Namespace: CTExtensions.ExportCore.ExportBaseTypesAssembly: CTInterface (in CTInterface.dll) Version: 25.0
Syntaxpublic abstract class ERPExportBaseExtraOptsWithUserSettings<FIELDSETTINGSTYPE, EXPORTSETTINGSTYPE, USERSETTINGSTYPE> : ExportBase<FIELDSETTINGSTYPE, EXPORTSETTINGSTYPE, Dummy, USERSETTINGSTYPE>
where FIELDSETTINGSTYPE : new(), SettingsObject
where EXPORTSETTINGSTYPE : new(), ExportSettingsBase<FIELDSETTINGSTYPE>
where USERSETTINGSTYPE : new(), SettingsObject
Public MustInherit Class ERPExportBaseExtraOptsWithUserSettings(Of FIELDSETTINGSTYPE As {New, SettingsObject}, EXPORTSETTINGSTYPE As {New, ExportSettingsBase(Of FIELDSETTINGSTYPE)}, USERSETTINGSTYPE As {New, SettingsObject})
Inherits ExportBase(Of FIELDSETTINGSTYPE, EXPORTSETTINGSTYPE, Dummy, USERSETTINGSTYPE)
Type Parameters
- FIELDSETTINGSTYPE
- Custom type derived from SettingsObject representing Export Profile Field settings.
- EXPORTSETTINGSTYPE
- Custom type derived from ExportSettingsBaseFIELDSETTINGSTYPE representing Export Profile settings.
- USERSETTINGSTYPE
- Custom type derived from SettingsObject representing User settings
The ERPExportBaseExtraOptsWithUserSettingsFIELDSETTINGSTYPE, EXPORTSETTINGSTYPE, USERSETTINGSTYPE type exposes the following members.
Constructors
Example
This example shows how to utilize classes of
CTExtensions.ExportCore,
CTExtensions.ExportCore.Config,
CTExtensions.ExportCore.ExportBaseTypes and
CTExtensions.ExportCore.EXTs namespaces for creating
a custom Export ERP integration that supports custom data storing on CT Profile, current User, Export Profile and Export Profile Field levels,
as well as very powerful
GenericExportHandlerT, E, I for the actual export process.
Language: C#
Class name: MyCustomErpIntegration
using ATR.CT.CTInterface;
using CTEngineLib;
using CTExtensions.ExportCore.Config;
using CTExtensions.ExportCore.EXTs;
using CTExtensions.ExportCore.ExportBaseTypes;
using System.Windows.Forms;
using System.IO;
using ATRControls2;
using System.Collections.Generic;
using CTExtensions.ExportCore.ExportHandler;
using ATRControlsXLib;
using System.Linq;
namespace CustomErpIntegrationDemo
{
public class MyCustomErpIntegration : ERPExportBaseExtraOptsWithUserAndProfileSettings<MyExportFieldSettings, MyExportSettings, MyUserSettings, MyProfileSettings>
{
public override string FriendlyName()
{
return "My Custom Integration";
}
public override string IdentifyingName()
{
return "MY-CUSTOM-ERP-INTEGRATION-12345";
}
public override List<EventExtension> GetEventExtensions()
{
return new List<EventExtension>() { new MyExportHandler() };
}
protected override ExportTypeExt<MyExportSettings, MyExportFieldSettings> CreateExportType()
{
return new ExportWithFullPDMSupport();
}
public class ExportWithFullPDMSupport : ExportTypeExt<MyExportSettings, MyExportFieldSettings>
{
public override bool AllowUseInSWPDM()
{
return true;
}
public override bool SupportsSilentExecution()
{
return true;
}
}
}
public class MyExportHandler : GenericExportHandler<MyCustomErpIntegration, MyExportItem, MyRowItemizer>
{
protected override void ManipulateExportDataBeforeItemization(ICTExportProfile profile, ICTExportProfileData data, string conf, bool bLastConfiguration)
{
MyExportSettings exportsettings = (GetParent() as MyCustomErpIntegration).GetExportSettings(profile as CTExportProfile);
foreach (var fieldSettings in exportsettings.FieldSettings)
{
string field = fieldSettings.Key;
MyExportFieldSettings settings = fieldSettings.Value;
if (settings.MyFieldBoolData)
{
for (int i = 0; i < data.Rows; i++)
data.SetValue(i, field, data.GetValueByName(field, i).ToUpper());
}
}
}
protected override void GetAdditionalColumnsSetup(IListViewEx oList, string configuration, out Dictionary<string, bool> oColsToAdd, out List<string> oColsToHide)
{
oColsToAdd = null;
oColsToHide = null;
oColsToAdd = new Dictionary<string, bool>() { { "Item Status", true } };
}
protected override void UpdateItemsPreFilling(List<MyExportItem> items)
{
MyExportSettings exportsettings = (GetParent() as MyCustomErpIntegration).GetExportSettings(moExportProfile as CTExportProfile);
MyUserSettings userSettings = (GetParent() as MyCustomErpIntegration).GetUserSettings();
MyProfileSettings profileSettings = (GetParent() as MyCustomErpIntegration).GetProfileSettings();
if (CurrentExportCase == ExportCase.SOLIDWORKS)
{
Log("This goes to %TEMP%\\MY-CUSTOM-ERP-INTEGRATION-12345.log");
}
else if (CurrentExportCase == ExportCase.PDM)
{
Log("This goes to Task Details");
}
else if (CurrentExportCase == ExportCase.SOLIDWORKS_Silent)
{
Log("This goes to Task Details and the operation is silent.");
}
if (items.Count > 0)
{
items.First().RowColorController.ClearColors();
items.First().SetValue("Item Status", "EXISTING");
items.First().RowColorController.SetFieldBGColor("Item Status", ExportItemColorController.COLOR_WHITE);
items.First().WillGetItemNumberAfterExport = false;
}
foreach (var item in items.Skip(1))
{
item.RowColorController.ClearColors();
item.SetValue("Item Status", "NEW");
item.RowColorController.SetFieldBGColor("Item Status", ExportItemColorController.COLOR_NEW);
item.WillGetItemNumberAfterExport = true;
}
if (items.Count > 0)
{
var ghostItem = items.First().AddGhostItem<MyExportItem>("Item '12345' in target ERP");
ghostItem.SetQuantityIn(items.First(), 1);
ghostItem.SetValue("Item Status", "Exists in ERP but not in CAD");
ghostItem.RowColorController.SetRowFGColor(ExportItemColorController.COLOR_GHOST);
}
}
protected override bool Export(List<MyExportItem> items)
{
MyExportSettings exportsettings = (GetParent() as MyCustomErpIntegration).GetExportSettings(moExportProfile as CTExportProfile);
MyUserSettings userSettings = (GetParent() as MyCustomErpIntegration).GetUserSettings();
MyProfileSettings profileSettings = (GetParent() as MyCustomErpIntegration).GetProfileSettings();
foreach (var item in items.Where(x => x.WillGetItemNumberAfterExport))
{
item.WillGetItemNumberAfterExport = false;
}
foreach (var item in items)
{
if (Itemizer.GetRowType(item.DataRows.First().Item1) == RowItemizer.RowType.Ghost)
continue;
item.RowColorController.ClearColors();
item.SetValue("Item Status", "OK");
item.RowColorController.SetFieldBGColor("Item Status", ExportItemColorController.COLOR_WHITE);
}
return true;
}
protected override bool SecondPhaseExport(List<MyExportItem> items)
{
return true;
}
}
public class MyExportItem : ExportItem
{
public bool WillGetItemNumberAfterExport { get; set; }
public MyExportItem()
{
WillGetItemNumberAfterExport = false;
}
public override bool RequiresWriteBack()
{
return base.RequiresWriteBack() || WillGetItemNumberAfterExport;
}
}
public class MyRowItemizer : RowItemizer
{
}
public class MyExportFieldSettings : SettingsObject
{
public string MyFieldStringData { get; set; }
public bool MyFieldBoolData { get; set; }
protected override void Deserialize(Stream s)
{
MyFieldStringData = s.PopString();
MyFieldBoolData = s.PopBool();
}
protected override void Serialize(Stream s)
{
s.PushString(MyFieldStringData);
s.PushBool(MyFieldBoolData);
}
public override ControlAdapter CreateAdapter(ICTExtension parent)
{
return new PropertyGridAdapter<MyExportFieldSettings>(parent);
}
}
public class MyUserSettings : SettingsObject
{
public bool Enabled { get; set; }
public string UserName { get; set; }
public string PassWord { get; set; }
protected override void Serialize(Stream s)
{
s.PushBool(Enabled);
s.PushString(UserName);
s.PushString(PassWord);
}
protected override void Deserialize(Stream s)
{
Enabled = s.PopBool();
UserName = s.PopString();
PassWord = s.PopString();
}
public override ControlAdapter CreateAdapter(ICTExtension parent)
{
return new MyUserSettingsGUI(parent);
}
}
public class MyUserSettingsGUI : ControlAdapter<MyUserSettings>
{
ATRControls2.WinForm.GenericLoginCtrl moCtrl;
public MyUserSettingsGUI(ICTExtension parent) : base(parent)
{
moCtrl = new ATRControls2.WinForm.GenericLoginCtrl();
moCtrl.BackColor = System.Drawing.Color.White;
moCtrl.ShowEnableCheck(true);
moCtrl.ShowUsernameField(true);
moCtrl.ShowPasswordField(true);
moCtrl.ShowDatabaseField(false);
moCtrl.ShowTestConnectionButton(false);
moCtrl.ShowCommunicationPointField(false);
moCtrl.Dock = System.Windows.Forms.DockStyle.Fill;
Controls.Add(moCtrl);
}
public override void LoadFrom(MyUserSettings settings)
{
moCtrl.LoginEnabled = settings.Enabled;
moCtrl.Username = settings.UserName;
moCtrl.Password = settings.PassWord;
}
public override void SaveTo(MyUserSettings settings)
{
settings.Enabled = moCtrl.LoginEnabled;
settings.UserName = moCtrl.Username;
settings.PassWord = moCtrl.Password;
}
}
public class MyExportSettings : ExportSettingsBase<MyExportFieldSettings>
{
public string TargetCompany { get; set; }
protected override void Deserialize(Stream s)
{
base.Deserialize(s);
TargetCompany = s.PopString();
}
protected override void Serialize(Stream s)
{
base.Serialize(s);
s.PushString(TargetCompany);
}
public override ControlAdapter CreateAdapter(ICTExtension extension)
{
return new MyExportSettingsGUI(extension);
}
}
public class MyExportSettingsGUI : ControlAdapter<MyExportSettings>
{
System.Windows.Forms.TextBox tb;
public MyExportSettingsGUI(ICTExtension ext) : base(ext)
{
tb = new System.Windows.Forms.TextBox();
tb.Dock = System.Windows.Forms.DockStyle.Top;
Controls.Add(tb);
}
public override void LoadFrom(MyExportSettings settings)
{
tb.Text = settings.TargetCompany;
}
public override void SaveTo(MyExportSettings settings)
{
settings.TargetCompany = tb.Text;
}
}
public class MyProfileSettings : SettingsObject
{
public string ConnectionString { get; set; }
protected override void Deserialize(Stream s)
{
ConnectionString = s.PopString();
}
protected override void Serialize(Stream s)
{
s.PushString(ConnectionString);
}
public override ControlAdapter CreateAdapter(ICTExtension parent)
{
return new PropertyGridAdapter<MyProfileSettings>(parent);
}
}
}
Revision HistoryDate | Version | Description |
---|
- | 2022 SP0 | First Release |
See Also