예제 #1
0
        private void update_Click(object sender, EventArgs e)
        {
            DataBase        addnc   = new DataBase();
            NC_Version_Num  version = new NC_Version_Num();
            MySqlConnection sqlcon  = new MySqlConnection(addnc.M_str_sqlcon);

            //MySqlDataReader reader = null;
            // string select = "select * from tb_nc where id='"+newnc.strNC_ID+"'";
            //MySqlCommand cmd = new MySqlCommand(select, sqlcon);
            sqlcon.Open();
            //reader = cmd.ExecuteReader();
            //if (reader.Read())
            //{
            //   reader.Close();
            //   sqlcon.Close();
            //  MessageBox.Show("该ID已经注册,确定进行系统升级?");
            //  reset_Click();
            //}
            // else
            {
                // reader.Close();//NCnum编号为short ,采用人工写入,后期可以考虑删除
                string       comm = "update tb_nc set state='" + newnc.strNC_state + "',id='" + newnc.strNC_ID + "',ip='" + newnc.strIP + "',port='" + newnc.strPort + "',fctr='" + newnc.strNC_factr + "',cltno='" + newnc.shrNCno + "',tp='" + this.txtxinhao.Text + "',ver1='" + newnc.strNC_Version_Num_1 + "',ver2='" + newnc.strNC_Version_Num_2 + "',ver3='" + newnc.strNC_Version_Num_3 + "',ver4='" + newnc.strNC_Version_Num_4 + "',ver5='" + newnc.strNC_Version_Num_5 + "',dt='" + newnc.tDatatime + "' where id='" + newnc.strNC_ID + "'";
                MySqlCommand cmd  = new MySqlCommand(comm, sqlcon);
                cmd.ExecuteNonQuery();
                cmd.Dispose();
                sqlcon.Close();
#if (MARCO_POSTWEB)
                PushToWeb();
#else
                Console.WriteLine(newnc.strNC_ID);
                MessageBox.Show("注册成功");
#endif
            }
            MessageBox.Show("系统升级成功");
        }
예제 #2
0
        private void registe_Click(object sender, EventArgs e)
        {
            DataBase        addnc   = new DataBase();
            NC_Version_Num  version = new NC_Version_Num();
            MySqlConnection sqlcon  = new MySqlConnection(addnc.M_str_sqlcon);
            MySqlDataReader reader  = null;
            string          select  = "select * from tb_nc where id='" + newnc.strNC_ID + "'";
            MySqlCommand    cmd     = new MySqlCommand(select, sqlcon);

            sqlcon.Open();
            reader = cmd.ExecuteReader();
            if (reader.Read())
            {
                reader.Close();
                sqlcon.Close();
                MessageBox.Show("该ID已经注册");
                reset_Click();
            }
            else
            {
                reader.Close();//NCnum编号为short ,采用人工写入,后期可以考虑删除
                string comm = "insert into tb_nc(state,id,ip,port,fctr,cltno,tp,ver1,ver2,ver3,ver4,ver5,dt) values('" + newnc.strNC_state + "','" + newnc.strNC_ID + "','" + newnc.strIP + "','" + newnc.strPort + "','" + newnc.strNC_factr + "','" + newnc.shrNCno + "','" + this.txtxinhao.Text + "','" + newnc.strNC_Version_Num_1 + "','" + newnc.strNC_Version_Num_2 + "','" + newnc.strNC_Version_Num_3 + "','" + newnc.strNC_Version_Num_4 + "','" + newnc.strNC_Version_Num_5 + "','" + newnc.tDatatime + "')";
                cmd = new MySqlCommand(comm, sqlcon);
                cmd.ExecuteNonQuery();
                cmd.Dispose();
                sqlcon.Close();
#if (MARCO_POSTWEB)
                PushToWeb();
#else
                Console.WriteLine(newnc.strNC_ID);
                MessageBox.Show("注册成功");
#endif
            }
        }
예제 #3
0
        private void PushToWeb()
        {
            NC_Version_Num     version      = new NC_Version_Num();     //保存版本信息的jason字符串
            Data_json          data_info    = new Data_json();          //上传WEB SERVICE的一级数据结构
            Data_Identity_info data_idten   = new Data_Identity_info(); //上传WEB SERVICE的二级数据结构
            string             jsonIdentity = "";                       //最终上传WEB 的JSON字符串

            version.strNC_Version_Num_1 = newnc.strNC_Version_Num_1;
            version.strNC_Version_Num_2 = newnc.strNC_Version_Num_2;
            version.strNC_Version_Num_3 = newnc.strNC_Version_Num_3;
            version.strNC_Version_Num_4 = newnc.strNC_Version_Num_4;
            version.strNC_Version_Num_5 = newnc.strNC_Version_Num_5;
            string strversion = WebSreverce_PostJson.ConvertToJson(version);

            data_idten.id  = newnc.strNC_ID;
            data_idten.tp  = newnc.strNC_Num;
            data_idten.ver = strversion;
            strversion     = WebSreverce_PostJson.ConvertToJson(data_idten);
            data_info.dt   = strversion;
            data_info.did  = Constants.IDENTITY;

            jsonIdentity = WebSreverce_PostJson.ConvertToJson(data_info);
            string reponce = WebSreverce_PostJson.Post_Jsonstr(WebSreverce_PostJson.urladd_inn, jsonIdentity);  //url表示数据服务器的地址及接口名称,可以定义成全局变量

            //Console.WriteLine(reponce);
            if (reponce == "ac")
            {
                Console.WriteLine(jsonIdentity);
                this.Test.BackColor = Color.WhiteSmoke;;
                //返回值正确,服务器收到了请求
                MessageBox.Show("Web服务器注册成功");
                reset_Click();
            }
            else
            {
                MessageBox.Show("注册失败,请检查与Web服务器的连接");
                reset_Click();
            }
        }