/// <summary> /// Gets the list. /// </summary> /// <param name="metaClass">The meta class.</param> /// <returns></returns> internal static MetaFieldCollection GetList(MetaClass metaClass) { #region ArgumentNullExceptions if (metaClass == null) { throw new ArgumentNullException("metaClass", AsyncResources.GetConstantValue("ARG_NULL_ERR_MSG")); } #endregion MetaFieldCollection retVal = new MetaFieldCollection(); using (SqlDataReader reader = SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_LoadMetaFieldListByMetaClassId"), new SqlParameter("@MetaClassId", metaClass.Id))) { while (reader.Read()) { MetaField newItem = MetaField.Load(metaClass, reader); newItem.SetOwnerMetaClass(metaClass); retVal.Add(newItem); } reader.Close(); } return(retVal); }
public void ReplaceUser(int oldUserId, int newUserId) { SqlHelper.ExecuteNonQuery(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_ReplaceUser"), new SqlParameter("@OldUserId", oldUserId), new SqlParameter("@NewUserId", newUserId)); }
/// <summary> /// Gets the list. /// </summary> /// <param name="NamespaceItems">The namespace items.</param> /// <returns></returns> public static MetaFieldCollection GetList(params string[] namespaceItems) { #region ArgumentNullExceptions if (namespaceItems == null) { throw new ArgumentNullException("NamespaceItems", AsyncResources.GetConstantValue("ARG_NULL_ERR_MSG")); } #endregion MetaFieldCollection retVal = new MetaFieldCollection(); foreach (string Namespace in namespaceItems) { using (SqlDataReader reader = SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_LoadMetaFieldByNamespace"), new SqlParameter("@Namespace", Namespace), new SqlParameter("@Deep", false))) { while (reader.Read()) { retVal.Add(MetaField.Load(reader)); } } } return(retVal); }
/// <summary> /// Gets the data reader. /// </summary> /// <param name="metaClass">The meta class.</param> /// <returns></returns> public static IDataReader GetDataReader(MetaClass metaClass) { #region ArgumentNullExceptions if (metaClass == null) { throw new ArgumentNullException("metaClass", AsyncResources.GetConstantValue("ARG_NULL_ERR_MSG")); } #endregion return(GetDataReader(metaClass.Id)); }
/// <summary> /// Loads the specified reader. /// </summary> /// <param name="reader">The reader.</param> /// <returns></returns> public static MetaField Load(SqlDataReader reader) { #region ArgumentNullExceptions if (reader == null) { throw new ArgumentNullException("reader", AsyncResources.GetConstantValue("ARG_NULL_ERR_MSG")); } #endregion return(MetaField.Load(null, reader)); }
/// <summary> /// Creates the virtual. /// </summary> /// <param name="metaNamespace">The namespace.</param> /// <param name="name">The name.</param> /// <param name="friendlyName">Name of the friendly.</param> /// <param name="description">The description.</param> /// <param name="dataType">Type of the data.</param> /// <param name="length">The length.</param> /// <param name="allowNulls">if set to <c>true</c> [allow nulls].</param> /// <param name="saveHistory">if set to <c>true</c> [save history].</param> /// <param name="multilanguageValue">if set to <c>true</c> [multi language value].</param> /// <param name="allowSearch">if set to <c>true</c> [allow search].</param> /// <returns></returns> public static MetaField CreateVirtual( string metaNamespace, string name, string friendlyName, string description, MetaDataType dataType, int length, bool allowNulls, bool saveHistory, bool multilanguageValue, bool allowSearch) { #region ArgumentNullExceptions if (metaNamespace == null) { throw new ArgumentNullException("Namespace", AsyncResources.GetConstantValue("ARG_NULL_ERR_MSG")); } if (name == null) { throw new ArgumentNullException("Name", AsyncResources.GetConstantValue("ARG_NULL_ERR_MSG")); } if (friendlyName == null) { throw new ArgumentNullException("FriendlyName", AsyncResources.GetConstantValue("ARG_NULL_ERR_MSG")); } #endregion MetaField retVal = new MetaField(); // Load MetaField Information [11/18/2004] retVal._id = -1; retVal._namespace = metaNamespace; retVal._name = name; retVal._friendlyName = friendlyName; retVal._description = description; retVal._dataType = dataType; retVal._length = length; retVal._allowNulls = allowNulls; retVal._saveHistory = saveHistory; retVal._multilanguageValue = multilanguageValue; retVal._allowSearch = allowSearch; retVal._systemMetaClassId = -1; return(retVal); }
/// <summary> /// Creates the specified namespace. /// </summary> /// <param name="metaNamespace">The namespace.</param> /// <param name="name">The name.</param> /// <param name="friendlyName">Name of the friendly.</param> /// <param name="description">The description.</param> /// <param name="dataType">Type of the data.</param> /// <param name="length">The length.</param> /// <param name="allowNulls">if set to <c>true</c> [allow nulls].</param> /// <param name="saveHistory">if set to <c>true</c> [save history].</param> /// <param name="multilanguageValue">if set to <c>true</c> [multilanguage value].</param> /// <param name="allowSearch">if set to <c>true</c> [allow search].</param> /// <returns></returns> public static MetaField Create( string metaNamespace, string name, string friendlyName, string description, MetaDataType dataType, int length, bool allowNulls, bool saveHistory, bool multilanguageValue, bool allowSearch) { #region ArgumentNullExceptions if (metaNamespace == null) { throw new ArgumentNullException("Namespace", AsyncResources.GetConstantValue("ARG_NULL_ERR_MSG")); } if (name == null) { throw new ArgumentNullException("Name", AsyncResources.GetConstantValue("ARG_NULL_ERR_MSG")); } if (friendlyName == null) { throw new ArgumentNullException("FriendlyName", AsyncResources.GetConstantValue("ARG_NULL_ERR_MSG")); } #endregion SqlParameter Retval = new SqlParameter("@Retval", SqlDbType.Int, 4); Retval.Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_AddMetaField"), new SqlParameter("@Namespace", metaNamespace), new SqlParameter("@Name", name), new SqlParameter("@FriendlyName", friendlyName), new SqlParameter("@Description", description), new SqlParameter("@DataTypeId", (int)dataType), new SqlParameter("@Length", length), new SqlParameter("@AllowNulls", allowNulls), new SqlParameter("@SaveHistory", saveHistory), //new SqlParameter("@MultiLanguageValue", multilanguageValue), new SqlParameter("@AllowSearch", allowSearch), Retval ); return(MetaField.Load((int)Retval.Value)); }
/// <summary> /// Loads the specified name. /// </summary> /// <param name="Name">The name.</param> /// <returns></returns> public static MetaField Load(string name) { #region ArgumentNullExceptions if (name == null) { throw new ArgumentNullException("Name", AsyncResources.GetConstantValue("ARG_NULL_ERR_MSG")); } #endregion MetaField retVal = null; using (SqlDataReader reader = SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_LoadMetaFieldByName"), new SqlParameter("@Name", name))) { if (reader.Read()) { retVal = MetaField.Load(reader); } reader.Close(); } return(retVal); }
/// <summary> /// Deletes at. /// </summary> /// <param name="Index">The index.</param> public void DeleteAt(int index) { MetaDictionaryItem item = this[index]; SqlHelper.ExecuteNonQuery(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_DeleteMetaDictionary"), new SqlParameter("@MetaDictionaryId", item.Id) ); this.InnerList.RemoveAt(index); // Decrease Index ReindexItems(); }
/// <summary> /// Adds the specified default value. /// </summary> /// <param name="DefaultValue">The default value.</param> /// <param name="Value">The value.</param> /// <param name="DefaultTag">The default tag.</param> /// <param name="Tag">The tag.</param> /// <returns></returns> internal void Insert(int index, string defaultValue, string value, object defaultTag, object tag) { if (index < 0 && index >= this.Count) { throw new ArgumentOutOfRangeException("index"); } SqlParameter spDefaultTag = new SqlParameter("@DefaultTag", SqlDbType.Image); spDefaultTag.Value = SqlHelper.Null2DBNull(defaultTag); SqlParameter spTag = new SqlParameter("@Tag", SqlDbType.Image); spTag.Value = SqlHelper.Null2DBNull(tag); SqlParameter Retval = new SqlParameter("@Retval", SqlDbType.Int, 4); Retval.Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_AddMetaDictionary"), new SqlParameter("@MetaFieldId", this.OwnerMetaFieldId), //new SqlParameter("@Language", SqlHelper.Null2DBNull(MetaDataContext.Current.Language)), //new SqlParameter("@DefaultValue", value), //spDefaultTag, new SqlParameter("@Value", value), spTag, new SqlParameter("@Index", index), Retval ); MetaDictionaryItem retVal = new MetaDictionaryItem((int)Retval.Value, this.OwnerMetaFieldId, defaultValue, value, index); this.InnerList.Insert(index, retVal); ReindexItems(); }
/// <summary> /// Reloads the meta dictionary. /// </summary> void ReloadMetaDictionary() { using (SqlDataReader reader = SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_LoadMetaDictionary"), new SqlParameter("@MetaFieldId", this.OwnerMetaFieldId))) { while (reader.Read()) { MetaDictionaryItem newItem = new MetaDictionaryItem(reader); this.InnerList.Add(newItem); } reader.Close(); } // ReIndex ReindexItems(); }
/// <summary> /// Gets the name of the unique. /// </summary> /// <param name="Name">The name.</param> /// <returns></returns> public static string GetUniqueName(string name) { SqlParameter UniqueName = new SqlParameter("@UniqueName", SqlDbType.NVarChar, 256); UniqueName.Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_GetUniqueFieldName"), new SqlParameter("@Name", name), UniqueName ); return((string)UniqueName.Value); }
/// <summary> /// Adds the specified default value. /// </summary> /// <param name="DefaultValue">The default value.</param> /// <param name="Value">The value.</param> /// <param name="DefaultTag">The default tag.</param> /// <param name="Tag">The tag.</param> /// <returns></returns> internal int Add(string defaultValue, string value, object defaultTag, object tag) { SqlParameter spDefaultTag = new SqlParameter("@DefaultTag", SqlDbType.Image); spDefaultTag.Value = SqlHelper.Null2DBNull(defaultTag); SqlParameter spTag = new SqlParameter("@Tag", SqlDbType.Image); spTag.Value = SqlHelper.Null2DBNull(tag); SqlParameter Retval = new SqlParameter("@Retval", SqlDbType.Int, 4); Retval.Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_AddMetaDictionary"), new SqlParameter("@MetaFieldId", this.OwnerMetaFieldId), //new SqlParameter("@Language", SqlHelper.Null2DBNull(MetaDataContext.Current.Language)), //new SqlParameter("@DefaultValue", value), //spDefaultTag, new SqlParameter("@Value", value), spTag, new SqlParameter("@Index", this.Count), Retval ); MetaDictionaryItem retVal = new MetaDictionaryItem((int)Retval.Value, this.OwnerMetaFieldId, defaultValue, value, this.Count); return(this.InnerList.Add(retVal)); }
public static void Save(Rule rule) { if (rule == null) { throw new ArgumentNullException("rule"); } byte[] data = Serialize(rule); int MetaClassId = MetaClass.Load(rule._innerClassName).Id; SqlParameter retVal = new SqlParameter("@RetVal", SqlDbType.Int, 4); retVal.Direction = ParameterDirection.Output; SqlHelper.ExecuteNonQuery(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_UpdateMetaRule"), new SqlParameter("@RuleId", rule._id), new SqlParameter("@MetaClassId", MetaClassId), new SqlParameter("@Data", data), retVal); rule._id = (int)retVal.Value; }
/// <summary> /// Deletes the specified meta field id. /// </summary> /// <param name="MetaFieldId">The meta field id.</param> public static void Delete(int metaFieldId) { SqlHelper.ExecuteNonQuery(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_DeleteMetaField"), new SqlParameter("@MetaFieldId", metaFieldId) ); }
public static Rule[] GetList(int metaClassId) { List <Rule> list = new List <Rule>(); using (IDataReader reader = SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_LoadMetaRuleByMetaClassId"), new SqlParameter("@MetaClassId", metaClassId))) { while (reader.Read()) { byte[] data = (byte[])reader["Data"]; int ruleId = (int)reader["RuleId"]; Rule rule = Deserialize(data); rule._id = ruleId; list.Add(rule); } reader.Close(); } return(list.ToArray()); }
/// <summary> /// Loads the specified meta field id. /// </summary> /// <param name="MetaFieldId">The meta field id.</param> /// <returns></returns> public static MetaField Load(int metaFieldId) { MetaField retVal = null; using (SqlDataReader reader = SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_LoadMetaField"), new SqlParameter("@MetaFieldId", metaFieldId))) { if (reader.Read()) { retVal = MetaField.Load(reader); } reader.Close(); } return(retVal); }
/// <summary> /// Deletes the specified meta dictionary id. /// </summary> /// <param name="MetaDictionaryId">The meta dictionary id.</param> public void Delete(int metaDictionaryId) { SqlHelper.ExecuteNonQuery(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_DeleteMetaDictionary"), new SqlParameter("@MetaDictionaryId", metaDictionaryId) ); foreach (MetaDictionaryItem item in this) { if (item.Id == metaDictionaryId) { this.InnerList.Remove(item); break; } } ReindexItems(); }
public static void CleanupLocalDiskStorage() { if (MetaDataContext.Current.MetaFileDataStorageType == MetaFileDataStorageType.DataBase) { return; } string[] FileList = Directory.GetFiles(MetaDataContext.Current.LocalDiskStorage, "*.mdpdata"); foreach (string fileName in FileList) { bool bGoodFile = false; try { int MetaKey = int.Parse(System.IO.Path.GetFileNameWithoutExtension(fileName), _culture); using (IDataReader reader = SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_GetMetaKeyInfo"), new SqlParameter("@MetaKey", MetaKey))) { if (reader.Read()) { bGoodFile = true; } } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); } if (!bGoodFile) { try { File.Delete(fileName); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); } } } }
/// <summary> /// Adds the specified key. /// </summary> /// <param name="key">The key.</param> /// <param name="value">The value.</param> public virtual void Add(string key, string value) { if (key == null) { throw new ArgumentNullException("key"); } if (value == null) { throw new ArgumentNullException("value"); } key = key.ToLower(CultureInfo.InvariantCulture); SqlHelper.ExecuteNonQuery(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_AddMetaAttribute"), new SqlParameter("@AttrOwnerId", this._OwnerId), new SqlParameter("@AttrOwnerType", (int)this._OwnerType), new SqlParameter("@Key", key), new SqlParameter("@Value", value)); this.contents.Add(key, value); }
/// <summary> /// Gets the data reader. /// </summary> /// <param name="MetaClassId">The meta class id.</param> /// <returns></returns> public static IDataReader GetDataReader(int metaClassId) { return((IDataReader)SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_LoadMetaFieldListByMetaClassId"), new SqlParameter("@MetaClassId", metaClassId))); }
/// <summary> /// Gets the list. /// </summary> /// <returns></returns> public static MetaFieldCollection GetList() { MetaFieldCollection retVal = new MetaFieldCollection(); using (SqlDataReader reader = SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_LoadMetaFieldList"))) { while (reader.Read()) { MetaField newItem = MetaField.Load(reader); retVal.Add(newItem); } reader.Close(); } return(retVal); }
/// <summary> /// Gets the data reader. /// </summary> /// <returns></returns> public static IDataReader GetDataReader() { return(SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_LoadMetaFieldList"))); }
/// <summary> /// Clears this instance. /// </summary> public virtual void Clear() { SqlHelper.ExecuteNonQuery(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_DeleteMetaAttribute"), new SqlParameter("@AttrOwnerId", _OwnerId), new SqlParameter("@AttrOwnerType", (int)_OwnerType)); this.contents.Clear(); }
public static void MetaFileCopyToLocalDisk(string path) { using (IDataReader reader = SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("mdpsp_sys_LoadMetaFileList"))) { while (reader.Read()) { byte[] Data = (byte[])(SqlHelper.DBNull2Null(reader["Data"])); using (FileStream stream = File.OpenWrite(System.IO.Path.Combine(path, string.Format(_culture, "{0}.mdpdata", (int)reader["MetaKey"])))) { stream.Write(Data, 0, Data.Length); stream.Flush(); } } } }
public static MetaTypeCollection GetSqlMetaTypes() { MetaTypeCollection retVal = new MetaTypeCollection(); using (SqlDataReader reader = SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_LoadMetaTypeList"))) { while (reader.Read()) { MetaType newType = MetaType.Load(reader); if (newType.IsSqlCommonType) { retVal.Add(newType); } } reader.Close(); } return(retVal); }
public static void MetaFileCopyToDataBase(string path) { foreach (string fileName in Directory.GetFiles(path, "*.mdpdata")) { try { int MetaKey = int.Parse(System.IO.Path.GetFileNameWithoutExtension(fileName), _culture); string FilePath = System.IO.Path.Combine(path, fileName); using (FileStream stream = File.OpenRead(FilePath)) { using (IDataReader reader = SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_GetMetaKeyInfo"), new SqlParameter("@MetaKey", MetaKey))) { if (reader.Read()) { byte[] Buffer = new byte[stream.Length]; stream.Read(Buffer, 0, Buffer.Length); //int MetaClassId = (int)reader["MetaClassId"]; //int MetaFieldId = (int)reader["MetaFieldId"]; //int MetaObjectId = (int)reader["MetaObjectId"]; SqlParameter spData = new SqlParameter("@Data", SqlDbType.Image); spData.Value = SqlHelper.Null2DBNull(Buffer); // Step 3. Save new values [11/30/2004] SqlHelper.ExecuteNonQuery(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_UpdateMetaFile"), new SqlParameter("@MetaKey", MetaKey), new SqlParameter("@FileName", fileName), new SqlParameter("@ContentType", string.Empty), new SqlParameter("@Size", stream.Length), spData, new SqlParameter("@CreationTime", File.GetCreationTime(FilePath)), new SqlParameter("@LastReadTime", File.GetLastAccessTime(FilePath)), new SqlParameter("@LastWriteTime", File.GetLastWriteTime(FilePath))); } } } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex); } } }
public static Rule Load(int ruleId) { Rule retVal = null; using (IDataReader reader = SqlHelper.ExecuteReader(MetaDataContext.Current, CommandType.StoredProcedure, AsyncResources.GetConstantValue("SP_LoadMetaRuleById"), new SqlParameter("@RuleId", ruleId))) { if (reader.Read()) { byte[] data = (byte[])reader["Data"]; retVal = Deserialize(data); retVal._id = (int)reader["RuleId"]; } reader.Close(); } return(retVal); }