Esempio 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;
        }
Esempio n. 2
0
        static JdUnion_GlbObject()
        {
            Type        t       = typeof(JdUnion_ModuleProcessClass);
            List <Type> subList = getAllSubClass(t);

            modules = new JdUnion_Modules();
            subList.ForEach(a => {
                JdUnion_ModuleClass mdl = new JdUnion_ModuleClass();
                mdl.ClassName           = a.Name;
                mdl.AccessUrl           = "";
                mdl.ModuleName          = a.Name;
                mdl.RequestModel        = "";
                modules.Modules.Add(mdl);
            });
            string json = modules.ToJson();
            string path = new JdUnion_SystemClass().getJsonPath("system.config.modules");

            if (!File.Exists(path))
            {
                SaveFile(path, json);
            }
            else
            {
                string strJson = File.OpenText(path).ReadToEnd();
                modules = modules.GetFromJson <JdUnion_Modules>(strJson);
            }
            modules.Modules.ForEach(a => mlist.Add(a.ClassName, a));
            subList.ForEach(a => {
                if (mlist.ContainsKey(a.Name))
                {
                    AllModuleClass.Add(a.Name, a);
                    JdUnion_ModuleProcessClass obj = Activator.CreateInstance(a) as JdUnion_ModuleProcessClass;
                    if (obj != null)
                    {
                        obj.InitClass(mlist[a.Name]);
                    }
                    //if(obj is AccessTokenClass)
                    //{
                    //    AccessObj = obj as AccessTokenClass;
                    //    AccessObj.InitRequestJson();
                    //}
                    if (obj is JdUnion_RequestClass)
                    {
                        (obj as JdUnion_RequestClass).InitRequestJson();
                    }
                }
            });
            //string strtest = Access_token;
        }
Esempio 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);
        }
        public bool InitClass(JdUnion_ModuleClass module)
        {
            if (module == null)
            {
                return(false);
            }
            Module = module;
            if (this.params_360buy.Count == 0)
            {
                LoadParams();
            }
            return(true);

            string json = this.getJsonContent(this.strJsonName);

            if (json == null)
            {
                return(false);
            }
            Module = module;
            return(true);
        }