public DataBaseHelper() { switch (Common.MyWeb.DbType) { case 0: dal = new Dukey.AccessDAL.DataBaseHelper(); break; case 1: dal = new Dukey.SQLServerDAL.DataBaseHelper(); break; case 2: dal = new Dukey.SQLiteDAL.DataBaseHelper(); break; } }
/// <summary> /// 创建数据帮助类 /// </summary> /// <returns></returns> public static IDataBaseHelper Create() { IDataBaseHelper dbhelper = AppCtx.Cache.RetrieveObject(DataBaseHelperFactoryID) as IDataBaseHelper; if (dbhelper == null) { dbhelper = Utils.CreateInstance(ModelConfig.DataBaseHelper) as IDataBaseHelper; if (dbhelper == null) { throw new Exception("不存在内容模型的数据库帮助类!"); } AppCtx.Cache.AddObjectWithFileChange(DataBaseHelperFactoryID, dbhelper, ModelConfig.ConfigFilePath); } return(dbhelper); }
public static IDataBaseHelper GetSqlDataClassHelper(SqlPrividerType privider, string constr, string modelNameSpace) { IDataBaseHelper classHelper = null; switch (privider) { case SqlPrividerType.SqlClient: classHelper = new SqlServerDBHelper(constr, modelNameSpace); break; case SqlPrividerType.OracleClient: classHelper = new OracleDBHelper(constr, modelNameSpace); break; case SqlPrividerType.Sqlite: classHelper = new SQLiteDBHelper(constr, modelNameSpace); break; case SqlPrividerType.MySqlClient: classHelper = new MySqlDBHelper(constr, modelNameSpace); break; } return(classHelper); }
public static IDataBaseHelper GetSqlDataClassHelper(SqlPrividerType privider, string constr, string modelNameSpace, Dictionary <string, string> dataBaseKyFieldTableDic, Dictionary <string, string> tableToTableNameDic) { IDataBaseHelper classHelper = null; switch (privider) { case SqlPrividerType.SqlClient: classHelper = new SqlServerDBHelper(constr, modelNameSpace, dataBaseKyFieldTableDic, tableToTableNameDic); break; case SqlPrividerType.OracleClient: classHelper = new OracleDBHelper(constr, modelNameSpace, dataBaseKyFieldTableDic, tableToTableNameDic); break; case SqlPrividerType.Sqlite: classHelper = new SQLiteDBHelper(constr, modelNameSpace, dataBaseKyFieldTableDic, tableToTableNameDic); break; case SqlPrividerType.MySqlClient: classHelper = new MySqlDBHelper(constr, modelNameSpace, dataBaseKyFieldTableDic, tableToTableNameDic); break; } return(classHelper); }
public DataBase(IDataBaseHelper helper) { _dbHelper = helper; }
/// <summary> /// 检查各项是否已经创建 /// </summary> void Exist(string Action) { IDataBaseHelper helper = DataBaseHelperFactory.Create(); StringBuilder sb = new StringBuilder(); sb.Append("{\"modelName\":\"" + ModelInfo.ModelName + "\",\"Data\":["); if (Action == "widget") { #region 检查部件 //部件 int widgetCount = 0; string viewPath = ModelHelper.GetWidgetDirectory(modelInfo, "View"); string listPath = ModelHelper.GetWidgetDirectory(modelInfo, "List"); string pageListPath = ModelHelper.GetWidgetDirectory(modelInfo, "PagedList"); if (Directory.Exists(viewPath)) { widgetCount++; } if (Directory.Exists(listPath)) { widgetCount++; } if (Directory.Exists(pageListPath)) { widgetCount++; } //存在至少一个部件 if (widgetCount > 0) { sb.Append("{\"name\":\"createWidget\",\"exist\":true},"); } else { sb.Append("{\"name\":\"createWidget\",\"exist\":false},"); } #endregion } if (isArticle) { #region 检查表结构 //int rowCount = 0; //try //{ // rowCount = helper.Count(ModelInfo.Name, ""); // sb.Append("{\"name\":\"createTable\",\"exist\":true},"); //} //catch //{ // sb.Append("{\"name\":\"createTable\",\"exist\":false},"); //} #endregion #region 检查左侧菜单 //MenuHelper MenuHelper = HelperFactory.Instance.GetHelper<MenuHelper>(); //We7.CMS.Common.MenuItem item = MenuHelper.GetMenuItemByTitle(ModelInfo.Label + "管理"); //if (item != null && !string.IsNullOrEmpty(item.ID)) //{ // sb.Append("{\"name\":\"addLeftMenu\",\"exist\":true},"); //} //else //{ // sb.Append("{\"name\":\"addLeftMenu\",\"exist\":false},"); //} #endregion if (Action == "layout") { #region 检查布局 string layoutPath = ModelHelper.GetModelLayoutDirectory(ModelInfo.ModelName) + "GenerateLayout.ascx"; if (File.Exists(layoutPath)) { layoutPath = String.Format("{0}/{1}/{2}/{3}", ModelConfig.ModelsDirectory, ModelInfo.GroupName, ModelInfo.Name, "GenerateLayout.ascx"); EditInfo entity = ModelInfo.Layout.Panels["edit"].EditInfo; sb.Append("{\"name\":\"createLayout\",\"exist\":true,\"path\":\"" + layoutPath + "\"},"); //ModelInfo.Layout.Panels["edit"].EditInfo.Layout; if (!string.IsNullOrEmpty(entity.Layout)) { chkAE.Checked = true; } if (!string.IsNullOrEmpty(entity.ViewerLayout)) { chkView.Checked = true; } if (!string.IsNullOrEmpty(entity.UcLayout)) { chkUC.Checked = true; } } else { sb.Append("{\"name\":\"createLayout\",\"exist\":false},"); } #endregion } } sb.Append("]}"); strScript = sb.ToString(); strScript = strScript.Remove(strScript.LastIndexOf(","), 1); strScript = new JavaScriptSerializer().Serialize(strScript); }