We have a BPM on the preprocessing GetRows method for UserCodes. It’s called from a customization (button click) that is passing in a UserCodeType as well as a part number and lot number all concatenated to form a string the BPM uses from the WhereClause. This UserCodeType obviously doesn’t actually exist because it’s different every time. In our current version (10.2.100.7) this still allows the BPM to fire. In the version we are upgrading to (2021.2.17) the BPM will not fire because the UserCode isn’t there. Has anyone else run into something like this and figured out a way around it?
That doesn’t sound right. Can you post the code?
Sure. The code that calls the method is pretty straightforward:
private void btnReprint_Click(object sender, System.EventArgs args)
{
UserCodesAdapter adapterUserCodes = new UserCodesAdapter(this.oTrans);
adapterUserCodes.BOConnect();
Ice.Lib.Searches.SearchOptions opts = new SearchOptions(SearchMode.AutoSearch);
opts.DataSetMode = DataSetMode.RowsDataSet;
string vwhereClause = "CodeTypeId = 'Trigger_RcptToInvAndReprintBartender#" + edvPartLot.dataView[edvPartLot.Row]["LotNum"].ToString() + "#" + edvPartLot.dataView[edvPartLot.Row]["PartNum"].ToString() + "#'";
//string vwhereClause = "";
opts.NamedSearch.WhereClauses.Add("UDCodeType",vwhereClause);
bool morePages;
// This is where it stops in the Kinetic version but works fine in 10.2
DataSet dsUserCodes = adapterUserCodes.GetRows(opts, out morePages);
// Cleanup Adapter Reference
adapterUserCodes.Dispose();
}
The code on the BPM is:
if(!String.IsNullOrEmpty(whereClauseUDCodeType) && whereClauseUDCodeType.StartsWith("CodeTypeId = 'Trigger_RcptToInvAndReprintBartender"))
{do some stuff}
It never gets to the BPM though. If I replace the CodeTypeID in the WhereClause it gets to the BPM but the BPM code requires the part and lot to function properly. The full error detail is:
Server Side Exception
BPM runtime caught an unexpected exception of ‘IOException’ type.
See more info in the Inner Exception section of Exception Details.
Exception caught in: Epicor.ServiceModel
Error Detail
Correlation ID: cf8fb61b-b705-4f72-8c4f-015f5865cdbf
Description: BPM runtime caught an unexpected exception of ‘IOException’ type.
See more info in the Inner Exception section of Exception Details.
Program: CommonLanguageRuntimeLibrary
Method: WinIOError
Original Exception Type: IOException
Framework Method: A001_CustomCodeAction
Framework Line Number: 0
Framework Column Number: 0
Framework Source: A001_CustomCodeAction at offset 1146 in file:line:column :0:0
Client Stack Trace
at Epicor.ServiceModel.Channels.ImplBase`1.ShouldRethrowNonRetryableException(Exception ex, DataSet[] dataSets)
at Ice.Proxy.BO.UserCodesImpl.GetRows(String whereClauseUDCodeType, String whereClauseUDCodes, Int32 pageSize, Int32 absolutePage, Boolean& morePages)
at Ice.Adapters.UserCodesAdapter.OnGetRows(SearchOptions opts, Boolean& MorePages, String[] whereClauses)
at Ice.Lib.Framework.EpiBaseAdapter.GetRows(SearchOptions opts, Boolean& morePages)
at Script.btnReprint_Click(Object sender, EventArgs args)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at Infragistics.Win.Misc.UltraButtonBase.OnClick(EventArgs e)
at Ice.Lib.Framework.EpiButton.OnClick(EventArgs e)
at Infragistics.Win.Misc.UltraButton.OnMouseUp(MouseEventArgs e)
at Ice.Lib.Framework.EpiButton.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Inner Exception
The specified path is invalid.
Just for giggles, replace {do some stuff}
with InfoMessage.Publish("I fired");
also, what error stack is in the server event viewer?
Sorry, I left out the test lines and just put the line where the issue is. This is the first line before that:
PublishInfoMessage(whereClauseUDCodeType, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
which returns only if I pass in a UserCode that exists. Otherwise it never returns anything. There’s also this after that
PublishInfoMessage("test1", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
which doesn’t fire because of the incorrect CodeType.
The error in the server event viewer is:
Ice.Common.EpicorServerException: BPM runtime caught an unexpected exception of ‘IOException’ type.
See more info in the Inner Exception section of Exception Details. —> System.IO.IOException: The specified path is invalid.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream…ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
at System.IO.StreamWriter…ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
at System.IO.StreamWriter…ctor(String path, Boolean append, Encoding encoding)
at System.IO.File.InternalAppendAllText(String path, String contents, Encoding encoding)
at Epicor.Customization.Bpm.BO.GetRowsPreProcessingDirective_bwRcptToInvAndReprintBartender_72754F116211472A9D3E223558D2DADB.A001_CustomCodeAction()
at Epicor.Customization.Bpm.BO.GetRowsPreProcessingDirective_bwRcptToInvAndReprintBartender_72754F116211472A9D3E223558D2DADB.ExecuteCore(Int32 step)
at Epicor.Customization.Bpm.DirectiveBase2.Execute() in C:\_releases\ICE\ICE4.1.200.0\Source\Server\Internal\Lib\Epicor.Customization.Bpm\DirectiveBase.Generic.cs:line 330 at Epicor.Customization.Bpm.DirectiveBase
2.Execute(TParam parameters) in C:_releases\ICE\ICE4.1.200.0\Source\Server\Internal\Lib\Epicor.Customization.Bpm\DirectiveBase.Generic.cs:line 180
— End of inner exception stack trace —
at Epicor.Customization.Bpm.DirectiveBase2.Execute(TParam parameters) in C:\_releases\ICE\ICE4.1.200.0\Source\Server\Internal\Lib\Epicor.Customization.Bpm\DirectiveBase.Generic.cs:line 201 at Epicor.Customization.Bpm.MethodCustomizationBase2
2.<>c__DisplayClass11_0.b__3(MethodDirectiveBase2 dir) in C:\_releases\ICE\ICE4.1.200.0\Source\Server\Internal\Lib\Epicor.Customization.Bpm\MethodCustomizationBase2.cs:line 135 at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable
1 source, Func2 predicate) at Epicor.Customization.Bpm.MethodCustomizationBase2
2.RunDirectives(TParam parameters) in C:_releases\ICE\ICE4.1.200.0\Source\Server\Internal\Lib\Epicor.Customization.Bpm\MethodCustomizationBase2.cs:line 137
at Epicor.Customization.Bpm.CustomizationBase22.Execute(TParam parameters) in C:\_releases\ICE\ICE4.1.200.0\Source\Server\Internal\Lib\Epicor.Customization.Bpm\CustomizationBase2.cs:line 87 at Epicor.Customization.Bpm.BO.UserCodesSvcCustomization.GetRows(String whereClauseUDCodeType, String whereClauseUDCodes, Int32 pageSize, Int32 absolutePage, Boolean& morePages) at Ice.Services.BO.UserCodesSvcFacade.GetRows(String whereClauseUDCodeType, String whereClauseUDCodes, Int32 pageSize, Int32 absolutePage, Boolean& morePages) in C:\_releases\ICE\ICE4.1.200.0\Source\Server\Services\BO\UserCodes\UserCodesSvcFacade.cs:line 294 at SyncInvokeGetRows(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at Epicor.Hosting.OperationBoundInvoker.InnerInvoke(Object instance, Func
2 func) in C:_releases\ICE\ICE4.1.200.17\Source\Server\Framework\Epicor.System\Hosting\OperationBoundInvoker.cs:line 59
at Epicor.Hosting.OperationBoundInvoker.Invoke(Object instance, Func`2 func) in C:_releases\ICE\ICE4.1.200.17\Source\Server\Framework\Epicor.System\Hosting\OperationBoundInvoker.cs:line 28
When I said replace it, I should have been more clear.
I want you to replace it, and comment out all other code.
Ok, I left the button click code the same and replaced everything in the BPM with the message. When I click the button I get nothing but the original error.
Server Side Exception
BPM runtime caught an unexpected exception of ‘IOException’ type.
See more info in the Inner Exception section of Exception Details.
Exception caught in: Epicor.ServiceModel
Error Detail
Correlation ID: cf8fb61b-b705-4f72-8c4f-015f5865cdbf
Description: BPM runtime caught an unexpected exception of ‘IOException’ type.
See more info in the Inner Exception section of Exception Details.
Program: CommonLanguageRuntimeLibrary
Method: WinIOError
Original Exception Type: IOException
Framework Method: A001_CustomCodeAction
Framework Line Number: 0
Framework Column Number: 0
Framework Source: A001_CustomCodeAction at offset 1146 in file:line:column :0:0
Client Stack Trace
at Epicor.ServiceModel.Channels.ImplBase`1.ShouldRethrowNonRetryableException(Exception ex, DataSet[] dataSets)
at Ice.Proxy.BO.UserCodesImpl.GetRows(String whereClauseUDCodeType, String whereClauseUDCodes, Int32 pageSize, Int32 absolutePage, Boolean& morePages)
at Ice.Adapters.UserCodesAdapter.OnGetRows(SearchOptions opts, Boolean& MorePages, String[] whereClauses)
at Ice.Lib.Framework.EpiBaseAdapter.GetRows(SearchOptions opts, Boolean& morePages)
at Script.btnReprint_Click(Object sender, EventArgs args)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at Ice.Lib.Framework.EpiButton.OnClick(EventArgs e)
at Infragistics.Win.Misc.UltraButton.OnMouseUp(MouseEventArgs e)
at Ice.Lib.Framework.EpiButton.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Inner Exception
The specified path is invalid.
That’s odd. I’m gonna fire it up and mine and see what happens.
this was my BPM
if(!String.IsNullOrEmpty(whereClauseUDCodeType) && whereClauseUDCodeType.StartsWith("CodeTypeId = 'Trigger_RcptToInvAndReprintBartender"))
{
InfoMessage.Publish(whereClauseUDCodeType);
}
That is very strange! I’ve got a test message as literally the very first line on the BPM and even it doesn’t show. I thought that maybe there was a file on the server it needed that wasn’t there (we’re in the middle of an upgrade and moving everything to a new server) but that didn’t really make sense since the BPM works when I use a different UserCode.
OK, now I’m even more confused. Evidently it has nothing to do with the UserCode having to exist. I just tried passing a random word through the WhereClause and it fired through the BPM. Didn’t get past the “if” obviosuly.
That means your error is further down, and it’s causing the bpm method to “crash”,
so it can’t return anything but an error.
If you could post the complete code, we could probably help you find it.
If not, start commenting out sections.
Also, I’d messagebox what’s coming in from the client in those two fields.
It doesn’t help that this is a customization that was created before I joined the company. Thanks for the assistance by the way.
//Temp Tables
PublishInfoMessage("1", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
Erp.Tables.Customer Customer = null;
Erp.Tables.Part Part = null;
Erp.Tables.Company Company = null;
Erp.Tables.PartLangDesc PartLangDesc = null;
Erp.Tables.PartLot PartLot = null;
Erp.Tables.JobHead JobHead = null;
Erp.Tables.PartTran PartTran = null;
//Temp Variables
string sLotNum = string.Empty;
string sPartNum = string.Empty;
string sJobNum = string.Empty;
string Entries = "";
decimal GrossM = decimal.Zero;
decimal BobbinC = decimal.Zero;
decimal Length = decimal.Zero;
string BTPrinter = string.Empty;
string BTDelim = string.Empty;
string BTOutPath = string.Empty;
string BTPath = string.Empty;
string LabelFile = string.Empty;
int RECORDS = 0;
string BTOutFile = string.Empty;
string BTProgram = string.Empty;
string BTWOutExt = string.Empty;
string BTPrintTime = string.Empty;
string BTOutPrefix = string.Empty;
string BTOutExt = string.Empty;
string LabelFile1 = string.Empty;
string LabelFile2 = string.Empty;
string BTQuote = string.Empty;
string BTComma = string.Empty;
string BTOutJob = string.Empty;
string lineout = string.Empty;
string sPartDesc = string.Empty;
string sPONum = string.Empty;
string sPackSlip = string.Empty;
string sTranQty = string.Empty;
string sOrderNum = string.Empty;
string sOrderLine = string.Empty;
string sOrderRel = string.Empty;
string sCustomer = string.Empty;
string sJob = string.Empty;
string sEmpID = string.Empty;
PublishInfoMessage(whereClauseUDCodeType, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
string testPath2 = @"\\\\BW-EPIC-2022\\EpicorData\\testBT2.text";
string testPath3 = @"\\\\BW-EPIC-2022\\EpicorData\\testBT3.text";
string BTCompanyPath = string.Empty;
PublishInfoMessage(whereClauseUDCodeType, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
bool reprint = true;
if(!String.IsNullOrEmpty(whereClauseUDCodeType) && whereClauseUDCodeType.StartsWith("CodeTypeId = 'Trigger_RcptToInvAndReprintBartender"))
{
PublishInfoMessage(whereClauseUDCodeType, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
//System.IO.File.AppendAllText(testPath2, whereClauseUDCodeType + Environment.NewLine);
//System.IO.File.AppendAllText(testPath2, "IN" + Environment.NewLine);
Entries = whereClauseUDCodeType;
string[] EntriesSplit = Entries.Split('#');
sLotNum = EntriesSplit[1];
sPartNum = EntriesSplit[2];
//System.IO.File.AppendAllText(testPath2, "AFTER FIRST" + Environment.NewLine);
//if(!String.IsNullOrEmpty(EntriesSplit[6]))
//{
// sJobNum = EntriesSplit[6];
//}
//System.IO.File.AppendAllText(testPath2, "AFTER FIRST2" + Environment.NewLine);
if(EntriesSplit.Count() > 4)
{
reprint = false;
// System.IO.File.AppendAllText(testPath2, "AFTER FIRST3" + Environment.NewLine);
if(!String.IsNullOrEmpty(EntriesSplit[3]))
{
GrossM = Convert.ToDecimal(EntriesSplit[3]);
//PublishInfoMessage(EntriesSplit[3], Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
}
if(!String.IsNullOrEmpty(EntriesSplit[4]))
{
BobbinC = Convert.ToDecimal(EntriesSplit[4]);
//PublishInfoMessage(EntriesSplit[4], Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
}
if(!String.IsNullOrEmpty(EntriesSplit[5]))
{
Length = Convert.ToDecimal(EntriesSplit[5]);
//PublishInfoMessage(EntriesSplit[5], Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
}
if(!String.IsNullOrEmpty(EntriesSplit[6]))
{
sJobNum = EntriesSplit[6];
}
}
PublishInfoMessage("3", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
System.IO.File.AppendAllText(testPath2, "AFTER ETNRIES" + DateTime.Now.ToString() + " " + sLotNum + Environment.NewLine);
PublishInfoMessage("4", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
//PublishInfoMessage("after entries", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
foreach(var iterator_PartLot in (from PartLot_Row in Db.PartLot
where PartLot_Row.Company == Session.CompanyID &&
PartLot_Row.LotNum == sLotNum && PartLot_Row.PartNum == sPartNum
select PartLot_Row))
{
var PartLot_xRow = iterator_PartLot;
if(PartLot_xRow != null)
{
//System.IO.File.AppendAllText(testPath2, "Part Lot not null" + Environment.NewLine);
var UD02_v1 = (from UD02_Row in Db.UD02
where UD02_Row.Company == Session.CompanyID &&
UD02_Row.Key4 == "UD30" &&
UD02_Row.Key1 == "User_Printer" &&
UD02_Row.Key3 == Session.UserID
select UD02_Row).FirstOrDefault();
if(UD02_v1 != null)
{
BTPrinter = UD02_v1.ShortChar03;
}
var UD02_v2 = (from UD02_Row in Db.UD02
where UD02_Row.Company == Session.CompanyID &&
UD02_Row.Key4 == "UD29" &&
UD02_Row.Key1 == "DefaultLabels" &&
UD02_Row.Key2 == Session.PlantID
select UD02_Row).FirstOrDefault();
if(UD02_v2 != null)
{
//System.IO.File.AppendAllText(testPath3, "AFTER ETNRIES" + DateTime.Now.ToString() + " " + sLotNum + Environment.NewLine);
//PublishInfoMessage("ud02 != null", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
BTDelim = UD02_v2.ShortChar03;
BTOutPath = UD02_v2.Character01;
BTPath = UD02_v2.Character02;
if (string.IsNullOrEmpty(BTPrinter))
{
BTPrinter = UD02_v2.ShortChar02; /* <-----------assign the default printer network path and name */
} //if (string.IsNullOrEmpty(BTPrinter))
BTPrintTime = (DateTime.Now.Hour * 60 * 60 + DateTime.Now.Minute * 60 + DateTime.Now.Second).ToString(); /* Set the BTPrintTime VARIABLE to current time*/
BTOutPrefix = "FGLbl"; /* prefix of the filename (will be modified by program)*/
//Revisar JOB //BTOutJob = ttUD32_xRow.Key2; /*job number */
BTOutExt = "bt"; /*Bartender output file extension*/
BTWOutExt = "btw";
var PartTranJ = (from PartTran_Row in Db.PartTran
where PartTran_Row.Company == Session.CompanyID &&
PartTran_Row.PartNum == PartLot_xRow.PartNum &&
PartTran_Row.LotNum == PartLot_xRow.LotNum
select PartTran_Row).FirstOrDefault();
if(PartTranJ != null)
{
BTOutJob = PartTranJ.JobNum;
}
//revisar ud32//if(ud32.Number09 > 0)
//{
Customer = (from Customer_Row in Db.Customer
where Customer_Row.Company == Session.CompanyID //&&
//Customer_Row.CustNum == number09 ?????????????????????
select Customer_Row).FirstOrDefault();
if (Customer != null) {
//LabelFile = Customer.ShortChar10; //Customer does not have a ShortChar10 property
} //if (Customer != null)
//}
Part = (from Part_Row in Db.Part
where Part_Row.Company == Session.CompanyID &&
//Part_Row.PartNum == ttUD32_xRow.ShortChar01
Part_Row.PartNum == PartLot_xRow.PartNum
select Part_Row).FirstOrDefault();
if (Part != null)
{
LabelFile = Part.ShortChar10;
sPartDesc = Part.PartDescription;
} //if (Part != null)
if (string.IsNullOrEmpty(LabelFile))
{
LabelFile = "GenShip1";
// System.IO.File.AppendAllText(testPath3, "AFTER ETNRIES" + DateTime.Now.ToString() + " " + sLotNum + " " + LabelFile + Environment.NewLine);
} //if (string.IsNullOrEmpty(LabelFile))
if (string.IsNullOrEmpty(LabelFile1) && string.IsNullOrEmpty(LabelFile2))
{
RECORDS = 3;
} //if (string.IsNullOrEmpty(LabelFile1) && string.IsNullOrEmpty(LabelFile2))
if (!string.IsNullOrEmpty(LabelFile1) && string.IsNullOrEmpty(LabelFile2))
{
RECORDS = 4;
} //if (!string.IsNullOrEmpty(LabelFile1) && string.IsNullOrEmpty(LabelFile2))
if (!string.IsNullOrEmpty(LabelFile1) && !string.IsNullOrEmpty(LabelFile2))
{
RECORDS = 5;
} //if (!string.IsNullOrEmpty(LabelFile1) && !string.IsNullOrEmpty(LabelFile2))
if (string.IsNullOrEmpty(BTDelim)) {
BTDelim = ",";
} //if (string.IsNullOrEmpty(BTDelim))
if (BTDelim == ",")
{
BTQuote = "\"";
BTComma = "\",\"";
} //if (BTDelim == ",")
else
{
BTQuote = string.Empty;
BTComma = BTDelim;
} //if (BTDelim == ",")
BTOutFile = BTOutPath + BTOutPrefix + "_" + BTPrintTime + "_" + BTOutJob + "." + BTOutExt; //Path
//BTOutFile = testPath2;
var CompanyN = (from Company_Row in Db.Company
where Company_Row.Company1 == Session.CompanyID
select Company_Row).FirstOrDefault();
if(CompanyN != null)
{
BTCompanyPath = CompanyN.BartenderPath_c + BTOutPrefix + "_" + BTPrintTime + "_" + BTOutJob + "." + BTOutExt; //Path;
}
BTOutFile = BTCompanyPath;
BTProgram = LabelFile + "." + BTWOutExt; /*actual name of the bartender source*/
string cmpLine = Session.CompanyID;
lineout = "%BTW% /AF=\"" + BTPath + BTProgram + "\" /D=\"<Trigger File Name>\" ";
if (RECORDS == 3)
{
lineout = lineout + "/PRN=\"" + BTPrinter + "\" /DBTEXTHEADER=" + RECORDS.ToString() + " /R=" + RECORDS.ToString() + " /C=2 /P /close /dd" + Environment.NewLine;
} //if (RECORDS == 3)
else
{
lineout = lineout + "/PRN=\"" + BTPrinter + "\" /DBTEXTHEADER=" + RECORDS.ToString() + " /R=" + RECORDS.ToString() + " /C=1 /P /close" + Environment.NewLine;
} //if (RECORDS == 3)
//System.IO.File.AppendAllText(BTOutFile, lineout);
if (!string.IsNullOrEmpty(LabelFile1))
{
BTProgram = LabelFile1 + "." + BTWOutExt; /*actual name of the bartender source*/
lineout = "%BTW% /AF=\"" + BTPath + BTProgram + "\" /D=\"<Trigger File Name>\" ";
if (RECORDS == 4)
{
lineout = lineout + "/PRN=\"" + BTPrinter + "\" /DBTEXTHEADER=" + RECORDS.ToString() + " /R=" + RECORDS.ToString() + " /C=1 /P /close /dd" + Environment.NewLine;
} else { //if (RECORDS == 4)
lineout = lineout + "/PRN=\"" + BTPrinter + "\" /DBTEXTHEADER=" + RECORDS.ToString() + " /R=" + RECORDS.ToString() + " /C=1 /P /close" + Environment.NewLine;
} //if (RECORDS == 4)
//System.IO.File.AppendAllText(BTOutFile, lineout);
}
if (!string.IsNullOrEmpty(LabelFile2))
{
BTProgram = LabelFile2 + "." + BTWOutExt; /*actual name of the bartender source*/
lineout = "%BTW% /AF=\"" + BTPath + BTProgram + "\" /D=\"<Trigger File Name>\" ";
lineout = lineout + "/PRN=\"" + BTPrinter + "\" /DBTEXTHEADER=" + RECORDS.ToString() + " /R=" + RECORDS.ToString() + " /C=1 /P /close /dd" + Environment.NewLine;
//System.IO.File.AppendAllText(BTOutFile, lineout);
} //if (!string.IsNullOrEmpty(LabelFile2))
lineout = lineout + "%END%" + Environment.NewLine;
//System.IO.File.AppendAllText(BTOutFile, lineout);
lineout = lineout + BTQuote + "Company";
lineout = lineout + BTComma + "CompanyName";
lineout = lineout + BTComma + "CompanyAddress1";
lineout = lineout + BTComma + "CompanyAddress2";
lineout = lineout + BTComma + "CompanyCity";
lineout = lineout + BTComma + "CompanyState";
lineout = lineout + BTComma + "CompanyZip";
lineout = lineout + BTComma + "CompanyCountry";
lineout = lineout + BTComma + "CompanyPhone";
//lineout = lineout + BTComma + "LP"; // Delete
lineout = lineout + BTComma + "PartNum"; //PartLot.PartNum
lineout = lineout + BTComma + "Partdesc"; //Part.PartDescription
lineout = lineout + BTComma + "Lotnum"; //PartLot.LotNum
lineout = lineout + BTComma + "POnum"; //PartTran.PONum
lineout = lineout + BTComma + "Packslip"; //PartTran.PackSlip
lineout = lineout + BTComma + "LPQty"; //PartTran.TranQty
lineout = lineout + BTComma + "OrderNum"; //PartTran.OrderNum
lineout = lineout + BTComma + "Orderline"; //PartTran.OrderLine
lineout = lineout + BTComma + "Orderrel"; //PartTran.OrderRelNum
lineout = lineout + BTComma + "Customer"; //Customer.CustID
lineout = lineout + BTComma + "Job"; //PartTran.JobNum
lineout = lineout + BTComma + "ReferenceId"; //?
lineout = lineout + BTComma + "EmployeeId"; // PartTran.EmpID
lineout = lineout + BTComma + "Gross Weight";// PartLot.bwGrossWeight_c
lineout = lineout + BTComma + "Bobbin_Count"; //PartLot.bwBobbinCount_c
lineout = lineout + BTComma + "MfgDate"; //PartLot.MfgDt
lineout = lineout + BTComma + "Part_percontainer";
lineout = lineout + BTComma + "IUM";
lineout = lineout + BTComma + "Bobbin_Type";
lineout = lineout + BTComma + "Metered";
lineout = lineout + BTComma + "Length";
lineout = lineout + BTComma + "UnitNW";
lineout = lineout + BTComma + "Imperial_Desc";
lineout = lineout + BTComma + "MFGLot";
lineout = lineout + BTComma + "FIRMWARE";
lineout = lineout + BTComma + "HEAT";
lineout = lineout + BTComma + "BATCH";
lineout = lineout + BTComma + "FIRSTREFDATE";
lineout = lineout + BTQuote + Environment.NewLine;
//System.IO.File.AppendAllText(BTOutFile, lineout);
Company = (from Company_Row in Db.Company
where Company_Row.Company1 == PartLot_xRow.Company
select Company_Row).FirstOrDefault();
if(Company != null)
{
lineout = lineout + BTQuote + PartLot_xRow.Company.TrimEnd();
lineout = lineout + BTComma + Company.Name.TrimEnd();
lineout = lineout + BTComma + Company.Address1.TrimEnd();
lineout = lineout + BTComma + Company.Address2.TrimEnd();
lineout = lineout + BTComma + Company.City.TrimEnd();
lineout = lineout + BTComma + Company.State.TrimEnd();
lineout = lineout + BTComma + Company.Zip.TrimEnd();
lineout = lineout + BTComma + Company.Country.TrimEnd();
lineout = lineout + BTComma + Company.PhoneNum.TrimEnd();
}
/* lineout = lineout + BTComma + ttUD32_xRow.Key2.TrimEnd();
lineout = lineout + BTComma + ttUD32_xRow.ShortChar01.TrimEnd();
lineout = lineout + BTComma + ttUD32_xRow.Character01.TrimEnd();
lineout = lineout + BTComma + ttUD32_xRow.ShortChar05.TrimEnd();
lineout = lineout + BTComma + ttUD32_xRow.Number10.ToString().TrimEnd();
lineout = lineout + BTComma + ttUD32_xRow.ShortChar07.TrimEnd();
lineout = lineout + BTComma + ttUD32_xRow.Number03.ToString().TrimEnd();
lineout = lineout + BTComma + ttUD32_xRow.Number04.ToString().TrimEnd();
lineout = lineout + BTComma + ttUD32_xRow.Number05.ToString().TrimEnd();
lineout = lineout + BTComma + ttUD32_xRow.Number06.ToString().TrimEnd();
lineout = lineout + BTComma + ttUD32_xRow.ShortChar02.TrimEnd();
lineout = lineout + BTComma + ttUD32_xRow.ShortChar03.TrimEnd();
lineout = lineout + BTComma + ttUD32_xRow.ShortChar10.TrimEnd();
lineout = lineout + BTComma + ttUD32_xRow.ShortChar15.TrimEnd();
lineout = lineout + BTComma + ttUD32_xRow.Number20.ToString().TrimEnd();
lineout = lineout + BTComma + ttUD32_xRow.Number19.ToString().TrimEnd();*/
/*var PartTranN = (from PartTran_Row in Db.PartTran
where PartTran_Row.Company == Session.CompanyID &&
PartTran_Row.PartNum == PartLot_xRow.PartNum &&
PartTran_Row.LotNum == PartLot_xRow.LotNum &&
PartTran_Row.TranType == "MFG-STK" && !reprint
select PartTran_Row).FirstOrDefault();*/
var PartTranN = (from PartTran_Row in Db.PartTran
where (PartTran_Row.TranType == "MFG-STK" || PartTran_Row.TranType == "SVG-STK") && PartTran_Row.Company == Session.CompanyID &&
PartTran_Row.PartNum == PartLot_xRow.PartNum &&
PartTran_Row.LotNum == PartLot_xRow.LotNum && !reprint
select PartTran_Row).FirstOrDefault();
if(PartTranN != null)
{
sPONum = PartTranN.PONum.ToString();
sPackSlip = PartTranN.PackSlip;
sTranQty = PartTranN.TranQty.ToString();
sOrderNum = PartTranN.OrderNum.ToString();
sOrderLine = PartTranN.OrderLine.ToString();
sOrderRel = PartTranN.OrderRelNum.ToString();
//sJob = PartTranN.JobNum;
sJob = PartLot_xRow.ShortChar01;
sEmpID = PartTranN.EmpID.ToString();
var CustomerN = (from Customer_Row in Db.Customer
where Customer_Row.Company == Session.CompanyID &&
Customer_Row.CustNum == PartTranN.CustNum
select Customer_Row).FirstOrDefault();
if(CustomerN != null)
{
sCustomer = CustomerN.CustID.ToString();
}
}
var PartBinN = (from PartBin_Row in Db.PartBin
where PartBin_Row.Company == Session.CompanyID &&
PartBin_Row.PartNum == PartLot_xRow.PartNum &&
PartBin_Row.LotNum == PartLot_xRow.LotNum && reprint
select PartBin_Row).FirstOrDefault();
if(PartBinN != null)
{
sTranQty = PartBinN.OnhandQty.ToString();
}
if(sJob == string.Empty)
{
sJob = PartLot_xRow.ShortChar01;
}
if(PartLot_xRow.ShortChar01 == string.Empty)
{
sJob = sJobNum;
}
lineout = lineout + BTComma + PartLot_xRow.PartNum;
lineout = lineout + BTComma + sPartDesc;
lineout = lineout + BTComma + PartLot_xRow.LotNum;
lineout = lineout + BTComma + sPONum;
lineout = lineout + BTComma + sPackSlip;
lineout = lineout + BTComma + sTranQty;
lineout = lineout + BTComma + sOrderNum;
lineout = lineout + BTComma + sOrderLine;
lineout = lineout + BTComma + sOrderRel;
lineout = lineout + BTComma + sCustomer;
lineout = lineout + BTComma + sJob;
lineout = lineout + BTComma + ""; //ReferenceId
lineout = lineout + BTComma + sEmpID; //EmployeeID
if(GrossM == decimal.Zero)
{
lineout = lineout + BTComma + PartLot_xRow["bwGrossWeight_c"].ToString();
}
else
{
lineout = lineout + BTComma + GrossM.ToString();
}
if(BobbinC == decimal.Zero)
{
lineout = lineout + BTComma + PartLot_xRow["bwBobbinCount_c"].ToString();
}
else
{
lineout = lineout + BTComma + BobbinC.ToString();
}
DateTime MfgDate = Convert.ToDateTime(PartLot_xRow.MfgDt);
lineout = lineout + BTComma + MfgDate.ToString("MM/dd/yyyy");
/*if (ttUD32_xRow.Date01 == null)
{
lineout = lineout + BTComma;
} //if (ttUD32_xRow.Date01 == null)
else
{
lineout = lineout + BTComma + ttUD32_xRow.Date01.ToString().TrimEnd();
} //if (ttUD32_xRow.Date01 == null)*/
Part = (from Part_Row in Db.Part
where Part_Row.Company == Session.CompanyID &&
Part_Row.PartNum == PartLot_xRow.PartNum
select Part_Row).FirstOrDefault();
if (Part != null)
{
lineout = lineout + BTComma + Part.PartsPerContainer.ToString().TrimEnd();
lineout = lineout + BTComma + Part.IUM.TrimEnd();
lineout = lineout + BTComma + Part.ShortChar01.TrimEnd();
if (Part.CheckBox01)
{
lineout = lineout + BTComma + "Metered";
if(Length == decimal.Zero)
{
lineout = lineout + BTComma + PartLot_xRow["bwLength_c"].ToString();
}
else
{
lineout = lineout + BTComma + Length.ToString();
}
} //if (Part.CheckBox01)
else
{
lineout = lineout + BTComma + "Non-Metered";
lineout = lineout + BTComma + "0";
}
lineout = lineout + BTComma + Part.NetWeight.ToString().TrimEnd();
PartLangDesc = (from PartLangDesc_Row in Db.PartLangDesc
where PartLangDesc_Row.Company == Session.CompanyID &&
PartLangDesc_Row.PartNum == Part.PartNum &&
PartLangDesc_Row.LangNameID == "enu"
select PartLangDesc_Row).FirstOrDefault();
if (PartLangDesc != null)
{
lineout = lineout + BTComma + PartLangDesc.Description.TrimEnd();
}
else //if (PartLangDesc != null)
{
lineout = lineout + BTComma;
}
}//if (Part != null)
if(PartLot_xRow.MfgLot != "")
{
lineout = lineout + BTComma + PartLot_xRow.MfgLot.TrimEnd();
}
else //if (!string.IsNullOrEmpty(PartLot.MfgLot))
{
lineout = lineout + BTComma;
}
if (!string.IsNullOrEmpty(PartLot_xRow.FirmWare))
{
lineout = lineout + BTComma + PartLot_xRow.FirmWare.TrimEnd();
}
else //if (!string.IsNullOrEmpty(PartLot.FirmWare))
{
lineout = lineout + BTComma;
}
if (!string.IsNullOrEmpty(PartLot_xRow.HeatNum))
{
lineout = lineout + BTComma + PartLot_xRow.HeatNum.TrimEnd();
}
else
{ //if (!string.IsNullOrEmpty(PartLot.HeatNum))
lineout = lineout + BTComma;
} //if (!string.IsNullOrEmpty(PartLot.HeatNum))
if (!string.IsNullOrEmpty(PartLot_xRow.Batch))
{
lineout = lineout + BTComma + PartLot_xRow.Batch.TrimEnd();
}
else
{ //if (!string.IsNullOrEmpty(PartLot.Batch))
lineout = lineout + BTComma;
} //if (!string.IsNullOrEmpty(PartLot.Batch))
if (PartLot_xRow.FirstRefDate != null)
{
DateTime FirstRef = Convert.ToDateTime(PartLot_xRow.FirstRefDate);
lineout = lineout + BTComma + FirstRef.ToString("MM/dd/yy").TrimEnd() + "\"";
}
else
{ //if (PartLot.FirstRefDate != null)
lineout = lineout + BTComma + "\"";
} //if (!string.IsNullOrEmpty(PartLot.Batch))
/* PartTran = (from PartTran_Row in Db.PartTran
where PartTran_Row.Company == Session.CompanyID &&
PartTran_Row.PartNum == PartLot_xRow.PartNum &&
PartTran_Row.LotNum == PartLot_xRow.LotNum
&& PartTran_Row.TranType == "MFG-STK"
select PartTran_Row).FirstOrDefault();
if(PartTran != null)
{
JobHead = (from JobHead_Row in Db.JobHead
where JobHead_Row.Company == Session.CompanyID &&
JobHead_Row.JobNum == PartTran.JobNum
select JobHead_Row).FirstOrDefault();
if(JobHead != null)
{
lineout = lineout + BTComma + JobHead.RevisionNum.TrimEnd();
}
}
lineout = lineout + BTComma + BTQuote;
*/
System.IO.File.AppendAllText(BTOutFile, lineout);
PublishInfoMessage("Label Submitted for Printing", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
}//if(UD02_v2 != null)
}//if(PartLot_xRow != null)
}//foreach(var iterator_PartLot
}//if(!String.IsNullOrEmpty(whereClauseUDCodeType)
Your error is probably one of these entries:
System.IO.File.AppendAllText
Check the file paths etc, going to them.
Might be here:
string testPath2 = @"\\\\BW-EPIC-2022\\EpicorData\\testBT2.text";
You have an @ in front, so the slash is interpreted literally, not as an escape.
This:
string testPath2 =
@"\\\\BW-EPIC-2022\\EpicorData\\testBT2.text";
says
“\\\\BW-EPIC-2022\\EpicorData\\testBT2.text”
This:
string testPath2 = "\\\\BW-EPIC-2022\\EpicorData\\testBT2.text";
says
This:
“\\BW-EPIC-2022\EpicorData\testBT2.text”;`
I’d change it to this:
string testPath2 = @"\\BW-EPIC-2022\EpicorData\testBT2.text";
You’re the man! That did it. Thanks again for your help.