Пример #1
0
        public static IEnumerable <Dictionary <string, object> > GetMainTypeTree()
        {
            var       dbNames   = WebConfigHelper.GetDBNames();
            SqlHelper sqlHelper = new SqlHelper("Base");
            string    sql       = "";
            string    topId     = CommonStr.MainTypeTreeRootID;
            string    topName   = ConfigurationManager.AppSettings["AppTitle"];

            for (int i = 0; i < dbNames.Count(); i++)
            {
                string tmpSql = @"select  '{0}' as Id, '' as ParentId, '{1}' Text, '' as IconCls, 0 as OrderIndex, '' as DBName, '{0}' as FullId
                      union
                      select  '{2}' as Id, '{0}' as ParentId, '{2}' Text, '' as IconCls, 0 as OrderIndex, '{2}' as DBName, '{0}.{2}' as FullId
                      union 
                      select Id, case when ParentId is null then '{2}' else ParentId end ParentId,Text,IconCls,OrderIndex, DBName,FullId FROM MF_MainType where DBName = '{2}' ";
                sql += string.Format(tmpSql, topId, topName, dbNames[i]);

                if (i != dbNames.Count() - 1)
                {
                    sql += " union ";
                }
            }

            var dt = sqlHelper.ExcuteTable(sql);

            return(dt.ToDicList());
        }
Пример #2
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            ControllerBuilder.Current.SetControllerFactory(new MFControllerFactory());

            AggregateCatalog aggregateCatalog = new AggregateCatalog();

            aggregateCatalog.Catalogs.Add(new DirectoryCatalog(AppDomain.CurrentDomain.SetupInformation.PrivateBinPath));
            MefDependencyResolver res = new MefDependencyResolver(new DisposableWrapperCatalog(aggregateCatalog, true));

            DependencyResolver.SetResolver(res);

            //dbconfig DatabaseInitializer Initialize
            var dbNameList = WebConfigHelper.GetDBNames();

            foreach (var dbName in dbNameList)
            {
                string initializerName = "{0}.DatabaseInitializer".ReplaceArg(dbName);
                Type   type            = ReflectionHelper.GetTypeBy(dbName, initializerName);
                if (type == null)
                {
                    continue;
                }
                type.InvokeMember("Initialize", System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Static
                                  | System.Reflection.BindingFlags.Public, null, null,
                                  new object[] { });
            }

            //MiniProfilerEF6.Initialize();
            //MF_Base.DatabaseInitializer.Initialize();
        }
Пример #3
0
        public static IEnumerable <Dictionary <string, object> > GetMainTypeTopTree()
        {
            string topId       = CommonStr.MainTypeTreeRootID;
            string topName     = ConfigurationManager.AppSettings["AppTitle"];
            var    topMainType = new { Id = topId, ParentId = "", Text = topName, DBName = "", OrderIndex = 0 };
            var    resList     = WebConfigHelper.GetDBNames().Select(a => new { Id = a, ParentId = topId, Text = a, DBName = a, OrderIndex = 0 }).ToList();

            resList.Insert(0, topMainType);
            return(resList.Select(a => a.ToDictionary()));
        }
Пример #4
0
    public static MvcHtmlString DBNames(this HtmlHelper html, string enumName = "DBNames")
    {
        var            tmpList        = WebConfigHelper.GetDBNames();
        List <dynamic> textValuePairs = new List <dynamic>();

        foreach (var item in tmpList)
        {
            textValuePairs.Add(new { text = item, value = item });
        }

        string result = string.Format("var {0} = {1};", enumName, textValuePairs.ToJson());

        return(MvcHtmlString.Create(result));
    }
Пример #5
0
        public JsonResult GetEntityList()
        {
            var            dbNames = WebConfigHelper.GetDBNames();
            List <dynamic> list    = new List <dynamic>();
            var            exsitEntityFullNames = UnitOfWork.Get <FormConfig>().Select(a => a.EntityFullName);

            //根据entityfullname筛选,同时排除已经定义的实体
            foreach (var name in dbNames)
            {
                string baseEntityName = "Entity";
                list.AddRange(CommonHelper.GetClassFullNames(name, baseEntityName)
                              .Select(a => new { DBName = name, EntityFullName = a.GetValue("FullName"), Name = a.GetValue("Description"), TableName = a.GetValue("ClassName") }));
            }

            return(Json(list));
        }
Пример #6
0
        public JsonResult GetEntityList()
        {
            string         entityFullName = QueryString("EntityFullName").ToLower();
            var            dbNames        = WebConfigHelper.GetDBNames();
            List <dynamic> list           = new List <dynamic>();
            //根据entityfullname筛选,同时排除已经定义的实体
            var exsitEntityFullNames = UnitOfWork.Get <WFDef>().Select(a => a.EntityFullName);

            foreach (var name in dbNames)
            {
                string baseEntityName = "Entity";
                list.AddRange(CommonHelper.GetClassFullNames(name, baseEntityName)
                              .Where(a => (string.IsNullOrEmpty(entityFullName) ? true : a.GetValue("FullName").ToLower().Contains(entityFullName)) && !exsitEntityFullNames.Contains(a.GetValue("FullName")))
                              .Select(a => new { DBName = name, EntityFullName = a.GetValue("FullName"), Name = a.GetValue("Description"), }));
            }
            return(Json(list));
        }
Пример #7
0
        public JsonResult GetDBNameList()
        {
            var dbNames = WebConfigHelper.GetDBNames().Select(a => new { id = a, text = a });

            return(Json(dbNames));
        }