O
OldeEnglishD
Guest
Batch File #1
==========================================================
rem @echo off
cd EDI_Part_Update_DB_Console2
LabelFiles2 "\\clncustools02\c$\Global Label Formats\Label Data Sets\Ford LAP Mix-Master Label Dataset.xls" "C:\EDI_Part_Update_DB_Console2" "\\Bemivas01\Public\IT\EDIFiles\862Test\*.xlsx" "C:\EDI_Part_Update_DB_Console2\ExcelCollection"
==========================================================
Batch File #2
==========================================================
rem @echo off
rem Excel Database File
copy %1 %2
rem Excel Files used to modify Excel Database File
copy %3 %4
rem Start "Ford_EDI_Parts_Update_2.exe" %1 %2 %4
Ford_EDI_Parts_Update_2.exe %1 %2 %4
rem pause
==========================================================
Program.cs
==========================================================
class Program
{
static void Main(string[] args)
{
string strFileDatabaseNamePath = "", strFileDatabaseName = "", strPathDBTo = "", strPath = "",
strPathSpreadSheetsTo = "", strFileDatabaseNameTemp = "", strFileNameOnly = "";
string[] arrFiles = null;
Process[] process1 = null;
int intResult = 0, intPos = 0;
ErrorLog.Log("Welcome to frmMain b4 InitializeComponent()", "Exe is Running", "C:\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
Thread.Sleep(100);
ErrorLog.Log("Welcome to frmMain af InitializeComponent()", "Exe is Running", "C:\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
Thread.Sleep(100);
strFileDatabaseNamePath = args[0].Replace("\r\n", "");
strPathDBTo = args[1].Replace("\r\n", "");
intPos = strFileDatabaseNamePath.LastIndexOf("\\");
strFileDatabaseName = strFileDatabaseNamePath.Substring(intPos + 1, strFileDatabaseNamePath.Length - intPos - 1);
strPathSpreadSheetsTo = args[2].Replace("\r\n", "");
strPath = strPathSpreadSheetsTo.Replace("*.xlsx", "");
intResult = FileToProcess.ReadRowsInSSheet(ref strFileDatabaseName, strPathDBTo);
if (intResult == 1)
{
==========================================================
FilesToProcess.cs
==========================================================
public class FileToProcess
{
//Bookmark -- Use a network path
public static int ReadRowsInSSheet(ref string strFileName, string strAppPath)
{
string strShipToPart = "", strSuppPart = "", strDesc = "", strHomeLoc = "", strCarLine = "", strPartFam = "", strCarDesig = "", strModelYr = "",
strSuppName = "", strCountryOfOrigin = "", strShipTo1 = "", strSuppCode = "", strProgram = "", strRetPartNum = "", strStdPack = "", strTareWgt = "",
strUnits = "", strContHgt = "", strUnitsINorMM = "", strWgtPerPiece = "", strUnits2 = "", strStdPackPerCont = "", strPartsPerPallet = "", strDock = "",
strLF = "", strReserveLF = "", strFordSuppCode = "", strShipTo2 = "", strShipTo2Name = "";
int intRow = 2, intRet = 0;
Microsoft.Office.Interop.Excel.Application oXLFrom = null;
Database2 db = new Database2();
_Workbook oWBFrom = null;
oXLFrom = new Microsoft.Office.Interop.Excel.Application();
oXLFrom.Interactive = false;
Thread.Sleep(100);
try
{
oWBFrom = oXLFrom.Workbooks.Open(strAppPath + "\\" + strFileName);
}
catch (Exception ex)
{
ErrorLog.Log(ex, "Open Excel File", "C:\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\", "FileToProcess.ReadRowsInSSheet.Open Method:");
CloseExcelProcesses_dll.Program.CloseProjectExcelFiles(ref oXLFrom);
return -1;
}
Thread.Sleep(100);
ErrorLog.Log("B4 Truncate", "Exe is Running", "C:\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
Thread.Sleep(100);
intRet = db.Truncate();
Thread.Sleep(100);
==========================================================
Database2.cs
==========================================================
public class Database2
{
int x = 5, y = 0;
public int Truncate()
{
MySqlConnection conn;
MySqlCommand cmd;
ErrorLog.Log("Welcome To Truncate", "Exe is Running", "C:\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
Thread.Sleep(100);
conn = null;
//Blows up here -- Cannot Open Connection
using (conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["FordEDIParts"].ConnectionString))
{
==========================================================
Why would it open the connection and have no problems in release mode but not able to emulate when exe is run from a batch file?
Continue reading...
==========================================================
rem @echo off
cd EDI_Part_Update_DB_Console2
LabelFiles2 "\\clncustools02\c$\Global Label Formats\Label Data Sets\Ford LAP Mix-Master Label Dataset.xls" "C:\EDI_Part_Update_DB_Console2" "\\Bemivas01\Public\IT\EDIFiles\862Test\*.xlsx" "C:\EDI_Part_Update_DB_Console2\ExcelCollection"
==========================================================
Batch File #2
==========================================================
rem @echo off
rem Excel Database File
copy %1 %2
rem Excel Files used to modify Excel Database File
copy %3 %4
rem Start "Ford_EDI_Parts_Update_2.exe" %1 %2 %4
Ford_EDI_Parts_Update_2.exe %1 %2 %4
rem pause
==========================================================
Program.cs
==========================================================
class Program
{
static void Main(string[] args)
{
string strFileDatabaseNamePath = "", strFileDatabaseName = "", strPathDBTo = "", strPath = "",
strPathSpreadSheetsTo = "", strFileDatabaseNameTemp = "", strFileNameOnly = "";
string[] arrFiles = null;
Process[] process1 = null;
int intResult = 0, intPos = 0;
ErrorLog.Log("Welcome to frmMain b4 InitializeComponent()", "Exe is Running", "C:\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
Thread.Sleep(100);
ErrorLog.Log("Welcome to frmMain af InitializeComponent()", "Exe is Running", "C:\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
Thread.Sleep(100);
strFileDatabaseNamePath = args[0].Replace("\r\n", "");
strPathDBTo = args[1].Replace("\r\n", "");
intPos = strFileDatabaseNamePath.LastIndexOf("\\");
strFileDatabaseName = strFileDatabaseNamePath.Substring(intPos + 1, strFileDatabaseNamePath.Length - intPos - 1);
strPathSpreadSheetsTo = args[2].Replace("\r\n", "");
strPath = strPathSpreadSheetsTo.Replace("*.xlsx", "");
intResult = FileToProcess.ReadRowsInSSheet(ref strFileDatabaseName, strPathDBTo);
if (intResult == 1)
{
==========================================================
FilesToProcess.cs
==========================================================
public class FileToProcess
{
//Bookmark -- Use a network path
public static int ReadRowsInSSheet(ref string strFileName, string strAppPath)
{
string strShipToPart = "", strSuppPart = "", strDesc = "", strHomeLoc = "", strCarLine = "", strPartFam = "", strCarDesig = "", strModelYr = "",
strSuppName = "", strCountryOfOrigin = "", strShipTo1 = "", strSuppCode = "", strProgram = "", strRetPartNum = "", strStdPack = "", strTareWgt = "",
strUnits = "", strContHgt = "", strUnitsINorMM = "", strWgtPerPiece = "", strUnits2 = "", strStdPackPerCont = "", strPartsPerPallet = "", strDock = "",
strLF = "", strReserveLF = "", strFordSuppCode = "", strShipTo2 = "", strShipTo2Name = "";
int intRow = 2, intRet = 0;
Microsoft.Office.Interop.Excel.Application oXLFrom = null;
Database2 db = new Database2();
_Workbook oWBFrom = null;
oXLFrom = new Microsoft.Office.Interop.Excel.Application();
oXLFrom.Interactive = false;
Thread.Sleep(100);
try
{
oWBFrom = oXLFrom.Workbooks.Open(strAppPath + "\\" + strFileName);
}
catch (Exception ex)
{
ErrorLog.Log(ex, "Open Excel File", "C:\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\", "FileToProcess.ReadRowsInSSheet.Open Method:");
CloseExcelProcesses_dll.Program.CloseProjectExcelFiles(ref oXLFrom);
return -1;
}
Thread.Sleep(100);
ErrorLog.Log("B4 Truncate", "Exe is Running", "C:\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
Thread.Sleep(100);
intRet = db.Truncate();
Thread.Sleep(100);
==========================================================
Database2.cs
==========================================================
public class Database2
{
int x = 5, y = 0;
public int Truncate()
{
MySqlConnection conn;
MySqlCommand cmd;
ErrorLog.Log("Welcome To Truncate", "Exe is Running", "C:\\LogFile\\" + Assembly.GetCallingAssembly().GetName().Name + "\\");
Thread.Sleep(100);
conn = null;
//Blows up here -- Cannot Open Connection
using (conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["FordEDIParts"].ConnectionString))
{
==========================================================
Why would it open the connection and have no problems in release mode but not able to emulate when exe is run from a batch file?
Continue reading...