Ejemplo n.º 1
0
 public int AccountRequest(string pwd)
 {
     try {
         con.Open();
         sql = "INSERT INTO users(user_password) VALUES(" + pwd + ")";
         MySQLCommand com = new MySQLCommand(sql, con);
         com.ExecuteNonQuery();
         sql = "SELECT LAST_INSERT_ID()";
         com = new MySQLCommand(sql, con);
         DbDataReader reader = com.ExecuteReader();
         int user_id = 0;
         if(reader.Read())
         {
             user_id = Int32.Parse(reader["user_id"].ToString());
         } 
         sql = "INSERT INTO users_information VALUES(null,null,null,null)";
         com = new MySQLCommand(sql, con);
         com.ExecuteNonQuery();
         return user_id;
     }
     catch { return 0; }
     finally
     {
         con.Close();
     }
 }
Ejemplo n.º 2
0
        //获得数据库数据
        private void GetUserData()
        {
            MySQLConnection DBConn = null;
            string connectStr = new MySQLConnectionString(Configuration.getDBIp(), "workflow", Configuration.getDBUsername(), Configuration.getDBPassword()).AsString;
            //System.Windows.Forms.MessageBox.Show(connectStr);
            DBConn = new MySQLConnection(connectStr);
            DBConn.Open();
            MySQLCommand setformat = new MySQLCommand("set names gb2312", DBConn);
            setformat.ExecuteNonQuery();
            setformat.Dispose();


            string sql = "select User_Id,User_Name,User_Dept,User_Job,User_Mail,User_Cell from tb_user";
            MySQLDataAdapter mda = new MySQLDataAdapter(sql, DBConn);

            DataTable ds = new DataTable();
            mda.Fill(ds);

            DBConn.Close();
            foreach (DataRow dr in ds.Rows)
            {
                UserModel um = new UserModel();
                um.ID = dr["User_Id"].ToString();
                um.Name = dr["User_Name"].ToString();
                um.Department = dr["User_Dept"].ToString();
             
                um.Email = dr["User_Mail"].ToString();
                um.PersonPosition = dr["User_Job"].ToString();
                um.Telephone = dr["User_Cell"].ToString();

                models.Add(um);
            }
            view.Source = models;
            this.listView1.DataContext = view;
        }
Ejemplo n.º 3
0
        //获得数据库数据
        private void GetUserData()
        {
            MySQLConnection DBConn = null;
            DBConn = new MySQLConnection(new MySQLConnectionString(Configuration.getDBIp(), "workflow", Configuration.getDBUsername(), Configuration.getDBPassword()).AsString);
            DBConn.Open();
            MySQLCommand setformat = new MySQLCommand("set names gb2312", DBConn);
            setformat.ExecuteNonQuery();
            setformat.Dispose();


            string sql = "select distinct User_Dept from tb_user";
            MySQLDataAdapter mda = new MySQLDataAdapter(sql, DBConn);

            DataTable ds = new DataTable();
            mda.Fill(ds);

            DBConn.Close();
            foreach (DataRow dr in ds.Rows)
            {
                UserModel um = new UserModel();
              
                um.Department = dr["User_Dept"].ToString();
             
                models.Add(um);
            }
            view.Source = models;
            this.listView1.DataContext = view;
        }
