Beispiel #1
0
        public static bool CreateTable(MetaStandard standard)
        {
            if (standard == null)
            {
                return(false);
            }

            try
            {
                StringBuilder strSQL = new StringBuilder("Create Table ");
                strSQL.Append(standard.TableName);
                strSQL.Append(" (");
                strSQL.Append(GetSQLFromField(IDFieldInfo));
                strSQL.Append(",");
                foreach (FieldInfo fInfo in standard.FieldsInfo)
                {
                    strSQL.Append(GetSQLFromField(fInfo));
                    strSQL.Append(",");
                }
                strSQL.Remove(strSQL.Length - 1, 1);
                strSQL.Append(")");

                Environment.AdodbHelper.ExecuteSQL(strSQL.ToString());
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Beispiel #2
0
        public static DataTable GetAllMetaData(MetaStandard standard)
        {
            DataTable dtResult = Environment.AdodbHelper.ExecuteDataTable(string.Format("select * from {0}", standard.TableName));

            TransCaption(dtResult, standard.GetFieldNameDictionary());

            return(dtResult);
        }
Beispiel #3
0
        public static bool UpdateMeatadata(MetaStandard standard, DataTable dtData)
        {
            if (standard == null)
            {
                return(false);
            }

            return(Environment.AdodbHelper.UpdateTable(standard.TableName, dtData));
        }
Beispiel #4
0
        public static void ReLoadItem(MetaStandard standard)
        {
            if (standard == null)
            {
                return;
            }

            Environment.NhibernateHelper.RefreshObject(standard, Define.enumLockMode.UpgradeNoWait);
        }
Beispiel #5
0
        public static DataTable GetMetadata(MetaStandard standard, string strClause, int countPerPage, int pageIndex, ref int totalCount)
        {
            if (!Environment.AdodbHelper.TableExists(standard.TableName))
            {
                if (!CreateTable(standard))
                {
                    ErrorMessage = "此标准的数据表不存在,并且创建失败";
                    return(null);
                }
            }
            DataTable dtResult = GetMetadata(standard.TableName, strClause, countPerPage, pageIndex, ref totalCount);

            TransCaption(dtResult, standard.GetFieldNameDictionary());

            return(dtResult);
        }
Beispiel #6
0
        /// <summary>
        /// 保存字典项
        /// </summary>
        /// <param name="standard"></param>
        /// <returns></returns>
        public static bool SaveStandard(MetaStandard standard)
        {
            if (standard == null)
            {
                return(false);
            }

            try
            {
                Environment.NhibernateHelper.SaveObject(standard);
                // 记录
                if (standard.FieldsInfo != null)
                {
                    foreach (FieldInfo fInfo in standard.FieldsInfo)
                    {
                        fInfo.Layer = standard.ID;
                        Environment.NhibernateHelper.SaveObject(fInfo);
                    }
                }
                Environment.NhibernateHelper.Flush();

                // 创建表
                if (Environment.AdodbHelper.TableExists(standard.TableName))
                {
                    int eCount = Environment.AdodbHelper.ExecuteSQL(string.Format("Drop table {0}", standard.TableName));
                    if (eCount < 1)
                    {
                        ErrorMessage = "删除原有数据表时出错";
                        return(false);
                    }
                }
                if (!CreateTable(standard))
                {
                    ErrorMessage = "创建新数据表时出错";
                    return(false);
                }

                return(true);
            }
            catch (Exception exp)
            {
                Environment.Logger.AppendMessage(Define.enumLogType.Error, string.Format("保存元数据标准时出错:{0}", exp.ToString()));

                return(false);
            }
        }
Beispiel #7
0
        /// <summary>
        /// 删除字典项
        /// </summary>
        /// <param name="standard"></param>
        /// <returns></returns>
        public static bool DeleteStandard(MetaStandard standard)
        {
            if (standard == null)
            {
                return(false);
            }

            try
            {
                // 记录
                if (standard.FieldsInfo != null)
                {
                    foreach (FieldInfo fInfo in standard.FieldsInfo)
                    {
                        Environment.NhibernateHelper.DeleteObject(fInfo);
                    }
                }
                Environment.NhibernateHelper.DeleteObject(standard);
                Environment.NhibernateHelper.Flush();

                // 删除数据表
                if (Environment.AdodbHelper.TableExists(standard.TableName))
                {
                    Environment.AdodbHelper.ExecuteSQL(string.Format("Drop table {0}", standard.TableName));
                }

                return(true);
            }
            catch (Exception exp)
            {
                ErrorMessage = "删除出错了!";
                Environment.Logger.AppendMessage(Define.enumLogType.Error, string.Format("删除元数据标准时出错:{0}", exp.ToString()));

                return(false);
            }
        }
Beispiel #8
0
 public MetaStandardHelper(MetaStandard metaStandard)
 {
 }