コード例 #1
0
        /// <summary>
        /// 发送字符串
        /// </summary>
        /// <param name="buffs"></param>
        private void SendString(ConString buffs)
        {
            string sen = string.Format("{0}|{1}<~", buffs._isCasting, buffs.conString);

            byte[] buff = Encoding.UTF8.GetBytes(sen);
            _udpClient.Send(buff, buff.Length, _endPoint);
        }
コード例 #2
0
        /// <summary>
        /// 发送停止标识符代表连接的结束
        /// </summary>
        public void StopCast()
        {
            ConString con = new ConString();

            con._isCasting = false;
            con.conString  = "Stopped";
            SendString(con);
        }
コード例 #3
0
        private void toolStripStokIn_Click(object sender, EventArgs e)
        {
            string        constring = ConString.DbConnection();
            SqlConnection con       = new SqlConnection(constring);

            con.Open();
            MessageBox.Show("connection open");
            con.Close();
        }
コード例 #4
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            if (nameTextBox.Text == String.Empty)
            {
                MessageBox.Show("please enter the category");
            }
            else
            {
                Category category = new Category();
                category.Name = nameTextBox.Text;
                //unique check
                bool          flag       = false;
                string        conString1 = ConString.DbConnection();
                SqlConnection connection = new SqlConnection(conString1);
                string        query2     = "select id,name from  category";
                SqlCommand    command    = new SqlCommand(query2, connection);
                connection.Open();
                SqlDataReader dr = command.ExecuteReader();
                while (dr.Read())
                {
                    if (dr[1].ToString() == category.Name)
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag == true)
                {
                    lblNameValidation.Text      = "This Category Exists";
                    lblNameValidation.ForeColor = Color.Red;
                    return;
                }
                bool isInserted = _categoryManager.IsInserted(category);
                if (isInserted)
                {
                    MessageBox.Show("Data Inserted ");
                    nameTextBox.Text       = String.Empty;
                    lblNameValidation.Text = String.Empty;
                    nameTextBox.Focus();
                    //
                    string         _conString = ConString.DbConnection();
                    SqlConnection  con        = new SqlConnection(_conString);
                    string         query      = "select id,name from category order by id desc";
                    SqlCommand     cmd        = new SqlCommand(query, con);
                    SqlDataAdapter da         = new SqlDataAdapter(cmd);
                    con.Open();
                    DataTable dt = new DataTable();
                    da.Fill(dt);
                    con.Close();
                    categoryVMBindingSource.DataSource = dt;

                    return;
                }
                MessageBox.Show("Data Failed");
            }
        }
コード例 #5
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string        conString = ConString.DbConnection();
            SqlConnection con       = new SqlConnection(conString);
            string        query     = "select id,name,password from login";
            SqlCommand    command   = new SqlCommand(query, con);

            SqlDataAdapter da = new SqlDataAdapter(command);
            DataTable      dt = new DataTable();

            this.Hide();
            MainUI mainUi = new MainUI();

            mainUi.ShowDialog();
        }
コード例 #6
0
        /// <summary>
        /// 添加链接
        /// </summary>
        /// <param name="connectionString">connectionstring</param>
        /// <returns>添加结果</returns>
        public Result AddConString(string connectionString)
        {
            if (string.IsNullOrWhiteSpace(connectionString))
            {
                return(new Result()
                {
                    Msg = "入参为空"
                });
            }

            var con  = ConnectionHelper.GetSqlSugarClient();
            var data = new ConString()
            {
                KeyID            = KeyIDHelper.Generator(),
                ConStringName    = string.Empty,
                ConnectionString = connectionString,
                Remark           = string.Empty,
                IsEnable         = true,
            };

            int runRt = con.Insertable <ConString>(data).ExecuteCommand();

            if (runRt > 0)
            {
                System.Threading.Tasks.Task.Run(() =>
                {
                    try
                    {
                        new BTask().AddDBTask(new DBTask()
                        {
                            BusinessKeyID   = data.KeyID,
                            BusinessType    = BusinessType.初始化,
                            NextExecuteTime = DateTime.Now,
                        });
                    }
                    catch (Exception e)
                    {
                        NLog.LogManager.GetCurrentClassLogger().Error(e);
                    }
                });
            }

            return(new Result()
            {
                Success = runRt > 0, Msg = runRt > 0 ? string.Empty : "写入失败"
            });
        }
