esb控件綁定服務器api列表代碼過程

1、esb.aspx.cs   增加接口

  protected void select_webAPI()
        {

            string sql = "select *  from webapilist";
            DataTable dt = DBSQLite.DataConn.select(DBSQLite.DataConn.currdb, sql);

            Response.Write(Pub.DtToJSON(dt, dt.Rows.Count, DBUtils.datetime_format_str));
        }

2、在ESB_Designer.Setting中增加類和方法

 public class WebAPI
    {
        public static List<string> get_keylist()
        {
            List<string> list = new List<string>();
            foreach (KeyValuePair<string, string> kv in items)
            {
                list.Add(kv.Key);
            }
            list.Sort();
            return list;
        }
        public static Dictionary<string, string> items = new Dictionary<string, string>();
    }

3、在webapi控件初始化時調用方法

   public override void init(FlowNode node)
        {
            _node = node;
            FlowNodeWebAPI wn = (FlowNodeWebAPI)_node;
            //add by yan 2020年4月27日14:30:46
            foreach (string s in WebAPI.get_keylist())
            {
                int idx = WebAPI.get_keylist().IndexOf(s);
                comboBox1.Items.Add(s);
                //comboBox1.SelectedIndex = 0;
                if (s== wn.ApiName)
                {
                    comboBox1.SelectedIndex = idx;
                }
            }
            comboBox1.Text = wn.ApiName;
            comboBox2.Text = wn.FunctionName;
        }

4、在esb 業務設計器初始化時調用接口和方法:

 private void do_select_webAPI()
        {

            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic["cmd"] = "select_webAPI";
            set_dict_user(dic);
            string json = Pub.HttpGet(Pub.curr_user.url, dic);
            DataTable dt = Pub.json2dt(json);
            if (dt != null)
            {
                ESB_Designer.Setting.WebAPI.items.Clear();
                foreach (DataRow dr in dt.Rows)
                {
                    string settingname = Pub.get_str(dr, "apiname");
                    string settingvalue = Pub.get_str(dr, "apidescription");
                    ESB_Designer.Setting.WebAPI.items[settingname] = settingvalue;
                }
            }
        }

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章