Ejemplo n.º 1
0
        private void ddl_className_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddl_className.SelectedIndex < 0)
            {
                return;
            }

            Type   cls = JdUnion_GlbObject.AllModuleClass[ddl_className.Text];
            object obj = Activator.CreateInstance(cls);                   // as;
            JdUnion_Bussiness_Class jdy = obj as JdUnion_Bussiness_Class; // as

            //JDYSCM_Class jdy = jdy_GlbObject.AllModuleClass[ddl_className.SelectedValue.ToString()];
            if (jdy == null)
            {
                return;
            }
            JdUnion_ModuleClass jm = JdUnion_GlbObject.modules.Modules.FindLast(a => a.ClassName == ddl_className.Text);

            if (jm == null)
            {
                return;
            }
            jdy.InitClass(jm);
            if (jdy.defaultRequestJson != null)
            {
                this.txt_PostData.Text = jdy.defaultRequestJson;
            }
            this.ddl_className.Tag = jdy;
            return;

            jdy.InitClass(JdUnion_GlbObject.mlist[ddl_className.Text]);
            ////jdy.app_key = this.txt_app_key.Text.Trim();
            ////jdy.app_secret = this.txt_app_secret.Text.Trim();
            ////jdy.access_token = this.txt_access_token.Text.Trim();
            if (this.txt_params_1_val.Text.Trim().Length > 0)
            {
                jdy.params_360buy.Add(this.txt_params_1_key.Text.Trim(), this.txt_params_1_val.Text.Trim());
            }
            if (this.txt_params_2_val.Text.Trim().Length > 0)
            {
                jdy.params_360buy.Add(this.txt_params_2_key.Text.Trim(), this.txt_params_2_val.Text.Trim());
            }
            if (this.txt_params_3_val.Text.Trim().Length > 0)
            {
                jdy.params_360buy.Add(this.txt_params_3_key.Text.Trim(), this.txt_params_3_val.Text.Trim());
            }
            jdy.InitRequestJson();
            if (jdy is JdUnion_Bussiness_List_Class)
            {
                ////(jdy as JdUnion_Bussiness_List_Class).filter = new JdUnion_Bussiness_List_Class.JdUnion_Bussiness_Filter_Class();
                ////(jdy as JdUnion_Bussiness_List_Class).filter.pageSize = int.Parse(txt_PageSize.Text);
                ////(jdy as JdUnion_Bussiness_List_Class).filter.pageIndex = int.Parse(txt_PageNo.Text);
                ////jdy.Req_PostData = "{\"filter\":" + (jdy as JdUnion_Bussiness_List_Class).filter.ToJson().Replace("null", "\"\"") + "}";
            }
            this.txt_url.Text      = jdy.getUrl();
            this.txt_PostData.Text = jdy.Req_PostData;
        }
Ejemplo n.º 2
0
        public static JdUnion_Bussiness_Class CreateBusinessClass(Type t)
        {
            Type   cls = JdUnion_GlbObject.AllModuleClass[t.Name];
            object obj = Activator.CreateInstance(cls);                   // as
            JdUnion_Bussiness_Class jdy = obj as JdUnion_Bussiness_Class; // as

            jdy.InitClass(mlist[t.Name]);
            return(jdy);
        }
Ejemplo n.º 3
0
        public bool getXmlData(XmlNode config, ref XmlDocument doc, ref XmlDocument xmlschemaDoc, ref string msg, XmlNode condition = null)
        {
            string strDefaultName = "DataTable1";
            string strRootName    = "NewDataSet";
            string ret            = "";
            string strName        = XmlUtil.GetSubNodeText(config, "module/@name");
            string strReqJson     = null;

            XmlNode xmlreq = config.SelectSingleNode("req");

            if (condition == null)
            {
                if (xmlreq != null)
                {
                    condition = xmlreq;
                }
            }
            Assembly assem = Assembly.GetExecutingAssembly();

            try
            {
                List <int> list = JdUnion_GlbObject.getElites();
                Dictionary <string, string> cols = null;
                Type t = assem.GetType(string.Format("{0}.{1}", assem.FullName.Split(',')[0], strName));
                if (t == null)
                {
                    msg = "无法识别的外部访问类";
                    return(false);
                }

                JdUnion_Bussiness_Class jgl = JdUnion_GlbObject.CreateBusinessClass(t) as JdUnion_Bussiness_Class;
                JdUnion_ModuleClass     jm  = JdUnion_GlbObject.modules.Modules.FindLast(a => a.ClassName == strName);
                if (jm == null)
                {
                    msg = "未配置正确的模块信息!";
                    return(false);
                }
                jgl.InitClass(jm);
                bool succ = jgl.getBusynessXmlData(condition, ref doc, ref xmlschemaDoc, ref msg);
                return(succ);
            }
            catch (Exception e)
            {
                msg = e.Message;
                return(false);
            }
            return(true);
        }
