Ejemplo n.º 1
0
 private void ExeMain()
 {
     GeneralCommon.Gp_LogTxt("Download Start00");
     if (MainMenu_Check())
     {
         Label1.Visible = true;
         Label1.Text    = "已打开过检验室程序";
         this.Refresh();
         if (MessageBox.Show("检验室程序正在运行,是否要关闭?关闭前请保存当前操作,以免丢失数据。", "更新提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
         {
             Process[] myProcess = null;
             myProcess = Process.GetProcessesByName(ProcessesName);
             foreach (Process myPro in myProcess)
             {
                 myPro.Kill();
             }
         }
     }
     if (UpdateInfo(GetFileInfo()) == true)
     {
         GeneralCommon.Gp_LogTxt("Download DownLoad_File00");
         DownLoad_File(GetFileInfo());
     }
     else
     {
         Label1.Visible = true;
         Label1.Text    = "程序已经是最新版本,无须更新";
         this.Refresh();
     }
     GeneralCommon.Gp_LogTxt("Download Process.Start00");
     Process.Start(sExePath + ProcessesName + ".exe");
     this.Dispose();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 执行存储过程
        /// </summary>
        /// <param name="ReferSql">调用存储过程语句</param>
        /// <return>DataTable</return>
        //---------------------------------------------------------------------------------------
        //   1.ID           : Gp_MsgBoxDisplay
        //   2.Input  Value : sMsg String, {sIcon String}, {sTitle String}
        //   3.Return Value :
        //   4.Create Date  :
        //   5.Modify Date  :
        //   6.Comment      : Message Box Only Display
        //---------------------------------------------------------------------------------------
        public static DataTable Gf_ExecProc2Ref(string ReferSql)
        {
            DataTable DataTab_temp = new DataTable();

            if (GeneralCommon.OleDbConn.State == 0)
            {
                if (GeneralCommon.GF_DbConnect() == false)
                {
                    return(DataTab_temp);
                }
            }

            try
            {
                GeneralCommon.Gp_LogData(ReferSql);
                OleDbDataAdapter OleDA = new OleDbDataAdapter(ReferSql, OleDbConn);
                OleDA.Fill(DataTab_temp);
                return(DataTab_temp);
            }
            catch (Exception ex)
            {
                Gp_MsgBoxDisplay("Gf_ExecProc2Ref Error : " + ex.Message);
                return(DataTab_temp);
            }

            finally
            {
                if (GeneralCommon.OleDbConn.State != 0)
                {
                    GeneralCommon.OleDbConn.Close();
                }
            }
        }
Ejemplo n.º 3
0
 private void Timer_Conut_Tick(object sender, EventArgs e)
 {
     Timer_Conut.Stop();
     if (GeneralCommon.GF_DbConnect() == true)
     {
         ExeMain();
     }
     else
     {
         GeneralCommon.Gp_MsgBoxDisplay("网络连接异常,进入检测程序", "W", "DataBase Connection");
         Chk_Net();
         this.Dispose();
     }
 }
Ejemplo n.º 4
0
 //==============================================================================================
 // Procedure Name : MainMenu_Check
 // Description : main
 //==============================================================================================
 private bool MainMenu_Check()
 {
     //return false;
     try
     {
         if (System.Diagnostics.Process.GetProcessesByName(ProcessesName).Length > 0)
         {
             return(true);
         }
         return(false);
     }
     catch (Exception ex)
     {
         GeneralCommon.Gp_MsgBoxDisplay(ex.Message);
         return(false);
     }
 }
Ejemplo n.º 5
0
        private void DownLoadMain_Load(object sender, System.EventArgs e)
        {
            try
            {
                GeneralCommon.Gp_LogTxt("DownLoad DownLoadMain_Load 00");
                sExePath        = System.IO.Directory.GetCurrentDirectory() + "\\";
                this.KeyPreview = true;
                GeneralCommon.Gp_FormCenter(this);

                // Sets the timer interval to 5 seconds.
                Timer_Conut.Interval = 1000;
                Timer_Conut.Start();
            }
            catch (Exception ex)
            {
                GeneralCommon.Gp_LogData("DownLoadMain_Load " + ex.Message);
            }
        }
Ejemplo n.º 6
0
        private bool UpdateInfo(ArrayList WinId)
        {
            try
            {
                if (WinId == null || WinId.Count == 0)
                {
                    return(false);
                }
                string sQuery     = "";
                string Server_Ver = "";
                string Client_Ver = null;
                if (Server_Info() == false)
                {
                    Label1.Visible = true;
                    Label1.Text    = "服务器连接超时,请检查";
                    return(false);
                }
                else
                {
                    for (int i = 0; i < WinId.Count; i++)
                    {
                        sQuery     = "{call PKG_MAIN.P_FIND_VER('" + WinId[i] + "')}";
                        Server_Ver = GeneralCommon.Gf_CodeFind(sQuery);

                        //Client Version
                        Client_Ver = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SOFTWARE\" + RegLocation + @"\VERSION\").GetValue(WinId[i].ToString(), "0.0.0").ToString();

                        if (Server_Ver != Client_Ver | !System.IO.File.Exists(sExePath + WinId[i]))
                        {
                            return(true);
                        }
                    }

                    return(true);
                }
            }
            catch //(System.Exception e)
            {
                return(false);
            }
        }
Ejemplo n.º 7
0
        //==============================================================================================
        // Procedure Name : GetFileInfo
        // Description : 获取所有文件信息
        //==============================================================================================
        private ArrayList GetFileInfo()
        {
            ArrayList functionReturnValue = new ArrayList();
            string    sQuery = "{call PKG_MAIN.P_GETFILEINFO()} ";

            try
            {
                DataTable DT_temp = GeneralCommon.Gf_ExecProc2Ref(sQuery);
                if (DT_temp.Rows.Count > 0)
                {
                    for (int i = 0; i < DT_temp.Rows.Count; i++)
                    {
                        functionReturnValue.Add(DT_temp.Rows[i][0].ToString().Trim());
                    }
                }
            }
            catch
            {
            }
            return(functionReturnValue);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 查找代码
        /// </summary>
        /// <param name="sQuery">查询语句</param>
        /// <return>string</return>
        public static string Gf_CodeFind(string sQuery)
        {
            string functionReturnValue = "";

            try
            {
                if (GF_DbConnect() == false)
                {
                    return("");
                }
                GeneralCommon.Gp_LogData(sQuery);
                OleDbCommand oc = new OleDbCommand(sQuery, OleDbConn);
                functionReturnValue = oc.ExecuteScalar().ToString();
                return(functionReturnValue);
            }
            catch (Exception ex)
            {
                Gp_MsgBoxDisplay("Gf_CodeFind Error : " + ex.Message);
                return("");
            }
        }
Ejemplo n.º 9
0
        //==============================================================================================
        // Procedure Name : Server_Info
        // Description : get server info from BZA_SERVINF table
        //==============================================================================================
        private bool Server_Info()
        {
            bool functionReturnValue = false;

            string sQuery = "{call PKG_MAIN.P_SERVER ()}";

            try
            {
                DataTable DT_temp = GeneralCommon.Gf_ExecProc2Ref(sQuery);
                if (DT_temp.Rows.Count > 0)
                {
                    sServerIP           = DT_temp.Rows[0][0].ToString().Trim();
                    sServerID           = DT_temp.Rows[0][1].ToString().Trim();
                    sServerPWD          = DT_temp.Rows[0][2].ToString().Trim();
                    sServerPATH         = DT_temp.Rows[0][3].ToString().Trim();
                    sServerPORT         = Convert.ToInt32(DT_temp.Rows[0][4].ToString().Trim());
                    functionReturnValue = true;
                }
            }
            catch
            {
            }
            return(functionReturnValue);
        }
Ejemplo n.º 10
0
        //==============================================================================================
        // Procedure Name : DownLoad_File
        // Description : 下载所有更新文件
        //==============================================================================================
        private bool DownLoad_File(ArrayList WinId)
        {
            //return true;
            bool functionReturnValue = false;

            if (MainMenu_Check())
            {
                if (MessageBox.Show("检验室程序正在运行,是否要关闭?关闭前请保存当前操作以免丢失数据。", "更新提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    Process[] myProcess = null;
                    myProcess = Process.GetProcessesByName(ProcessesName);
                    foreach (Process myPro in myProcess)
                    {
                        myPro.Kill();
                    }
                }
                else
                {
                    return(true);;
                }
            }

            if (WinId == null)
            {
                return(true);
            }



            string sQuery     = null;
            int    i          = 0;
            string Client_Ver = null;
            string Server_Ver = null;


            FILE_SIZE = 0;



            functionReturnValue = false;

            try
            {
                //check ftp server info
                if (string.IsNullOrEmpty(sServerIP) | string.IsNullOrEmpty(sServerID) | string.IsNullOrEmpty(sServerPWD) | string.IsNullOrEmpty(sServerPATH)) //
                {
                    GeneralCommon.Gp_MsgBoxDisplay("FTP服务器信息不存在...!!", "W");
                    return(false);
                }

                Cursor.Current = Cursors.WaitCursor;
                Application.DoEvents();

                //check download folder
                if (!System.IO.Directory.Exists(sExePath))
                {
                    System.IO.Directory.CreateDirectory(sExePath);
                }


                this.pic_Close.Visible = false;
                Label1.Visible         = true;
                Label1.Text            = "程序更新中,请勿关闭";

                for (i = 0; i < WinId.Count; i++)
                {
                    //Server Version
                    sQuery     = "{call PKG_MAIN.P_FIND_VER('" + WinId[i] + "')}";
                    Server_Ver = GeneralCommon.Gf_CodeFind(sQuery);

                    //Client Version
                    Client_Ver = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SOFTWARE\" + RegLocation + @"\VERSION\").GetValue(WinId[i].ToString(), "0.0.0").ToString();// Interaction.GetSetting("CYEDM", "VERSION", WinId[i], "0.0.0");

                    if (Server_Ver != Client_Ver | !System.IO.File.Exists(sExePath + WinId[i]))
                    {
                        //Client File Delete
                        if (System.IO.File.Exists(sExePath + WinId[i]))
                        {
                            System.IO.File.Delete(sExePath + WinId[i]);
                        }
                        int    point   = WinId[i].ToString().LastIndexOf(@"\");
                        string spath   = sExePath;
                        string sysname = "";
                        if (point > 0)
                        {
                            spath = sExePath + WinId[i].ToString().Substring(0, point);
                            if (System.IO.Directory.Exists(spath) == false)
                            {
                                System.IO.Directory.CreateDirectory(spath);// FileSystem.MkDir(spath);
                            }
                            sysname = WinId[i].ToString().Substring(point + 1);
                        }
                        FTPClient ftp = new FTPClient(sServerIP, sServerPATH, sServerID, sServerPWD, sServerPORT);
                        if (ftp.Get(WinId[i].ToString(), sExePath, WinId[i].ToString()))
                        {
                            Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SOFTWARE\" + RegLocation + @"\VERSION\").SetValue(WinId[i].ToString(), Server_Ver);
                        }
                        else
                        {
                            GeneralCommon.Gp_MsgBoxDisplay("下载文件出错 : " + ftp.strReply);
                            GeneralCommon.Gp_LogData(WinId[i].ToString() + " " + ftp.strReply);
                        }
                    }
                }

                PrgDown.Visible   = false;
                pic_Close.Visible = true;

                Label1.Visible      = false;
                functionReturnValue = true;
                Cursor.Current      = Cursors.Default;

                Application.DoEvents();
            }
            catch (Exception ex)
            {
                PrgDown.Visible = false;

                GeneralCommon.Gp_MsgBoxDisplay("下载文件 Error : " + ex.Message);

                Cursor.Current = Cursors.Default;

                Application.DoEvents();
            }

            return(functionReturnValue);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 日志记录
        /// </summary>
        /// <param name="sLOG_INFO">信息</param>
        /// <param name="sLOG_MSG">日志信息</param>
        /// <param name="sLOG_data">信息内容</param>
        /// <param name="sLOG_TYPE">信息类型</param>
        /// <param name="sINS_EMP">插入人</param>
        /// <return>bool</return>
        public static bool Gp_Log(string sLOG_INFO, string sLOG_MSG, string sLOG_data, string sLOG_TYPE, string sINS_EMP)
        {
            bool functionReturnValue = false;

            //Db Connection Check
            if (GeneralCommon.OleDbConn_Log.State == 0)
            {
                if (GeneralCommon.GF_DbConnect() == false)
                {
                    return(false);
                }
            }

            //  OleDbTransaction OleTra;
            //  OleTra = OleDbConn.BeginTransaction();
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                OleDbCommand OleDC = new OleDbCommand("PKG_Z_LOG.SET_LOG", OleDbConn_Log);
                OleDC.CommandType = CommandType.StoredProcedure;

                OleDC.Parameters.Add(new OleDbParameter("sLOG_INFO", string.IsNullOrEmpty(sLOG_INFO) ? "" : sLOG_INFO)); //.Replace("'", "''")));
                OleDC.Parameters.Add(new OleDbParameter("sLOG_MSG", string.IsNullOrEmpty(sLOG_MSG) ? "" : sLOG_MSG));    //.Replace("'", "''")));
                OleDC.Parameters.Add(new OleDbParameter("sLOG_data", string.IsNullOrEmpty(sLOG_data) ? "" : sLOG_data)); //.Replace("'", "''") ));
                OleDC.Parameters.Add(new OleDbParameter("sLOG_TYPE", string.IsNullOrEmpty(sLOG_TYPE) ? "" : sLOG_TYPE));
                OleDC.Parameters.Add(new OleDbParameter("sINS_EMP", string.IsNullOrEmpty(sINS_EMP) ? string.IsNullOrEmpty(GeneralCommon.sUserID) ? "SYSTEM" : GeneralCommon.sUserID : sINS_EMP));
                OleDC.Parameters.Add(new OleDbParameter("sIP", Gf_GetIP()));
                //Ceate Input Parameter
                //for (int iCount = 0; iCount < 5; iCount++)
                //{
                //    OleDC.Parameters.Add(sLOG_INFO);//new OleDbParameter("", OleDbType.Variant));
                //    OleDC.Parameters[iCount].Value = Para_Info[iCount];
                //    //  OleDC.Parameters[iCount].Size = 2000;
                //    // OleDC.Parameters.Add(Para_Info[iCount]);
                //}

                // OleDC.Parameters.Add("e_code", OleDbType.Integer).Direction = ParameterDirection.Output;
                // OleDC.Parameters.Add("e_msg", OleDbType.Variant).Direction = ParameterDirection.Output;
                //   OleDC.Transaction = OleTra;
                OleDC.ExecuteNonQuery();



                //Process Error Check
                //if (OleDC.Parameters["e_code"].Value.ToString() != "0")
                //{
                //    OleTra.Rollback();
                //    sErrMessg = "Gf_ExecProc2Modify Error Code : " + Proce_Name + " " + OleDC.Parameters["e_code"].Value.ToString() + "\r" + "Error Mesg : " + OleDC.Parameters["e_msg"].Value.ToString();
                //    Gp_MsgBoxDisplay(sErrMessg);
                //    functionReturnValue = false;
                //}
                //else
                //{
                //    OleTra.Commit();
                //    functionReturnValue = true;
                //}
                //Cursor.Current = Cursors.Default;
            }
            catch (Exception ex)
            {
                // OleTra.Rollback();
                functionReturnValue = false;
                Cursor.Current      = Cursors.Default;
                Gp_MsgBoxDisplay("日志记录错误 : " + sLOG_data + " " + ex.Message);
            }
            //finally

            return(functionReturnValue);
        }