Ejemplo n.º 4
0
        //获得数据库数据
        private void GetUserData()
        {
            MySQLConnection DBConn = null;
            DBConn = new MySQLConnection(new MySQLConnectionString(Configuration.getDBIp(), "template", Configuration.getDBUsername(), Configuration.getDBPassword()).AsString);
            DBConn.Open();
            MySQLCommand setformat = new MySQLCommand("set names gb2312", DBConn);
            setformat.ExecuteNonQuery();
            setformat.Dispose();

            string type = MainWindow.wfmodel.WFModel_Type;
            string sql = "select name, description,type from template where type = '"+type+"'";
            MySQLDataAdapter mda = new MySQLDataAdapter(sql, DBConn);

            DataTable ds = new DataTable();
            mda.Fill(ds);

            DBConn.Close();
            foreach (DataRow dr in ds.Rows)
            {
                TemplateModel um = new TemplateModel();
                um.name = dr["name"].ToString();
                um.desc = dr["description"].ToString();
                um.type = dr["type"].ToString();
                models.Add(um);
            }
            view.Source = models;
            this.listView1.DataContext = view;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 得到连接对象
 /// </summary>
 /// <returns></returns>
 public void GetConn()
 {
     MySQLConnection conn = null;
     conn = new MySQLConnection(new MySQLConnectionString("svn.breadth.cn", "mez", "root", "breadth2009").AsString);
     conn.Open();
     MySQLCommand comn = new MySQLCommand("set names utf-8", conn);
     comn.ExecuteNonQuery();
 }
Ejemplo n.º 6
0
        public void insertFollow(int fanId, int followerId)
        {
            init();
            con.Open();
            string sql = "insert into follow_list value(null,"
                         + fanId + ","
                         + followerId + ")";

            System.Diagnostics.Debug.WriteLine(sql);
            MySQLCommand cmd = new MySQLCommand(sql, con);

            cmd.ExecuteNonQuery();
            con.Close();
        }
Ejemplo n.º 7
0
        //获得数据库数据
        void GetTemplateData()
        {
            models.Clear();
            MySQLConnection DBConn = null;

            DBConn = new MySQLConnection(new MySQLConnectionString(Configuration.getDBIp(), "workflow", Configuration.getDBUsername(), Configuration.getDBPassword()).AsString);
            try
            {
                DBConn.Open();
                MySQLCommand setformat = new MySQLCommand("set names gb2312", DBConn);
                setformat.ExecuteNonQuery();
                setformat.Dispose();


                string           sql = "select model_name,owner,model_content,lastedit_time,model_disc,create_time from wf_model";
                MySQLDataAdapter mda = new MySQLDataAdapter(sql, DBConn);

                DataTable ds = new DataTable();
                mda.Fill(ds);

                DBConn.Close();
                foreach (DataRow dr in ds.Rows)
                {
                    WFModel wfm = new WFModel();
                    wfm.WFModel_CreateTime   = dr["create_time"].ToString();
                    wfm.WFModel_LasteditTime = dr["lastedit_time"].ToString();
                    wfm.WFModel_Name         = dr["model_name"].ToString();
                    wfm.WFModel_Owner        = dr["owner"].ToString();
                    string test = dr["model_content"].ToString();
                    if (dr["model_content"] == null || dr["model_content"].ToString().Length <= 0)
                    {
                        wfm.WFModel_Content = "";
                    }
                    else
                    {
                        wfm.WFModel_Content = Encoding.Default.GetString((Byte[])dr["model_content"]);
                    }

                    models.Add(wfm);
                }
                view.Source = models;
                this.listView1.DataContext = view;
            }
            catch (Exception e)
            {
                MessageBox.Show("数据库连接失败,请检查网络连接或者数据库配置");
                return;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 执行查询语句,返回MySQLDataReader ( 注意:调用该方法后,一定要对MySQLDataReader进行Close )
        /// </summary>
        /// <param name="strSQL">查询语句</param>
        /// <returns>MySQLDataReader</returns>
        public static MySQLDataReader ExecuteReader(string strSQL, bool islog = false)
        {
            if (!loadConnectStr)
            {
                LoadConnectStr();
            }

            MySQLConnection connection = null;

            if (islog)
            {
                connection = new MySQLConnection(realConnStrLog);
            }
            else
            {
                connection = new MySQLConnection(realConnStrGame);
            }

            MySQLCommand cmd     = new MySQLCommand(strSQL, connection);
            MySQLCommand cmdname = new MySQLCommand("SET NAMES 'latin1'", connection);

            try
            {
                connection.Open();
                int             res      = cmdname.ExecuteNonQuery();
                MySQLDataReader myReader = cmd.ExecuteReaderEx();
                return(myReader);
            }
            catch (MySql.Data.MySqlClient.MySqlException e)
            {
                throw e;
            }
            finally
            {
                if (cmd != null)
                {
                    cmd.Dispose();
                }
                if (cmdname != null)
                {
                    cmdname.Dispose();
                }
                if (connection != null)
                {
                    connection.Dispose();
                    connection.Close();
                }
            }
        }
Ejemplo n.º 9
0
        public void updateArticle2(Article article)
        {
            init();
            con.Open();
            string sql = "update article set "
                         + "`like` = " + article.like + ","
                         + "collect = " + article.collect + " where "
                         + "id = " + article.id;

            System.Diagnostics.Debug.WriteLine(sql);
            MySQLCommand cmd = new MySQLCommand(sql, con);

            cmd.ExecuteNonQuery();
            return;
        }
Ejemplo n.º 10
0
        public void deleteCollect(int articleId, int userId, string time)
        {
            init();
            con.Open();
            string sql = "delete from collect_list where "
                         + "article_id = " + articleId + " && "
                         + "user_id = " + userId;

            System.Diagnostics.Debug.WriteLine(sql);
            MySQLCommand cmd = new MySQLCommand(sql, con);

            cmd.ExecuteNonQuery();
            con.Close();
            return;
        }
Ejemplo n.º 11
0
        public MySQLDataReader GetDataReader(string commandStr)
        {
            connection.Open();

            MySQLCommand cmdTemp = (MySQLCommand)connection.CreateCommand();

            cmdTemp.CommandText = "set names gbk";
            cmdTemp.ExecuteNonQuery();

            command             = (MySQLCommand)connection.CreateCommand();
            command.CommandText = commandStr;
            dataReader          = (MySQLDataReader)command.ExecuteReader();

            return(dataReader);
        }
Ejemplo n.º 12
0
        private void FundBuy(GameServerClient client, int nID, byte[] cmdParams, int count)
        {
            bool            bResult = false;
            MySQLConnection conn    = null;

            try
            {
                FundDBItem item    = DataHelper.BytesToObject <FundDBItem>(cmdParams, 0, count);
                string     cmdText = string.Format("UPDATE t_fund SET state='0' where zoneID='{0}' and userID='{1}' and roleID='{2}' and fundType='{3}' and state='1'", new object[]
                {
                    item.ZoneID,
                    item.UserID,
                    item.RoleID,
                    item.FundType
                });
                string cmdText2 = string.Format("INSERT INTO t_fund(zoneID,userID,roleID,fundType,fundID,buyTime) VALUE('{0}','{1}','{2}','{3}','{4}','{5}')", new object[]
                {
                    item.ZoneID,
                    item.UserID,
                    item.RoleID,
                    item.FundType,
                    item.FundID,
                    item.BuyTime
                });
                GameDBManager.SystemServerSQLEvents.AddEvent(string.Format("+SQL: {0}", cmdText), EventLevels.Important);
                GameDBManager.SystemServerSQLEvents.AddEvent(string.Format("+SQL: {0}", cmdText2), EventLevels.Important);
                conn = DBManager.getInstance().DBConns.PopDBConnection();
                MySQLCommand cmd = new MySQLCommand(cmdText, conn);
                bResult = (cmd.ExecuteNonQuery() > 0);
                cmd     = new MySQLCommand(cmdText2, conn);
                cmd.ExecuteNonQuery();
                cmd.Dispose();
                bResult = true;
            }
            catch (Exception ex)
            {
                LogManager.WriteException(ex.Message);
                bResult = false;
            }
            finally
            {
                if (null != conn)
                {
                    DBManager.getInstance().DBConns.PushDBConnection(conn);
                }
            }
            client.sendCmd <bool>(nID, bResult);
        }
Ejemplo n.º 13
0
        public void insertNewCollect(int articleId, int userId, string time)
        {
            init();
            con.Open();
            string sql = "insert into collect_list value(null,"
                         + articleId + ","
                         + userId + ","
                         + "\"" + time + "\")";

            System.Diagnostics.Debug.WriteLine(sql);
            MySQLCommand cmd = new MySQLCommand(sql, con);

            cmd.ExecuteNonQuery();
            con.Close();
            return;
        }
Ejemplo n.º 14
0
        //获得数据库数据
        void GetTemplateData()
        {
            models.Clear();
            MySQLConnection DBConn = null;
            DBConn = new MySQLConnection(new MySQLConnectionString(Configuration.getDBIp(), "workflow", Configuration.getDBUsername(), Configuration.getDBPassword()).AsString);
            try
            {

                DBConn.Open();
                MySQLCommand setformat = new MySQLCommand("set names gb2312", DBConn);
                setformat.ExecuteNonQuery();
                setformat.Dispose();


                string sql = "select model_name,owner,model_content,lastedit_time,model_disc,create_time from wf_model";
                MySQLDataAdapter mda = new MySQLDataAdapter(sql, DBConn);

                DataTable ds = new DataTable();
                mda.Fill(ds);

                DBConn.Close();
                foreach (DataRow dr in ds.Rows)
                {
                    WFModel wfm = new WFModel();
                    wfm.WFModel_CreateTime = dr["create_time"].ToString();
                    wfm.WFModel_LasteditTime = dr["lastedit_time"].ToString();
                    wfm.WFModel_Name = dr["model_name"].ToString();
                    wfm.WFModel_Owner = dr["owner"].ToString();
                    string test = dr["model_content"].ToString();
                    if (dr["model_content"] == null || dr["model_content"].ToString().Length<=0)
                    {
                        wfm.WFModel_Content = "";
                    }else
                        wfm.WFModel_Content = Encoding.Default.GetString((Byte[])dr["model_content"]);

                    models.Add(wfm);
                }
                view.Source = models;
                this.listView1.DataContext = view;
            }
            catch (Exception e)
            {
                MessageBox.Show("数据库连接失败,请检查网络连接或者数据库配置");
                return;
            }

        }
Ejemplo n.º 15
0
        private void HandleClrZhanBao(GameServerClient client, int nID, byte[] cmdParams, int count)
        {
            MySQLConnection conn = null;

            try
            {
                string   cmdData = new UTF8Encoding().GetString(cmdParams, 0, count);
                string[] fields  = cmdData.Split(new char[]
                {
                    ':'
                });
                if (fields.Length != 2)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true);
                    client.sendCmd(30767, "0");
                }
                else
                {
                    int    role        = Convert.ToInt32(fields[0]);
                    int    role2       = Convert.ToInt32(fields[1]);
                    long   unionCouple = this.GetUnionCouple(role, role2);
                    string sql         = string.Format("DELETE FROM t_couple_arena_zhan_bao WHERE `union_couple`={0};", unionCouple);
                    conn = DBManager.getInstance().DBConns.PopDBConnection();
                    MySQLCommand cmd = new MySQLCommand(sql, conn);
                    GameDBManager.SystemServerSQLEvents.AddEvent(string.Format("+SQL: {0}", sql), EventLevels.Important);
                    cmd.ExecuteNonQuery();
                    cmd.Dispose();
                    lock (this.Mutex)
                    {
                        this.CoupleZhanBaoDict.Remove(unionCouple);
                    }
                    client.sendCmd <bool>(nID, true);
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(LogTypes.Error, "HandleClrZhanBao failed, " + ex.Message, null, true);
                client.sendCmd <bool>(nID, false);
            }
            finally
            {
                if (null != conn)
                {
                    DBManager.getInstance().DBConns.PushDBConnection(conn);
                }
            }
        }
Ejemplo n.º 16
0
        private void handleSave(GameServerClient client, int nID, byte[] cmdParams, int count)
        {
            bool            bResult = false;
            MySQLConnection conn    = null;

            try
            {
                TradeBlackHourItem data   = DataHelper.BytesToObject <TradeBlackHourItem>(cmdParams, 0, count);
                DBRoleInfo         dbRole = DBManager.getInstance().GetDBRoleInfo(ref data.RoleId);
                if (dbRole == null)
                {
                    throw new Exception("TradeBlackManager.handleSave not Find DBRoleInfo, roleid=" + data.RoleId);
                }
                string sql = string.Format("REPLACE INTO t_ban_trade(rid,day,hour,market_in_price,market_times,market_out_price,Trade_in_price,Trade_times,Trade_out_price,distinct_roles)  VALUES({0},'{1}',{2},{3},{4},{5},{6},{7},{8},{9})", new object[]
                {
                    data.RoleId,
                    data.Day,
                    data.Hour,
                    data.MarketInPrice,
                    data.MarketTimes,
                    data.MarketOutPrice,
                    data.TradeInPrice,
                    data.TradeTimes,
                    data.TradeOutPrice,
                    data.TradeDistinctRoleCount
                });
                GameDBManager.SystemServerSQLEvents.AddEvent(string.Format("+SQL: {0}", sql), EventLevels.Important);
                conn = DBManager.getInstance().DBConns.PopDBConnection();
                MySQLCommand cmd = new MySQLCommand(sql, conn);
                cmd.ExecuteNonQuery();
                cmd.Dispose();
                bResult = true;
            }
            catch (Exception ex)
            {
                LogManager.WriteException("TradeBlackManager.handleSave " + ex.Message);
                bResult = false;
            }
            finally
            {
                if (conn != null)
                {
                    DBManager.getInstance().DBConns.PushDBConnection(conn);
                }
            }
            client.sendCmd <bool>(nID, bResult);
        }
Ejemplo n.º 17
0
        public static ToolboxCategoryItems loadUserbox()
        {
            MySQLConnection DBConn = new MySQLConnection(new MySQLConnectionString(Configuration.getDBIp(), "workflow", Configuration.getDBUsername(), Configuration.getDBPassword()).AsString);

            if (DBConn != null)
            {
                try
                {
                    DBConn.Open();
                    string       sql1   = "set names gb2312";
                    MySQLCommand DBComm = new MySQLCommand(sql1, DBConn); //設定下達 command
                    DBComm.ExecuteNonQuery();
                    DBComm.Dispose();
                    string           sql           = "select * from tb_user";
                    MySQLDataAdapter mda           = new MySQLDataAdapter(sql, DBConn);
                    DataTable        UserDataTable = new DataTable();
                    mda.Fill(UserDataTable);
                    DBConn.Close();
                    loadSystemIcon();

                    ToolboxCategoryItems toolboxCategoryItems = new ToolboxCategoryItems();
                    ToolboxCategory      users = new System.Activities.Presentation.Toolbox.ToolboxCategory("系统工作人员");

                    foreach (DataRow dr in UserDataTable.Rows)
                    {
                        //byte[] temp = Encoding.Default.GetBytes(dr["User_Name"].ToString());
                        //temp = System.Text.Encoding.Convert(Encoding.GetEncoding("utf8"), Encoding.GetEncoding("gb2312"), temp);
                        //string username = Encoding.Default.GetString(temp);
                        //ToolboxItemWrapper User = new ToolboxItemWrapper(typeof(Wxwinter.BPM.WFDesigner.User), username);
                        ToolboxItemWrapper User = new ToolboxItemWrapper(typeof(Wxwinter.BPM.WFDesigner.User), dr["User_Name"].ToString());
                        users.Add(User);
                    }
                    toolboxCategoryItems.Add(users);
                    parentWindow.statusInfo.Text = "";
                    return(toolboxCategoryItems);
                }
                catch (Exception e)
                {
                    parentWindow.statusInfo.Text = "数据库连接失败,请检查网络设置和数据库连接配置";
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 18
0
        public void Save_recoder()
        {
            DBConn.Open();
            MySQLCommand DBComm   = new MySQLCommand("select * from `parkingsystem`.`record`", DBConn);
            MySQLCommand firstCmd = new MySQLCommand("set names big5", DBConn);

            firstCmd.ExecuteNonQuery();
            MySQLDataReader DBReader = DBComm.ExecuteReaderEx();

            DBReader.Read();
            bool s = true;

            do
            {
                string compareID = ("" + DBReader.GetValue(0)); //Tad_ID
                string state     = ("" + DBReader.GetValue(2)); //目前狀態

                if (compareID == textBox1.Text)
                {
                    if (state == "P")                               //要出去
                    {
                        string Etime = ("" + DBReader.GetValue(3)); //進入時間

                        UPdata(compareID, Etime);
                        s = false;
                        break;
                    }
                    else if (state == "E")//正在進入
                    {
                        s = false;
                        break;
                    }
                    else if (state == "")//正在出去
                    {
                        s = false;
                        break;
                    }
                }
            } while (DBReader.Read());

            if (s)
            {
                save();     //要進來
            }
            DBConn.Close();
        }
        private void bt_Search_Click(object sender, EventArgs e)
        {
            if (cB_condition.Text.Equals("Reader") && tB_find.Text != null)     //reader
            {
                MySQLCommand DBComm1  = new MySQLCommand("select * from `RFID_Project`.`reader`", DBConn);
                MySQLCommand firstCmd = new MySQLCommand("set names big5", DBConn);
                firstCmd.ExecuteNonQuery();
                MySQLDataReader DBReader1 = DBComm1.ExecuteReaderEx();

                while (DBReader1.Read())
                {
                    if (tB_find.Text == DBReader1.GetString(0))    //查單一個設備
                    {
                        tB_id.Text        = DBReader1.GetString(0);
                        tB_buy_date.Text  = DBReader1.GetString(2);
                        tB_buy_money.Text = DBReader1.GetString(3);
                        tB_manager.Text   = DBReader1.GetString(4);
                        tB_type.Text      = DBReader1.GetString(5);
                        tB_meno.Text      = "架設地點:" + DBReader1.GetString(1);
                        break;
                    }
                }
            }

            if (cB_condition.Text.Equals("Tag") && tB_find.Text != null)      //tag
            {
                MySQLCommand DBComm   = new MySQLCommand("select * from `RFID_Project`.`tag`", DBConn);
                MySQLCommand firstCmd = new MySQLCommand("set names big5", DBConn);
                firstCmd.ExecuteNonQuery();
                MySQLDataReader DBReader = DBComm.ExecuteReaderEx();

                while (DBReader.Read())
                {
                    if (tB_find.Text == DBReader.GetString(0))    //查單一個設備
                    {
                        tB_id.Text        = DBReader.GetString(0);
                        tB_buy_date.Text  = DBReader.GetString(1);
                        tB_buy_money.Text = DBReader.GetString(2);
                        tB_manager.Text   = DBReader.GetString(3);
                        tB_type.Text      = DBReader.GetString(4);
                        tB_meno.Text      = "目前所屬學生:" + DBReader.GetString(5);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 20
0
        public void insertNewComment(Comment com)
        {
            com.comment = encode.stringToNum(com.comment);
            init();
            con.Open();
            string sql = "insert into comment_list value(null,"
                         + com.articleId + ","
                         + com.userId + ","
                         + "\"" + com.comment + "\","
                         + "\"" + com.time + "\")";

            System.Diagnostics.Debug.WriteLine(sql);
            MySQLCommand cmd = new MySQLCommand(sql, con);

            cmd.ExecuteNonQuery();
            return;
        }
Ejemplo n.º 21
0
        public bool IsNameCanUseInDb(DBManager dbMgr, string name)
        {
            bool result;

            if (dbMgr == null || string.IsNullOrEmpty(name))
            {
                result = false;
            }
            else
            {
                MySQLConnection conn       = null;
                string          prefixName = name + "99999999";
                try
                {
                    int    key = Thread.CurrentThread.ManagedThreadId;
                    string sql = string.Format("REPLACE INTO t_name_check(`id`,`name`) VALUES({0},'{1}');", key, prefixName);
                    conn = dbMgr.DBConns.PopDBConnection();
                    GameDBManager.SystemServerSQLEvents.AddEvent(string.Format("+SQL: {0}", sql), EventLevels.Important);
                    MySQLCommand cmd = new MySQLCommand(sql, conn);
                    cmd.ExecuteNonQuery();
                    cmd = new MySQLCommand(string.Format("SELECT name FROM t_name_check WHERE Id = {0};", key), conn);
                    MySQLDataReader reader = cmd.ExecuteReaderEx();
                    if (reader.Read())
                    {
                        string nameInDb = reader["name"].ToString();
                        if (!string.IsNullOrEmpty(nameInDb) && nameInDb == prefixName)
                        {
                            return(true);
                        }
                    }
                }
                catch (Exception)
                {
                    return(false);
                }
                finally
                {
                    if (null != conn)
                    {
                        dbMgr.DBConns.PushDBConnection(conn);
                    }
                }
                result = false;
            }
            return(result);
        }
Ejemplo n.º 22
0
        private string saveSms(PDUData pduData)
        {
            string sqlstr = "insert into mo_999 (dest,src,cmd,time) values (" +
                            "'" + this.phoneNum + "'"
                            + ",'" + pduData.getOA() + "'"
                            + ",'" + pduData.getMsg() + "'"
                            + ",now())";

            Console.WriteLine("aaaaaaaaaaaaaaaaaaaaaaa" + sqlstr);

            MySQLConnection conn = getConn();
            MySQLCommand    comm = new MySQLCommand(sqlstr, conn);

            comm.ExecuteNonQuery();

            return(sqlstr);
        }
Ejemplo n.º 23
0
        public void ExecuteDataReaderForAnyFieldType(string mySqlTypeDeclaration, string insertedLiteral, object expectedValue)
        {
            var c = CachedConnection;
            {
                using (var cmd1 = new MySQLCommand("DROP TABLE IF EXISTS number_type_test", c))
                    cmd1.ExecuteNonQuery();

                using (var cmd2 = new MySQLCommand($@"CREATE TABLE number_type_test ( id INT NOT NULL,COL_VALUE {mySqlTypeDeclaration},PRIMARY KEY (id));", c))
                    cmd2.ExecuteNonQuery();

                using (var cmd3 = new MySQLCommand($@"INSERT INTO number_type_test ( id ,COL_VALUE)values(0,{insertedLiteral});", c)) cmd3.ExecuteNonQuery();

                using (var cmd = new MySQLCommand("select id, COL_VALUE from number_type_test where id=0", c))
                {
                    var reader = cmd.ExecuteReader();
                    Assert.True(reader.Read());

                    {
                        var ordinal       = reader.GetOrdinal("COL_VALUE");
                        var executeScalar = reader.GetValue(ordinal);

                        Assert.NotNull(executeScalar);
                        if (expectedValue == null)
                        {
                            Assert.Null(executeScalar);
                        }
                        else
                        {
                            Assert.NotNull(executeScalar);
                            Assert.IsType(expectedValue.GetType(), executeScalar);
                            if (expectedValue is string)
                            {
                                expectedValue = "'" + expectedValue.ToString() + "'";
                            }
                            if (executeScalar is string)
                            {
                                executeScalar = "'" + executeScalar.ToString() + "'";
                            }
                            Assert.Equal(expectedValue, executeScalar);
                        }
                    }

                    Assert.False(reader.Read());
                }
            }
        }
Ejemplo n.º 24
0
 public void UseDatabase(string databaseKey, string databaseName)
 {
     if (databaseKey != this.DatabaseKey)
     {
         try
         {
             MySQLCommand cmd = new MySQLCommand(string.Format("use '{0}'", databaseName), this.DbConn);
             cmd.ExecuteNonQuery();
             cmd.Dispose();
             this.DatabaseKey = databaseKey;
         }
         catch (Exception ex)
         {
             LogManager.WriteExceptionUseCache(ex.ToString());
         }
     }
 }
Ejemplo n.º 25
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            DBConn.Open();
            MySQLCommand DBComm   = new MySQLCommand("select * from `parkingsystem`.`manager`", DBConn);
            MySQLCommand firstCmd = new MySQLCommand("set names big5", DBConn);

            firstCmd.ExecuteNonQuery();
            MySQLDataReader DBReader = DBComm.ExecuteReaderEx();

            while (DBReader.Read())
            {
                string tagstr = DBReader.GetString(0);
                if (tB_id.Text == tagstr)
                {
                    pictureBox1.ImageLocation = DBReader.GetString(5);                       //圖片
                }
            }
        }
Ejemplo n.º 26
0
 public static void Insert(string text)
 {
     lock (conn)
     {
         try
         {
             MySQLCommand commn;
             commn = new MySQLCommand("create table if not exists monsqldb (text varchar(1000))", conn);
             commn.ExecuteNonQuery();
             commn = new MySQLCommand("insert into monsqldb values('" + text + "')", conn);
             commn.ExecuteNonQuery();
         }
         catch (Exception ex)
         {
             System.Windows.Forms.MessageBox.Show("数据库访问出错:" + ex.Message);
         }
     }
 }
Ejemplo n.º 27
0
 public void ExecuteSqlTranWithIndentity(Hashtable SQLStringList)
 {
     using (DbTransaction trans = this.DbConn.BeginTransaction())
     {
         using (MySQLCommand cmd = new MySQLCommand())
         {
             try
             {
                 int indentity = 0;
                 foreach (object obj in SQLStringList)
                 {
                     DictionaryEntry  myDE     = (DictionaryEntry)obj;
                     string           cmdText  = myDE.Key.ToString();
                     MySQLParameter[] cmdParms = (MySQLParameter[])myDE.Value;
                     foreach (MySQLParameter q in cmdParms)
                     {
                         if (q.Direction == ParameterDirection.InputOutput)
                         {
                             q.Value = indentity;
                         }
                     }
                     MyDbConnection3.PrepareCommand(cmd, this.DbConn, trans, cmdText, cmdParms);
                     int val = cmd.ExecuteNonQuery();
                     foreach (MySQLParameter q in cmdParms)
                     {
                         if (q.Direction == ParameterDirection.Output)
                         {
                             indentity = Convert.ToInt32(q.Value);
                         }
                     }
                     cmd.Parameters.Clear();
                     this.LogSql(cmdText);
                 }
                 trans.Commit();
             }
             catch
             {
                 trans.Rollback();
                 throw;
             }
         }
     }
 }
Ejemplo n.º 28
0
        public bool Check()
        {
            DBConn.Open();
            MySQLCommand DBComm   = new MySQLCommand("select * from `RFID_Project`.`user`", DBConn);
            MySQLCommand firstCmd = new MySQLCommand("set names big5", DBConn);

            firstCmd.ExecuteNonQuery();
            MySQLDataReader DBReader = DBComm.ExecuteReaderEx();

            DBReader.Read();

            do
            {
                string id       = ("" + DBReader.GetValue(0)); //id
                string passoord = ("" + DBReader.GetValue(1)); //password

                if (tB_Id.Text == id)
                {
                    if (tB_OldPW.Text == passoord)                                                          // 檢查舊密碼
                    {
                        if (tB_NewPW.Text == tB_NewRPW.Text && tB_NewPW.Text != "" && tB_NewRPW.Text != "") // 新密碼兩欄位是否相同
                        {
                            //更新資料庫
                            MySQLCommand    DBCom     = new MySQLCommand("UPDATE `RFID_Project`.`user` SET `password` = '" + tB_NewPW.Text + "' WHERE CONVERT( `user`.`id` USING utf8 ) = '" + DBReader.GetString(0) + "' LIMIT 1 ;", DBConn);
                            MySQLDataReader DBReader1 = DBCom.ExecuteReaderEx();

                            return(true);
                        }
                    }
                }
            }while (DBReader.Read());

            if (tB_NewPW.Text.Length <= 4)
            {
                MessageBox.Show("密碼長度需大於4個字元");
                return(false);
            }
            else
            {
                MessageBox.Show("欄位有錯 ! 請再檢查一次");
            }
            return(false);
        }
Ejemplo n.º 29
0
        public void updateUser(User user)
        {
            init();
            con.Open();
            string sql = "update user set "
                         + "follow = " + user.follow + ","
                         + "fans = " + user.fans + ","
                         + "`like` = " + user.like + ","
                         + "collect = " + user.collect + ","
                         + "`comment` = " + user.comment + " "
                         + "where id = " + user.id;

            System.Diagnostics.Debug.WriteLine(sql);
            MySQLCommand cmd = new MySQLCommand(sql, con);

            cmd.ExecuteNonQuery();
            con.Close();
            return;
        }
Ejemplo n.º 30
0
 //执行SQL语句,返回影响的记录数
 /// <summary>
 /// 执行SQL语句,返回影响的记录数
 /// </summary>
 /// <param name="SQLString">SQL语句</param>
 /// <returns>影响的记录数</returns>
 public int ExecuteNonQuery(string SQLString)
 {
     using (MySQLConnection connection = new MySQLConnection(connectionString))
     {
         using (MySQLCommand cmd = new MySQLCommand(SQLString, connection))
         {
             try
             {
                 connection.Open();
                 int rows = cmd.ExecuteNonQuery();
                 return rows;
             }
             catch (MySQLException e)
             {
                 connection.Close();
                 throw e;
             }
         }
     }
 }
Ejemplo n.º 31
0
 /// <summary>
 /// 执行SQL语句,返回影响的记录数
 /// </summary>
 /// <param name="SQLString">SQL语句</param>
 /// <returns>影响的记录数</returns>
 public int ExecuteNonQuery(string SQLString, params MySQLParameter[] cmdParms)
 {
     using (MySQLConnection connection = new MySQLConnection(connectionString))
     {
         using (MySQLCommand cmd = new MySQLCommand())
         {
             try
             {
                 PrepareCommand(cmd, connection, null, SQLString, cmdParms);
                 int rows = cmd.ExecuteNonQuery();
                 cmd.Parameters.Clear();
                 return rows;
             }
             catch (MySQLException e)
             {
                 throw e;
             }
         }
     }
 }
Ejemplo n.º 32
0
        public void save()
        {
            DBConn.Open();
            MySQLCommand firstCmd = new MySQLCommand("set names big5", DBConn);

            firstCmd.ExecuteNonQuery();

            string          enter    = System.DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss");
            MySQLCommand    DBComm   = new MySQLCommand("INSERT INTO `parkingsystem`.`record` (`Tag_ID`,`carID`,`state`,`Etime`)VALUES ('" + textBox1.Text + "','" + textBox3.Text + "','" + "E" + "','" + enter + "');", DBConn);
            MySQLDataReader DBReader = DBComm.ExecuteReaderEx();

            DBConn.Close();

            if (SNcar != 0)
            {
                textBox4.Text  = ("" + ++Ncar);
                textBox5.Text  = ("" + --SNcar);
                tB_event.Text += (enter + "    有車輛進入!      " + textBox3.Text + "\r\n"); //message
            }
        }
Ejemplo n.º 33
0
        public void Delete(MySQLConnection con)
        {
            try
            {
                con.Open();

                MySQLCommand cmd = new MySQLCommand("DELETE FROM `test_table`", con);                //, `SerialNumberLastUsed`
                cmd.ExecuteNonQuery();
                cmd.Dispose();
                con.Close();
            }
            catch (Exception e)
            {
                if (con != null)
                {
                    con.Close();
                }
                throw e;
            }
        }
Ejemplo n.º 34
0
        public static ToolboxCategoryItems loadTemplatebox()
        {
            MySQLConnection DBConn = new MySQLConnection(new MySQLConnectionString(Configuration.getDBIp(), "template", Configuration.getDBUsername(), Configuration.getDBPassword()).AsString);
            if (DBConn != null)
            {
                try
                {
                    DBConn.Open();
                    string sql = "select * from template";
                    MySQLDataAdapter mda = new MySQLDataAdapter(sql, DBConn);
                    MySQLCommand mcd = new MySQLCommand(sql, DBConn);
                    mcd.ExecuteNonQuery();
                    DataTable TemplateDataTable = new DataTable();
                    mda.Fill(TemplateDataTable);
                    DBConn.Close();
                    loadSystemIcon();

                    ToolboxCategoryItems toolboxCategoryItems = new ToolboxCategoryItems();
                    ToolboxCategory templates = new System.Activities.Presentation.Toolbox.ToolboxCategory("表单模板");

                    foreach (DataRow dr in TemplateDataTable.Rows)
                    {
                        ToolboxItemWrapper Template = new ToolboxItemWrapper(typeof(Wxwinter.BPM.WFDesigner.Template), dr["NAME"].ToString());
                        templates.Add(Template);
                    }
                    toolboxCategoryItems.Add(templates);
                    parentWindow.statusInfo.Text = "";
                    return toolboxCategoryItems;
                }
                catch (Exception e)
                {
                    parentWindow.statusInfo.Text = "数据库连接失败,请检查网络设置和数据库连接配置";
                    return null;
                }
                
            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 35
0
        public static ToolboxCategoryItems loadTemplatebox()
        {
            MySQLConnection DBConn = new MySQLConnection(new MySQLConnectionString(Configuration.getDBIp(), "template", Configuration.getDBUsername(), Configuration.getDBPassword()).AsString);

            if (DBConn != null)
            {
                try
                {
                    DBConn.Open();
                    string           sql = "select * from template";
                    MySQLDataAdapter mda = new MySQLDataAdapter(sql, DBConn);
                    MySQLCommand     mcd = new MySQLCommand(sql, DBConn);
                    mcd.ExecuteNonQuery();
                    DataTable TemplateDataTable = new DataTable();
                    mda.Fill(TemplateDataTable);
                    DBConn.Close();
                    loadSystemIcon();

                    ToolboxCategoryItems toolboxCategoryItems = new ToolboxCategoryItems();
                    ToolboxCategory      templates            = new System.Activities.Presentation.Toolbox.ToolboxCategory("表单模板");

                    foreach (DataRow dr in TemplateDataTable.Rows)
                    {
                        ToolboxItemWrapper Template = new ToolboxItemWrapper(typeof(Wxwinter.BPM.WFDesigner.Template), dr["NAME"].ToString());
                        templates.Add(Template);
                    }
                    toolboxCategoryItems.Add(templates);
                    parentWindow.statusInfo.Text = "";
                    return(toolboxCategoryItems);
                }
                catch (Exception e)
                {
                    parentWindow.statusInfo.Text = "数据库连接失败,请检查网络设置和数据库连接配置";
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 36
0
        public ManagerHost()
        {
            InitializeComponent();
            MySQLConnection SQLconnection = new MySQLConnection(new MySQLConnectionString
                                                                    ("localhost", "DormitoryManage", "root", "123456").AsString);
            string SQLstr = "SELECT managerName FROM manager_info where managerNumber = " + PublicValue.MAGNUM;

            SQLconnection.Open();
            MySQLCommand SQLcommand1 = new MySQLCommand("SET NAMES GB2312", SQLconnection);

            SQLcommand1.ExecuteNonQuery();   //执行设置字符集的语句
            MySQLCommand    SQLcommand2 = new MySQLCommand(SQLstr, SQLconnection);
            MySQLDataReader SQLreader   = (MySQLDataReader)SQLcommand2.ExecuteReader();

            if (SQLreader.Read())
            {
                string temp = SQLreader["managerName"].ToString();
                this.Text = temp + "(公寓管理员)的主页";
            }
            SQLconnection.Close();
        }
 public static DataTable ExecuteDataTable(string SQLString)
 {
     using (MySQLConnection connection = new MySQLConnection(connectionString))
     {
         DataSet ds = new DataSet();
         try
         {
             connection.Open();
             MySQLDataAdapter command = new MySQLDataAdapter(SQLString, connection);
             MySQLCommand commn = new MySQLCommand("set names gbk", connection);
             commn.ExecuteNonQuery();
             command.Fill(ds, "ds");
             connection.Close();
         }
         catch (MySQLException ex)
         {
             throw new Exception(ex.Message);
         }
         return ds.Tables[0];
     }
 }
Ejemplo n.º 38
0
        private void button1_Click(object sender, EventArgs e)
        {
            Ip       = textBox1.Text.ToString();
            Password = textBox2.Text.ToString();
            Port     = Convert.ToInt32(textBox3.Text);
            Username = textBox4.Text.ToString();
            KuName   = textBox6.Text.ToString();
            MySQLConnection DBConn;

            DBConn = new MySQLConnection(new MySQLConnectionString(Ip, KuName, Username, Password, Port).AsString);
            DBConn.Open();
            try
            {
                MySQLCommand cmd = new MySQLCommand("select xls.id,config.id from xls,config where config.id=xls.id", DBConn);
                cmd.ExecuteNonQuery();
                MessageBox.Show("连接成功!");
            }
            catch (MySQLException ex)
            {
                switch (ex.Number)
                {
                case 1146:
                    MessageBox.Show("相关表不存在,系统正在为您创建!");
                    string       mySelectQuery = "CREATE TABLE xls(id int(11) auto_increment,DATE VARCHAR(255),IP VARCHAR(255),URL VARCHAR(255),MD5 VARCHAR(255),FLAG VARCHAR(255),CLASS VARCHAR(255),PRIMARY KEY (id))";
                    string       configsql     = "CREATE TABLE config(id int(11) auto_increment,CLASS VARCHAR(255),keyword VARCHAR(255),PRIMARY KEY (id))";
                    MySQLCommand cmd           = new MySQLCommand(mySelectQuery, DBConn);
                    MySQLCommand cmd2          = new MySQLCommand(configsql, DBConn);
                    cmd.ExecuteNonQuery();
                    cmd2.ExecuteNonQuery();
                    MessageBox.Show("创建成功!");
                    break;

                default:
                    MessageBox.Show(ex.Message);
                    break;
                }
            }
            DBConn.Close();
            this.Close();
        }
Ejemplo n.º 39
0
 private int saveModel()
 {
     if (WFModelInst == null)
     {
         return(-3);
     }
     else
     {
         try
         {
             MySQLConnection DBConn   = new MySQLConnection(new MySQLConnectionString(Configuration.getDBIp(), "workflow", Configuration.getDBUsername(), Configuration.getDBPassword()).AsString);
             string          checkSql = "select model_name from wf_model where model_name = '" + WFModelInst.WFModel_Name + "';";
             DBConn.Open();
             MySQLCommand    mcd      = new MySQLCommand(checkSql, DBConn);
             MySQLDataReader DBReader = mcd.ExecuteReaderEx(); //DBComm.ExecuteReaderEx();
             if (DBReader.Read())
             {
                 return(-1);
             }
             else
             {
                 string insertSql = "insert into wf_model (model_name,model_type,owner) values ('" + WFModelInst.WFModel_Name + "','" + WFModelInst.WFModel_Type + "','" + WFModelInst.WFModel_Owner + "');";
                 try
                 {
                     MySQLCommand mcd2 = new MySQLCommand(insertSql, DBConn);
                     mcd2.ExecuteNonQuery();
                     return(0);
                 }
                 catch (Exception Ex)
                 {
                     return(-2);
                 }
             }
         }
         catch (MySQLException e) {
             //MessageBox.Show("数据库连接失败,请检查网络连接或者数据库配置");
             return(-2);
         }
     }
 }
Ejemplo n.º 40
0
    public static void Send_MSG_By_QA_DB(string[][] msgs)
    {
        string _dbConString = ConfigurationManager.ConnectionStrings["TD_OA"].ConnectionString;

        using (MySQLConnection conn =
                   new MySQLConnection(_dbConString))
        {
            conn.Open();

            MySQLCommand commn = new MySQLCommand("set names gb2312; ", conn);
            commn.ExecuteNonQuery();
            commn.Dispose();
            for (int _s = 0, _sCnt = msgs.Length; _s < _sCnt; _s++)
            {
                if (msgs[_s].Length < 2)
                {
                    continue;
                }
                commn = new MySQLCommand(OA_MSG_SEND_SQL, conn);
                string[] _values = new string[] {
                    "yutao",
                    msgs[_s][0],
                    msgs[_s][1],
                    System.DateTime.Now.ToLocalTime().ToString()
                };
                for (int _i = 0, _iCnt = OA_MSG_PARAMS.Length; _i < _iCnt; _i++)
                {
                    DbParameter dbParameter = commn.CreateParameter();
                    dbParameter.DbType        = DbType.String;
                    dbParameter.ParameterName = string.Format("@{0}", OA_MSG_PARAMS[_i]);
                    dbParameter.Value         = _values[_i];
                    dbParameter.Direction     = ParameterDirection.Input;
                    commn.Parameters.Add(dbParameter);
                }
                commn.ExecuteNonQuery();
            }
            conn.Close();
        }
    }
Ejemplo n.º 41
0
        public void GetPeopleDate(string str)
        {
            models.Clear();
            MySQLConnection DBConn = null;
            DBConn = new MySQLConnection(new MySQLConnectionString(Configuration.getDBIp(), "workflow", Configuration.getDBUsername(), Configuration.getDBPassword()).AsString);
            try
            {
                DBConn.Open();
                MySQLCommand setformat = new MySQLCommand("set names gb2312", DBConn);
                setformat.ExecuteNonQuery();
                setformat.Dispose();

                string sql = "select tb_per.User_Name , tb_user.User_Mail from tb_user, tb_per where tb_per.user_name = tb_user.User_Name and tb_per.user_authority = ";
                sql += "'" + str + "'";
                //MessageBox.Show(sql);
                MySQLDataAdapter mda = new MySQLDataAdapter(sql, DBConn);

                DataTable ds = new DataTable();
                mda.Fill(ds);
                DBConn.Close();

                foreach (DataRow dr in ds.Rows)
                {
                    peopleInfo wfm = new peopleInfo();
                    wfm.peopleName = dr["user_name"].ToString();
                    wfm.peopleEmail = dr["User_Mail"].ToString();       
                    models.Add(wfm);
                }
                view.Source = models;
                this.peopleListView.DataContext = view;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("数据库连接失败,请检查网络连接或者数据库配置");
                return;
            }
        }
Ejemplo n.º 42
0
        private void Del_Click(object sender, RoutedEventArgs e)
        {
            MySQLConnection DBConn = null;
            DBConn = new MySQLConnection(new MySQLConnectionString(Configuration.getDBIp(), "workflow", Configuration.getDBUsername(), Configuration.getDBPassword()).AsString);
             try
            {

                DBConn.Open();
                MySQLCommand setformat = new MySQLCommand("set names gb2312", DBConn);
                setformat.ExecuteNonQuery();
                setformat.Dispose();

                string sql = "delete from wf_model where model_name = '";
                sql += ((WFModel)listView1.SelectedItem).WFModel_Name;
                 sql += "'";
                //MessageBox.Show(sql);
                MySQLCommand cmd = new MySQLCommand(sql, DBConn);
                cmd.ExecuteNonQuery();
                cmd.Dispose();
            }
            catch (Exception e1)
            {
                MessageBox.Show("数据库连接失败,请检查网络连接或者数据库配置");
                return;
            }
             GetTemplateData();
        }
Ejemplo n.º 43
0
        private string saveSms(PDUData pduData)
        {
            string sqlstr = "insert into mo_999 (dest,src,cmd,time) values (" +
                                "'" + this.phoneNum + "'"
                                + ",'" + pduData.getOA() + "'"
                                + ",'" + pduData.getMsg() + "'"
                                + ",now())";
            Console.WriteLine("aaaaaaaaaaaaaaaaaaaaaaa"+sqlstr);

            MySQLConnection conn = getConn();
            MySQLCommand comm = new MySQLCommand(sqlstr, conn);
            comm.ExecuteNonQuery();

            return sqlstr;
        }
 private void Gbk()
 {
     MySQLCommand cmd = new MySQLCommand("set names gbk", conn);
     int r=cmd.ExecuteNonQuery();
 }
Ejemplo n.º 45
0
        public bool AccountInfoEditor(AccountInfo accountInfo)
        {
            try
            {
                con.Open();
                sql = "UPDATE user_sex = " + accountInfo.Sex + ", user_birthday = " + accountInfo.Birthday + ", user_phone = " + accountInfo.Phone + " FROM users_information WHERE user_id = " + accountInfo.User_id;
                MySQLCommand com = new MySQLCommand(sql, con);
                com.ExecuteNonQuery();
                return true;
            }
            catch
            {
                return false;
            }
            finally
            {
                con.Close();
            }

        }
Ejemplo n.º 46
0
        private bool addOneUrl(int pos)
        {
            //添加第pos条团购条目信息
            string query;
            int link_id;
            MD5 md5 = new MD5CryptoServiceProvider(); ;
            //XmlNode oneUrl = lashouDocument.DocumentElement.ChildNodes[pos];
            oneUrl oneUrl = xmlparse.getOneUrl(pos);
            StatisticOutput sta = staContext.statistic(oneUrl);

            Console.WriteLine("Insert the data to the database....");
            query = "insert into links (site_id, url, title, description) values(5, \"" +
                sta.url + "\",\"" + sta.title + "\",\"" + sta.description + "\")";
            cmd = new MySQLDriverCS.MySQLCommand(query, conn);
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            query = "select link_id from links where url = \"" + sta.url + "\"";
            cmd = new MySQLDriverCS.MySQLCommand(query, conn);
            IDataReader dt = cmd.ExecuteReader();
            link_id = Convert.ToInt32(dt.GetSchemaTable().Rows[0]["link_id"]);
            foreach (DictionaryEntry de in sta.keywordList)
            {
                int keyword_id = 0;
                query = "select keyword_id from keywords where keyword = \"" + de.Key + "\"";
                cmd = new MySQLDriverCS.MySQLCommand(query, conn);
                dt = cmd.ExecuteReader();
                if (dt.GetSchemaTable().Rows.Count == 0)
                {
                    query = "insert into keywords (keyword) values (\"" + de.Key + "\")";
                    cmd = new MySQLDriverCS.MySQLCommand(query, conn);
                    cmd.ExecuteNonQuery();
                    cmd.Dispose();

                    query = "select keyword_id from keywords where keyword = \"" + de.Key + "\"";
                    cmd = new MySQLDriverCS.MySQLCommand(query, conn);
                    dt = cmd.ExecuteReader();
                    keyword_id = Convert.ToInt32(dt.GetSchemaTable().Rows[0]["keyword_id"]);
                }
                else
                    keyword_id = Convert.ToInt32(dt.GetSchemaTable().Rows[0]["keyword_id"]);
                byte[] hash = md5.ComputeHash(System.Text.Encoding.Default.GetBytes(de.Key.ToString()));
                string flag;
                switch (hash[0] >> 4)
                {
                    case 10:
                        flag = "a";
                        break;
                    case 11:
                        flag = "b";
                        break;
                    case 12:
                        flag = "c";
                        break;
                    case 13:
                        flag = "d";
                        break;
                    case 14:
                        flag = "e";
                        break;
                    case 15:
                        flag = "f";
                        break;
                    default:
                        flag = (hash[0] >> 4).ToString();
                        break;
                }
                query = "insert into link_keyword" + flag + "(link_id, keyword_id, weight, time, feat, discount) values (" +
                    link_id + "," + keyword_id + "," + de.Value + "," + sta.time + "," + sta.feat + "," +
                    sta.discount + ")";
                cmd = new MySQLDriverCS.MySQLCommand(query, conn);
                cmd.ExecuteNonQuery();
                cmd.Dispose();
            }
            Console.WriteLine("Write one link sucessfully!");
            return true;
        }
Ejemplo n.º 47
0
        //确认本次添加操作
        private void Confirm_Click(object sender, RoutedEventArgs e)
        {
            //得到新的添加项
            int id;
            DataRow row;
            row = TemplateSelectTable.NewRow();
            DataRowView selectrow = ListBox2.SelectedItem as DataRowView;
            if (selectrow == null)
            {
                MessageBox.Show("请选择要添加的表单模板!");
                return;
            }
            id = Convert.ToInt32(selectrow["ID"].ToString());
            row["Template_Id"] = id;
            row["Template_Name"] = selectrow["NAME"].ToString();
            foreach (DataRow dr in TemplateDataTable.Rows)
            {
                if ( Convert.ToInt32(dr["ID"].ToString()) == id)
                {
                    row["Template_HtmlSource"] = dr["HTMLSOURCE"].ToString();
                    row["Template_Description"] = dr["DESCRIPTION"].ToString();
                    break;
                }
            }
            TemplateSelectTable.Rows.Add(row);
            TemplateSelectTable.AcceptChanges();


            //将添加的表单模板信息填入数据库的tb_templateselectlist表中
            MySQLConnection DBConn = null;
            DBConn = new MySQLConnection(new MySQLConnectionString(Configuration.getDBIp(), "template", Configuration.getDBUsername(), Configuration.getDBPassword()).AsString);
            DBConn.Open();
            AddFlag = false;
            for (int i = 0; i < TemplateSelectTable.Rows.Count; i++)
            {
                string sqlInsert = "insert into tb_templateselectlist(Template_Id , Template_Name,Template_HtmlSource,Template_Description) values ('" + TemplateSelectTable.Rows[i]["Template_Id"] + "' , '" + TemplateSelectTable.Rows[i]["Template_Name"] + "' , '" + TemplateSelectTable.Rows[i]["Template_HtmlSource"] + "' , '" + TemplateSelectTable.Rows[i]["Template_Description"] + "')";
                MySQLCommand mySqlCommand = new MySQLCommand(sqlInsert, DBConn);
                try
                {
                    mySqlCommand.ExecuteNonQuery();
                    AddFlag = true;
                }
                catch (Exception ex)
                {
                    String message = ex.Message;
                    MessageBox.Show("添加表单模板数据失败!该表单模板数据已存在于表中。" + message);
                }
            }
            DBConn.Close();
            this.Close();
        }
Ejemplo n.º 48
0
 private void reRing(RequestBean req)
 {
     MySQLConnection conn = getConn ();
     string sqlstr2 = "update ring_request set doing=0 where id=" + req.mobileId;
     MySQLCommand comm2 = new MySQLCommand (sqlstr2, conn);
     comm2.ExecuteNonQuery ();
 }
Ejemplo n.º 49
0
        RequestBean getNextRequest()
        {
            Monitor.Enter (this);

            RequestBean bean = null;

            int modenId = -1;
            string portName = null;
            for (int i = 0; i < portNameDataGridView.RowCount - 1; i++) {
                if ("free" == (string)portNameDataGridView.Rows [i].Cells [1].Value) {

                    portName = (string)portNameDataGridView.Rows [i].Cells [0].Value;
                    modenId = i;
                    break;
                }
            }

            bean = new RequestBean ();
            bean.modenId = modenId;
            bean.portName = portName;
            bean.batchId = 1;
            bean.mobileId = 1;
            bean.mobile = "18601345193";

            Monitor.Exit (this);
            return bean;

            if (modenId != -1 && portName != null) {
                MySQLConnection conn = getConn ();

                string sqlstr = "select * from ring_request where doing=0 order by priority desc,time limit 1";
                MySQLCommand comm = new MySQLCommand (sqlstr, conn);

                MySQLDataReader dbReader = comm.ExecuteReaderEx ();
                if (dbReader.Read ()) {
                    portNameDataGridView.Rows [modenId].Cells [1].Value = "准备中.....";

                    string sqlstr2 = "update ring_request set doing=1 where id=" + dbReader.GetInt32 (0);
                    MySQLCommand comm2 = new MySQLCommand (sqlstr2, conn);
                    comm2.ExecuteNonQuery ();

                    bean = new RequestBean ();
                    bean.modenId = modenId;
                    bean.portName = portName;
                    bean.batchId = dbReader.GetInt32 (1);
                    bean.mobileId = dbReader.GetInt32 (0);
                    bean.mobile = dbReader.GetString (2);

                }
                dbReader.Close ();

            }

            Monitor.Exit (this);
            return bean;
        }
Ejemplo n.º 50
0
        private void saveResult(RequestBean req, string ringState)
        {
            MySQLConnection conn = getConn ();

            string sqlstr = "insert into ring_state set "
                                     + "batch_id=" + req.batchId
                                     + ",mobile='" + req.mobile
                                     + "',status='" + ringState
                                     + "',moden_port='" + req.portName
                                     + "',time=now()";
            MySQLCommand comm = new MySQLCommand (sqlstr, conn);
            comm.ExecuteNonQuery ();
        }
        //执行SQL语句,返回影响的记录数
        //<param name="sqlString">sql语句</param>
        public static int ExecuteNonQuery(string SQLString)
        {
            using (MySQLConnection connection = new MySQLConnection(connectionString))
            {

                using (MySQLCommand cmd = new MySQLCommand(SQLString, connection))
                {
                    try
                    {
                        connection.Open();
                        MySQLCommand setformat = new MySQLCommand("set names gb2312", connection);
                        setformat.ExecuteNonQuery();
                        setformat.Dispose();
                        int rows = cmd.ExecuteNonQuery();
                        return rows;
                    }
                    catch (MySQLException e)
                    {
                        connection.Close();
                        throw e;
                    }
                }
            }
        }
Ejemplo n.º 52
0
        public void Update(string tableName, string set, string where)
        {
            MySQLCommand commn = null;

            try
            {
                string insertString = "UPDATE TABLE_NAME SET SET_CONDITION WHERE WHERE_CONDITION";
                insertString = insertString.Replace("TABLE_NAME", tableName);
                insertString = insertString.Replace("SET_CONDITION", set);
                insertString = insertString.Replace("WHERE_CONDITION", where);
                Common.Log(insertString);
                conn.Open();
                commn = new MySQLCommand();
                commn.CommandText = insertString;
                commn.CommandType = CommandType.Text;
                commn.Connection = conn;
                commn.ExecuteNonQuery();
            }
            catch (MySQLException mySqlException)
            {
                Common.Log(mySqlException.ToString());
            }
            finally
            {
                if (commn != null)
                {
                    commn.Dispose();
                }

                if (conn != null)
                {
                    conn.Close();
                    conn.Dispose();
                }
            }
        }
Ejemplo n.º 53
0
        private int saveModel()
        {
            if (WFModelInst == null)
                return -3;
            else
            {
                try
                {
                    MySQLConnection DBConn = new MySQLConnection(new MySQLConnectionString(Configuration.getDBIp(), "workflow", Configuration.getDBUsername(), Configuration.getDBPassword()).AsString);
                    string checkSql = "select model_name from wf_model where model_name = '" + WFModelInst.WFModel_Name + "';";
                    DBConn.Open();
                    MySQLCommand mcd = new MySQLCommand(checkSql, DBConn);
                    MySQLDataReader DBReader = mcd.ExecuteReaderEx(); //DBComm.ExecuteReaderEx();
                    if (DBReader.Read())
                    {
                        return -1;
                    }
                    else
                    {
                        string insertSql = "insert into wf_model (model_name,model_type,owner) values ('" + WFModelInst.WFModel_Name + "','" + WFModelInst.WFModel_Type + "','" + WFModelInst.WFModel_Owner + "');";
                        try
                        {
                            MySQLCommand mcd2 = new MySQLCommand(insertSql, DBConn);
                            mcd2.ExecuteNonQuery();
                            return 0;
                        }
                        catch (Exception Ex)
                        {
                            return -2;

                        }
                    }
                }
                catch (MySQLException e) {
                    //MessageBox.Show("数据库连接失败,请检查网络连接或者数据库配置");
                    return -2;
                }
            }

        }
Ejemplo n.º 54
0
 public bool InsertOnlineUser(int user_id)
 {
     try
     {
         con.Open();
         string sql = "INSERT INTO user_online(user_id) VALUES(" + user_id + ")";
         MySQLCommand com = new MySQLCommand(sql, con);
         com.ExecuteNonQuery();
         return true;
     }
     catch
     {
         return false;
     }
     finally
     {
         con.Close();
     }
 }
Ejemplo n.º 55
0
        public void Insert(string tableName, IDictionary<string, string> item)
        {
            MySQLCommand commn = null;

            try
            {
                List<string> columns = item.Keys.ToList<string>();
                List<string> values = item.Values.ToList<string>();

                for (int index = 0; index < values.Count; index++)
                {
                    if (string.IsNullOrEmpty(values[index]))
                    {
                        values.RemoveAt(index);
                        columns.RemoveAt(index);
                        index--;
                    }
                }

                sqlCommnBuilder = new StringBuilder();
                sqlCommnBuilder.Append("INSERT INTO ");
                sqlCommnBuilder.Append(tableName);
                sqlCommnBuilder.Append(" (");
                for (int index = 0; index < columns.Count; index++)
                {
                    sqlCommnBuilder.Append(columns[index]);
                    sqlCommnBuilder.Append(", ");
                }
                sqlCommnBuilder.Remove(sqlCommnBuilder.Length - 2, 2);
                sqlCommnBuilder.Append(") VALUES ('");
                for (int index = 0; index < values.Count; index++)
                {
                    sqlCommnBuilder.Append(values[index]);
                    sqlCommnBuilder.Append("', '");
                }
                sqlCommnBuilder.Remove(sqlCommnBuilder.Length - 4, 4);
                sqlCommnBuilder.Append("')");
                conn.Open();
                Common.Log(sqlCommnBuilder.ToString());
                commn = new MySQLCommand();
                commn.CommandType = CommandType.Text;
                commn.CommandText = sqlCommnBuilder.ToString();
                commn.Connection = conn;
                int id = commn.ExecuteNonQuery();
                int t = id;
            }
            catch (MySQLException mySQLException)
            {
                Common.Log(mySQLException.ToString());
            }
            finally
            {
                if (commn != null)
                {
                    commn.Dispose();
                }

                if (conn != null)
                {
                    conn.Close();
                    conn.Dispose();
                }
            }
        }
Ejemplo n.º 56
0
        public static ToolboxCategoryItems loadUserbox()
        {
            MySQLConnection DBConn = new MySQLConnection(new MySQLConnectionString(Configuration.getDBIp(), "workflow", Configuration.getDBUsername(), Configuration.getDBPassword()).AsString);
            if (DBConn != null)
            {
                try
                {
                    DBConn.Open();
                    string sql1 = "set names gb2312";
                    MySQLCommand DBComm = new MySQLCommand(sql1, DBConn); //設定下達 command
                    DBComm.ExecuteNonQuery();
                    DBComm.Dispose();
                    string sql = "select * from tb_user";
                    MySQLDataAdapter mda = new MySQLDataAdapter(sql, DBConn);
                    DataTable UserDataTable = new DataTable();
                    mda.Fill(UserDataTable);
                    DBConn.Close();
                    loadSystemIcon();

                    ToolboxCategoryItems toolboxCategoryItems = new ToolboxCategoryItems();
                    ToolboxCategory users = new System.Activities.Presentation.Toolbox.ToolboxCategory("系统工作人员");

                    foreach (DataRow dr in UserDataTable.Rows)
                    {
                        //byte[] temp = Encoding.Default.GetBytes(dr["User_Name"].ToString());
                        //temp = System.Text.Encoding.Convert(Encoding.GetEncoding("utf8"), Encoding.GetEncoding("gb2312"), temp);
                        //string username = Encoding.Default.GetString(temp);
                        //ToolboxItemWrapper User = new ToolboxItemWrapper(typeof(Wxwinter.BPM.WFDesigner.User), username);
                        ToolboxItemWrapper User = new ToolboxItemWrapper(typeof(Wxwinter.BPM.WFDesigner.User), dr["User_Name"].ToString());
                        users.Add(User);
                    }
                    toolboxCategoryItems.Add(users);
                    parentWindow.statusInfo.Text = "";
                    return toolboxCategoryItems;
                }
                catch (Exception e)
                {
                    parentWindow.statusInfo.Text = "数据库连接失败,请检查网络设置和数据库连接配置";
                    return null;
                }

            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 57
0
        static void Main(string[] args)
        {
            //   while (true)
            //    {

                try
                {
                    StreamReader objReader = new StreamReader("setting.ini");
                    string sLine = "";
                    ArrayList arrText = new ArrayList();
                    while (sLine != null)
                    {
                        sLine = objReader.ReadLine();
                        if (sLine != null)
                            arrText.Add(sLine);
                    }
                    objReader.Close();
                   // foreach (string sOutput in arrText)
                   // dbconn = sOutput;
                    //MySQLConnection conn = new MySQLConnection(new MySQLConnectionString("192.168.234.129", "qqnotic", "toryzen", "q1w2e3r4").AsString);//实例化一个连接对象其中myquest为数据库名,root为数据库用户名,amttgroup为数据库密码
                    MySQLConnection conn = new MySQLConnection(new MySQLConnectionString(arrText[0].ToString(), arrText[1].ToString(), arrText[2].ToString(), arrText[3].ToString()).AsString);//实例化一个连接对象其中myquest为数据库名,root为数据库用户名,amttgroup为数据库密码
                    conn.Open();
                    MySQLCommand commn = new MySQLCommand("set names gb2312;", conn);
                    commn.ExecuteNonQuery();
                    MySQLCommand cmds = new MySQLCommand("select * from qqnotic where isok = 0 limit 1", conn);
                    MySQLDataReader reader = cmds.ExecuteReaderEx();
                    while (reader.Read())
                    {
                        int userid = int.Parse(reader["userid"].ToString()); //用户id
                        int checktype = int.Parse(reader["btype"].ToString()); //业务类型

                        MySQLCommand cmdname = new MySQLCommand("select * from qqname where id = " + userid, conn);
                        MySQLDataReader readername = cmdname.ExecuteReaderEx();
                        while (readername.Read())
                        {
                            qq = int.Parse(readername["qqnum"].ToString()); //qq号码
                            qqname = (string)readername["qqname"];   //qq昵称
                            realname = (string)readername["realname"]; //用户真名
                        }

                        bbtype = "光宇信息中心通知";   //通知标题
                        bbcontent = (string)reader["content"];  //通知内容

                        /* 若指定通知类型 */
                        if (checktype != 0)
                        {

                            MySQLCommand cmdtype = new MySQLCommand("select * from btype where id = " + checktype, conn);
                            MySQLDataReader btype = cmdtype.ExecuteReaderEx();
                            while (btype.Read())
                            {
                                bbtype = (string)btype["type"]; //通知标题
                                bbcontent = (string)btype["content"]; //通知内容
                            }

                        }

                        System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));

                        int timeStamp = (int)(System.DateTime.Now - startTime).TotalSeconds;

                        MySQLCommand excmds = new MySQLCommand("UPDATE `qqnotic`.`qqnotic` SET `isok` = '1',`extime` = " + timeStamp + " WHERE `qqnotic`.`id` =" + reader["id"], conn);

                        excmds.ExecuteNonQuery(); //写入系统时间

                        notis = bbtype + ":\n" + realname + "您好," + bbcontent;

                        Console.WriteLine(System.DateTime.Now + "向用户" + realname + "(" + qq + ") 发送一条信息!");
                    }
                    conn.Close();
                }
                catch { Exception e; }

                if (qq != 0 && notis != "")
                {
                    try
                    {
                        Clipboard.Clear();
                        Clipboard.SetDataObject(notis,true);
                    }
                    catch { Exception e; }
                    const int WM_CHAR = 0x0102;
                    const int WM_KEYDOWN = 0x0100;
                    const int WM_PASTE = 0x0302;
                    const int WM_SETTEXT = 0x000C;
                    const int WM_Close = 0x0010;
                    string[] cmd = new string[] { "start tencent://message/?uin=" + qq + "&Site=gyyx.cn&Menu=yes" };
                    Cmd(cmd);
                    Thread.Sleep(1000);
                    EnumWindows(PrintWindow, IntPtr.Zero);
                    string tr = notis;
                    IntPtr hwndCalc = hander;

                    //ShowWindow(hwndCalc,1);

                    PostMessage(hwndCalc, WM_PASTE, 0, 0);
                    Thread.Sleep(500);
                    PostMessage(hwndCalc, WM_KEYDOWN, 13, 0);
                    Thread.Sleep(500);
                    //PostMessage(hwndCalc, WM_KEYDOWN, 27, 0);
                    PostMessage(hwndCalc, WM_Close, 0, 0);
                    Thread.Sleep(1000);
                    qq = 0;
                    notis = "";
                }
             //   else { Thread.Sleep(6000); }

               //     }
        }
Ejemplo n.º 58
0
 public bool DelOnlineUser(int user_id)
 {
     try
     {
         con.Open();
         string sql = "DELETE user_online WHERE user_id=" + user_id;
         MySQLCommand com = new MySQLCommand(sql, con);
         com.ExecuteNonQuery();
         return true;
     }
     catch
     {
         return false;
     }
     finally
     {
         con.Close();
     }
 }
Ejemplo n.º 59
-1
 public bool InsertIntoOverMessages(MessageData msg)
 {
     try
     {
         con.Open();
         sql = "INSERT INTO over_messages(sender_id,receiver_id,time,message) VALUES(" + msg.User_id + "," + msg.Receiver_id + "," + msg.Time + "," + msg.Message + ")";
         MySQLCommand com = new MySQLCommand(sql, con);
         com.ExecuteNonQuery();
         return true;
     }
     catch
     {
         return false;
     }
     finally
     {
         con.Close();
     }
 }
Ejemplo n.º 60
-1
        public ArrayList SelOverMessages(int user_id)
        {
            try
            {
                con.Open();
                DataSet ds = new DataSet();
                sql = "SELECT * FROM over_messages where receiver_id=" + user_id;
                MySQLCommand com = new MySQLCommand(sql, con);
                MySQLDataAdapter adp = new MySQLDataAdapter(com);
                adp.Fill(ds);

                ArrayList messages = new ArrayList();
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    MessageData msg = new MessageData();
                    msg.User_id = (int)dr["sender_id"];
                    msg.Receiver_id = (int)dr["receiver_id"];
                    msg.Time = (DateTime)dr["time"];
                    msg.Message = dr["message"].ToString();
                    messages.Add(msg);
                }

                sql = "DELETE user_message where receiver_id=" + user_id;
                com = new MySQLCommand(sql, con);
                com.ExecuteNonQuery();

                return messages;
            }
            catch(Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }
        }