Ejemplo n.º 4
0
        public bool getXmlData(ref XmlDocument retdoc, ref XmlDocument xmlschemaDoc, ref string msg, bool onlyFirstPage = true, bool onlyOrgData = false)
        {
            JdUnion_Bussiness_Class jdyreq = this;
            string      strDefaultName     = "DataTable1";
            string      strRootName        = "NewDataSet";
            string      ret = null;
            XmlDocument doc = new XmlDocument();

            if (xmlschemaDoc == null)
            {
                xmlschemaDoc = new XmlDocument();
            }
            msg = null;
            try
            {
                //jdyreq.InitClass(jdyreq.Module);
                jdyreq.sign = null;
                if (jdyreq is JdUnion_Bussiness_List_Class)
                {
                    (jdyreq as JdUnion_Bussiness_List_Class).RequestSizeAndPage((jdyreq as JdUnion_Bussiness_List_Class).pager.pageSize, 1, null);
                }
                jdyreq.InitRequestJson();
                ret          = jdyreq.GetRequest();
                xmlschemaDoc = jdyreq.getRequestSchema();
                XmlSchemaClass xmlSchema = new XmlSchemaClass(xmlschemaDoc);
                //string strXml = XML_JSON.Json2XML(ret);
                XmlDocument tmp = jdyreq.getRealXml(ret, out msg);
                if (msg != null)
                {
                    return(false);
                }
                doc.LoadXml(tmp.OuterXml);
                if (onlyOrgData)
                {
                    if (retdoc == null)
                    {
                        retdoc = new XmlDocument();
                    }
                    retdoc.LoadXml(tmp.OuterXml);
                    return(true);
                }
                if (jdyreq is JdUnion_Bussiness_List_Class)
                {
                    if (onlyFirstPage)
                    {
                        return(getXmlDataSet(doc, xmlSchema, ref retdoc, ref msg));
                        //return true;
                    }
                    //return true;
                }
                else
                {
                    return(getXmlDataSet(doc, xmlSchema, ref retdoc, ref msg));
                }


                int?totalCount = XmlNodeIntVal(doc, xmlSchema.rootNodePath, xmlSchema.totalCountItemName); //, //int.Parse(XmlUtil.GetSubNodeText(tmp, xmlSchema.pageCountItemName));
                int?totalsize  = XmlNodeIntVal(doc, xmlSchema.rootNodePath, xmlSchema.pageSizeItemName);
                if (totalsize == null)
                {
                    totalsize = (this as JdUnion_Bussiness_List_Class).pager.pageSize;//按实际返回的数量计算页大小
                }
                int totalPage = (totalCount.Value / totalsize.Value) + ((totalCount.Value % totalsize.Value) == 0 ? 0 : 1);
                if (totalPage > 1)//如果不止一页
                {
                    XmlNode rootnode = doc.SelectSingleNode(xmlSchema.rootNodePath);
                    for (int i = 2; i <= totalPage; i++)
                    {
                        (jdyreq as JdUnion_Bussiness_List_Class).RequestSizeAndPage((this as JdUnion_Bussiness_List_Class).pager.pageSize, i, null);
                        jdyreq.sign = null;//必须重置
                        jdyreq.InitRequestJson();
                        ret = jdyreq.GetRequest();

                        XmlDocument ntmp = jdyreq.getRealXml(ret, out msg);
                        if (msg != null)
                        {
                            continue;
                            //return false;
                        }
                        string xpath = string.Format("{0}/{1}", xmlSchema.rootNodePath, xmlSchema.dataItemName);
                        foreach (XmlNode node in ntmp.SelectNodes(xpath))//子节点全部加入根结点
                        {
                            rootnode.AppendChild(doc.ImportNode(node, true));
                        }
                    }
                }
                return(getXmlDataSet(doc, xmlSchema, ref retdoc, ref msg));
            }
            catch (Exception e)
            {
                msg = e.Message;
                return(false);
            }
            //return true;
        }
