예제 #1
0
 /// <summary>
 ///
 /// </summary>
 public MyTcpClient()
 {
     _serverIP           = XmlFlexflow.ReadXmlNodeValue("Tcp_Listener_IP");
     _port               = Int32.Parse(XmlFlexflow.ReadXmlNodeValue("Tcp_Listener_Port"));
     this._getResultStr  = XmlFlexflow.ReadXmlNodeValue("Tcp_Client_Get_Result");
     this._getSuccessStr = XmlFlexflow.ReadXmlNodeValue("Tcp_Client_Success");
 }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mess"></param>
        /// <returns></returns>
        public static SocketMess getSocketMessWithSuccessFlag(string mess)
        {
            XmlFlexflow xff        = new XmlFlexflow();
            string      successStr = xff.ReadXmlNodeValue("Tcp_Client_Success");

            return(new SocketMess(successStr + mess));
        }
        /// <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);
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="str"></param>
        public static void RecordLog(string configFilePath, string str)
        {
            string yy = DateTime.Now.Year.ToString();
            string mm = DateTime.Now.Month.ToString();
            string dd = DateTime.Now.Day.ToString();

            if (mm.Length == 1)
            {
                mm = "0" + mm;
            }
            if (dd.Length == 1)
            {
                dd = "0" + dd;
            }
            string date        = yy + mm + dd;
            string logfilename = XmlFlexflow.ReadXmlNodeValue("LogPath") + "\\" + "FOX" + date + ".txt";

            if (File.Exists(logfilename))
            {
                FileStream   fsOutput = new FileStream(logfilename, FileMode.Append, FileAccess.Write);
                StreamWriter srOutput = new StreamWriter(fsOutput);
                srOutput.WriteLine("\r\n" + DateTime.Now.ToString() + ": " + str);
                srOutput.Close();
            }
            else
            {
                FileStream   fsOutput = new FileStream(logfilename, FileMode.Append, FileAccess.Write);
                StreamWriter srOutput = new StreamWriter(fsOutput);
                srOutput.WriteLine("\r\n" + DateTime.Now.ToString() + ": " + str);
                srOutput.Close();
            }
        }
예제 #5
0
 /// <summary>
 ///
 /// </summary>
 public FTPHelper()
 {
     this._ftpServerIP   = XmlFlexflow.ReadXmlNodeValue("FTP_IPADDR");
     this.FtpUserID      = XmlFlexflow.ReadXmlNodeValue("FTP_USER");
     this._ftpPassword   = XmlFlexflow.ReadXmlNodeValue("FTP_PASSWORD");
     this._ftpRemotePath = XmlFlexflow.ReadXmlNodeValue("FTP_REMOTE_DIR");
     this._ftpURI        = "ftp://" + this._ftpServerIP + "/" + this._ftpRemotePath + "/";
 }
        /// <summary>
        ///
        /// </summary>
        public MyTCPListener()
        {
            string    _serverIP = XmlFlexflow.ReadXmlNodeValue("Tcp_Listener_IP");
            Int32     _port     = Int32.Parse(XmlFlexflow.ReadXmlNodeValue("Tcp_Listener_Port"));
            IPAddress localAddr = IPAddress.Parse(_serverIP);

            _server = new TcpListener(localAddr, _port);
            this.start();
        }
예제 #7
0
 private static void initConStr()
 {
     connStr += "Server=" + XmlFlexflow.ReadXmlNodeValue("SERVER_NAME") + ";";
     connStr += "database=" + XmlFlexflow.ReadXmlNodeValue("DATABASE_NAME") + ";";
     connStr += "User ID=" + XmlFlexflow.ReadXmlNodeValue("USER_ID") + ";";
     connStr += "password="******"PASSWORD");
     //conStr += "password="******"PASSWORD"));
     //conStr=System.Configuration.ConfigurationManager
 }
예제 #8
0
        /// <summary>
        ///
        /// </summary>
        public FTPHelper(string remoteDir)
        {
            XmlFlexflow xff = new XmlFlexflow();

            this._ftpServerIP   = XmlFlexflow.ReadXmlNodeValue("FTP_IPADDR");
            this.FtpUserID      = XmlFlexflow.ReadXmlNodeValue("FTP_USER");
            this._ftpPassword   = XmlFlexflow.ReadXmlNodeValue("FTP_PASSWORD");
            this._ftpRemotePath = remoteDir;
            this._ftpURI        = "ftp://" + this._ftpServerIP + "/" + this._ftpRemotePath + "/";
        }
예제 #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mess"></param>
        /// <returns></returns>
        public static bool ifSuccess(string mess)
        {
            string successStr = XmlFlexflow.ReadXmlNodeValue("Tcp_Client_Success");

            if (successStr.Equals(mess))
            {
                return(true);
            }
            return(false);
        }
예제 #10
0
        private static void initConStr()
        {
            string host_Name = XmlFlexflow.ReadXmlNodeValue("SERVER_NAME");
            string user_Id   = XmlFlexflow.ReadXmlNodeValue("USER_ID");
            string password  = XmlFlexflow.ReadXmlNodeValue("PASSWORD");

            oracleConnStr = String.Format(@"Data Source=(DESCRIPTION="
                                          + "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST={0} )(PORT=1521)))"
                                          + "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));"
                                          + "User Id={1};Password={2};", host_Name, user_Id, password);
        }
예제 #11
0
        //判断是否为成功信息。
        /// <summary>
        ///
        /// </summary>
        /// <param name="strResult"></param>
        /// <returns></returns>
        public bool ifSuccess()
        {
            XmlFlexflow xff        = new XmlFlexflow();
            string      successStr = xff.ReadXmlNodeValue("Tcp_Client_Success");

            if (successStr.Equals(this._mess))
            {
                return(true);
            }
            return(false);
        }
        /// <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);
            }
        }