public void SaveAttributeValue(string attributeName, string value)
        {
            //Encrypt sensitive data
            //Encryption.EncryptValues(value);

            AttributesDAL.SaveAttributeValue(ObjectName, attributeName, ItemId, value);
        }
        public static DataTable GetObjects()
        {
            DataSet result = new DataSet();

            using (SqlDataReader reader = AttributesDAL.GetAllOjbects())
                result = CSCore.DataHelper.BaseSqlHelper.GetDataSet(reader);

            return(result.Tables[0]);
        }
        public static void DeleteAttributes(string objectName, int itemId, List <string> attributeNames)
        {
            XElement deleteAttributesElem = new XElement("DeleteAttributes");

            foreach (string attributeName in attributeNames)
            {
                deleteAttributesElem.Add(new XElement(attributeName));
            }

            AttributesDAL.DeleteSingleAttributeValue(objectName, itemId, deleteAttributesElem.ToString());
        }
        public void LoadAttributeValues()
        {
            attributeValues = new Dictionary <string, AttributeValue>();

            using (SqlDataReader reader = AttributesDAL.GetAllAttributeValues(ObjectName, ItemId))
            {
                while (reader.Read())
                {
                    attributeValues.Add(Attribute.CaseFixAttributeName(Convert.ToString(reader["AttributeName"])), new AttributeValue(Convert.ToString(reader["Value"] ?? string.Empty)));
                }
            }

            attributeValuesLoaded = true;
        }
Beispiel #5
0
        private void Populate(ObjectAttribute objectAttribute, bool newItem)
        {
            List <Dictionary <string, string> > items = new List <Dictionary <string, string> >();
            Dictionary <string, string>         item  = new Dictionary <string, string>();

            if (!newItem)
            {
                // get all attributes associated to item
                using (SqlDataReader reader = AttributesDAL.GetAllAttributeValuesExtended(objectAttribute.ObjectName, objectAttribute.ItemId))
                {
                    while (reader.Read())
                    {
                        item = new Dictionary <string, string>();
                        item.Add("_Associated", true.ToString()); // indicates if attribute value is associated to item

                        item.Add("AttributeName", Convert.ToString(reader["AttributeName"]));
                        item.Add("Value", Convert.ToString(reader["Value"] ?? string.Empty));
                        item.Add("SqlDbType", Convert.ToString(reader["SqlDbType"]));
                        item.Add("ObjectAttributeTypeName", Convert.ToString(reader["ObjectAttributeTypeName"]));
                        items.Add(item);
                    }
                }
            }

            // get all attributes associated to object and add to list if not already in it
            using (SqlDataReader reader = AttributesDAL.GetObjectAttributes(objectAttribute.ObjectName))
            {
                while (reader.Read())
                {
                    if ((!newItem && items.FirstOrDefault(x =>
                    {
                        return(x["AttributeName"] == Convert.ToString(reader["AttributeName"]));
                    }) == null)
                        ||
                        (newItem)) // newItem = "true" will add all items
                    {
                        item = new Dictionary <string, string>();
                        item.Add("_Associated", false.ToString()); // indicates if attribute value is associated to item
                        item.Add("AttributeName", Convert.ToString(reader["AttributeName"]));
                        item.Add("SqlDbType", Convert.ToString(reader["SqlDbType"]));
                        item.Add("ObjectAttributeTypeName", Convert.ToString(reader["ObjectAttributeTypeName"]));
                        items.Add(item);
                    }
                }
            }

            rptAttributes.DataSource = items;
            rptAttributes.DataBind();
        }
        public static void SaveAttributeValues(string objectName, int itemId, Dictionary <string, AttributeValue> attributeValues)
        {
            XElement attributeValuesElem = new XElement("AttributeValues");

            if (attributeValues != null)
            {
                foreach (string attributeName in attributeValues.Keys)
                {
                    //Encrypt sensitive data
                    //Encryption.EncryptValues(attributeValues[attributeName].Value);

                    attributeValuesElem.Add(new XElement(Attributes.Attribute.CaseFixAttributeName(attributeName), attributeValues[attributeName].Value));
                }
            }

            AttributesDAL.SaveAttributeValues(objectName, itemId, attributeValuesElem.ToString());
        }
 public static IEnumerable <Attribute> GetAttributes(string objectName)
 {
     using (SqlDataReader reader = AttributesDAL.GetObjectAttributes(objectName))
     {
         while (reader.Read())
         {
             yield return new Attribute()
                    {
                        Name                    = Attribute.CaseFixAttributeName(Convert.ToString(reader["AttributeName"])),
                        Description             = Convert.ToString(reader["AttributeDescription"] ?? string.Empty),
                        SqlDbType               = Convert.ToString(reader["SqlDbType"]).ToLower(),
                        ValueTypeName           = Convert.ToString(reader["ValueTypeName"]).ToLower(),
                        DisplayLabel            = Convert.ToString(reader["DisplayLabel"] ?? string.Empty),
                        ObjectAttributeTypeName = Convert.ToString(reader["ObjectAttributeTypeName"] ?? string.Empty)
                    }
         }
         ;
     }
 }
 public static int SaveAttribute(string attributeName, string description)
 {
     return(AttributesDAL.SaveAttribute(attributeName, description));
 }
 public static void DeleteSingleObjectAttribute(int objectId, int attributeId)
 {
     AttributesDAL.DeleteSingleObjectAttribute(objectId, attributeId);
 }
 public static void DeleteAttribute(string attributeName)
 {
     AttributesDAL.DeleteAttribute(attributeName);
 }
 public static SqlDataReader GetAllObjectAttributeTypes()
 {
     return(AttributesDAL.GetAllObjectAttributeTypes());
 }
 public static void SaveObjectAttribute(int objectId, int attributeId, int objectAttributeTypeId, string description, string displayLabel)
 {
     AttributesDAL.SaveObjectAttribute(objectId, attributeId, objectAttributeTypeId, description, displayLabel);
 }
 public static SqlDataReader GetAttributeObjects(string attributeName)
 {
     return(AttributesDAL.GetAttributeObjects(attributeName));
 }
 public static SqlDataReader GetObjectAttributes(string objectName)
 {
     return(AttributesDAL.GetObjectAttributes(objectName));
 }
 public static void SaveAttributeById(int attributeId, string attributeName, string description, string defaultValueTypeName)
 {
     AttributesDAL.SaveAttributeById(attributeId, attributeName, description, defaultValueTypeName);
 }
 public void DeleteAttributeValues()
 {
     AttributesDAL.DeleteAttributeValues(ObjectName, ItemId);
 }
 public static SqlDataReader GetAllAttributes()
 {
     return(AttributesDAL.GetAllAttributes());
 }