예제 #1
0
파일: Firebird.cs 프로젝트: rebider/soa
        protected override void CreateDatabase()
        {
            //base.CreateDatabase();

            if (String.IsNullOrEmpty(FileName) || File.Exists(FileName))
            {
                return;
            }

            //The miminum you must specify:

            //Hashtable parameters = new Hashtable();
            //parameters.Add("User", "SYSDBA");
            //parameters.Add("Password", "masterkey");
            //parameters.Add("Database", @"c:\database.fdb");
            //FbConnection.CreateDatabase(parameters);

            DAL.WriteDebugLog("创建数据库:{0}", FileName);

            DbConnection conn   = Database.Factory.CreateConnection();
            MethodInfoX  method = MethodInfoX.Create(conn.GetType(), "CreateDatabase", new Type[] { typeof(String) });

            if (method == null)
            {
                return;
            }

            method.Invoke(null, Database.ConnectionString);
        }
예제 #2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            Int32 n = (Int32)MethodInfoX.Create(EntityType, "ScanAndAdd").Invoke(null);

            WebHelper.Alert("扫描完成,共添加菜单" + n + "个!");
        }
        catch (Exception ex)
        {
            WebHelper.Alert("出错!" + ex.Message);
        }
    }
예제 #3
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        String xml = MethodInfoX.Create(EntityType, "Export").Invoke(null, Provider.MenuRoot.Childs) as String;

        Response.Clear();
        Response.Buffer          = true;
        Response.Charset         = "utf8";
        Response.ContentEncoding = Encoding.UTF8;
        Response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode("菜单.xml") + "");
        Response.ContentType = "xml/text";
        Response.Output.Write(xml);
        Response.Flush();
        Response.End();
    }
예제 #4
0
        /// <summary>处理消息</summary>
        /// <returns></returns>
        public Message Invoke()
        {
            var method = Method;

            try
            {
                if (method == null)
                {
                    throw new ArgumentNullException("Method", String.Format("无法找到目标方法{0}.{1}!", Type, Name));
                }

                var rs = MethodInfoX.Create(method).Invoke(null, Parameters);
                if (rs == null)
                {
                    return(new NullMessage());
                }
                else if (rs is IList)
                {
                    // 采用实体集合消息返回列表型数据,避免序列化反序列化实体集合所带来的各种问题,到了客户端后,一律转化为List<T>
                    return new EntitiesMessage()
                           {
                               Values = rs as IList
                           }
                }
                ;
                else
                {
                    return new EntityMessage()
                           {
                               Value = rs
                           }
                };
            }
            catch (Exception ex)
            {
                return(new ExceptionMessage()
                {
                    Value = ex
                });
            }
        }
예제 #5
0
    protected void Button3_Click(object sender, EventArgs e)
    {
        if (!FileUpload1.HasFile)
        {
            return;
        }

        String xml = Encoding.UTF8.GetString(FileUpload1.FileBytes);

        try
        {
            MethodInfoX.Create(EntityType, "Import").Invoke(null, xml);

            gv.DataBind();
        }
        catch (Exception ex)
        {
            WebHelper.Alert(ex.Message);

            HmTrace.WriteLine(ex.ToString());
        }
    }
예제 #6
0
파일: XTrace.cs 프로젝트: xlfj5211/esb
        /// <summary>获取调用栈</summary>
        /// <param name="start"></param>
        /// <param name="maxNum"></param>
        /// <param name="split"></param>
        /// <returns></returns>
        public static String GetCaller(int start = 1, int maxNum = 0, String split = null)
        {
            // 至少跳过当前这个
            if (start < 1)
            {
                start = 1;
            }
            var st = new StackTrace(start, true);

            if (String.IsNullOrEmpty(split))
            {
                split = "<-";
            }

            Type last  = null;
            var  asm   = Assembly.GetEntryAssembly();
            var  entry = asm == null ? null : asm.EntryPoint;

            var sb    = new StringBuilder();
            int count = st.FrameCount;

            if (maxNum > 0 && maxNum < count)
            {
                count = maxNum;
            }
            for (int i = 0; i < count; i++)
            {
                var sf     = st.GetFrame(i);
                var method = sf.GetMethod();
                // 跳过<>类型的匿名方法

                if (method == null || String.IsNullOrEmpty(method.Name) || method.Name[0] == '<' && method.Name.Contains(">"))
                {
                    continue;
                }

                //var name = method.ToString();
                //// 去掉前面的返回类型
                //var p = name.IndexOf(" ");
                //if (p >= 0) name = name.Substring(p + 1);

                var mix  = MethodInfoX.Create(method);
                var type = method.DeclaringType ?? method.ReflectedType;
                if (type != null)
                {
                    if (type != last)
                    {
                        sb.Append(mix.Name);
                    }
                    else
                    {
                        sb.Append(mix.TinyName);
                    }
                }
                else
                {
                    sb.Append(mix.Name);
                }
                //sb.Append(MethodInfoX.Create(method).Name);

                // 如果到达了入口点,可以结束了
                if (method == entry)
                {
                    break;
                }

                if (i < count - 1)
                {
                    sb.Append(split);
                }

                last = type;
            }
            return(sb.ToString());
        }