Ejemplo n.º 5
0
        private void btn_request_Click(object sender, EventArgs e)
        {
            this.txt_url.Text    = "";
            this.txt_result.Text = "正在准备请求!";
            ////jdy_GlbObject.ResetAccess();
            ////string ret = jdy_GlbObject.Access_token;
            ////this.txt_req_name.Text = ret;
            ////this.txt_bdId.Text = jdy_GlbObject.bdId.ToString();

            JdUnion_Bussiness_Class jdy = ddl_className.Tag as JdUnion_Bussiness_Class;

            if (jdy == null)
            {
                return;
            }
            //////Type cls = JdUnion_GlbObject.AllModuleClass[ddl_className.Text];
            //////object obj = Activator.CreateInstance(cls);// as;
            //////JdUnion_Bussiness_Class jdy = obj as JdUnion_Bussiness_Class;// as
            //JDYSCM_Class jdy = jdy_GlbObject.AllModuleClass[ddl_className.SelectedValue.ToString()];
            if (jdy == null)
            {
                return;
            }
            jdy.InitClass(JdUnion_GlbObject.mlist[ddl_className.Text]);
            this.txt_app_key.Text      = jdy.app_key;
            this.txt_app_secret.Text   = jdy.app_secret;
            this.txt_access_token.Text = jdy.access_token;
            //jdy.timestamp = this.txt_timestamp.Text.Trim();
            //jdy.params_360buy.Clear();
            jdy.sign = null;//必须要置空

            if (this.txt_params_1_val.Text.Trim().Length > 0)
            {
                jdy.setBussiessItems(this.txt_params_1_key.Text, this.txt_params_1_val.Text);
            }
            if (this.txt_params_2_val.Text.Trim().Length > 0)
            {
                jdy.setBussiessItems(this.txt_params_1_key.Text, this.txt_params_1_val.Text);
            }
            if (this.txt_params_3_val.Text.Trim().Length > 0)
            {
                jdy.setBussiessItems(this.txt_params_1_key.Text, this.txt_params_1_val.Text);
            }
            if (txt_PostData.Text.Trim().Length > 0)
            {
                if (jdy.params_360buy.Count == 0)
                {
                    jdy.params_360buy.Add(this.txt_params_1_key.Text, this.txt_PostData.Text);
                }
            }
            if (jdy is JdUnion_Bussiness_List_Class)
            {
                (jdy as JdUnion_Bussiness_List_Class).pager           = new JdUnion_Bussiness_List_Class.JdUnion_Bussiness_Filter_Class();
                (jdy as JdUnion_Bussiness_List_Class).pager.pageIndex = int.Parse(txt_PageNo.Text);
                (jdy as JdUnion_Bussiness_List_Class).pager.pageSize  = int.Parse(txt_PageSize.Text);
            }



            //this.txt_PostData.Text  =
            //jdy.InitRequestJson();
            ////if (jdy is JdUnion_Bussiness_List_Class)
            ////{
            ////    (jdy as JdUnion_Bussiness_List_Class).filter = new JdUnion_Bussiness_List_Class.JdUnion_Bussiness_Filter_Class();
            ////    (jdy as JdUnion_Bussiness_List_Class).filter.pageSize = int.Parse(txt_PageSize.Text);
            ////    (jdy as JdUnion_Bussiness_List_Class).filter.page = int.Parse(txt_PageNo.Text);
            ////    jdy.Req_PostData = "{\"filter\":" + (jdy as JdUnion_Bussiness_List_Class).filter.ToJson().Replace("null", "\"\"") + "}";
            ////}
            //this.txt_url.Text = jdy.getUrl();
            //this.txt_PostData.Text = jdy.Req_PostData;

            //jdy.Req_PostData = this.txt_PostData.Text;
            this.txt_url.Text = jdy.getUrl();
            //this.txt_result.Text = this.chkbox_Post.Checked?jdy.PostRequest():jdy.GetRequest();
            string      msg    = null;
            XmlDocument xmldoc = null;
            XmlDocument schema = null;
            bool        succ   = jdy.getXmlData(ref xmldoc, ref schema, ref msg, false, false);

            if (xmldoc != null)
            {
                this.txt_result.Text = xmldoc.OuterXml;
            }
        }