Exemple #1
0
        public static int GetGameDBID(string sIP, string sServerNM, string sServerDB, string sSrcTbl, string sDesTbl, string sUser, string sPwd, int iGameID)
        {
            string strSQL;

            try
            {
                strSQL = "SELECT id From gamedb_info WHERE server_ip  ='" + sIP + "'";
                strSQL = strSQL + " AND server_name='" + sServerNM + "'";
                strSQL = strSQL + " AND server_db='" + sServerDB + "'";
                strSQL = strSQL + " AND srctable='" + sSrcTbl + "'";
                strSQL = strSQL + " AND destable='" + sDesTbl + "'";
                strSQL = strSQL + " AND user_id='" + sUser + "'";
                strSQL = strSQL + " AND user_pwd='" + sPwd + "'";
                strSQL = strSQL + " AND game_id=" + iGameID + "";
                DataSet dGameNm = CommonCLS.RunOracle(strSQL);
                if (dGameNm != null && dGameNm.Tables[0].Rows.Count > 0)
                {
                    return(Convert.ToInt32(dGameNm.Tables[0].Rows[0].ItemArray[0]));
                }
                else
                {
                    return(0);
                }
            }
            catch (System.Exception ex)
            {
                CommonCLS.SaveLog("SaveData->" + ex.Message);
                return(0);
            }
        }
Exemple #2
0
        bool leftOpen             = true; //左边listview是否打开
        #endregion

        #region 方法

        #region 获取游戏菜单
        /// <summary>
        ///  获取游戏菜单
        /// </summary>
        /// <returns></returns>
        private DataSet LoadGameMenu()
        {
            try
            {
                string  strSql = "select t.* from game_info t";
                DataSet dsGame = CommonCLS.RunOracle(strSql);                    //查询数据库

                return(dsGame);
            }
            catch (System.Exception ex)
            {
                CommonCLS.SaveLog(ex.ToString());
                return(null);
            }
        }
Exemple #3
0
        public static string GetGameTbSpaceById(int iID)
        {
            string strSQL;

            try
            {
                strSQL = "SELECT TABLE_SPACE_NAME From Game_Info WHERE game_id =" + iID;
                DataSet dGameNm = CommonCLS.RunOracle(strSQL);
                if (dGameNm != null && dGameNm.Tables[0].Rows.Count > 0)
                {
                    return(dGameNm.Tables[0].Rows[0].ItemArray[0].ToString());
                }
                else
                {
                    return("");
                }
            }
            catch (System.Exception ex)
            {
                CommonCLS.SaveLog("GetGameTbSpace->" + ex.Message);
                return("");
            }
        }
Exemple #4
0
        public static int GetGameDbTypeById(int iID)
        {
            string strSQL;

            try
            {
                strSQL = "SELECT TYPE_DB From Game_Info WHERE game_id =" + iID;
                DataSet dGameNm = CommonCLS.RunOracle(strSQL);
                if (dGameNm != null && dGameNm.Tables[0].Rows.Count > 0)
                {
                    return(Convert.ToInt32(dGameNm.Tables[0].Rows[0].ItemArray[0]));
                }
                else
                {
                    return(0);
                }
            }
            catch (System.Exception ex)
            {
                CommonCLS.SaveLog("GetGameDbType->" + ex.Message);
                return(0);
            }
        }
