private static bool UpdateCustomization(CommandLineParams o, Session epiSession)
        {
            using (StreamReader sr = new StreamReader($@"{o.ProjectFolder}\Script.cs"))
            {
                var oTrans = new ILauncher(epiSession);
                Ice.Adapters.GenXDataAdapter ad = new Ice.Adapters.GenXDataAdapter(oTrans);
                ad.BOConnect();

                GenXDataImpl i      = (GenXDataImpl)ad.BusinessObject;
                string       script = (sr.ReadToEnd().Replace("public partial class Script", "public class Script").Replace("public static partial class Script", "public static class Script").EscapeXml());
                var          ds     = i.GetByID(o.Company, o.ProductType, o.LayerType, o.CSGCode, o.Key1, o.Key2, o.Key3);
                var          chunk  = ds.XXXDef[0];
                if (chunk.SysRevID != o.Version && o.Version > 0)
                {
                    if (MessageBox.Show("The customization appears to have been updated internally within Epicor, this means that if you continue you may be over-writing some changes made. Would you like to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                    {
                        return(false);
                    }
                }
                string content = ad.GetDechunkedStringByIDWithCompany(o.Company, o.ProductType, o.LayerType, o.CSGCode, o.Key1, o.Key2, o.Key3);

                string newC = Regex.Replace(content, @"(?=\/\/ \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*)[\s\S]*?(?=<\/PropertyValue>)", script,
                                            RegexOptions.IgnoreCase);
                ad.ChunkNSaveUncompressedStringByID(o.Company, o.ProductType, o.LayerType, o.CSGCode, o.Key1, o.Key2, o.Key3, chunk.Description, chunk.Version, false, newC);
            }
            return(true);
        }
        /// <summary>
        /// Updates Epicor Customization
        /// Deprecated will be replaced shortly.
        /// </summary>
        /// <param name="o"></param>
        /// <param name="epiSession"></param>
        /// <returns></returns>
        private static bool UpdateCustomization(CommandLineParams o, Session epiSession)
        {
            var r = o;

            Log.Information($"Updating Customization. Company: {r.Company}, CGCCode: {r.CSGCode}, Key1: {r.Key1}, Key3:{r.Key2}, Key3: {r.Key3}, LayerType: {r.LayerType}, ProductType: {r.ProductType}");
            using (StreamReader sr = new StreamReader($@"{o.ProjectFolder}\Script.cs"))
            {
                try
                {
                    var oTrans = new ILauncher(epiSession);
                    Ice.Adapters.GenXDataAdapter ad = new Ice.Adapters.GenXDataAdapter(oTrans);
                    ad.BOConnect();

                    GenXDataImpl i      = (GenXDataImpl)ad.BusinessObject;
                    string       script = (sr.ReadToEnd().Replace("public partial class Script", "public class Script").Replace("public static partial class Script", "public static class Script"));
                    var          ds     = i.GetByID(o.Company, o.ProductType, o.LayerType, o.CSGCode, o.Key1, o.Key2, o.Key3);
                    var          chunk  = ds.XXXDef[0];
                    if (chunk.SysRevID != o.Version && o.Version > 0)
                    {
                        if (MessageBox.Show("The customization appears to have been updated internally within Epicor, this means that if you continue you may be over-writing some changes made. Would you like to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                        {
                            return(false);
                        }
                    }
                    string     content = ad.GetDechunkedStringByIDWithCompany(o.Company, o.ProductType, o.LayerType, o.CSGCode, o.Key1, o.Key2, o.Key3);
                    XDocument  doc     = XDocument.Load(new StringReader(content));
                    XNamespace ns      = "http://tempuri.org/XMLSchema.xsd";
                    var        elList  = doc.Descendants(ns + "PropertyName").ToList().Where(xm => xm.Value == "Script").FirstOrDefault();
                    (elList.NextNode as XElement).Value = script;
                    //string newC = Regex.Replace(content, @"(?=\/\/ \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*)[\s\S]*?(?=<\/PropertyValue>)", script,
                    //RegexOptions.IgnoreCase);
                    ad.ChunkNSaveUncompressedStringByID(o.Company, o.ProductType, o.LayerType, o.CSGCode, o.Key1, o.Key2, o.Key3, chunk.Description, chunk.Version, false, doc.ToString());
                    Log.Information("Customization Updated");
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "Failed to Update Customization");
                }
            }
            return(true);
        }