Could anyone assist as to why I would get this kind of error with the below code? I am performing serial matching, and I use this exact same code in another process that creates serials and matches them (upper and lower parts). In this case, we have a upper level part I am attempting to match. I manually matched a serial, traced, and verified that the dataset from my code matches what I got from the trace. So… I am very much lost, any help would be greatly appreciated
Error:
Serial Number Match failed:
--------------------------------
Exception:The underlying provider failed on EnlistTransaction.System.PlatformNotSupportedException: This platform does not support distributed transactions.
at System.Transactions.Distributed.DistributedTransactionManager.CreateTransaction(TransactionOptions options)
at System.Transactions.TransactionStatePromoted.EnterState(InternalTransaction tx)
at System.Transactions.EnlistableStates.Promote(InternalTransaction tx)
at System.Transactions.Transaction.Promote()
at System.Transactions.TransactionInterop.ConvertToDistributedTransaction(Transaction transaction)
at System.Transactions.TransactionInterop.GetExportCookie(Transaction transaction, Byte[] whereabouts)
at System.Data.SqlClient.SqlInternalConnection.GetTransactionCookie(Transaction transaction, Byte[] whereAbouts)
at System.Data.SqlClient.SqlInternalConnection.EnlistNonNull(Transaction tx)
at System.Data.SqlClient.SqlInternalConnection.EnlistTransaction(Transaction transaction)
at System.Data.SqlClient.SqlConnection.EnlistTransaction(Transaction transaction)
at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.EnlistTransaction(DbConnection connection, EnlistTransactionInterceptionContext interceptionContext)
at System.Data.Entity.Core.EntityClient.EntityConnection.EnlistTransaction(Transaction transaction)
Code:
// Support Functions
Func<string, object, bool> debugMsg = (title, dataObj) =>
{
string jsonTxt = JsonConvert.SerializeObject(dataObj);
string jsonMessage = string.Format("{0}: {1}{2}", title, Environment.NewLine, jsonTxt);
this.PublishInfoMessage(jsonMessage, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"UBAQ", "Advanced");
return true;
};
Func<string, bool> showMsg = (message) =>
{
this.PublishInfoMessage(message, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"UBAQ", "Advanced");
return true;
};
// Common variables
var currPlant = callContextClient.CurrentPlant;
var currCompany = callContextClient.CurrentCompany;
// Get the params the BAQ was called with
var jobNum = executionParams.ExecutionParameter.Where(m => m.ParameterID == "sJobNum").Select(m => m.ParameterValue).FirstOrDefault();
var assemblySeqStr = executionParams.ExecutionParameter.Where(m => m.ParameterID == "sAssemblySeq").Select(m => m.ParameterValue).FirstOrDefault();
var mtlSeqStr = executionParams.ExecutionParameter.Where(m => m.ParameterID == "sMtlSeq").Select(m => m.ParameterValue).FirstOrDefault();
// Setup our service calls
var serialMatchingSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SerialMatchingSvcContract>(Db);
if (!string.IsNullOrEmpty(jobNum) && !string.IsNullOrEmpty(assemblySeqStr) && !string.IsNullOrEmpty(mtlSeqStr))
{
/***************************************************************
* Validations & Data Setup
***************************************************************/
// Setup our two int type params
int assemblySeq = 0;
int mtlSeq = 0;
int.TryParse(assemblySeqStr, out assemblySeq);
int.TryParse(mtlSeqStr, out mtlSeq);
// Ensure we have a JobAsmbl record (aka they saved the Issue Material form)
var jobAsmblRec = Db.JobAsmbl.Where(m => m.Company == currCompany && m.Plant == currPlant && m.JobNum == jobNum && m.AssemblySeq == assemblySeq).ToList();
if (!jobAsmblRec.Any())
{
string msgTxt = string.Format("ERROR retrieving Job Assembly information");
showMsg(msgTxt);
return;
}
var jobAsmbl = jobAsmblRec.FirstOrDefault();
// Get the upper level part from JobHead
string upperlvlPart = Db.JobHead.Where(m => m.Company == currCompany && m.Plant == currPlant && m.JobNum == jobNum)
.Select(m => m.PartNum).First();
string cfmPart = Db.JobMtl.Where(m => m.Company == currCompany && m.Plant == currPlant && m.JobNum == jobNum)
.Select(m => m.PartNum).FirstOrDefault();
// Ensure we have a CFM part, and the logic above didn't pull the same part# twice
if (string.IsNullOrEmpty(cfmPart) || (cfmPart == upperlvlPart))
{
string msgTxt = string.Format("ERROR retrieving the Upper level part and CFM part");
showMsg(msgTxt);
return;
}
// Get our Serial Number prefix for the upper level part
var snPrefix = Db.PartPlant.Where(m => m.Company == currCompany && m.Plant == currPlant && m.PartNum == upperlvlPart)
.Select(m => m.SNPrefix).First();
// Get available WIP serials for our CFM part in SerialNo
var cfmSerialNumbers = Db.SerialNo.Where(m => m.Company == currCompany && m.PartNum == cfmPart && m.JobNum == jobNum && m.AssemblySeq == assemblySeq && m.MtlSeq == mtlSeq && m.SNStatus == "WIP");
/***************************************************************
* Serial Number Matching
***************************************************************/
// Loop through our serials and perform matching
bool hadError = false;
List<string> matchedSerials = new List<string>();
foreach (var serialNum in cfmSerialNumbers)
{
var serialNumber = serialNum.SerialNumber;
var partNum = serialNum.PartNum;
string opRevMsg;
string opnoBOMMsg;
// Append the prefix to the serial number to setup our upper level part serial number
var uperLvlPartSerial = string.Format("{0}{1}", snPrefix, serialNumber);
var serialMatchingTS = serialMatchingSvc.ChangeSerialNum(uperLvlPartSerial, upperlvlPart, String.Empty, jobNum, assemblySeq, out opRevMsg, out opnoBOMMsg);
if (serialMatchingTS != null)
{
serialMatchingTS.SerialMatchHdr[0].RowMod = "U";
serialMatchingTS.SerialMatchAsmbl[0].RowMod = "U";
serialMatchingSvc.GetAvailableToMatch("mtl", ref serialMatchingTS);
Erp.Tablesets.AvailToMatchTable smAvailToMatchTS = serialMatchingTS.AvailToMatch;
Erp.Tablesets.SerialMatchMtlTable smMtlTS = serialMatchingTS.SerialMatchMtl;
// Loop through each available to match row in our tableset
foreach (Erp.Tablesets.AvailToMatchRow arow in smAvailToMatchTS)
{
if (arow.SerialNumber == serialNumber && arow.PartNum == cfmPart)
{
// Set the matched and selected
arow.Matched = true;
arow.Selected = true;
// loop through the match material rows
foreach (Erp.Tablesets.SerialMatchMtlRow rowMtl in smMtlTS)
{
rowMtl.MtlSerialNo = arow.SerialNumber;
matchedSerials.Add(string.Format("{0} <--> {1}", rowMtl.MtlSerialNo, rowMtl.TopSerialNum));
break;
}
break;
}
}
// Now run the match update
try
{
serialMatchingSvc.UpdateSMMtl("J", ref serialMatchingTS);
}
catch (Exception ex)
{
string errTxt = string.Format("Serial Number Match failed for {0}:{1}--------------------------------{2}Exception:{3}{4}",
uperLvlPartSerial, Environment.NewLine, Environment.NewLine, ex.Message, ex.InnerException);
hadError = true;
showMsg(errTxt);
}
}
}
// Display a matching status to the user
string finalMsgHeader = "Match CFM Serials process has completed";
if (hadError) {
finalMsgHeader = "Match CFM Serials process failed, see below";
}
string statHdr = string.Format("Job: {0}{1}Assembly Seq# {2}{3}Mtl Seq# {4}{5}CFM Part: {6}{7}Upper Level Part: {8}{9}",
jobNum, Environment.NewLine, assemblySeqStr, Environment.NewLine, mtlSeqStr, Environment.NewLine, cfmPart, Environment.NewLine, upperlvlPart, Environment.NewLine);
string matchStat = string.Join(Environment.NewLine, matchedSerials);
string FinalMsgTxt = string.Format("{5}:{0}--------------------------------{1}{2}{3}{4}",
Environment.NewLine, Environment.NewLine, statHdr, Environment.NewLine, matchStat, finalMsgHeader);
showMsg(FinalMsgTxt);
}