コード例 #7
0
        /// <summary>
        /// 发送一个连接字符串表示连接开始
        /// </summary>
        /// <param name="connStr"></param>
        public void StartCast(string connStr)
        {
            ConString con = new ConString();

            con.conString  = connStr;
            con._isCasting = true;
            this.source    = new CancellationTokenSource();
            Task.Run(() =>
            {
                while (!this.source.IsCancellationRequested)
                {
                    SendString(con);
                    Thread.Sleep(5000);
                }
                Debug.WriteLine("请求消息发送线程已经取消");
            }, this.source.Token);
        }
コード例 #8
0
        private void CategorySetupUI_Load(object sender, EventArgs e)
        {
            this.MinimumSize = this.Size;
            this.MaximumSize = this.Size;
            this.MinimizeBox = false;
            this.MaximizeBox = false;

            //Grid view
            string         _conString = ConString.DbConnection();
            SqlConnection  con        = new SqlConnection(_conString);
            string         query      = "select id,name from category order by id desc";
            SqlCommand     cmd        = new SqlCommand(query, con);
            SqlDataAdapter da         = new SqlDataAdapter(cmd);

            con.Open();
            DataTable dt = new DataTable();

            da.Fill(dt);
            con.Close();
            categoryVMBindingSource.DataSource = dt;
        }
コード例 #9
0
        /// <summary>
        /// 修改链接
        /// </summary>
        /// <param name="keyID">链接对应逐渐</param>
        /// <returns>添加结果</returns>
        public Result UpdateConString(string keyID, ConString paramIn)
        {
            if (string.IsNullOrWhiteSpace(keyID))
            {
                return(new Result()
                {
                    Msg = "主键不能为空"
                });
            }

            var con   = ConnectionHelper.GetSqlSugarClient();
            var count = con.Updateable <ConString>(new ConString()
            {
                ConStringName = paramIn.ConStringName, Remark = paramIn.Remark
            }).Where(p => p.KeyID == keyID).ExecuteCommand();

            return(new Result()
            {
                Success = count > 0
            });
        }
コード例 #10
0
ファイル: mainForm.cs プロジェクト: ecustyuanzhen/KtvPlayer
        private DataTable getSong(string sql, string tableName)
        {
            //string sql = "select * from KTV where Name='" + tx.Text + "'";
            ConString     ConString = new ConString();
            SqlConnection con       = ConString.GetConn();

            con.Open();
            da = new SqlDataAdapter(sql, con);
            DataTable dt = new DataTable();

            da.Fill(ds, tableName);
            dt = ds.Tables[tableName];
            con.Close();
            return(dt);

            //SqlHelper sqlhelper = new SqlHelper();
            //Console.Write(sqlhelper.DoSqlCommand(sql));
            //string str = ConfigurationManager.ConnectionStrings["MyConnect"].ToString();
            //SqlConnection con = new SqlConnection(str);
            //SqlCommand cmd = new SqlCommand(sql, con);
            //cmd.CommandType = CommandType.Text;
            //cmd.CommandText = sql;
        }
コード例 #11
0
 public Result UpdateConString(string keyID, [FromBody] ConString paramIn)
 {
     return(new BConString().UpdateConString(keyID, paramIn));
 }
コード例 #12
0
ファイル: TaskDeal.cs プロジェクト: a815952553/DBOPeratorAPI
        /// <summary>
        /// 构建表model
        /// </summary>
        /// <param name="tables">表信息</param>
        /// <param name="conInfo">链接信息</param>
        /// <returns>结果</returns>
        private List <TableInfo> BuildTableModel(Dictionary <string, List <Table> > tables, ConString conInfo)
        {
            List <string> selfDatabases = new List <string>()
            {
                "information_schema", "mysql", "performance_schema", "test", "sys"
            };
            List <TableInfo> result = new List <TableInfo>();

            foreach (var item in tables.Keys)
            {
                if (selfDatabases.Contains(item))
                {
                    continue;
                }

                foreach (var table in tables[item])
                {
                    if (result.Exists(p => ((Regex.Replace(table.Table_Name, Pattern, string.Empty) == p.TableName && p.SplitType != SplitType.None) || (table.Table_Name == p.TableName && p.SplitType == SplitType.None)) && string.IsNullOrWhiteSpace(p.TableName) == false && p.DatabaseName == item) == false)
                    {
                        TableInfo model = new TableInfo();
                        model.AddTime = DateTime.Now;
                        this.InitSplitType(table.Table_Name, tables[item], model);
                        model.ConStringKeyID = conInfo.KeyID;
                        model.DatabaseName   = item;
                        model.IsDelete       = false;
                        model.IsEnable       = 1;
                        model.ModifyTime     = DateTime.Now;
                        model.TableDesc      = table.Table_Comment;
                        result.Add(model);
                    }
                }
            }

            return(result);
        }