コード例 #1
0
        public void UpdateHelpText(ObjectGroupingItemData data)
        {
            if (ConnParams == null)
            {
                throw new NullPropertyException("Connection parameters is null!");
            }

            if (data == null)
            {
                return;
            }

            using (SqlConnection conn = new SqlConnection(_connParams.ConnectionString))
            {
                string     cmdText = ResManager.GetDBScript("spPragmaSQL_ObjectGroup_UpdateDescription");
                SqlCommand cmd     = new SqlCommand(cmdText, conn);
                cmd.CommandTimeout = 0;

                AddParam(cmd, "@ObjectID", SqlDbType.Int, data.ID);
                AddParam(cmd, "@Description", SqlDbType.Text, data.HelpText);
                AddParam(cmd, "@DescriptionFormat", SqlDbType.VarChar, data.HelpTextFormat);
                AddParam(cmd, "@UpdatedBy", SqlDbType.VarChar, _connParams.CurrentUsername);
                conn.Open();
                cmd.ExecuteNonQuery();
                data.UpdatedBy = _connParams.CurrentUsername;
            }
        }
コード例 #2
0
        public void AddItem(ObjectGroupingItemData data, string desc, string descFormat)
        {
            if (ConnParams == null)
            {
                throw new NullPropertyException("Connection parameters is null!");
            }
            if (data == null)
            {
                throw new NullParameterException("Item data is null!");
            }

            using (SqlConnection conn = new SqlConnection(_connParams.ConnectionString))
            {
                string     cmdText = ResManager.GetDBScript("spPragmaSQL_ObjectGroup_Insert");
                SqlCommand cmd     = new SqlCommand(cmdText, conn);
                cmd.CommandTimeout = 0;

                AddParam(cmd, "@ParentID", SqlDbType.Int, data.ParentID);
                AddParam(cmd, "@Name", SqlDbType.VarChar, data.Name);
                AddParam(cmd, "@ParentObjName", SqlDbType.VarChar, data.ParentObjectName);
                AddParam(cmd, "@Description", SqlDbType.Text, desc);
                AddParam(cmd, "@DescriptionFormat", SqlDbType.VarChar, descFormat);
                AddParam(cmd, "@ObjType", SqlDbType.Int, data.Type);
                AddParam(cmd, "@CreatedBy", SqlDbType.VarChar, _connParams.CurrentUsername);
                SqlParameter param = cmd.Parameters.Add("@ObjectID", System.Data.SqlDbType.Int);
                param.Direction = System.Data.ParameterDirection.Output;
                conn.Open();
                cmd.ExecuteNonQuery();
                data.ID = (int?)param.Value;
            }
        }
コード例 #3
0
 public void DeleteItem(ObjectGroupingItemData data)
 {
     if (data == null)
     {
         throw new NullParameterException("Item data is null!");
     }
     DeleteItem(data.ID);
 }
コード例 #4
0
        public static ObjectGroupingItemData Create(string name, int?type, int?id, string parentObjectName, int?parentID, string createdBy)
        {
            ObjectGroupingItemData result = new ObjectGroupingItemData(type);

            result.Name             = name;
            result.ID               = id;
            result.ParentObjectName = parentObjectName;
            result.ParentID         = parentID;
            result.CreatedBy        = createdBy;
            return(result);
        }
コード例 #5
0
        public ObjectGroupingItemData CreateCopy( )
        {
            ObjectGroupingItemData result = new ObjectGroupingItemData(this.Type);

            result.Name             = this.Name;
            result.Populated        = this.Populated;
            result.ID               = this.ID;
            result.ParentID         = this.ParentID;
            result.ParentObjectName = this.ParentObjectName;
            result.CreatedBy        = this.CreatedBy;
            result.UpdatedBy        = this.UpdatedBy;
            result.HelpText         = this.HelpText;
            result.HelpTextFormat   = this.HelpTextFormat;

            return(result);
        }
コード例 #6
0
        public IList <ObjectGroupingItemData> GetChildren(int?parentID)
        {
            if (ConnParams == null)
            {
                throw new NullPropertyException("Connection parameters is null!");
            }

            IList <ObjectGroupingItemData> result = new List <ObjectGroupingItemData>();

            using (SqlConnection conn = new SqlConnection(_connParams.ConnectionString))
            {
                string     cmdText = ResManager.GetDBScript("spPragmaSQL_ObjectGroup_List");
                SqlCommand cmd     = new SqlCommand(cmdText, conn);
                cmd.CommandTimeout = 0;
                AddParam(cmd, "@ParentID", System.Data.SqlDbType.Int, parentID);

                conn.Open();
                SqlDataReader reader = cmd.ExecuteReader();

                string name           = String.Empty;
                int?   type           = null;
                int?   id             = null;
                string parentObjName  = String.Empty;
                string createdBy      = String.Empty;
                string updatedBy      = String.Empty;
                string helpText       = String.Empty;
                string helpTextFormat = String.Empty;
                bool   dbObjectExists = true;

                ObjectGroupingItemData data = null;
                try
                {
                    while (reader.Read())
                    {
                        dbObjectExists = true;
                        name           = reader["Name"].GetType() == typeof(DBNull) ? String.Empty : (string)reader["Name"];
                        type           = reader["ObjType"].GetType() == typeof(DBNull) ? null : (int?)reader["ObjType"];
                        id             = reader["ObjectID"].GetType() == typeof(DBNull) ? null : (int?)reader["ObjectID"];
                        parentObjName  = reader["ParentObjName"].GetType() == typeof(DBNull) ? String.Empty : (string)reader["ParentObjName"];
                        createdBy      = reader["CreatedBy"].GetType() == typeof(DBNull) ? String.Empty : (string)reader["CreatedBy"];
                        updatedBy      = reader["UpdatedBy"].GetType() == typeof(DBNull) ? String.Empty : (string)reader["UpdatedBy"];

                        helpText       = reader["Description"].GetType() == typeof(DBNull) ? String.Empty : (string)reader["Description"];
                        helpTextFormat = reader["DescriptionFormat"].GetType() == typeof(DBNull) ? String.Empty : (string)reader["DescriptionFormat"];

                        try
                        {
                            dbObjectExists = reader["DBObjectExists"].GetType() == typeof(DBNull) ? false : (bool)reader["DBObjectExists"];
                        }
                        catch { }

                        data                 = ObjectGroupingItemDataFactory.Create(name, type, id, parentObjName, parentID, createdBy);
                        data.HelpText        = helpText;
                        data.HelpTextFormat  = helpTextFormat;
                        data.UpdatedBy       = updatedBy;
                        data.DbObjectMissing = !dbObjectExists && (type != DBObjectType.GroupingFolderY && type != DBObjectType.GroupingFolderY);
                        result.Add(data);
                    }
                }
                finally
                {
                    reader.Close();
                }
            }

            return(result);
        }
コード例 #7
0
 public void AddItem(ObjectGroupingItemData data)
 {
     AddItem(data, String.Empty, String.Empty);
 }