/// <summary> /// 下载最新版,初始化连接字符串. /// </summary> /// <returns></returns> public static bool downloadTheLatestVersionAndInitConnStr() { //===================================================================== // Project Name : BaseDao // Project Description : // Class Name : Class1 // File Name : Class1 // Namespace : BaseDao // Class Version : v1.0.0.0 // Class Description : // CLR : 4.0.30319.42000 // Author : 董 魁 ([email protected]) // Addr : 中国 陕西 咸阳 // Create Time : 2019-10-22 14:57:19 // Modifier: // Update Time : 2019-10-22 14:57:19 //====================================================================== // Copyright © DGCZ 2019 . All rights reserved. // ===================================================================== Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!File.Exists(Application.StartupPath + "\\flexflow.cfg")) { MessageBox.Show(string.Format(@"文件:{0},未找到!", Application.StartupPath + "\\flexflow.cfg"), "提示:", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } XmlFlexflow.configFilePath = Application.StartupPath + "\\flexflow.cfg"; string ftpIPADDR = XmlFlexflow.ReadXmlNodeValue("FTP_IPADDR"); releaseVersion = string.Empty; //先测试是否可以ping通 if (!ConnectByPing.pingTheAddress(ftpIPADDR)) { MessageBox.Show("未能与版本服务器: " + ftpIPADDR + "取得联系!", "提示: ", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } //检查软件版本 MSG msg = CheckAppVerionByFTP.checkAppVersionAndOutReleaseVersion(ftpIPADDR, out releaseVersion); if (!msg.Flag) { if (!msg.Msg.Contains("更新")) { return(false); } //自动升级。 //判断是否存在update文件 if (!Directory.Exists(Application.StartupPath + "\\update")) { //给出提示: MessageBox.Show("未发现升级目录: " + Application.StartupPath + "\\update", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } //进行升级 CmdHelper.LaunchBatOrExe(string.Format(@"{0}\update\UpdateProgram.exe", Application.StartupPath), Application.ProductName + " " + releaseVersion); //进行升级时,也需要退出,防止覆盖时,提示文件正在使用中。 return(false); } return(true); }
/// <summary> /// OracleDaoHelper,SqlDaoHelper 数据库的连接字符串赋值 /// </summary> /// <returns></returns> public static bool setTheValueOfTheConnStr(out bool flag_open_mesSqlConn) { #region 数据库联接测试。 string host_Name = XmlFlexflow.ReadXmlNodeValue("SERVER_NAME"); string service_Name = XmlFlexflow.ReadXmlNodeValue("SERVICE_NAME"); string user_Id = XmlFlexflow.ReadXmlNodeValue("USER_ID"); string password = XmlFlexflow.ReadXmlNodeValue("PASSWORD"); string mes_host_Name = XmlFlexflow.ReadXmlNodeValue("MES_SERVER_NAME"); string mes_db_Name = XmlFlexflow.ReadXmlNodeValue("MES_DATABASE_NAME"); string mes_user_Id = XmlFlexflow.ReadXmlNodeValue("MES_USER_ID"); string mes_password = XmlFlexflow.ReadXmlNodeValue("MES_PASSWORD"); XmlFlexflow.configFilePath = System.Windows.Forms.Application.StartupPath + "\\flexflow.cfg"; //先测试是否可以ping通 if (!ConnectByPing.pingTheAddress(mes_host_Name)) { MessageBox.Show("与" + host_Name + " 连接失败!", "提示: ", MessageBoxButtons.OK, MessageBoxIcon.Information); flag_open_mesSqlConn = false; return(false); } #endregion //再这个启动类里,对对象进行初始化。 OracleDaoHelper daoHelper = new OracleDaoHelper(host_Name, service_Name, user_Id, password); SqlDaoHelper sqlHelper = new SqlDaoHelper(mes_host_Name, mes_db_Name, mes_user_Id, mes_password); SqlConnection sqlConn = new SqlConnection(SqlDaoHelper.conn_str); try { sqlConn.Open(); sqlConn.Close(); sqlConn.Dispose(); flag_open_mesSqlConn = true; return(true); } catch (Exception ex) { MessageBox.Show(ex.ToString()); MessageBox.Show("基于MES_制卡系统中的所属部门,组将无法获取"); flag_open_mesSqlConn = false; return(false); } }