Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="modelName"></param>
        /// <param name="mtype">模块类型</param>
        /// <param name="mtype2"></param>
        /// <param name="isService"></param>
        /// <returns></returns>
        private static string GetFilePath(string modelName, string mtype, string mtype2, bool isService)
        {
            string text = mtype.ToString();

            FastDev.DevDB.Model.Config.Model model = GetModelByModelName(modelName);
            string modelType = ((model == null) ? "others" : model.moduleName);

            if (string.IsNullOrEmpty(modelType))
            {
                modelType = "others";
            }
            if (text == "main")
            {
                text = "list";
            }
            if (!string.IsNullOrEmpty(mtype2))
            {
                text = mtype2;
            }
            string text3 = new HttpServerUtility(HttpContext.Current).MapPath(string.Format("~/ui/{0}/{1}{2}.js", modelName, isService ? "service_" : "", text));

            if (File.Exists(text3))
            {
                return(text3);
            }
            return(new HttpServerUtility(HttpContext.Current).MapPath(string.Format("~/ui/{0}/{1}/{2}{3}.js", modelType, modelName, isService ? "service_" : "", text)));
        }
Ejemplo n.º 2
0
        private static FastDev.DevDB.Model.Config.Model GetModelByName(string modelName)
        {
            DbContext  currentDb  = SysContext.GetCurrentDb();
            core_model core_model = currentDb.FirstOrDefault <core_model>("where ModelName = @0", new object[1]
            {
                modelName
            });

            if (core_model == null)
            {
                return(null);
            }
            core_module core_module = null;

            if (!string.IsNullOrEmpty(core_model.ModuleID))
            {
                core_module = currentDb.FirstOrDefault <core_module>("where ID = @0", new object[1]
                {
                    core_model.ModuleID
                });
            }
            string          textField       = "ID";
            core_modelField core_modelField = currentDb.FirstOrDefault <core_modelField>("where IsTextField = 1 and FieldType = @0", new object[1]
            {
                "string"
            });

            if (core_modelField != null)
            {
                textField = core_modelField.FieldName;
            }
            else
            {
                core_modelField = currentDb.FirstOrDefault <core_modelField>("where FieldType = @0", new object[1]
                {
                    "string"
                });
                if (core_modelField != null)
                {
                    textField = core_modelField.FieldName;
                }
            }
            FastDev.DevDB.Model.Config.Model model = new FastDev.DevDB.Model.Config.Model();
            model.name      = core_model.ModelName;
            model.title     = core_model.ModelTitle;
            model.textField = textField;
            if (core_module != null)
            {
                model.moduleName  = core_module.ModuleName;
                model.moduleTitle = core_module.ModuleTitle;
            }
            return(model);
        }