superJoev
superJoev
2021/01/21 22:19
  • c#

 

0个回复
qq_49868769
B※N~『峰』
2021/01/21 16:38
  • c语言
  • visual studio
  • asp.net
    protected void Page_Load(object sender, EventArgs e)
    {
        //正常换行
        GridView1.Attributes.Add("style", "word-break:keep-all;word-wrap:normal");
        //下面这行是自动换行
        GridView1.Attributes.Add("style", "word-break:break-all;word-wrap:break-word");
       
        if (!IsPostBack)
          
        {
            this.TextBox4.Attributes.Add("onfocus", "javascript:WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',readOnly:true})");
            ViewState["search"] = null;
            LoadGridview();//加载表
        }

        
      

    }
 
private void LoadGridview()
    {
        
        string str = ConfigurationManager.ConnectionStrings["sqlconn"].ToString();
        using (SqlConnection con = new SqlConnection(str))
        {
            SqlCommand cmd = new SqlCommand("select * from wbx order by id desc", con);
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            sda.Fill(ds);
            this.GridView1.DataSource = ds.Tables[0].DefaultView;
            this.GridView1.DataBind();
            sda.Dispose();
           ds.Dispose();
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        ViewState["search"] = 1;
        LoadSearchGridview(TextBox2.Text);
    }
    private void LoadSearchGridview(string search)
    {

        string strSearch = null;
        if (TextBox2.Text != "无信息")
        {
            strSearch = "select * from wbx where 提交人='" + search + "' order by id desc";
        }
        sqlcon = new SqlConnection(strCon);
        sqlcon.Open();
        SqlDataAdapter adsa = new SqlDataAdapter(strSearch, sqlcon);
        DataSet adds = new DataSet();
        adsa.Fill(adds,"wbx");
        this.GridView1.DataSource = adds;
        this.GridView1.DataKeyNames = new string[] {  "提交人" };
        this.GridView1.DataBind();
        sqlcon.Close();
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
       
        GridView1.PageIndex = e.NewPageIndex;
        {
            if (ViewState["search"] == null)
            {
                LoadGridview();//加载表
            }
            else
            {
                LoadSearchGridview(TextBox2.Text); //加载查询后的表
            }
        }
        
      
    }

    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.Visible = true;
        GridView1.EditIndex= e.NewEditIndex;
        LoadGridview();
    }

 

0个回复
weixin_42563605
程许源
2021/01/21 15:52
  • c#

现有需求基于C#实现kafka的kerberos认证,我在网上没有找到别的方案,目前我用的是Confluent.kafka
代码如下

```
using Confluent.Kafka;
using Confluent.Kafka.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace GatewaySim
{
    class _cls_confluent_producer : cls_disposable_base,_inf_confluent_producer
    {
        private string broker;
        private Producer<string,string> _producer;
        private Dictionary<string, object> config_produce = new Dictionary<string, object>();

        public bool init_produce(string broker,string keytab)
        {
            try
            {
                this.broker = broker;
                this.config_produce.Add("bootstrap.servers", broker);
                this.config_produce.Add("api.version.request", "true");
                this.config_produce.Add("security.protocol", "SASL_PLAINTEXT");
                this.config_produce.Add("sasl.mechanisms", "GSSAPI");
                this.config_produce.Add("sasl.kerberos.service.name", "kafka");
                this.config_produce.Add("debug", "security,broker,protocol");
                this.config_produce.Add("sasl.kerberos.principal", "xxxx@xxx.xxx.COM");
                _producer = new Producer<string, string>(config_produce, new StringSerializer(Encoding.UTF8), new StringSerializer(Encoding.UTF8));
                
                return true;
            }
            catch (Exception e) { 
                
                LogHelper.Info("_cls_confluent_producer init exception:"+ e.Message); 
            }
            return false;
        }
        public obj_msg_result produce(string topic, string message, string key)
        {
            try
            {
                var ret = _producer.ProduceAsync(topic, key, message).Result;
                if(ret.Error.Code == ErrorCode.NoError)
                {
                    obj_msg_result s = new obj_msg_result();
                    s.Offset = ret.Offset;
                    s.Partition = ret.Partition;
                    s.Topic = topic;
                    s.Message = ret.Value;
                    s.Key = ret.Key;

                    return s;
                }
                _producer.Flush(10000);
               
            }
            catch (Exception e) { 
                LogHelper.Info("_cls_confluent_producer exception :" + e.Message);
               
            };

            return null;
        }
}

main代码------------------------------------------------------


public static _cls_confluent_producer _producer = new _cls_confluent_producer();
static void Main(string[] args)
        {
            

            _producer.init_produce(Properties.Settings.Default.kafka_broker, Properties.Settings.Default.keytab);
            int i = 0;
            while (i < 10)
            {
                i++;
                _producer.produce("test", "test"+i, i+"");
                LogHelper.Info("test " + i);
            }
            }
```

代码指定到var ret = _producer.ProduceAsync(topic, key, message).Result;这一行就会报错,报错如下
![图片说明](https://img-ask.csdn.net/upload/202101/21/1611215252_272464.jpg)

有没有大佬会解决的,或者有别的基于C#实现kafka认证kerberos的方案也可以指导一下(调用java实现的就算了),多谢!!!

0个回复
TA_ccj
TA_ccj
2021/01/21 10:53
  • android
  • c#

在游戏刚刚启动, 启动动画结束的时候

一般都会有一个进度条, 有时候是在加载资源, 有时候是检测到更新了执行资源更新,

这个跟场景切换时的进度条不同的是, 场景之间的切换是从一个已经打开了的场景跳转到另一个没有打开的场景, 是从 1 加载 2
而这个游戏刚刚启动时的加载是从 0 加载 1, 

那这个游戏刚刚启动时的进度条是怎么实现的呢? 请各位大佬前辈指点一下思路

2个回复
Aganstrong
Aganstrong
2021/01/21 10:02
  • asp.net
  • c#

C#中 判断 (A == B || A == C || A == D) 只有这种写法吗?

有没有其他更简便的写法,因为 A 实在太长了

2个回复