I opened an existing (working) bartender BPM we have set up as a JobHead data directive & changed a printer string. Now we get a compile error when I save it. It works (ignoring it).
If Epicor is making this a hard stop error in future releases, we should fix it now.
How do we fix it? Is System.IO.File.WriteAllLines no longer a good way to create bartender labels?
Here’s the offending part:
System.IO.File.WriteAllLines("\\\\e10bartend\\Commander\\Scan\\JobPartLabels\\" + "Label " + JobNum.ToString() + ".bt", contents);
Full code:
PostTran.BOMLabelV2.cs(450,1): warning ECF1002: The ‘System.IO.File.WriteAllLines(string, string)’ method cannot be called.
PostTran.BOMLabelV2.AsyncHost.cs(137,1): warning ECF1002: The ‘System.IO.File.WriteAllLines(string, System.Collections.Generic.IEnumerable)’ method cannot be called.
//Create Bartender Script File
string printer = Printer;
string headers = "?";
string label = "C:\\Commander\\GScreen_1x2.btw";
string copies = Quantity.ToString();
var datas = (
from e in Db.JobMtl.With(LockHint.NoLock)
where
e.Company == "<masked>" && e.JobNum == JobNum
orderby e.BoxColor_c, e.MtlSeq ascending
select new { e.PartNum, e.Description, e.MtlSeq, e.IUM, e.RequiredQty, e.BoxColor_c} ).Distinct().ToArray().Select( e => $"{e.PartNum}, {e.IUM}, {e.Description}, {e.MtlSeq}, {e.RequiredQty}, {e.BoxColor_c}" );
//Splitting up MaxMtlSeq Into an Array
string[] MtlSeqList = MaxMtlSeq.Split(',');
//Bartender Header Information
string text = string.Format("%BTW% /AF=\"{0}\" /D=\"<Trigger File Name>\" /PRN=\"{1}\" /R=3 /C={2} /P ", label, printer, copies);
//Column Headers
headers = string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",", new object[]
{
"PartNum",
"IUM",
"PartDescription",
"MtlSeq",
"RequiredQty",
"BoxColor_c"
});
//Printing specific labels based on what is in MaxMtlSeq
if (MaxMtlSeq == "ALL")
{
datas = (
from e in Db.JobMtl.With(LockHint.NoLock)
where
e.Company == "<masked>" && e.JobNum == JobNum
select new { e.PartNum, e.Description, e.MtlSeq, e.IUM, e.RequiredQty, e.BoxColor_c} ).Distinct().ToArray().Select(e => $"{e.PartNum}, {e.IUM}, {e.Description}, {e.MtlSeq}, {e.RequiredQty}, {e.BoxColor_c}" );
}
else if (MaxMtlSeq != "" && MaxMtlSeq != "ALL" )
{
datas = (
from e in Db.JobMtl.With(LockHint.NoLock)
where
e.Company == "<masked>" && e.JobNum == JobNum && MtlSeqList.ToList().Contains(e.MtlSeq.ToString())
select new { e.PartNum, e.Description, e.MtlSeq, e.IUM, e.RequiredQty, e.BoxColor_c} ).Distinct().ToArray().Select( e => $"{e.PartNum}, {e.IUM}, {e.Description}, {e.MtlSeq}, {e.RequiredQty}, {e.BoxColor_c}" );
}
string[] bartenderInfo = new string[]
{
text,
"%END%", //bartender footer
headers,
//datas
};
var contents = bartenderInfo.Concat(datas);
System.IO.File.WriteAllLines("\\\\e10bartend\\Commander\\Scan\\JobPartLabels\\" + "Label " + JobNum.ToString() + ".bt", contents);