private void Export_Click(object sender, EventArgs e) { long quotenumber; if (txtQuoteid.Text != null) { bool parsed = Int64.TryParse(txtQuoteid.Text, out quotenumber); ClipperApi.ExportQuote(quotenumber, "CMD" + txtQuoteid.Text, @"c:\temp\toto.txt"); if (!parsed) { MessageBox.Show("Int32.TryParse could not parse '{0}' to an int."); } } }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); AlmaCamBinFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); ParamFolder = AlmaCamBinFolder + @"\ActcutClipperExeParam"; // ActcutClipperExeParam : nom de sous répertoire imposé ParamFile = ParamFolder + @"\Param.txt"; // Nom du fichier contenant les commandes : nom imposé WorkFile = ParamFolder + @"\Param.wrk"; // Nom du fichier contenant les commandes : nom imposé ResultFile = ParamFolder + @"\Result.txt"; // Nom du fichier contenant les resultats : nom imposé if (Directory.Exists(ParamFolder) == false) { Directory.CreateDirectory(ParamFolder); } string[] arguments = Environment.GetCommandLineArgs(); string action; string user; string db; long quoteNumber; string orderNumber; string exportFile; GetParam(arguments, out action, out user, out db, out quoteNumber, out orderNumber, out exportFile); #region Init if (action == "Init" && db != null) { bool ret = Init(db, user); if (ret) { File.WriteAllText(ResultFile, "Ok"); ManageCommand(); } else { File.WriteAllText(ResultFile, "Error"); Environment.ExitCode = -1; } } #endregion #region Export Quote else if (action == "ExportQuote" && db != null) { bool ret = Init(db, user); if (ret) { bool status = ClipperApi.ExportQuote(quoteNumber, orderNumber, exportFile); Environment.ExitCode = (status ? 0 : -1); } else { Environment.ExitCode = -2; } } #endregion #region Get Quote else if (action == "SelectQuoteUI" && db != null) { bool ret = Init(db, user); if (ret) { long quoteId; bool status = ClipperApi.SelectQuoteUI(out quoteId); Environment.ExitCode = (int)quoteId; } else { Environment.ExitCode = -2; } } #endregion } }