Exemple #5
0
        public static int GetGameID(string strName)
        {
            string strSQL;

            try
            {
                strSQL = "SELECT game_id From Game_Info WHERE game_name ='" + strName.Trim() + "'";
                DataSet dGameNm = CommonCLS.RunOracle(strSQL);
                if (dGameNm != null && dGameNm.Tables[0].Rows.Count > 0)
                {
                    return(Convert.ToInt32(dGameNm.Tables[0].Rows[0].ItemArray[0]));
                }
                else
                {
                    return(0);
                }
            }
            catch (System.Exception ex)
            {
                CommonCLS.SaveLog("GetGameID->" + ex.Message);
                return(0);
            }
        }
        public void ReadDate()
        {
            string strBCP      = string.Empty; //BCP语句
            string strBcpPatch = string.Empty; //BCP路径
            string strCtlPatch = string.Empty; //CTL路径
            int    log_source  = 0;            //源记录数
            int    log_result  = 0;            //录入记录数

            string error        = string.Empty;
            int    log_ExistNum = 0;//目的表中以存在的记录数

            string sql = string.Empty;
            int    log_ExistNumAfter = 0; //目的表中导入后的记录数

            int      iHasChecked = 0;     //时候有行选中
            string   strBcpFileNM;
            FileInfo fiTmp = null;

            try
            {
                for (int j = 0; j < this.dataGV.Rows.Count; j++)
                {
                    if (this.dataGV.Rows[j].Cells["chkDoCollect"].Value.ToString() == "1")
                    {
                        iHasChecked = 1;
                        break;
                    }
                }
                if (iHasChecked == 0)
                {
                    MessageBox.Show("请选择要手动采集的对象");
                    return;
                }
                for (int i = 0; i < this.dataGV.Rows.Count; i++)
                {
                    if (this.dataGV.Rows[i].Cells["chkDoCollect"].Value.ToString() == "1")
                    {
                        //建立游戏名字目录
                        if (System.IO.Directory.Exists(Application.StartupPath + @"\" + this.Text) == false)
                        {
                            System.IO.Directory.CreateDirectory(Application.StartupPath + @"\" + this.Text);
                        }

                        //读取BCP
                        OracleParameter[] parameters =
                        {
                            new OracleParameter("v_ExpressID", OracleDbType.Int32),
                            new OracleParameter("cur_Result",  OracleDbType.RefCursor)
                        };
                        parameters[0].Direction = ParameterDirection.Input;
                        parameters[1].Direction = ParameterDirection.Output;

                        parameters[0].Value = this.dataGV.Rows[i].Cells["express_id"].Value.ToString();
                        DataSet dsBCP = CommonCLS.RunOracleSP("PD_GameInfo_Pack.PD_BCP_Query", parameters);


                        if (dsBCP != null && dsBCP.Tables[0].Rows.Count > 0)
                        {
                            //目的表中以存在的记录数

                            sql = " SELECT count(*) FROM " + dsBCP.Tables[0].Rows[0].ItemArray[4].ToString().Trim()
                                  + " Where TO_CHAR(SCN_TO_TIMESTAMP(ora_rowscn),'YYYY/MM/DD')='" + Convert.ToDateTime(this.dataGV.Rows[i].Cells["CollectTime"].Value.ToString()).ToShortDateString().Replace("-", "/") + "'";
                            DataSet dslog_ExistNum = CommonCLS.RunOracle(sql);
                            log_ExistNum = Convert.ToInt32(dslog_ExistNum.Tables[0].Rows[0].ItemArray[0]);
                            //执行BCP
                            try
                            {
                                strBcpFileNM = this.dataGV.Rows[i].Cells["server_Name"].Value.ToString() + this.dataGV.Rows[i].Cells["log_table"].Value.ToString() + ".txt";
                                fiTmp        = new FileInfo(strBcpFileNM);
                                //判断采集时间是否当天的日期

                                string strBcpTmp = string.Empty;
                                strBcpTmp = dsBCP.Tables[0].Rows[0].ItemArray[1].ToString().ToUpper().Replace("'%S' AS SERVERIP , '%S' AS SERVERDB",
                                                                                                              "'" + this.dataGV.Rows[i].Cells["ip"].Value.ToString() + "' AS ServerIP,'" + this.dataGV.Rows[i].Cells["log_table"].Value.ToString() + "' AS ServerDB");
                                if (this.dataGV.Rows[i].Cells[6].Value.ToString() != CommonCLS.GetSysDate().ToString("yyyy/MM/dd").Replace("-", "/"))
                                {
                                    //不是当天日期则替换bcp sql中的getdate或now函数
                                    if (strBcpTmp.ToUpper().Contains("GETDATE()") == true || strBcpTmp.ToUpper().Contains("NOW()") == true)
                                    {
                                        strBcpTmp = strBcpTmp.Replace("GETDATE()", "CONVERT(DATETIME,'" + this.dataGV.Rows[i].Cells[6].Value.ToString() + "')");
                                    }
                                    else
                                    {
                                        strBcpTmp = strBcpTmp.Replace("NOW()", "CONVERT(DATETIME,'" + this.dataGV.Rows[i].Cells[6].Value.ToString() + "')");
                                    }
                                }
                                //删除采集时间的错误数据

                                DelFailedData(Convert.ToDateTime(this.dataGV.Rows[i].Cells["CollectTime"].Value.ToString()).ToShortDateString().Replace("-", "/"), dsBCP.Tables[0].Rows[0].ItemArray[4].ToString().Trim());
                                strBCP = " BCP \"" + strBcpTmp + " \" queryout " + Application.StartupPath + @"\" + this.Text + @"\" + fiTmp.Name
                                         + " -c -S\"" + this.dataGV.Rows[i].Cells["ip"].Value.ToString() + "\""
                                         + " -U\"" + this.dataGV.Rows[i].Cells["User_Id"].Value.ToString() + "\""
                                         + " -P\"" + this.dataGV.Rows[i].Cells["User_Pwd"].Value.ToString() + "\"";
                                strBcpPatch = dsBCP.Tables[0].Rows[0].ItemArray[0].ToString().Trim();
                                Invoke(new EventHandler(delegate(object sender, EventArgs e)
                                {
                                    this.lblLoading.Visible = true;
                                    this.lblLoading.Text    = "执行BCP," +
                                                              "IP:" + this.dataGV.Rows[i].Cells[3].Value.ToString() +
                                                              ".大区:" + this.dataGV.Rows[i].Cells[2].Value.ToString() +
                                                              ".库:" + this.dataGV.Rows[i].Cells[4].Value.ToString() +
                                                              ".表:" + this.dataGV.Rows[i].Cells[5].Value.ToString() +
                                                              ".采集数据中..";
                                    this.btnOk.Enabled      = false;
                                    this.btrRefresh.Enabled = false;
                                    this.dataGV.Enabled     = false;
                                }
                                                        )
                                       );
                                ExeCommand(strBCP);//执行bcp命令并显示操作结果


                                //源记录数
                                strBCP = strBCP.ToUpper();
                                string[] line = File.ReadAllLines(Application.StartupPath + @"\" + this.Text + @"\" + fiTmp.Name);
                                log_source = line.Length;
                            }
                            catch (System.Exception ex)
                            {
                                error = "执行BCP,下载数据失败";
                            }
                            try
                            {
                                //执行CTL
                                Invoke(new EventHandler(delegate(object sender, EventArgs e)
                                {
                                    this.lblLoading.Text = "执行CTL,保存采集数据中,共有" + log_source + "条数据,处理时间较长.请稍候..";
                                }
                                                        )
                                       );
                                //strCtlPatch = System.Text.Encoding.Default.GetString((byte[])dsBCP.Tables[0].Rows[0].ItemArray[4]);
                                //strCtlPatch = strCtlPatch.Replace(strCtlPatch.Substring(strCtlPatch.IndexOf("INFILE") + 7, strCtlPatch.IndexOf(".txt") - 13), "'" + Application.StartupPath + @"\" + this.Text + @"\" + fiTmp.Name + "'");
                                strCtlPatch = this.BuildCTL(this.dataGV.Rows[i].Cells["server_Name"].Value.ToString() + this.dataGV.Rows[i].Cells["log_table"].Value.ToString() + ".ctl",
                                                            "Append", dsBCP.Tables[0].Rows[0].ItemArray[7].ToString(), dsBCP.Tables[0].Rows[0].ItemArray[4].ToString());

                                FileStream fs  = new FileStream(Application.StartupPath + @"\" + this.Text + @"\" + this.dataGV.Rows[i].Cells["server_Name"].Value.ToString() + this.dataGV.Rows[i].Cells["log_table"].Value.ToString() + ".ctl", FileMode.Append, FileAccess.Write);
                                byte[]     str = System.Text.Encoding.Default.GetBytes(strCtlPatch);
                                fs.Write(str, 0, str.Length);
                                fs.Close();
                                string sCtlNm = strBcpFileNM = this.dataGV.Rows[i].Cells["server_Name"].Value.ToString() + this.dataGV.Rows[i].Cells["log_table"].Value.ToString() + ".CTL";
                                ExeCommand("sqlldr " + CommonCLS.UserName + "/" + CommonCLS.PASSWORD + "@" + CommonCLS.TNS + " control=" + Application.StartupPath + @"\" + this.Text + @"\" + sCtlNm);  //执行bcp命令并显示操作结果


                                System.IO.File.Delete(Application.StartupPath + @"\" + this.Text + @"\" + fiTmp.Name);
                            }
                            catch (System.Exception ex2)
                            {
                                error = "执行CTL,导入数据失败";
                            }

                            //读取写入记录数


                            //执行CTL
                            Invoke(new EventHandler(delegate(object sender, EventArgs e)
                            {
                                this.lblLoading.Text    = "采集结束!..";
                                this.lblLoading.Visible = false;
                                this.btnOk.Enabled      = true;
                                this.btrRefresh.Enabled = true;
                                this.dataGV.Enabled     = true;
                            }
                                                    )
                                   );

                            sql = " SELECT count(*) FROM " + dsBCP.Tables[0].Rows[0].ItemArray[3].ToString().Trim();
                            DataSet ExistNumAfter = CommonCLS.RunOracle(sql);
                            log_ExistNumAfter = Convert.ToInt32(ExistNumAfter.Tables[0].Rows[0].ItemArray[0]);
                            //sql = " SELECT count(*) FROM " + dsBCP.Tables[0].Rows[0].ItemArray[3].ToString().Trim();
                            //DataSet dsCountResult = CommonCLS.RunOracle(sql);
                            //log_result = Convert.ToInt32(dsCountResult.Tables[0].Rows[0].ItemArray[0]);
                            log_result = log_ExistNumAfter - log_ExistNum;
                            string log_detail = "";
                            if (error == string.Empty)
                            {
                                log_detail = "[" + this.dataGV.Rows[i].Cells[3].Value.ToString() + "]执行[" + this._strGameName + "--" + this.dataGV.Rows[i].Cells[4].Value.ToString() + "]成功,数据源[" + log_source + "]条记录,保存[" + log_result + "]条记录";
                            }
                            else
                            {
                                log_detail = "[" + this.dataGV.Rows[i].Cells[3].Value.ToString() + "]执行[" + this._strGameName + "--" + this.dataGV.Rows[i].Cells[4].Value.ToString() + "]失败,失败原因:[" + error + "]";
                            }
                            //写操作LOG
                            OracleParameter[] parametersOpLog =
                            {
                                new OracleParameter("v_LogSource", OracleDbType.Varchar2),
                                new OracleParameter("v_LogResult", OracleDbType.Varchar2),
                                new OracleParameter("v_Detail",    OracleDbType.Varchar2),
                                new OracleParameter("v_id",        OracleDbType.Int32),
                                new OracleParameter("v_Result",    OracleDbType.Decimal)
                            };
                            parametersOpLog[0].Direction = ParameterDirection.Input;
                            parametersOpLog[1].Direction = ParameterDirection.Input;
                            parametersOpLog[2].Direction = ParameterDirection.Input;
                            parametersOpLog[3].Direction = ParameterDirection.Input;
                            parameters[4].Direction      = ParameterDirection.Output;

                            parametersOpLog[0].Value = log_source;
                            parametersOpLog[1].Value = log_result;
                            parametersOpLog[2].Value = log_detail;
                            parametersOpLog[3].Value = this.dataGV.Rows[i].Cells[10].Value.ToString();
                            int resultOpLog = CommonCLS.RunOracleNonQuerySp("PD_Game_Admin.PD_ExpressLOG_Update", parametersOpLog);



                            //sql = " UPDATE EXPRESS_LOG SET ";
                            ////sql = sql + " LOG_DATE=(select to_char(sysdate,'YYYY/MM/DD')  from dual), ";
                            //sql = sql + " LOG_SOURCE=" + log_source +", ";
                            //sql = sql + " LOG_RESULT=" + log_result + ", ";
                            //sql = sql + " LOG_DETAIL='" + log_detail + "' ";
                            //sql = sql + " WHERE id=" + this.dataGV.Rows[i].Cells[10].Value.ToString();
                            //CommonCLS.RunOracleNonQuery(sql);
                        }
                    }
                }

                Invoke(new EventHandler(delegate(object sender, EventArgs e)
                {
                    this.GetMonitorData();
                    MessageBox.Show("执行完毕");
                }
                                        )
                       );
            }
            catch (System.Exception ex)
            {
            }
        }
Exemple #7
0
        /// <summary>
        ///  检查用户名和密码

        /// </summary>
        ///  /// <param name="_strUserNm">账号</param>
        /// <param name="_strPwd">密码</param>
        /// <returns></returns>
        private int CheckLogin(string _strUserNm, string _strPwd)
        {
            try
            {
                //Modify 2009/09/07 wyh Begin *********************************
                this.ShowStatusControl();
                string strSql = "SELECT userid ,pwd,id,status FROM User_Info";
                strSql = strSql + " WHERE userid= '" + _strUserNm.Trim() + "'" + " AND  pwd='" + _strPwd.Trim() + "'"; //登录检查SQL语句

                this.Cursor = Cursors.WaitCursor;
                DataSet dsLogin = CommonCLS.RunOracle(strSql);                    //查询数据库



                //OracleParameter[] parameters =
                //{
                //    new OracleParameter("v_userid", OracleDbType.Varchar2),
                //    new OracleParameter("v_pwd", OracleDbType.Varchar2),
                //    new OracleParameter("cur_Result", OracleDbType.RefCursor)
                //};
                //parameters[0].Direction = ParameterDirection.Input;
                //parameters[1].Direction = ParameterDirection.Input;
                //parameters[2].Direction = ParameterDirection.Output;

                //parameters[0].Value = _strUserNm.Trim();
                //parameters[1].Value = _strPwd.Trim();
                //DataSet dsLogin = CommonCLS.RunOracleSP("PD_GameInfo_Pack.PD_CheckLogin_QueryAll", parameters);
                //Modify 2009/09/07 End******************************************

                this.HideStatus();
                if (dsLogin != null && dsLogin.Tables[0].Rows.Count > 0)
                {
                    if (dsLogin.Tables[0].Rows[0].ItemArray[3].ToString() == "0")
                    {
                        return(2);        //帐号停止使用
                    }


                    if (dsLogin.Tables[0].Rows[0].ItemArray[0].ToString() == _strUserNm.Trim() && dsLogin.Tables[0].Rows[0].ItemArray[1].ToString() == _strPwd.Trim())
                    {
                        CommonCLS.LoginUserID = dsLogin.Tables[0].Rows[0].ItemArray[2].ToString();

                        return(0);        //登录成功
                    }
                    else
                    {
                        return(1);       //登录失败
                    }
                }
                else
                {
                    return(1);
                }
            }
            catch (System.Exception ex)
            {
                CommonCLS.SaveLog(ex.ToString());
                return(1);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }